Beispiel #1
0
 /**
  *
  */
 protected function get_field_name($added = '')
 {
     $array_name = $this->parent->get_array_name();
     if ($added) {
         $added = '[' . $added . ']';
     }
     return $array_name ? $array_name . "[" . $this->name . "]" . $added : $this->name . $added;
 }
Beispiel #2
0
 /**
  * @param $cc_env
  * @param int $nc_ctpl
  * @param $type
  * @return null
  */
 protected function inherit($cc_env, $nc_ctpl = 0, $type)
 {
     // system superior object
     $nc_core = nc_Core::get_object();
     if (empty($cc_env)) {
         global $perm;
         // error message
         if (is_object($perm) && $perm->isSupervisor()) {
             // backtrace info
             $debug_backtrace_info = debug_backtrace();
             // choose error
             if (isset($debug_backtrace_info[2]['function']) && $debug_backtrace_info[2]['function'] == "nc_objects_list") {
                 // error info for the supervisor
                 trigger_error(sprintf(NETCAT_FUNCTION_OBJECTS_LIST_CC_ERROR, $debug_backtrace_info[2]['args'][1]), E_USER_WARNING);
             } else {
                 // error info for the supervisor
                 trigger_error(sprintf(NETCAT_FUNCTION_LISTCLASSVARS_ERROR_SUPERVISOR, $cc), E_USER_WARNING);
             }
         }
         return null;
     }
     $nc_tpl_in_cc = 0;
     if ($cc_env['Class_Template_ID'] && !$nc_ctpl) {
         $nc_tpl_in_cc = $cc_env['Class_Template_ID'];
     }
     $class_env = $nc_core->component->get_for_cc($cc_env['Sub_Class_ID'], $cc_env['Class_ID'], $nc_ctpl, $nc_tpl_in_cc, $type);
     foreach ((array) $class_env as $key => $val) {
         if (!array_key_exists($key, $cc_env) || $cc_env[$key] == "") {
             $cc_env[$key] = $val;
         }
     }
     if ($cc_env["NL2BR"] == -1) {
         $cc_env["NL2BR"] = $class_env["NL2BR"];
     }
     if ($cc_env["AllowTags"] == -1) {
         $cc_env["AllowTags"] = $class_env["AllowTags"];
     }
     if ($cc_env["UseCaptcha"] == -1) {
         $cc_env["UseCaptcha"] = $class_env["UseCaptcha"];
     }
     if ($nc_core->modules->get_by_keyword("cache")) {
         if ($cc_env["CacheForUser"] == -1) {
             $cc_env["CacheForUser"] = $class_env["CacheForUser"];
         }
     }
     if ($class_env['CustomSettingsTemplate']) {
         require_once $nc_core->ADMIN_FOLDER . "array_to_form.inc.php";
         $a2f = new nc_a2f($class_env['CustomSettingsTemplate'], 'CustomSettings');
         $a2f->set_value($cc_env['CustomSettings']);
         $cc_env["Sub_Class_Settings"] = $a2f->get_values_as_array();
     }
     $cc_env['sysTbl'] = intval($class_env['System_Table_ID']);
     $sub_env = $nc_core->subdivision->get_by_id($cc_env["Subdivision_ID"]);
     $inherited_params = array('Read_Access_ID', 'Write_Access_ID', 'Edit_Access_ID', 'Checked_Access_ID', 'Delete_Access_ID', 'Subscribe_Access_ID', 'Moderation_ID');
     if ($nc_core->modules->get_by_keyword("cache")) {
         $inherited_params[] = 'Cache_Access_ID';
         $inherited_params[] = 'Cache_Lifetime';
     }
     foreach ($inherited_params as $v) {
         if (!$cc_env[$v]) {
             $cc_env[$v] = $sub_env[$v];
         }
     }
     $cc_env['Subdivision_Name'] = $sub_env['Subdivision_Name'];
     $cc_env['Hidden_URL'] = $sub_env['Hidden_URL'];
     $Domain = $nc_core->catalogue->get_by_id($cc_env['Catalogue_ID'], 'Domain');
     $cc_env['Hidden_Host'] = $Domain ? $Domain : $nc_core->DOMAIN_NAME;
     return $cc_env;
 }
Beispiel #3
0
function ActionForm_for_modal($SubClassID)
{
    global $CatalogueID, $SubdivisionID, $loc, $perm;
    global $SUB_FOLDER, $HTTP_ROOT_PATH, $MODULE_FOLDER, $ADMIN_FOLDER, $ADMIN_PATH;
    $nc_core = nc_Core::get_object();
    $db = $nc_core->db;
    $type = 2;
    $SubdivisionID = $SubdivisionID ? +$SubdivisionID : $nc_core->sub_class->get_by_id($SubClassID, 'Subdivision_ID');
    $CatalogueID = $CatalogueID ? +$CatalogueID : $nc_core->subdivision->get_by_id($SubdivisionID, 'Catalogue_ID');
    $SubEnv = $nc_core->sub_class->get_by_id($SubClassID);
    $ClassEnv = $db->get_row("SELECT * FROM `Class` WHERE `Class_ID` = '" . intval($SubEnv["Class_ID"]) . "'", ARRAY_A);
    if (nc_module_check_by_keyword("cache")) {
        $cache_select_fields = "s.`Cache_Access_ID`, s.`Cache_Lifetime`, s.`CacheForUser`,";
    } else {
        $cache_select_fields = "";
    }
    $select = "SELECT " . $cache_select_fields . "\n                          s.`Sub_Class_Name`,\n                          s.`Subdivision_ID`,\n                          s.`Priority`,\n                          s.`Read_Access_ID`,\n                          s.`Write_Access_ID`,\n                          s.`Edit_Access_ID`,\n                          s.`Checked_Access_ID`,\n                          s.`Delete_Access_ID`,\n                          s.`Moderation_ID`,\n                          s.`EnglishName`,\n                          s.`Checked`,\n                          s.`Subscribe_Access_ID`,\n                          s.`DaysToHold`,\n                          s.`AllowTags`,\n                          s.`NL2BR`,\n                          s.`RecordsPerPage`,\n                          s.`SortBy`,\n                          s.`Created`,\n                          s.`LastUpdated`,\n                          c.`Class_Name`,\n                          c.`Class_ID`,\n                          c.`System_Table_ID`,\n                          s.`DefaultAction`,\n                          s.`UseCaptcha`,\n                          c.`CustomSettingsTemplate`,\n                          s.`CustomSettings`,\n                          s.`Class_Template_ID`,\n                          s.`isNaked`,\n                          s.`SrcMirror`,\n                          s.`AllowRSS`,\n                          s.`Edit_Class_Template`\n                       FROM `Sub_Class` as s,\n                            `Class` as c\n                           WHERE `Sub_Class_ID` = " . +$SubClassID . "\n                             AND c.`Class_ID` = s.`Class_ID`";
    $Array = $db->get_row($select, ARRAY_A);
    if ($db->is_error) {
        throw new nc_Exception_DB_Error($db->last_query, $db->last_error);
    }
    if (empty($Array)) {
        nc_print_status(CONTROL_CONTENT_CATALOUGE_FUNCS_ERROR_NOSUBCLASS, 'info');
        return;
    }
    if ($Array['Class_Template_ID']) {
        $Array['CustomSettingsTemplate'] = $db->get_var("SELECT `CustomSettingsTemplate`\n                                                                 FROM `Class`\n                                                                     WHERE `Class_ID` = " . $Array['Class_Template_ID']);
    }
    $mobile = $nc_core->catalogue->get_by_id($CatalogueID, 'ncMobile');
    $classTemplatesArr = $db->get_results("SELECT `Class_Name`,\n                                                      `Class_ID`\n                                                   FROM `Class`\n                                                       WHERE `ClassTemplate` = '" . $Array['Class_ID'] . "'\n                                                         AND `Type` " . (!$mobile ? "IN ('useful', 'title', 'mobile')" : "= 'mobile'"), ARRAY_A);
    $class_array = nc_get_class_template_array_by_id($Array['Class_Template_ID'] ? $Array['Class_Template_ID'] : $Array['Class_ID']);
    $edit_class_select = null;
    if (count($class_array) > 1) {
        $edit_class_select = nc_get_class_template_form_select_by_array($class_array, $Array['Edit_Class_Template']);
    }
    $classInfo = nc_sub_class_get_classInfo($perm, $Array, $classTemplatesArr, $edit_class_select);
    if ($loc->SubdivisionID) {
        $wsts = CONTROL_CONTENT_SUBCLASS_ONSECTION;
    } else {
        $wsts = CONTROL_CONTENT_SUBCLASS_ONSITE;
    }
    $wsts_msg = nc_sub_class_get_wsts_msg($wsts);
    require_once $ADMIN_FOLDER . "related/format.inc.php";
    $field = new field_relation_subclass();
    $fieldsets = new nc_admin_fieldset_collection();
    $fieldsets->set_prefix(nc_sub_class_get_prefix($SubClassID, $Array));
    $fieldsets->set_static_prefix(nc_sub_class_get_style_prefix());
    $fieldsets->set_suffix("\n            </div>\n            " . $nc_core->token->get_input() . "\n            <input type='hidden' name='phase' value='4' />\n            <input type='hidden' name='SubClassID' value='{$SubClassID}' />\n            <input type='hidden' name='SubdivisionID' value='{$loc->SubdivisionID}' />\n            <input type='hidden' name='CatalogueID' value='{$loc->CatalogueID}' />\n            <input type='submit' style='display: none;' />\n            ");
    $fieldsets->new_fieldset('main_info', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MAININFO)->add(nc_sub_class_get_main_info($Array, $classInfo, $wsts_msg, $field));
    $fieldsets->new_fieldset('objlist', CONTROL_CONTENT_SUBDIVISION_FUNCS_OBJ_HOWSHOW)->add(nc_sub_class_get_objlist($Array));
    if ($Array['CustomSettingsTemplate']) {
        require_once $ADMIN_FOLDER . 'array_to_form.inc.php';
        $values = $CustomSettings ? $CustomSettings : $Array['CustomSettings'];
        $a2f = new nc_a2f($Array['CustomSettingsTemplate'], 'CustomSettings');
        $a2f->set_value($values);
        $fieldsets->new_fieldset('CustomSettings', CONTROL_CONTENT_SUBDIVISION_CUSTOM_SETTINGS_TEMPLATE)->add(nc_sub_class_get_CustomSettings($a2f));
    }
    $fieldsets->new_fieldset('access', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ACCESS)->add(nc_subdivision_show_access($SubEnv));
    #$fieldsets->new_fieldset('rss', 'RSS')->add(nc_subclass_show_export('rss', $SubdivisionID, $SubClassID));
    #$fieldsets->new_fieldset('xml', 'XML')->add(nc_subclass_show_export('xml', $SubdivisionID, $SubClassID));
    if (nc_module_check_by_keyword('cache')) {
        $fieldsets->new_fieldset('cache', CONTROL_CONTENT_SUBCLASS_FUNCS_CACHE)->add(nc_subdivision_show_cache($SubEnv));
    }
    if (nc_module_check_by_keyword('comments')) {
        $fieldsets->new_fieldset('comments', CONTROL_CONTENT_SUBCLASS_FUNCS_COMMENTS)->add(nc_subdivision_show_comments($SubEnv));
    }
    echo $fieldsets->to_string();
}
Beispiel #4
0
/**
 * Сохранение информации о конкретном параметре пользовательских настроек
 * @return <type>
 */
function nc_customsettings_save_once()
{
    $nc_core = nc_Core::get_object();
    $ClassID = $nc_core->input->fetch_get_post('ClassID');
    $TemplateID = $nc_core->input->fetch_get_post('TemplateID');
    $old_name = $nc_core->input->fetch_get_post('param');
    $new_name = $nc_core->input->fetch_get_post('name');
    $type = $nc_core->input->fetch_get_post('type');
    $subtype = $nc_core->input->fetch_get_post('subtype');
    $caption = $nc_core->input->fetch_get_post('caption');
    $default_value = $nc_core->input->fetch_get_post('default_value');
    if (!preg_match("/^[a-z0-9_]+\$/i", $new_name)) {
        throw new Exception(NETCAT_CUSTOM_ONCE_ERROR_FIELD_NAME);
    }
    if (!$caption) {
        throw new Exception(NETCAT_CUSTOM_ONCE_ERROR_CAPTION);
    }
    if ($ClassID) {
        $custom_settings = $nc_core->component->get_by_id($ClassID, 'CustomSettingsTemplate');
    } else {
        $custom_settings = $nc_core->template->get_by_id($TemplateID, 'CustomSettings');
    }
    if (!$custom_settings) {
        $custom_settings = array();
    } else {
        $a2f = new nc_a2f($custom_settings, '');
        $custom_settings = $a2f->eval_value($custom_settings);
    }
    $keys = empty($custom_settings) ? array() : array_keys($custom_settings);
    if (in_array($new_name, $keys) && $new_name != $old_name) {
        throw new Exception(NETCAT_CUSTOM_ONCE_ERROR_FIELD_EXISTS);
    }
    $param = array('type' => $type, 'subtype' => $subtype, 'caption' => $caption);
    if ($default_value) {
        $param['default_value'] = $default_value;
    }
    $input = $nc_core->input->fetch_get_post();
    // загружаем объект для работы с полем
    $classname = "nc_a2f_field_" . $type . ($subtype ? "_" . $subtype : "");
    if (!class_exists($classname)) {
        return false;
    }
    $fl = new $classname();
    $ex_params = $fl->get_extend_parameters();
    if (!empty($ex_params)) {
        foreach ($ex_params as $k => $v) {
            if ($type == 'select' && $subtype == 'static' && $k == 'values') {
                $param['values'] = array();
                if (!empty($_POST['select_static_key'])) {
                    foreach ($_POST['select_static_key'] as $i => $option_key) {
                        $option_key = trim($option_key);
                        $option_value = trim($_POST['select_static_value'][$i]);
                        if (!strlen($option_key) || !strlen($option_value)) {
                            continue;
                        }
                        $param['values'][$option_key] = $option_value;
                    }
                }
            } else {
                if (isset($input['cs_' . $k])) {
                    $param[$k] = $input['cs_' . $k];
                }
            }
        }
    }
    /*
          foreach ( $input as $k => $v ) {
          if ( nc_preg_match('/cs_([a-z0-9_]+)/i', $k, $match) ) $param[$match[1]] = $v;
          } */
    $custom_settings_new = array();
    if (!empty($custom_settings)) {
        foreach ($custom_settings as $k => $v) {
            if ($k != $old_name && $k != $new_name) {
                $custom_settings_new[$k] = $v;
            }
            if ($k == $old_name || $k == $new_name) {
                $custom_settings_new[$new_name] = $param;
            }
        }
    }
    if (!$old_name) {
        $custom_settings_new[$new_name] = $param;
    }
    $s = nc_a2f::array_to_string($custom_settings_new);
    $s = $custom_settings_new ? '$settings_array = ' . $s . ';' : '';
    if ($ClassID) {
        $nc_core->component->update($ClassID, array('CustomSettingsTemplate' => $s));
    } else {
        $nc_core->template->update($TemplateID, array('CustomSettings' => $s));
    }
    return true;
}
Beispiel #5
0
function ListClassVars($cc, $user_table_mode, $nc_ctpl = 0)
{
    global $db, $perm;
    global $MODULE_VARS, $DOMAIN_NAME;
    global $cc_in_sub, $nc_core;
    global $current_cc;
    $nc_ctpl = intval($nc_ctpl);
    // cache section
    if (0 && $nc_core->modules->get_by_keyword("cache")) {
        try {
            $nc_cache_function = nc_cache_function::getObject();
            $cc_data = $db->get_row("SELECT `Catalogue_ID`, `Subdivision_ID`, `Sub_Class_ID`\n        FROM `Sub_Class` WHERE `Sub_Class_ID` = '" . intval($cc) . "'", ARRAY_A);
            // make uniqe string concat parameters for this function
            $data_string = $user_table_mode . "-" . serialize($MODULE_VARS['auth']) . "-" . $DOMAIN_NAME . "-" . $nc_ctpl;
            // check cached data
            $cached_data = $nc_cache_function->read($cc_data, $data_string, $MODULE_VARS['cache']['DEFAULT_LIFETIME']);
            if ($cached_data != -1) {
                // debug info
                $cache_debug_info = "Readed, catalogue[" . $cc_data['Catalogue_ID'] . "], sub[" . $cc_data['Subdivision_ID'] . "], cc[" . $cc_data['Sub_Class_ID'] . "], Access_ID[-], Lifetime[-], bytes[" . strlen($cached_data) . "]";
                $nc_cache_function->debugMessage($cache_debug_info, __FILE__, __LINE__);
                // return cache if not eval flag setted
                $Array = unserialize($cached_data);
                return $Array;
            }
        } catch (Exception $e) {
            // for debug
            $nc_cache_function->errorMessage($e);
        }
    }
    if (!$user_table_mode) {
        $Array = array();
        if ($cc_in_sub) {
            foreach ($cc_in_sub as $row) {
                if ($row["Sub_Class_ID"] == $cc) {
                    $Array = $row;
                    break;
                }
            }
        }
        if (empty($Array)) {
            $Array = $db->get_row("SELECT * FROM `Sub_Class` WHERE `Sub_Class_ID` = '" . intval($cc) . "'", ARRAY_A);
        }
        if ($current_cc['Sub_Class_ID'] == $cc && $nc_core->get_page_type() == 'rss') {
            $class_cond = "`Type` = 'rss' AND `ClassTemplate` = '" . $Array["Class_ID"] . "' ";
        } else {
            if ($nc_ctpl) {
                $class_cond = "`Class_ID` = '" . $nc_ctpl . "'";
            } else {
                // use class template or not?
                $class_cond = "`Class_ID` = '" . ($Array["Class_Template_ID"] ? $Array["Class_Template_ID"] : $Array["Class_ID"]) . "'";
            }
        }
        if ($nc_core->inside_admin) {
            $class_env = $db->get_row("SELECT * FROM Class WHERE `Type` = 'inside_admin' AND `ClassTemplate` = '" . $Array["Class_ID"] . "' LIMIT 1 ", ARRAY_A);
        }
        if (!$nc_core->inside_admin && $nc_core->admin_mode) {
            $class_env = $db->get_row("SELECT * FROM Class WHERE `Type` = 'admin_mode' AND `ClassTemplate` = '" . $Array["Class_ID"] . "' LIMIT 1 ", ARRAY_A);
        }
    } else {
        $user_table_id = $db->get_var("SELECT `System_Table_ID` FROM `System_Table` WHERE `System_Table_Name` = 'User'");
        $class_cond = "`System_Table_ID` = '" . $user_table_id . "'";
        $Array["System_Table_ID"] = $user_table_id;
        $Array["Subdivision_ID"] = $MODULE_VARS['auth']['USER_LIST_SUB'];
        $Array["EnglishName"] = $MODULE_VARS['auth']['USER_KEYWORD'];
    }
    //выйдем из функции, если $cc указан неверно
    if (!$Array) {
        // error message
        if (is_object($perm) && $perm->isSupervisor()) {
            // backtrace info
            $debug_backtrace_info = debug_backtrace();
            // choose error
            if (isset($debug_backtrace_info[1]['function']) && $debug_backtrace_info[1]['function'] == "nc_objects_list") {
                // error info for the supervisor
                trigger_error(sprintf(NETCAT_FUNCTION_OBJECTS_LIST_CC_ERROR, $cc), E_USER_WARNING);
            } else {
                // error info for the supervisor
                trigger_error(sprintf(NETCAT_FUNCTION_LISTCLASSVARS_ERROR_SUPERVISOR, $cc), E_USER_WARNING);
            }
        }
        return NULL;
    }
    // inherit from Class
    if (!$class_env) {
        $class_env = $db->get_row("SELECT * FROM `Class` WHERE " . $class_cond, ARRAY_A);
    }
    if ($class_env['CustomSettingsTemplate']) {
        require_once $GLOBALS['ADMIN_FOLDER'] . "array_to_form.inc.php";
        $a2f = new nc_a2f($class_env['CustomSettingsTemplate'], $Array['CustomSettings'], 'CustomSettings');
        $Array["Sub_Class_Settings"] = $a2f->get_values_as_array();
    }
    foreach ($class_env as $key => $val) {
        if ($Array[$key] == "") {
            $Array[$key] = $val;
        }
    }
    if ($Array["NL2BR"] == -1) {
        $Array["NL2BR"] = $class_env["NL2BR"];
    }
    if ($Array["AllowTags"] == -1) {
        $Array["AllowTags"] = $class_env["AllowTags"];
    }
    if ($Array["UseCaptcha"] == -1) {
        $Array["UseCaptcha"] = $class_env["UseCaptcha"];
    }
    if ($nc_core->modules->get_by_keyword("cache")) {
        if ($Array["CacheForUser"] == -1) {
            $Array["CacheForUser"] = $class_env["CacheForUser"];
        }
    }
    if ($Array["Subdivision_ID"]) {
        $parent_sub = $Array["Subdivision_ID"];
        $Domain = $db->get_var("SELECT Catalogue.Domain FROM `Catalogue`\n      LEFT JOIN `Subdivision` ON Subdivision.Catalogue_ID = Catalogue.Catalogue_ID\n      WHERE Subdivision.Subdivision_ID = '" . $parent_sub . "'");
        $HiddenHost = $Domain ? strchr($Domain, ".") ? $Domain : $Domain . "." . $DOMAIN_NAME : $DOMAIN_NAME;
        while ($parent_sub) {
            $ParentArray = GetSubdivisionByID($parent_sub);
            if ($Array["Subdivision_ID"] == $parent_sub) {
                $Array["Subdivision_Name"] = $ParentArray["Subdivision_Name"];
                $Array["Hidden_URL"] = $ParentArray["Hidden_URL"];
                $Array["Hidden_Host"] = $HiddenHost;
            }
            if (!$Array["Read_Access_ID"]) {
                $Array["Read_Access_ID"] = $ParentArray["Read_Access_ID"];
            }
            if (!$Array["Write_Access_ID"]) {
                $Array["Write_Access_ID"] = $ParentArray["Write_Access_ID"];
            }
            if (!$Array["Edit_Access_ID"]) {
                $Array["Edit_Access_ID"] = $ParentArray["Edit_Access_ID"];
            }
            if (!$Array["Delete_Access_ID"]) {
                $Array["Delete_Access_ID"] = $ParentArray["Delete_Access_ID"];
            }
            if (!$Array["Checked_Access_ID"]) {
                $Array["Checked_Access_ID"] = $ParentArray["Checked_Access_ID"];
            }
            if (!$Array["Subscribe_Access_ID"]) {
                $Array["Subscribe_Access_ID"] = $ParentArray["Subscribe_Access_ID"];
            }
            if ($nc_core->modules->get_by_keyword("cache")) {
                if (!$Array["Cache_Access_ID"]) {
                    $Array["Cache_Access_ID"] = $ParentArray["Cache_Access_ID"];
                }
                if (!$Array["Cache_Lifetime"]) {
                    $Array["Cache_Lifetime"] = $ParentArray["Cache_Lifetime"];
                }
            }
            if (!$Array["Moderation_ID"]) {
                $Array["Moderation_ID"] = $ParentArray["Moderation_ID"];
            }
            $parent_sub = $ParentArray["Parent_Sub_ID"];
        }
        if (!$Array["Catalogue_ID"]) {
            $Array["Catalogue_ID"] = $ParentArray["Catalogue_ID"];
        }
    }
    if ($Array["Catalogue_ID"] == $GLOBALS["catalogue"]) {
        $ParentArray = $GLOBALS["current_catalogue"];
    } else {
        $ParentArray = $db->get_row("SELECT * FROM `Catalogue` WHERE `Catalogue_ID` = '" . $Array["Catalogue_ID"] . "'", ARRAY_A);
    }
    if (!$Array["Read_Access_ID"]) {
        $Array["Read_Access_ID"] = $ParentArray["Read_Access_ID"];
    }
    if (!$Array["Write_Access_ID"]) {
        $Array["Write_Access_ID"] = $ParentArray["Write_Access_ID"];
    }
    if (!$Array["Edit_Access_ID"]) {
        $Array["Edit_Access_ID"] = $ParentArray["Edit_Access_ID"];
    }
    if (!$Array["Subscribe_Access_ID"]) {
        $Array["Subscribe_Access_ID"] = $ParentArray["Subscribe_Access_ID"];
    }
    if (!$Array["Delete_Access_ID"]) {
        $Array["Delete_Access_ID"] = $ParentArray["Delete_Access_ID"];
    }
    if (!$Array["Checked_Access_ID"]) {
        $Array["Checked_Access_ID"] = $ParentArray["Checked_Access_ID"];
    }
    if ($nc_core->modules->get_by_keyword("cache")) {
        if (!$Array["Cache_Access_ID"]) {
            $Array["Cache_Access_ID"] = $ParentArray["Cache_Access_ID"];
        }
        if (!$Array["Cache_Lifetime"]) {
            $Array["Cache_Lifetime"] = $ParentArray["Cache_Lifetime"];
        }
    }
    if (!$Array["Moderation_ID"]) {
        $Array["Moderation_ID"] = $ParentArray["Moderation_ID"];
    }
    // cache section
    if ($nc_core->modules->get_by_keyword("cache") && $Array['Cache_Access_ID'] == 1 && is_object($nc_cache_function)) {
        try {
            $bytes = $nc_cache_function->add($Array, $data_string, serialize($Array));
            // debug info
            if ($bytes) {
                $cache_debug_info = "Writed, catalogue[" . $Array['Catalogue_ID'] . "], sub[" . $Array['Subdivision_ID'] . "], cc[" . $Array['Sub_Class_ID'] . "], Access_ID[-], Lifetime[-], bytes[" . $bytes . "]";
                $nc_cache_function->debugMessage($cache_debug_info, __FILE__, __LINE__, "ok");
            }
        } catch (Exception $e) {
            // for debug
            $nc_cache_function->errorMessage($e);
        }
    }
    $Array['sysTbl'] += 0;
    return $Array;
}
Beispiel #6
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();
 }
Beispiel #7
0
     $UI_CONFIG = new ui_config_subdivision_subclass($SubdivisionID, 'add');
 }
 $error = "";
 // сохранение формы
 if ($phase == 2 || $phase == 4) {
     $CustomSettings = $nc_core->input->fetch_post('CustomSettings');
     // получение значения дополнительных настроек (CustomSettings)
     if (!$ClassID) {
         $SQL = "SELECT `Class_ID`\n                            FROM `Sub_Class`\n                                WHERE `Sub_Class_ID` = " . +$SubClassID;
         $ClassID = $db->get_var($SQL);
     }
     $SQL = "SELECT `CustomSettingsTemplate`\n                        FROM `Class`\n                            WHERE `Class_ID` = " . +($Class_Template_ID ? $Class_Template_ID : $ClassID);
     $settings_array = $db->get_var($SQL);
     if ($settings_array) {
         require_once $ADMIN_FOLDER . "array_to_form.inc.php";
         $a2f = new nc_a2f($settings_array, 'CustomSettings');
         if (!$a2f->validate($CustomSettings)) {
             $error = $a2f->get_validation_errors();
         } else {
             $a2f->save($CustomSettings);
             $CustomSettings = $a2f->get_values_as_string();
         }
     } else {
         $CustomSettings = "";
     }
     // транслитерация, если пустой EnglishName
     if (empty($EnglishName)) {
         // здесь не нужна проверка на уникальность, поскольку далее
         // значение используется лишь для проверки на валидность
         $EnglishName = nc_transliterate($SubClassName, true);
     }
Beispiel #8
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();
Beispiel #9
0
settype($catalogue_id, "integer");
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);
Beispiel #10
0
function ActionCatalogueCompleted($CatalogueID, $type)
{
    global $nc_core, $db, $ROOT_FOLDER, $admin_mode;
    global $systemTableID, $systemTableName;
    global $FILES_FOLDER, $INCLUDE_FOLDER;
    global $FILECHMOD, $DIRCHMOD, $ADMIN_FOLDER, $MODULE_FOLDER;
    global $CatalogueID;
    if (isset($_POST['nc_shop_mode_' . $CatalogueID]) && +$_POST['nc_shop_mode_' . $CatalogueID] != $nc_core->get_settings('nc_shop_mode_' . $CatalogueID)) {
        $nc_core->set_settings('nc_shop_mode_' . $CatalogueID, +$_POST['nc_shop_mode_' . $CatalogueID]);
    }
    require_once $INCLUDE_FOLDER . "s_files.inc.php";
    $is_there_any_files = getFileCount(0, $systemTableID);
    $lm_type = $nc_core->page->get_field_name('last_modified_type');
    if ($type == 1) {
        $action = "add";
    }
    if ($type == 2) {
        $CatalogueID = intval($CatalogueID);
        $action = "change";
        $message = $CatalogueID;
    }
    $sm_field = $nc_core->page->get_field_name('sitemap_include');
    $sm_change_field = $nc_core->page->get_field_name('sitemap_changefreq');
    $sm_priority_field = $nc_core->page->get_field_name('sitemap_priority');
    $params = array('Catalogue_Name', 'Domain', 'Template_ID', 'Read_Access_ID', 'Write_Access_ID', 'Edit_Access_ID', 'Subscribe_Access_ID', 'Checked_Access_ID', 'Delete_Access_ID', 'Moderation_ID', 'Checked', 'Priority', 'Mirrors', 'Robots', 'Cache_Access_ID', 'Cache_Lifetime', 'TitleSubIDName', 'DisplayType', 'TitleSubIDKeyword', 'TitleTemplateID', 'E404SubIDName', 'E404SubIDKeyword', 'TitleSubID', 'E404SubID', 'E404TemplateID', 'CommentsEditRules', 'CommentAccessID', 'CommentsDeleteRules', 'posting', 'last_modified_type', 'DisallowIndexing', 'ncOfflineText', 'ncMobile', 'ncMobileSrc', 'ncMobileRedirect', 'ncMobileIdentity');
    if ($nc_core->modules->get_by_keyword('search')) {
        $params = array_merge($params, array($sm_field, $sm_change_field, $sm_priority_field));
    }
    foreach ($params as $v) {
        global ${$v};
    }
    $st = new nc_Component(0, 1);
    foreach ($st->get_fields() as $v) {
        $name = 'f_' . $v['name'];
        global ${$name};
        if ($v['type'] == 6) {
            global ${$name . "_old"};
            global ${"f_KILL" . $v['id']};
        }
        if ($v['type'] == 8) {
            global ${$name . "_day"};
            global ${$name . "_month"};
            global ${$name . "_year"};
            global ${$name . "_hours"};
            global ${$name . "_minutes"};
            global ${$name . "_seconds"};
        }
    }
    $Checked = intval($Checked);
    $Mirrors = str_replace(array("http://", "https://", "/"), "", $Mirrors);
    $Priority += 0;
    $Template_ID = intval($Template_ID);
    $posting = 1;
    // prepare template custom settings
    $settings = $db->get_var("SELECT CustomSettings FROM Template WHERE Template_ID = '" . $Template_ID . "'");
    if ($settings) {
        require_once $ADMIN_FOLDER . "array_to_form.inc.php";
        $a2f = new nc_a2f($settings, 'TemplateSettings');
        if ($a2f->has_errors()) {
            $warnText = $a2f->get_validation_errors();
            $posting = 0;
        }
        $a2f->save($_POST['TemplateSettings']);
        $TemplateSettings = $a2f->get_values_as_string();
        $TemplateSettings = addcslashes($TemplateSettings, "'");
    } else {
        $TemplateSettings = "";
    }
    require $ROOT_FOLDER . "message_fields.php";
    if ($posting == 0) {
        nc_print_status($warnText, 'error');
        CatalogueForm($CatalogueID, 3, "index.php", $type, $action);
        return false;
    }
    require $ROOT_FOLDER . "message_put.php";
    if (nc_module_check_by_keyword("comments")) {
        include_once $MODULE_FOLDER . "comments/function.inc.php";
    }
    switch ($ncMobile) {
        case 2:
            $ncMobile = 0;
            $ncResponsive = 1;
            break;
        case 1:
            $ncMobile = 1;
            $ncResponsive = 0;
            break;
        default:
            $ncMobile = 0;
            $ncResponsive = 0;
            break;
    }
    if ($type == 1) {
        $insert = "INSERT INTO `Catalogue` (";
        for ($i = 0; $i < $fldCount; $i++) {
            if ($fldTypeOfEdit[$i] == 3) {
                continue;
            }
            $insert .= $fld[$i] . ",";
        }
        if (nc_module_check_by_keyword("cache")) {
            $insert .= "`Cache_Access_ID`, `Cache_Lifetime`,";
        }
        $insert .= "`Catalogue_Name`, `Domain`, `" . $nc_core->page->get_field_name('language') . "`, `Template_ID`,  `Read_Access_ID`, `Write_Access_ID`, `Edit_Access_ID`, `Checked_Access_ID`, `Delete_Access_ID`, `Subscribe_Access_ID`, `Moderation_ID`, `Checked`, `Priority`, `Created`, `Mirrors`, `Robots`, `" . $lm_type . "`, `TemplateSettings` , `ncOfflineText`, `ncMobile`, `ncMobileSrc`, `ncMobileRedirect`, `ncMobileIdentity`, `ncResponsive`) ";
        $insert .= "VALUES (";
        for ($i = 0; $i < $fldCount; $i++) {
            if ($fldTypeOfEdit[$i] == 3 || $fldTypeOfEdit[$i] == 2 && !nc_field_check_admin_perm()) {
                continue;
            }
            // поле недоступно никому или доступно администратору но нет прав администратора
            if (isset(${$fld[$i] . 'Defined'}) && ${$fld[$i] . 'Defined'} == true) {
                $insert .= ${$fld[$i] . 'NewValue'} . ",";
            } else {
                $insert .= $fldValue[$i] . ",";
            }
        }
        if (nc_module_check_by_keyword("cache")) {
            $insert .= "'" . intval($Cache_Access_ID) . "',";
            $insert .= "'" . intval($Cache_Lifetime) . "',";
        }
        $insert .= "'" . $db->escape($Catalogue_Name) . "',";
        $insert .= "'" . $db->escape($Domain) . "',";
        $insert .= "'" . $db->escape($nc_core->input->fetch_get_post('language') != '' ? $nc_core->input->fetch_get_post('language') : MAIN_LANG) . "',";
        $insert .= "'" . $db->escape($Template_ID) . "',";
        $insert .= "'" . intval($Read_Access_ID) . "',";
        $insert .= "'" . intval($Write_Access_ID) . "',";
        $insert .= "'" . intval($Edit_Access_ID) . "',";
        $insert .= "'" . intval($Checked_Access_ID) . "',";
        $insert .= "'" . intval($Delete_Access_ID) . "',";
        $insert .= "'" . intval($Subscribe_Access_ID) . "',";
        $insert .= "'" . intval($Moderation_ID) . "',";
        $insert .= "'" . intval($Checked) . "',";
        $insert .= "'" . intval($Priority) . "',";
        $insert .= "'" . date("Y-m-d H:i:s") . "',";
        $insert .= "'" . $db->escape($Mirrors) . "',";
        $insert .= "'" . $db->escape($Robots) . "',";
        $insert .= "'" . intval($last_modified_type) . "',";
        $insert .= "'" . $db->escape($TemplateSettings) . "',";
        $insert .= "'" . $db->escape($ncOfflineText) . "',";
        $insert .= "'" . intval($ncMobile) . "',";
        $insert .= "'" . intval($ncMobileSrc) . "',";
        $insert .= "'" . intval($ncMobileRedirect) . "',";
        $insert .= "'" . intval($ncMobileIdentity) . "',";
        $insert .= "'" . intval($ncResponsive) . "'";
        $insert .= ")";
        // execute core action
        $nc_core->event->execute("addCataloguePrep", 0);
        $db->query($insert);
        if ($db->is_error) {
            throw new nc_Exception_DB_Error($db->last_query, $db->last_error);
        }
        $CatalogueID = $db->insert_id;
        // execute core action
        $nc_core->event->execute("addCatalogue", $CatalogueID);
        $message = $CatalogueID;
        if (nc_module_check_by_keyword("comments")) {
            if ($CommentAccessID > 0) {
                // add comment relation
                $CommentRelationID = nc_comments::addRule($db, array($message), $CommentAccessID, $CommentsEditRules, $CommentsDeleteRules);
                // update inserted data
                $db->query("UPDATE `Catalogue` SET `Comment_Rule_ID` = '" . (int) $CommentRelationID . "' WHERE `Catalogue_ID` = '" . (int) $message . "'");
            }
        }
        // проверка названия раздела
        if (!$TitleSubIDName || !$E404SubIDName) {
            nc_print_status(CONTROL_CONTENT_SUBDIVISION_INDEX_ERROR_THREE_NAME, 'error');
            return false;
        }
        // проверка символов для ключевого слова
        if (!$nc_core->subdivision->validate_hidden_url($TitleSubIDKeyword) || !$nc_core->subdivision->validate_hidden_url($E404SubIDKeyword)) {
            nc_print_status(CONTROL_CONTENT_SUBDIVISION_SUBCLASS_ERROR_KEYWORD_INVALID, 'error');
            return false;
        }
        // execute core action
        $nc_core->event->execute("addSubdivisionPrep", $CatalogueID, 0);
        // Добавление раздела для титульной страницы
        $db->query("INSERT INTO `Subdivision`\n      SET `Catalogue_ID` = '" . intval($CatalogueID) . "',\n      `Parent_Sub_ID` = 0,\n      `Subdivision_Name` = '" . $db->escape($TitleSubIDName) . "',\n      `Template_ID` = '" . intval($TitleTemplateID) . "',\n      `Checked` = 0,\n      `EnglishName` = '" . $db->escape($TitleSubIDKeyword) . "',\n      `Hidden_URL` = '/" . $db->escape($TitleSubIDKeyword) . "/',\n      `Priority` = 0");
        $title_sub_id = $db->insert_id;
        // execute core action
        $nc_core->event->execute("addSubdivision", $CatalogueID, $title_sub_id);
        // execute core action
        $nc_core->event->execute("addSubdivisionPrep", $CatalogueID, 0);
        // Добавление раздела для титульной страницы
        $db->query("INSERT INTO `Subdivision`\n      SET `Catalogue_ID` = '" . $CatalogueID . "',\n      `Parent_Sub_ID` = 0,\n      `Subdivision_Name` = '" . $db->escape($E404SubIDName) . "',\n      `Template_ID` = '" . intval($E404TemplateID) . "',\n      `Checked` = 0,\n      `EnglishName` = '" . $db->escape($E404SubIDKeyword) . "',\n      `Hidden_URL` = '/" . $db->escape($E404SubIDKeyword) . "/',\n      `Priority` = 1");
        $e404_sub_id = $db->insert_id;
        // execute core action
        $nc_core->event->execute("addSubdivision", $CatalogueID, $e404_sub_id);
        // для этого апдейта не нужно вызывать трансляцию события
        $db->query("UPDATE `Catalogue` SET `Title_Sub_ID` = '" . $title_sub_id . "', `E404_Sub_ID` = '" . $e404_sub_id . "' WHERE `Catalogue_ID` = '" . $CatalogueID . "'");
        //добавление системной настройки режима работы магазина.
        if (nc_module_check_by_keyword("netshop")) {
            $db->query("INSERT INTO `Settings` (`Key`, `Value`, `Module`, `Catalogue_ID`) VALUES ('nc_shop_mode_" . $CatalogueID . "', '2', 'system', '0')");
        }
    }
    if ($type == 2) {
        $cur_checked = $db->get_var("SELECT `Checked` FROM `Catalogue` WHERE `Catalogue_ID` = '" . $CatalogueID . "'");
        if (nc_module_check_by_keyword("comments")) {
            // get rule id
            $CommentData = nc_comments::getRuleData($db, array($CatalogueID));
            $CommentRelationID = $CommentData['ID'];
            // do something
            switch (true) {
                case $CommentAccessID > 0 && $CommentRelationID:
                    // update comment rules
                    nc_comments::updateRule($db, array($CatalogueID), $CommentAccessID, $CommentsEditRules, $CommentsDeleteRules);
                    break;
                case $CommentAccessID > 0 && !$CommentRelationID:
                    // add comment relation
                    $CommentRelationID = nc_comments::addRule($db, array($CatalogueID), $CommentAccessID, $CommentsEditRules, $CommentsDeleteRules);
                    break;
                case $CommentAccessID <= 0 && $CommentRelationID:
                    // delete comment rules
                    nc_comments::dropRuleCatalogue($db, $CatalogueID);
                    $CommentRelationID = 0;
                    break;
            }
        }
        $update = " UPDATE `Catalogue` SET ";
        for ($i = 0; $i < $fldCount; $i++) {
            if ($fldTypeOfEdit[$i] == 3) {
                continue;
            }
            // поле недоступно никому
            if (isset(${$fld[$i] . 'Defined'}) && ${$fld[$i] . 'Defined'} == true) {
                $update .= $fld[$i] . "=" . ${$fld[$i] . 'NewValue'} . ",";
            } else {
                $update .= $fld[$i] . "=" . $fldValue[$i] . ",";
            }
        }
        $update .= "`Catalogue_Name` = '" . $db->escape($Catalogue_Name) . "',";
        $update .= "`Domain` = '" . $db->escape($Domain) . "',";
        $update .= "`Template_ID` = " . intval($Template_ID) . ",";
        $update .= "`Read_Access_ID` = '" . intval($Read_Access_ID) . "',";
        $update .= "`Write_Access_ID` = '" . intval($Write_Access_ID) . "',";
        $update .= "`Edit_Access_ID` = '" . intval($Edit_Access_ID) . "',";
        $update .= "`Checked_Access_ID` = '" . intval($Checked_Access_ID) . "',";
        $update .= "`Delete_Access_ID` = '" . intval($Delete_Access_ID) . "',";
        $update .= "`Subscribe_Access_ID` = '" . intval($Subscribe_Access_ID) . "',";
        if (nc_module_check_by_keyword("cache")) {
            $update .= "`Cache_Access_ID` = '" . intval($Cache_Access_ID) . "',";
            $update .= "`Cache_Lifetime` = '" . intval($Cache_Lifetime) . "',";
        }
        if (nc_module_check_by_keyword("comments")) {
            $update .= "`Comment_Rule_ID` = '" . intval($CommentRelationID) . "',";
        }
        $update .= "`Moderation_ID` = '" . intval($Moderation_ID) . "',";
        $update .= "`Checked` = '" . intval($Checked) . "',";
        $update .= "`Priority` = '" . intval($Priority) . "',";
        $update .= "`Mirrors` = '" . $db->escape($Mirrors) . "',";
        $update .= "`Robots` = '" . $db->escape($Robots) . "',";
        $update .= "`Title_Sub_ID` = '" . intval($TitleSubID) . "',";
        $update .= "`E404_Sub_ID` = '" . intval($E404SubID) . "',";
        $update .= "`" . $lm_type . "` = '" . intval($last_modified_type) . "',";
        $update .= "`DisallowIndexing`= '" . intval($DisallowIndexing) . "',";
        $update .= "`" . $nc_core->page->get_field_name('language') . "` = '" . $nc_core->input->fetch_get_post('language') . "',";
        if ($nc_core->modules->get_by_keyword('search')) {
            $update .= "`" . $sm_field . "` = '" . $nc_core->input->fetch_get_post('sitemap_include') . "',";
            $update .= "`" . $sm_change_field . "` = '" . $nc_core->input->fetch_get_post('sitemap_changefreq') . "',";
            $update .= "`" . $sm_priority_field . "` = '" . str_replace(',', '.', sprintf("%.1f", doubleval($nc_core->input->fetch_get_post('sitemap_priority')))) . "',";
        }
        $update .= "`TemplateSettings` = '" . $db->escape($TemplateSettings) . "',";
        $update .= "`ncOfflineText` = '" . $db->escape($ncOfflineText) . "',";
        $update .= "`ncMobile` = '" . intval($ncMobile) . "',";
        $update .= "`ncMobileSrc` = '" . intval($ncMobileSrc) . "',";
        $update .= "`ncMobileRedirect` = '" . intval($ncMobileRedirect) . "',";
        $update .= "`ncMobileIdentity` = '" . intval($ncMobileIdentity) . "',";
        $update .= "`ncResponsive` = '" . intval($ncResponsive) . "',";
        $update .= "`DisplayType` = '" . $db->escape($DisplayType) . "'";
        $update .= " WHERE `Catalogue_ID` = " . $CatalogueID;
        // execute core action
        $nc_core->event->execute("updateCataloguePrep", $CatalogueID);
        if ($cur_checked != $Checked) {
            $nc_core->event->execute($Checked ? "checkCataloguePrep" : "uncheckCataloguePrep", $CatalogueID);
        }
        $db->query($update);
        if ($db->is_error) {
            throw new nc_Exception_DB_Error($db->last_query, $db->last_error);
        }
        // execute core action
        $nc_core->event->execute("updateCatalogue", $CatalogueID);
        // произошло включение / выключение
        if ($cur_checked != $Checked) {
            $nc_core->event->execute($Checked ? "checkCatalogue" : "uncheckCatalogue", $CatalogueID);
        }
    }
    /*     * */
    if (is_array($filetable_lastid) && !empty($filetable_lastid)) {
        foreach ($filetable_lastid as $id) {
            $db->query("UPDATE `Filetable` SET `Message_ID` = '" . $message . "' WHERE `ID` = '" . intval($id) . "'");
        }
    }
    /*     * */
    if ($tmpFile) {
        @mkdir($FILES_FOLDER . "c/", $DIRCHMOD);
    }
    for ($i = 0; $i < count($tmpFile); $i++) {
        eval("\$tmpNewFile[\$i] = \"" . $tmpNewFile[$i] . "\";");
        if ($FileFS[$i] == NC_FS_PROTECTED || $FileFS[$i] == NC_FS_ORIGINAL) {
            @rename($nc_core->FILES_FOLDER . $tmpNewFile[$i], $nc_core->FILES_FOLDER . $File_PathNew[$i] . $tmpNewFile[$i]);
        } else {
            @rename($nc_core->FILES_FOLDER . $tmpFile[$i], $nc_core->FILES_FOLDER . $File_Path[$i] . $tmpNewFile[$i]);
        }
        @chmod($FILES_FOLDER . "c/" . $tmpNewFile[$i], $FILECHMOD);
    }
    // сброс
    $nc_core->catalogue->load_all();
    return true;
}
Beispiel #11
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>
 public function action_settings($widget_id, $block_widget_id)
 {
     $widget_class_id = $this->widget_table->where_id($widget_id)->get_value('Widget_Class_ID');
     if (in_array($widget_class_id, $this->system_widgetclass_ids)) {
         require_once $this->nc_core->ADMIN_FOLDER . 'array_to_form.inc.php';
         $block_widget = $this->block_widget_table->where_id($block_widget_id)->get_row();
         $settings = $block_widget['Widget_Settings'] ? unserialize($block_widget['Widget_Settings']) : array();
         $template_folder = $this->nc_core->WIDGET_TEMPLATE_FOLDER . 'aggregator/' . $widget_id . '/';
         $custom_settings_file = $template_folder . 'CustomSettings.html';
         if (file_exists($custom_settings_file)) {
             $fields = (include $custom_settings_file);
             $form = false;
             $view = $this->view('widget_block/widget_settings');
             if (is_array($fields)) {
                 $form = new nc_a2f($fields, 'custom_settings');
                 $form->set_values($settings);
                 $view->with('form', $form)->with('fields', $form->get_fields());
             } else {
                 $view->with('form', false)->with('fields', array());
             }
             return $view;
         }
     }
     return $this->nc_core->ui->alert->info(NETCAT_CUSTOM_NONE_SETTINGS);
 }
Beispiel #13
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);
Beispiel #14
0
             $quick_mode = true;
             setcookie("QUICK_BAR_CLOSED", -1, time() + $nc_core->get_variable("ADMIN_AUTHTIME"), "/", $cookie_domain);
         } else {
             setcookie("QUICK_BAR_CLOSED", 1, time() + $nc_core->get_variable("ADMIN_AUTHTIME"), "/", $cookie_domain);
         }
     }
 }
 if ($nc_core->template->get_current("CustomSettings") && $nc_core->subdivision->get_current('Template_ID') == $template) {
     require_once $nc_core->ADMIN_FOLDER . "array_to_form.inc.php";
     $nc_a2f = new nc_a2f($nc_core->template->get_current("CustomSettings"));
     $nc_a2f->set_value($nc_core->subdivision->get_current("TemplateSettings"));
     $template_settings = $nc_a2f->get_values_as_array();
 }
 if ($nc_core->template->get_current("CustomSettings") && $nc_core->subdivision->get_current('Template_ID') != $template) {
     require_once $nc_core->ADMIN_FOLDER . "array_to_form.inc.php";
     $nc_a2f = new nc_a2f($nc_core->template->get_current("CustomSettings"), array());
     $template_settings = $nc_a2f->get_values_as_array();
 }
 if ($nc_core->inside_admin) {
     // output interface settings (add 'em to the footer before </body>)
     $UI_CONFIG = new ui_config_objects($cc);
     $js_code = '".$UI_CONFIG->to_json()."';
     if ($template_footer && nc_preg_match("/(<\\/body>)/i", $template_footer, $regs)) {
         $template_footer = str_replace($regs[1], $js_code . $regs[1], $template_footer);
     } else {
         $template_footer .= $js_code;
     }
 }
 #if ($quick_mode && nc_quickbar_permission()) {
 #    $template_footer = nc_cut_jquery($template_footer);
 #}
Beispiel #15
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>";
Beispiel #16
0
<?php

if (!class_exists("nc_system")) {
    die;
}
$ui = $this->get_ui();
$ui->add_settings_toolbar();
$ui->add_submit_button(NETCAT_MODULE_SEARCH_ADMIN_SAVE);
$ui->add_back_button();
$rule = $this->data_form('nc_search_rule', 'rules');
if ($this->get_input('copy')) {
    $rule->load($this->get_input('copy'));
    // ->set_id(null);
}
$form_description = array('name' => array('type' => 'string', 'caption' => NETCAT_MODULE_SEARCH_ADMIN_RULE_NAME . ':'), 'site_id' => array('type' => 'select', 'values' => $search_providers, 'subtype' => 'sql', 'sqlquery' => "SELECT `Catalogue_ID` as `id`, " . "       CONCAT(`Catalogue_Name`, ' ', IF(LENGTH(`Domain`)>0, CONCAT('(', `Domain`, ')'), '')) as `name`" . "  FROM `Catalogue`", 'caption' => NETCAT_MODULE_SEARCH_ADMIN_RULE_SITE . ':', 'default_value' => 1));
$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>", "");
Beispiel #17
0
function nc_subdivision_add()
{
    $nc_core = nc_Core::get_object();
    $db = $nc_core->db;
    $CatalogueID = intval($nc_core->input->fetch_get_post('CatalogueID'));
    $ParentSubID = intval($nc_core->input->fetch_get_post('ParentSubID'));
    $Template_ID = intval($nc_core->input->fetch_get_post('Template_ID'));
    $input = $nc_core->input->fetch_get_post();
    // проверка названия раздела
    $Subdivision_Name = trim($nc_core->input->fetch_get_post('Subdivision_Name'));
    if (!$Subdivision_Name) {
        throw new Exception(CONTROL_CONTENT_SUBDIVISION_INDEX_ERROR_THREE_NAME);
    }
    // проверка ключевого слова
    $EnglishName = trim($nc_core->input->fetch_get_post('EnglishName'));
    if (empty($EnglishName)) {
        $EnglishName = nc_transliterate($Subdivision_Name, true);
    }
    // проверка на валидность
    $EnglishName = nc_check_english_name(0, $EnglishName, 1);
    if (!$nc_core->subdivision->validate_english_name($EnglishName)) {
        throw new Exception(CONTROL_CONTENT_SUBDIVISION_SUBCLASS_ERROR_KEYWORD_INVALID);
    }
    // проверка уникальности ключевого слова
    if (!IsAllowedSubdivisionEnglishName($EnglishName, $ParentSubID, 0, $CatalogueID)) {
        throw new Exception(CONTROL_CONTENT_SUBDIVISION_INDEX_ERROR_THREE_KEYWORD);
    }
    // визуальные настройки
    $TemplateSettings = "";
    if ($_POST['is_parent_template'] == 'true') {
        $Template_ID = 0;
    }
    if ($Template_ID) {
        $settings = $nc_core->db->get_var("SELECT `CustomSettings` FROM `Template` WHERE `Template_ID` = '" . $Template_ID . "'");
        if ($settings) {
            require_once $nc_core->ADMIN_FOLDER . "array_to_form.inc.php";
            $a2f = new nc_a2f($settings, 'TemplateSettings');
            if (!$a2f->validate($_POST['TemplateSettings'])) {
                throw new Exception($a2f->get_validation_errors());
            }
            if (isset($_POST['TemplateSettings']) && !empty($_POST['TemplateSettings'])) {
                $a2f->save($_POST['TemplateSettings']);
                $TemplateSettings = $a2f->get_values_as_string();
            }
        }
    }
    // execute core action
    $nc_core->event->execute("addSubdivisionPrep", $CatalogueID, 0);
    // добавление раздела
    $db->query("\n        INSERT INTO `Subdivision`\n            SET `Created` = NOW(),\n                `Subdivision_Name` = '" . $db->escape($Subdivision_Name) . "',\n                `EnglishName` = '" . $db->escape($EnglishName) . "',\n                `Parent_Sub_ID` = '" . $ParentSubID . "',\n                `Catalogue_ID` = '" . $CatalogueID . "',\n                `Checked` = '" . intval($input['Checked']) . "',\n                `Priority` = '" . intval($input['Priority']) . "',\n                `Favorite` = '" . intval($input['Favorite']) . "',\n                `UseMultiSubClass` = 1,\n                `Template_ID` = '" . $Template_ID . "',\n                `TemplateSettings` = '" . $db->escape($TemplateSettings) . "',\n                `UseEditDesignTemplate` = '" . intval($input['UseEditDesignTemplate']) . "',\n                `DisplayType` = '" . $db->escape($nc_core->input->fetch_get_post('DisplayType')) . "'");
    if ($db->is_error) {
        throw new nc_Exception_DB_Error($db->last_query, $db->last_error);
    }
    $SubdivisionID = $db->insert_id;
    // обновим Hidden_URL
    $hidden_url = GetHiddenURL($ParentSubID);
    UpdateHiddenURL($hidden_url ? $hidden_url : "/", $ParentSubID, $CatalogueID);
    $nc_core->event->execute("addSubdivision", $CatalogueID, $SubdivisionID);
    // добавление компонента в разделе
    $Class_ID = intval($input['Class_ID']);
    $Class_Template_ID = intval($input['Class_Template_ID']);
    if ($Class_ID) {
        // визуальные настройки
        $CustomSettings = "";
        $settings_array = $db->get_var("SELECT `CustomSettingsTemplate` FROM `Class`\n      WHERE `Class_ID` = '" . ($Class_Template_ID ? $Class_Template_ID : $Class_ID) . "'");
        if ($settings_array) {
            require_once $nc_core->ADMIN_FOLDER . "array_to_form.inc.php";
            $a2f = new nc_a2f($settings_array, 'CustomSettings');
            if (!$a2f->validate($_POST['CustomSettings'])) {
                $error = $a2f->get_validation_errors();
            } else {
                $a2f->save($_POST['CustomSettings']);
                $CustomSettings = $a2f->get_values_as_string();
            }
        }
        $nc_core->event->execute("addSubClassPrep", $CatalogueID, $SubdivisionID, 0);
        $db->query("INSERT INTO `Sub_Class`\n      (`Subdivision_ID`, `Catalogue_ID`, `Class_ID`, `Sub_Class_Name`, `Checked`, `EnglishName`, `Created`, `CustomSettings`, `Class_Template_ID`)\n       VALUES\n       ('" . $SubdivisionID . "', '" . $CatalogueID . "', '" . $Class_ID . "', '" . $Subdivision_Name . "', 1, '" . $EnglishName . "',  '" . date("Y-m-d H:i:s") . "',  '" . addcslashes($CustomSettings, "'") . "', '" . $Class_Template_ID . "')");
        if ($SubClassID = $db->insert_id) {
            $nc_core->event->execute("addSubClass", $CatalogueID, $SubdivisionID, $SubClassID);
        }
    }
    return $SubdivisionID;
}