blog->settings->addNamespace('enhancePostContent'); $s = $core->blog->settings->enhancePostContent; # -- Prepare queries and object -- $_filters = libEPC::blogFilters(); $filters_id = array(); foreach($_filters as $name => $filter) { $filters_id[$filter['id']] = $name; } $action = isset($_POST['action']) ? $_POST['action'] : ''; $default_part = isset($_REQUEST['part']) ? $_REQUEST['part'] : key($filters_id); $records = new epcRecords($core); # -- Action -- if (!empty($action)) { # --BEHAVIOR-- enhancePostContentAdminSave $core->callBehavior('enhancePostContentAdminSave',$core); } try { # Update filter settings if ($action == 'savefiltersetting' && isset($filters_id[$default_part]) ) { # Parse filters options $name = $filters_id[$default_part]; $f = array( 'nocase' => !empty($_POST['filter_nocase']), 'plural' => !empty($_POST['filter_plural']), 'limit' => abs((integer) $_POST['filter_limit']), 'style' => (array) $_POST['filter_style'], 'notag' => (string) $_POST['filter_notag'], 'tplValues' => (array) $_POST['filter_tplValues'], 'pubPages' => (array) $_POST['filter_pubPages'] ); $s->put('enhancePostContent_'.$name, serialize($f)); $core->blog->triggerBlog(); dcPage::addSuccessNotice( __('Filter successfully updated.') ); http::redirect( $p_url.'part='.$default_part.'#setting' ); } # Add new filter record if ($action == 'savenewrecord' && isset($filters_id[$default_part]) && !empty($_POST['new_key']) && !empty($_POST['new_value']) ) { $cur = $records->openCursor(); $cur->epc_filter = $filters_id[$default_part]; $cur->epc_key = html::escapeHTML($_POST['new_key']); $cur->epc_value = html::escapeHTML($_POST['new_value']); $records->addRecord($cur); $core->blog->triggerBlog(); dcPage::addSuccessNotice( __('Filter successfully updated.') ); http::redirect( $p_url.'&part='.$default_part.'#record' ); } # Update filter records if ($action == 'saveupdaterecords' && isset($filters_id[$default_part]) && $_filters[$filters_id[$default_part]]['has_list'] ) { foreach($_POST['epc_id'] as $k => $id) { $k = abs((integer) $k); $id = abs((integer) $id); if (empty($_POST['epc_key'][$k]) || empty($_POST['epc_value'][$k]) ) { $records->delRecord($id); } elseif ($_POST['epc_key'][$k] != $_POST['epc_old_key'][$k] || $_POST['epc_value'][$k] != $_POST['epc_old_value'][$k] ) { $cur = $records->openCursor(); $cur->epc_filter = $filters_id[$default_part]; $cur->epc_key = html::escapeHTML($_POST['epc_key'][$k]); $cur->epc_value = html::escapeHTML($_POST['epc_value'][$k]); $records->updRecord($id,$cur); } } $core->blog->triggerBlog(); $redir = !empty($_REQUEST['redir']) ? $_REQUEST['redir'] : $p_url.'&part='.$default_part.'#record'; dcPage::addSuccessNotice( __('Filter successfully updated.') ); http::redirect( $redir ); } } catch(Exception $e) { $core->error->add($e->getMessage()); } # -- Prepare page -- $breadcrumb = array( html::escapeHTML($core->blog->name) => '', __('Enhance post content') => $p_url ); $top_menu = array(); foreach($filters_id as $id => $name) { $active = ''; if ($default_part == $id) { $breadcrumb[__($filters_id[$default_part])] = ''; $active = ' class="active"'; } $top_menu[] = ''.__($name).''; } # -- Display page -- # Headers echo '
'.$filter['help'].'
'; # Filter settings echo ''.__('No record').'
'; } else { echo ' '; } echo ''.__('Configuration').' - enhancePostContent - '.$core->plugins->moduleInfo('enhancePostContent', 'version').'
';