function nc_catalogue_form_shop_mode($CatalogueID) { $radio = array(); $radio[] = array('attr' => array('value' => '0'), 'desc' => CATALOGUE_FORM_SHOP_MODE_SIMPLE); $radio[] = array('attr' => array('value' => '1'), 'desc' => CATALOGUE_FORM_SHOP_MODE_ISHOP); if (nc_Core::get_object()->modules->get_by_keyword('netshop')) { $radio[] = array('attr' => array('value' => '2'), 'desc' => CATALOGUE_FORM_SHOP_MODE_NETSHOP); } return nc_get_modal_radio('nc_shop_mode_' . $CatalogueID, $radio, +nc_Core::get_object()->get_settings('nc_shop_mode_' . $CatalogueID)); }
function ActionForm($SubClassID, $phase, $type) { global $loc, $perm; global $SubdivisionID; global $CatalogueID; global $UI_CONFIG, $SUB_FOLDER, $HTTP_ROOT_PATH, $MODULE_FOLDER, $ADMIN_FOLDER, $ADMIN_PATH; $nc_core = nc_Core::get_object(); $db = $nc_core->db; $SubdivisionID = $SubdivisionID ? intval($SubdivisionID) : $nc_core->sub_class->get_by_id($SubClassID, 'Subdivision_ID'); $CatalogueID = $CatalogueID ? intval($CatalogueID) : $nc_core->subdivision->get_by_id($SubdivisionID, 'Catalogue_ID'); if ($type == 2) { $SubEnv = $nc_core->sub_class->get_by_id($SubClassID, 0, 1, 1); $ClassEnv = $db->get_row("SELECT * FROM `Class` WHERE `Class_ID` = '" . intval($SubEnv["Class_ID"]) . "'", ARRAY_A); } elseif ($type == 1) { if (!$SubdivisionID) { $SubEnv = $db->get_row("SELECT * FROM `Catalogue` WHERE `Catalogue_ID` = '" . $CatalogueID . "'", ARRAY_A); } else { $SubEnv = $nc_core->subdivision->get_by_id($SubdivisionID); } $UI_CONFIG->locationHash = "subclass.add(" . $SubdivisionID . ")"; } if ($phase == 2 && $type == 1 && $SubdivisionID) { $Sub_Class_count = $db->get_var("SELECT COUNT(*) FROM `Sub_Class` WHERE `Subdivision_ID` = '" . $SubdivisionID . "'"); if (!$Sub_Class_count) { nc_print_status(CONTROL_CONTENT_SUBDIVISION_FIRST_SUBCLASS, 'info'); } } echo "<form enctype='multipart/form-data' method='post' action='SubClass.php' id='adminForm' class='nc-form'>"; if ($type == 1) { // insert global $ClassID; $Sub_Class_fs = $db->get_var("SELECT c.`File_Mode` FROM `Sub_Class` AS sc, `Class` AS c WHERE sc.`Class_ID` = c.`Class_ID` AND sc.`Subdivision_ID` = '" . $SubdivisionID . "'"); $sql = "SELECT `Class_ID` as value, " . "CONCAT(`Class_ID`, '. ', `Class_Name`) as description, " . "`Class_Group` as optgroup " . "FROM `Class` " . "WHERE `ClassTemplate` = 0 AND File_Mode = 0 " . "ORDER BY `Class_Group`, `Priority`, `Class_ID`"; $classesV4 = (array) $db->get_results($sql, ARRAY_A); $sql = "SELECT `Class_ID` as value, " . "CONCAT(`Class_ID`, '. ', `Class_Name`) as description, " . "`Class_Group` as optgroup " . "FROM `Class` " . "WHERE `ClassTemplate` = 0 AND File_Mode = 1 " . "ORDER BY `Class_Group`, `Priority`, `Class_ID`"; $classesV5 = (array) $db->get_results($sql, ARRAY_A); if (!$ClassID) { if (!$selected_value) { $selected_value = $db->get_var("SELECT `Class_ID` FROM `Class` ORDER BY `File_Mode` DESC, `Class_Group`, `Class_ID` LIMIT 1"); } } else { $selected_value = $ClassID; } $ClassEnv = $db->get_row("SELECT * FROM `Class` WHERE `Class_ID`='" . intval($selected_value) . "'", ARRAY_A); $Array["AllowTags"] = -1; $Array["NL2BR"] = -1; $Array["UseCaptcha"] = -1; global $SubClassName, $Read_Access_ID, $Write_Access_ID, $Edit_Access_ID, $DefaultAction; global $Checked_Access_ID, $Delete_Access_ID; global $SubscribeAccessID, $Moderation_ID, $Checked, $Priority, $CustomSettings; global $EnglishName, $DaysToHold, $AllowTags, $NL2BR, $RecordsPerPage, $SortBy, $UseCaptcha, $Class_Template_ID, $isNaked; if (nc_module_check_by_keyword("cache")) { global $CacheForUser; } if ($Priority == "" && $Checked == "") { $Checked = 1; } if ($Priority == "") { $Priority = $db->get_var("SELECT (`Priority` + 1) FROM `Sub_Class` WHERE `Subdivision_ID` = '" . $loc->SubdivisionID . "' ORDER BY `Priority` DESC LIMIT 1"); list($SubClassName, $EnglishName) = $db->get_row("SELECT `Subdivision_Name`, `EnglishName` FROM `Subdivision` WHERE `Subdivision_ID` = '" . $loc->SubdivisionID . "'", ARRAY_N); } $Array["Sub_Class_Name"] = $SubClassName; $Array["Read_Access_ID"] = $Read_Access_ID; $Array["Write_Access_ID"] = $Write_Access_ID; $Array["Edit_Access_ID"] = $Edit_Access_ID; $Array["Checked_Access_ID"] = $Checked_Access_ID; $Array["Delete_Access_ID"] = $Delete_Access_ID; $Array["Subscribe_Access_ID"] = $SubscribeAccessID; if (nc_module_check_by_keyword("cache")) { $Array["Cache_Access_ID"] = $CacheAccessID; $Array["Cache_Lifetime"] = $CacheLifetime; $Array["CacheForUser"] = $CacheForUser != "" ? $CacheForUser : -1; } $Array["Moderation_ID"] = $Moderation_ID; $Array["DefaultAction"] = $DefaultAction; $Array["Checked"] = $Checked; $Array["Priority"] = $Priority; $Array["EnglishName"] = $EnglishName . ($Sub_Class_count ? '-' . $Sub_Class_count : ''); $Array["DaysToHold"] = $DaysToHold; if ($AllowTags != "") { $Array["AllowTags"] = $AllowTags; } if ($NL2BR != "") { $Array["NL2BR"] = $NL2BR; } if ($UseCaptcha != "") { $Array["UseCaptcha"] = $UseCaptcha; } $Array["RecordsPerPage"] = $RecordsPerPage; $Array["SortBy"] = $SortBy; $Array["Class_Template_ID"] = $Class_Template_ID; $Array["isNaked"] = $isNaked; $Array["SrcMirror"] = $SrcMirror; // visual settings $Array['CustomSettingsTemplate'] = $db->get_var("SELECT `CustomSettingsTemplate` FROM `Class`\n WHERE `Class_ID` = '" . ($Class_Template_ID ? $Class_Template_ID : $ClassID ? $ClassID : $selected_value) . "'"); $classInfo = "<tr><td>"; $classInfo .= "\n <font color='gray'>" . CONTROL_CONTENT_SUBCLASS_TYPE . ":<br/>\n\n <div id='nc_mirror_radio'>\n " . nc_get_modal_radio('is_mirror', array(array('attr' => array('value' => '0', 'onClick' => '$nc("#nc_class_select").show(); $nc("#nc_mirror_select").hide(); $nc("#loadClassTemplates").html("")'), 'desc' => CONTROL_CONTENT_SUBCLASS_TYPE_SIMPLE), array('attr' => array('value' => '1', 'onClick' => '$nc("#nc_class_select").hide(); $nc("#nc_mirror_select").show(); $nc("#loadClassTemplates").html("")'), 'desc' => CONTROL_CONTENT_SUBCLASS_TYPE_MIRROR)), 0) . "\n </div>"; $classInfo .= "<div id='nc_class_select'>"; if ($Sub_Class_fs === null && (!empty($classesV4) || !empty($classesV5)) || $Sub_Class_fs == 0 && !empty($classesV4) || $Sub_Class_fs == 1 && !empty($classesV5)) { $classInfo .= "<font color='gray'>" . CONTROL_CLASS_CLASS . ":<br>"; $classInfo .= "<select id='ClassID' name='ClassID' onchange='if (this.options[this.selectedIndex].value) {loadClassDescription(this.options[this.selectedIndex].value); loadClassCustomSettings(this.options[this.selectedIndex].value); loadClassTemplates(this.options[this.selectedIndex].value, 0, " . $CatalogueID . ");}'>"; if ($Sub_Class_fs === null && (!empty($classesV4) || !empty($classesV5))) { if (!empty($classesV5)) { $classInfo .= "<option disabled='disabled'>" . CONTROL_CLASS . " v5</option>\n"; $classInfo .= nc_select_options($classesV5, $selected_value); } if (!empty($classesV4)) { $classInfo .= "<option disabled='disabled'>" . CONTROL_CLASS . " v4</option>\n"; $classInfo .= nc_select_options($classesV4, $selected_value); } } else { if ($Sub_Class_fs == 0 && !empty($classesV4)) { $classInfo .= nc_select_options($classesV4, $selected_value); } else { if ($Sub_Class_fs == 1 && !empty($classesV5)) { $classInfo .= nc_select_options($classesV5, $selected_value); } } } $classInfo .= "</select>"; $classInfo .= "<div id='loadClassDescription'></div>"; $classInfo .= "<script>if ('" . $selected_value . "') {loadClassDescription(" . $selected_value . ");}</script>"; } else { $classInfo .= CONTROL_CLASS_NONE; } $classInfo .= "</div>"; $classInfo .= "\n <div id='nc_mirror_select' style='display: none;'>\n <div>\n " . CONTROL_CONTENT_SUBCLASS_SRCMIRROR . ":\n </div>\n\n <div>\n <span id='cs_SrcMirror_caption' style='font-weight:bold;'>" . CONTROL_CONTENT_SUBCLASS_SRCMIRROR_NONE . "</span>\n <input id='cs_SrcMirror_value' name='SrcMirror' type='hidden' value='' /> \n <a href='#' onclick=\"window.open('" . $ADMIN_PATH . "related/select_subclass.php?cs_type=rel_cc&cs_field_name=SrcMirror', 'nc_popup_SrcMirror', 'width=800,height=500,menubar=no,resizable=no,scrollbars=yes,toolbar=no,resizable=yes'); return false;\">\n\t\t\t\t\t\t\t\t" . CONTROL_CONTENT_SUBCLASS_SRCMIRROR_EDIT . "\n\t\t\t\t\t\t\t</a> \n\n <a href='#' onclick=\"document.getElementById('cs_SrcMirror_value').value='';document.getElementById('cs_SrcMirror_caption').innerHTML = '" . CONTROL_CONTENT_SUBCLASS_SRCMIRROR_NONE . "';return false;\">\n " . CONTROL_CONTENT_SUBCLASS_SRCMIRROR_DELETE . "\n </a>\n </div>\n\n </div>"; $classInfo .= "<div id='loadClassTemplates'></div>"; $classInfo .= "\n <script>\n var old_val = \$nc('#cs_SrcMirror_value').val();\n setInterval(function() {\n var val = \$nc('#cs_SrcMirror_value').val();\n if (old_val != val) {\n if (val) {\n loadClassTemplates(val, 0, 0, 1);\n }\n old_val = val;\n }\n }, 200);\n if ('" . $selected_value . "') {loadClassTemplates(" . $selected_value . ($Class_Template_ID ? ", " . $Class_Template_ID : ", 0") . ($CatalogueID ? ", " . $CatalogueID : "") . ");}\n </script>"; $classInfo .= "</td></tr>\n"; } if ($type == 2) { 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\n " . $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\n `Sub_Class` as s,\n `Class` as c\n WHERE\n `Sub_Class_ID` = '" . intval($SubClassID) . "'\n AND\n 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` FROM `Class`\n WHERE `Class_ID` = '" . intval($Array['Class_Template_ID']) . "'"); } $mobile = $nc_core->catalogue->get_by_id($CatalogueID, 'ncMobile'); $SQL = "SELECT `Class_Name`,\n `Class_ID`\n FROM `Class`\n WHERE `ClassTemplate` = {$Array['Class_ID']}\n AND `Type` IN ('useful', 'title', 'mobile', 'responsive')"; $classTemplatesArr = $db->get_results($SQL, ARRAY_A); $class_array = nc_get_class_template_array_by_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); } $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, true)); $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='{$phase}' />\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' class='hidden'>\n </form>"); $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)); } else { $fieldsets->new_fieldset('CustomSettings')->add("<div id='loadClassCustomSettings'></div>"); } $fieldsets->new_fieldset('access', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ACCESS)->add(nc_subdivision_show_access($SubEnv)); if ($type == 2) { $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')) { require_once $nc_core->MODULE_FOLDER . 'comments/function.inc.php'; $fieldsets->new_fieldset('comments', CONTROL_CONTENT_SUBCLASS_FUNCS_COMMENTS)->add(nc_subdivision_show_comments($SubEnv)); } echo $fieldsets->to_string(); if ($type == 1) { $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => STRUCTURE_TAB_SUBCLASS_ADD, "action" => "mainView.submitIframeForm()", "align" => "right"); } elseif ($type == 2) { $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_SAVE, "action" => "mainView.submitIframeForm()", "align" => "right"); } }
function nc_subdivision_show_comments($env) { require_once nc_Core::get_object()->MODULE_FOLDER . 'comments/function.inc.php'; $db = nc_Core::get_object()->db; $AccessType = array(0 => array(0 => 1, 1 => CLASSIFICATOR_USERGROUP_ALL), 1 => array(0 => 2, 1 => CLASSIFICATOR_USERGROUP_REGISTERED), 2 => array(0 => 3, 1 => CLASSIFICATOR_USERGROUP_AUTHORIZED), 3 => array(0 => 4, 1 => CLASSIFICATOR_COMMENTS_DISABLE)); $comments_data = nc_comments::getRuleData($db, array($env['Catalogue_ID'], $env['Subdivision_ID'], $env['Sub_Class_ID'], $env['Message_ID'])); $parent_comment_rule = $env['Comment_Rule_ID'] ? $db->get_row("SELECT * FROM `Comments_Rules` WHERE `ID` = " . $env['Comment_Rule_ID'], ARRAY_A) : array(); $comments_change_variants = array('disable' => CLASSIFICATOR_COMMENTS_DISABLE, 'enable' => CLASSIFICATOR_COMMENTS_ENABLE, 'unreplied' => CLASSIFICATOR_COMMENTS_NOREPLIED); //правила в любом случае наследуются, inherit_radio позволяет удалить правило текщей сущности //$hide_inherit_radio = !isset($env['Parent_Sub_ID']) && !$env['Message_ID']; $html = "<script type='text/javascript'>\n \$nc(function() {\n \$nc('input[name=CommentAccessID]').click(function(){\n var radioValue = \$nc('input[name=CommentAccessID]:checked').val();\n var inputs = \$nc('#CommentsEditRules, #CommentsDeleteRules');\n\n if (0 == radioValue) {\n inputs.attr('disabled', 'disabled');\n } else {\n inputs.removeAttr('disabled');\n }\n\n });\n\n "; if ($comments_data["Access_ID"] == 0) { $html .= "\n \$nc('#CommentsEditRules, #CommentsDeleteRules').attr('disabled', 'disabled');\n "; } $html .= "\n });\n </script>\n <style>\n div.nc_table_comments > div {\n border-bottom: 1px #cccccc solid;\n display: table;\n }\n\n div.nc_table_comments > div > div {\n display: inline-block;\n padding-top: 9px;\n padding-bottom: 11px;\n }\n\n div.nc_table_comments div.col_1 {\n width: 214px;\n }\n\n div.nc_table_comments div.col_2 {\n text-align: center;\n width: 134px;\n }\n\n div.nc_table_comments div.col_3 {\n text-align: center;\n width: 61px;\n }\n\n div.nc_table_comments div.col_4 {\n text-align: center;\n width: 180px;\n }\n\n div.nc_table_comments div.col_5 {\n text-align: center;\n width: 158px;\n }\n\n div.nc_table_comments div.col_6 {\n text-align: center;\n width: 116px;\n }\n\n div.nc_table_comments > div.row_1 {\n padding-top: 3px;\n padding-bottom: 2px;\n }\n\n div.nc_table_comments div.col_checked {\n background-color: #eeeeee;\n }\n\n </style>"; $comments_radio = array(); $comments_radio['inherit'] = array('attr' => array('value' => '0'), 'desc' => CONTROL_CONTENT_SUBDIVISION_FUNCS_ACCESS_INHERIT); $comments_radio += array(array('attr' => array('value' => '1'), 'desc' => CLASSIFICATOR_USERGROUP_ALL), array('attr' => array('value' => '2'), 'desc' => CLASSIFICATOR_USERGROUP_REGISTERED), array('attr' => array('value' => '3'), 'desc' => CLASSIFICATOR_USERGROUP_AUTHORIZED), array('attr' => array('value' => '4'), 'desc' => CLASSIFICATOR_COMMENTS_DISABLE)); if ($hide_inherit_radio) { unset($comments_radio['inherit']); } $html .= "<div>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_COMMENTS_ADD . "</div>"; $html .= nc_get_modal_radio('CommentAccessID', $comments_radio, +$comments_data["Access_ID"]); $html .= "<br/>"; $html .= "\n <style>\n div.nc_table_content > div > div {\n display: inline-block;\n }\n\n div.nc_table_content div.col_1 {\n width: 244px;\n }\n </style>\n\n <div class='nc_table_content'>\n <div>\n <div class='col_1'>\n " . CONTROL_CONTENT_SUBDIVISION_FUNCS_COMMENTS_AUTHOR_EDIT . "\n </div>\n\n <div class='col_2'>"; $html .= " <select name='CommentsEditRules' id='CommentsEditRules' " . ($comments_data["Access_ID"] > 0 ? '' : 'disabled ') . ">"; foreach ($comments_change_variants as $key => $value) { switch (true) { case empty($comments_data) && empty($parent_comment_rule) && $key == "disable": $opt_selected = " selected"; break; case empty($comments_data) && $parent_comment_rule['Edit_Rule'] == $key: $opt_selected = " selected"; break; case $comments_data['Edit_Rule'] == $key: $opt_selected = " selected"; break; default: $opt_selected = ""; } $html .= " <option value='{$key}'{$opt_selected}>{$value}</option>"; } $html .= " </select>\n\n </div>\n </div>\n\n <div>\n <div class='col_1'>\n " . CONTROL_CONTENT_SUBDIVISION_FUNCS_COMMENTS_AUTHOR_DELETE . "\n </div>\n\n <div class='col_2'>"; $html .= " <select name='CommentsDeleteRules' id='CommentsDeleteRules'" . ($comments_data["Access_ID"] > 0 ? '' : 'disabled ') . ">"; foreach ($comments_change_variants as $key => $value) { switch (true) { case empty($comments_data) && empty($parent_comment_rule) && $key == "disable": $opt_selected = " selected"; break; case empty($comments_data) && $parent_comment_rule['Delete_Rule'] == $key: $opt_selected = " selected"; break; case $comments_data['Delete_Rule'] == $key: $opt_selected = " selected"; break; default: $opt_selected = ""; } $html .= " <option value='{$key}'{$opt_selected}>{$value}</option>\r\n"; } $html .= " </select>\n </div>\n </div>\n </div>"; return $html; }