Exemple #1
0
 public function make_form($data)
 {
     $data = (object) $data;
     $fields = $this->get_fields();
     foreach ($fields as $name => &$field) {
         if (empty($field['field'])) {
             unset($fields[$name]);
             continue;
         }
         $field['type'] = $field['field'];
         $field['value'] = isset($data->{$name}) ? $data->{$name} : null;
         $field['caption'] = isset($field['title']) ? $field['title'] : null;
         if (empty($field['size'])) {
             $field['size'] = 64;
         }
         if (!empty($field['required'])) {
             $field['caption'] .= ' (*):';
         } else {
             $field['caption'] .= ":";
         }
     }
     $form = new nc_a2f($fields, 'data');
     $form->show_default_values(false)->show_header(false);
     return $form->render();
 }
Exemple #2
0
$form = new nc_a2f($form_description, "data");
$form->set_value($rule);
$area = $rule->get('area_string');
$interval = $rule->get('interval');
$type = $rule->get('interval_type');
$time_input = "<span class='rule_time'>" . "<input type='text' name='data[hour][]' value='" . sprintf("%02d", $rule->get('hour')) . "' maxlength='2' />:" . "<input type='text' name='data[minute][]' value='" . sprintf("%02d", $rule->get('minute')) . "' maxlength='2' />" . "</span>";
$int_input = "<input type='text' class='rule_interval_input' name='data[interval][]' value='{$interval}' />";
?>

<fieldset>
    <legend><?php 
echo NETCAT_MODULE_SEARCH_ADMIN_RULE;
?>
</legend>
    <?php 
echo $form->render("<div>", "", "</div>", "");
?>
    <div class="ncf_row space_before">
        <div class="ncf_caption"><?php 
echo NETCAT_MODULE_SEARCH_ADMIN_RULE_AREA_TO_INDEX;
?>
:</div>
        <div class="rule_radio">
            <!-- ↓ sic (ignored) -->
            <input type="radio" name="area" value="site" id="r-site" <?php 
echo $area ? "" : "checked";
?>
 />
            <label for="r-site"><?php 
echo NETCAT_MODULE_SEARCH_ADMIN_RULE_AREA_WHOLE_SITE;
?>
Exemple #3
0
        nc_search::save_setting($k, $v);
    }
    // check SearchProvider
    if ($search_provider_changed) {
        $new_provider = $input['SearchProvider'];
        if (@class_exists($new_provider)) {
            try {
                $provider = new $new_provider();
                if ($provider instanceof nc_search_provider) {
                    $provider->first_run();
                } else {
                    nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SETTINGS_INCORRECT_PROVIDER_CLASS, 'error', array($new_provider));
                }
            } catch (Exception $e) {
                nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SETTINGS_PROVIDER_CLASS_INITIALIZATION_ERROR, 'error', array($new_provider, $e->getMessage()));
            }
        } else {
            nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SETTINGS_PROVIDER_CLASS_NOT_FOUND, 'error', array($new_provider));
        }
    }
    // done saving
    nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SETTINGS_SAVED, 'ok');
}
$settings = array('ComponentID', 'SearchProvider', 'IndexerSecretKey', 'IndexerNormalizeLinks', 'IndexerSaveTaskEveryNthCycle', 'IndexerRemoveIdleTasksAfter', 'IndexerTimeThreshold', 'IndexerMemoryThreshold', 'IndexerConsoleMemoryThreshold', 'IndexerConsoleTimeThreshold', 'IndexerConsoleDocumentsPerSession', 'IndexerConsoleSlowdownDelay', 'IndexerConsoleRestartHungTasks', 'IndexerInBrowserSlowdownDelay', 'MinScheduleInterval', 'CrawlerMaxRedirects', 'NumberOfEntriesPerSitemap', 'MaxTermsPerQuery', 'MaxTermsPerField', 'ZendSearchLucene_MaxBufferedDocs', 'ZendSearchLucene_MaxMergeDocs', 'ZendSearchLucene_MergeFactor', 'PhpMorphy_LoadDictsDuringIndexing', 'DatabaseIndex_LoadAllCodesForIndexing', 'DatabaseIndex_MaxSimilarityCandidates', 'DatabaseIndex_MaxRewriteTerms', 'DatabaseIndex_UseUtf8Levenshtein', 'DatabaseIndex_MaxProximityTerms', 'DatabaseIndex_MaxProximityDistance', 'DatabaseIndex_AlwaysGetTotalCount', 'DatabaseIndex_OptimizationFrequency');
$form_description = array();
foreach ($settings as $s) {
    $form_description[$s] = array('type' => 'string', 'caption' => $s, 'value' => nc_search::get_setting($s));
}
$form = new nc_a2f($form_description, "settings");
echo "<form class='settings system_settings' method='POST'>", "<input type='hidden' name='view' value='systemsettings' />", $form->render("<div>", "", "</div>", ""), "</form>";
Exemple #4
0
settype($sub_id, "integer");
settype($template_id, "integer");
if ($template_id == 0 || $_REQUEST['is_parent_template'] == 'true') {
    //  наследование
    print CONTROL_TEMPLATE_CUSTOM_SETTINGS_INHERITED;
    exit;
}
$qry_join = "";
if ($catalogue_id && !$sub_id) {
    $qry_join = "LEFT JOIN Catalogue as this ON (this.Catalogue_ID={$catalogue_id} AND this.Template_ID=t.Template_ID)";
} else {
    if ($sub_id) {
        $qry_join = "LEFT JOIN Subdivision as this ON (this.Subdivision_ID={$sub_id} AND this.Template_ID=t.Template_ID)";
    } else {
        trigger_error("No catalogue_id nor sub_id", E_USER_ERROR);
    }
}
$tpl_data = $db->get_row("SELECT t.CustomSettings, this.TemplateSettings\n                            FROM Template as t\n                                 {$qry_join}\n                           WHERE t.Template_ID={$template_id}", ARRAY_A);
if (!$tpl_data['CustomSettings']) {
    print CONTROL_TEMPLATE_CUSTOM_SETTINGS_NOT_AVAILABLE;
    exit;
}
$a2f = new nc_a2f($tpl_data['CustomSettings'], 'TemplateSettings');
$a2f->set_value($tpl_data['TemplateSettings']);
// this is only for inside_admin mode
$vs_template_header = "<table class='admin_table' style='width: 100%;'><tr><th>%CAPTION</th><th>%VALUE</th><th>%DEFAULT</th></tr>";
$vs_template_object = "<tr><td>%CAPTION&nbsp</td><td>%VALUE&nbsp</td><td>%DEFAULT&nbsp</td></tr>";
$vs_template_footer = "</table>";
$vs_template_divider = "<tr><td colspan='3'>%CAPTION</td></tr>";
print $a2f->render($vs_template_header, $vs_template_object, $vs_template_footer, $vs_template_divider);
Exemple #5
0
<?php

if (!class_exists("nc_system")) {
    die;
}
$ui = $this->get_ui();
$ui->add_lists_toolbar();
$ui->add_submit_button(NETCAT_MODULE_SEARCH_ADMIN_SAVE);
$ui->add_back_button();
$stopword = $this->data_form('nc_search_language_stopword', 'stopwords_save', false);
$form_description = array('language' => array('type' => 'select', 'subtype' => 'static', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE . ':', 'values' => $this->get_language_list(), 'default_value' => nc_Core::get_object()->lang->detect_lang(true)), 'word' => array('type' => 'string', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_STOPWORD_FIELD_CAPTION . ':'));
$form = new nc_a2f($form_description, "data");
$form->set_value($stopword);
echo "<fieldset><legend>", NETCAT_MODULE_SEARCH_ADMIN_STOPWORD, "</legend>", $form->render("<div>", "", "</div>", ""), "</fieldset>";
?>
<script type="text/javascript">
    // :(
    $nc('form').attr('onsubmit', "return ($nc(this).find(\"input[name='data[word]']\").val().length > 0)");
</script>
Exemple #6
0
<?php

if (!class_exists("nc_system")) {
    die;
}
$ui = $this->get_ui();
$ui->add_settings_toolbar();
$ui->add_back_button();
$extension = $this->data_form('nc_search_extension_rule', 'extensions');
$registered_providers = $this->get_db()->get_col("SELECT `ExtensionClass` FROM `Search_Extension`" . " WHERE `ExtensionInterface` = 'nc_search_provider'");
$search_providers = array('' => NETCAT_MODULE_SEARCH_ADMIN_SEARCH_PROVIDER_ANY);
foreach ($registered_providers as $p) {
    $search_providers[$p] = $p;
}
$form_description = array('extension_interface' => array('type' => 'select', 'subtype' => 'static', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_INTERFACE . ':', 'values' => array('nc_search_language_analyzer' => 'nc_search_language_analyzer', 'nc_search_language_corrector' => 'nc_search_language_corrector', 'nc_search_language_filter' => 'nc_search_language_filter', 'nc_search_document_parser' => 'nc_search_document_parser'), 'default_value' => 'nc_search_language_filter'), 'extension_class' => array('type' => 'string', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_CLASS . ':'), 'search_provider' => array('type' => 'select', 'values' => $search_providers, 'caption' => NETCAT_MODULE_SEARCH_ADMIN_SEARCH_PROVIDER . ':', 'default_value' => ' '), 'action' => array('type' => 'select', 'subtype' => 'static', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_ACTION . ':', 'values' => array('' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_ACTION_ANY, 'searching' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_ACTION_SEARCHING, 'indexing' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_ACTION_INDEXING), 'default_value' => ' '), 'language' => array('type' => 'select', 'subtype' => 'static', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE . ':', 'values' => $this->get_language_list(true), 'default_value' => ' '), 'content_type' => array('type' => 'string', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_CONTENT_TYPE . ':'), 'priority' => array('type' => 'int', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_PRIORITY . ':', 'min' => 0, 'max' => 255, 'default' => 127));
$form = new nc_a2f($form_description, "data");
$form->set_value($extension);
echo "<fieldset><legend>", NETCAT_MODULE_SEARCH_ADMIN_EXTENSION, "</legend>", $form->render("<div>", "", "</div>", ""), "<input type='hidden' name='data[enabled]' value='0' />\n", "<div class='extension_cb_row'><input type='checkbox' name='data[enabled]' value='1'", $extension->get('enabled') ? " checked='checked'" : "", " id='cb_enabled' /> <label for='cb_enabled'>", NETCAT_MODULE_SEARCH_ADMIN_EXTENSION_ENABLED, "</label></div>\n", "</fieldset>";
$ui->add_submit_button(NETCAT_MODULE_SEARCH_ADMIN_SAVE);
Exemple #7
0
<?php

if (!class_exists("nc_system")) {
    die;
}
$ui = $this->get_ui();
$ui->add_lists_toolbar();
$ui->add_submit_button(NETCAT_MODULE_SEARCH_ADMIN_SAVE);
$ui->add_back_button();
$synonyms = $this->data_form('nc_search_language_synonyms', 'synonyms');
$form_description = array('language' => array('type' => 'select', 'subtype' => 'static', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE . ':', 'values' => $this->get_language_list(), 'default_value' => nc_Core::get_object()->lang->detect_lang(true)));
$form = new nc_a2f($form_description, "data");
$form->set_value($synonyms);
echo "<fieldset><legend>", NETCAT_MODULE_SEARCH_ADMIN_SYNONYMS, "</legend>", $form->render("<div>", "", "</div>", ""), "<div class='ncf_row'><div class='ncf_caption'>", NETCAT_MODULE_SEARCH_ADMIN_SYNONYMS_FIELD_CAPTION, ":</div>", "<div id='synonym_list'></div>", "<div id='add_synonym_row'><span>", nc_admin_img("i_obj_add.gif", NETCAT_MODULE_SEARCH_ADMIN_ADD), NETCAT_MODULE_SEARCH_ADMIN_ADD, "</span></div>", "<div id='synonym_filter_row'><input type='checkbox' name='data[dont_filter]' id='dont_filter' /> ", "<label for='dont_filter'>", NETCAT_MODULE_SEARCH_ADMIN_SYNONYMS_DO_NOT_APPLY_FILTERS, "</label> ", "<span class='inline_help_mark' id='filters_help'>[ ? ]</span>", "<div class='inline_help' id='filters_help_hover'>", NETCAT_MODULE_SEARCH_ADMIN_SYNONYMS_DO_NOT_APPLY_FILTERS_HELP, "</div>", "</div>", "</fieldset>";
?>
<script type="text/javascript">
    (function($, words) {
        var tpl = $("<div class='word'><input type='text' name='data[words][]' />" +
            "<span class='delete_word'>" +
            "<?php 
echo nc_admin_img("delete", NETCAT_MODULE_SEARCH_ADMIN_DELETE);
?>
" +
            "</span>" +
            "</div>");

        var add_word = function(word) {
            var row = tpl.clone();
            row.find("input").val(word || '');
            row.find(".delete_word").click(function() {
                $(this).parent().remove();