Ejemplo n.º 1
0
function CatalogueForm($CatalogueID, $phase, $action, $type, $bar_action = null)
{
    # type = 1 - это insert
    # type = 2 - это update
    global $ROOT_FOLDER, $HTTP_FILES_PATH, $DOMAIN_NAME;
    global $SUB_FOLDER, $HTTP_ROOT_PATH, $ADMIN_PATH;
    global $systemTableID, $systemTableName, $admin_mode;
    global $FILES_FOLDER, $INCLUDE_FOLDER, $MODULE_FOLDER, $ADMIN_FOLDER;
    global $UI_CONFIG;
    if (!$bar_action) {
        $bar_action = 'edit';
    }
    $nc_core = nc_Core::get_object();
    $db = $nc_core->db;
    $lm_type = $nc_core->page->get_field_name('last_modified_type');
    $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');
    $lang_field = $nc_core->page->get_field_name('language');
    $CatalogueID = intval($CatalogueID);
    $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', 'TitleSubIDKeyword', 'TitleTemplateID', 'E404SubIDName', 'E404SubIDKeyword', 'E404TemplateID', 'CommentsEditRules', 'CommentAccessID', 'CommentsDeleteRules', 'DisplayType', 'last_modified_type', 'AllowIndexing', $sm_field, $sm_change_field, $sm_priority_field, 'ncOfflineText');
    foreach ($params as $v) {
        ${$v} = $nc_core->input->fetch_get_post($v);
    }
    $st = new nc_Component(0, 1);
    foreach ($st->get_fields(0, 0) as $v) {
        $v = 'f_' . $v;
        ${$v} = $nc_core->input->fetch_get_post($v);
    }
    $showFields = false;
    if ($type == 1) {
        $mandatoryFields = array();
        foreach ($st->get_fields() as $f) {
            if ($f['not_null']) {
                $mandatoryFields[] = $f['name'];
            }
        }
        $showFields = count($mandatoryFields) > 0;
    }
    if ($nc_core->modules->get_by_keyword('calendar', 0)) {
        echo nc_set_calendar(0);
    }
    echo "<form id='adminForm' class='nc-form' enctype='multipart/form-data' method='post' name='adminForm' action='" . $action . "'>";
    if ($type == 1) {
        if ($Priority == "" && $Checked == "") {
            $Checked = 1;
        }
        if ($Priority == "") {
            $Priority = $db->get_var("SELECT MAX(`Priority`)+1 FROM `Catalogue`");
        }
        foreach ($params as $v) {
            $Array[$v] = ${$v};
        }
        $Array['Read_Access_ID'] = 1;
        $Array['Write_Access_ID'] = 3;
        $Array['Edit_Access_ID'] = 3;
        $Array['Checked_Access_ID'] = 3;
        $Array['Delete_Access_ID'] = 3;
    } else {
        if ($type == 2) {
            try {
                $Array = $nc_core->catalogue->get_by_id($CatalogueID);
            } catch (Exception $e) {
                nc_print_status(CONTROL_CONTENT_CATALOUGE_FUNCS_ERROR_NOCATALOGUE, 'info');
                EndHtml();
                exit;
            }
        }
    }
    //по умолчанию: публикация объекта сразу после добавления
    if (!$Array["Moderation_ID"]) {
        $Array["Moderation_ID"] = 1;
    }
    if (!$Array[$lm_type]) {
        $Array[$lm_type] = 1;
    }
    if (!$Array[$sm_change_field]) {
        $Array[$sm_change_field] = 'daily';
    }
    if (!$Array[$sm_priority_field]) {
        $Array[$sm_priority_field] = 0.5;
    }
    $fieldsets = new nc_admin_fieldset_collection();
    $access_actions = array('Read', 'Write', 'Edit', 'Checked', 'Delete');
    foreach ($access_actions as $access_action) {
        $Array["_db_{$access_action}_Access_ID"] = $Array[$access_action . "_Access_ID"];
    }
    $fields_hack = array($nc_core->page->get_field_name('last_modified'), $nc_core->page->get_field_name('last_modified_type'), 'Moderation_ID', 'Cache_Access_ID', 'Cache_Lifetime', 'DisallowIndexing', 'Template_ID');
    if ($nc_core->modules->get_by_keyword('search')) {
        $fields_hack[] = $nc_core->page->get_field_name('sitemap_include');
        $fields_hack[] = $nc_core->page->get_field_name('sitemap_changefreq');
        $fields_hack[] = $nc_core->page->get_field_name('sitemap_priority');
    }
    foreach ($fields_hack as $field_name) {
        $Array['_db_' . $field_name] = $Array[$field_name];
    }
    $Array['_db_inherit_' . $sm_change_field] = $Array['_db_' . $sm_change_field];
    $Array['_db_inherit_Template_ID'] = $Array['Template_ID'];
    $bar_all = $bar_action == 'all';
    $display = array('edit' => $bar_all || $bar_action == 'edit' || $bar_action == 'wizard', 'design' => $bar_action == 'design' || $bar_action == 'wizard', 'seo' => $bar_action == 'seo' || $bar_action == 'wizard', 'system' => $bar_action == 'system' || $bar_action == 'wizard', 'fields' => $bar_action == 'fields' || $bar_action == 'wizard' || $showFields);
    $p_div_bar_action = '';
    $s_div_bar_action = '';
    if ($bar_action == 'all') {
        $p_div_bar_action = "<div style='display: none;'>";
        $s_div_bar_action = '</div>';
    }
    $fieldsets->set_prefix("\n        {$p_div_bar_action}\n        <div id='nc_seo_edit_info'" . ($bar_action != 'edit' ? " style='display:none;'" : "") . " class='nc_admin_settings_info'>\n            <div class='nc_admin_settings_info_actions'>\n                <div>\n                    <span>" . CLASS_TAB_CUSTOM_ADD . ":</span> {$Array['Created']}\n                </div>\n                " . ($Array['LastUpdated'] ? "<div>\n                    <span>" . CLASS_TAB_CUSTOM_EDIT . ":</span> {$Array['LastUpdated']}\n                </div>" : "") . "\n            </div>\n\n            <div class='nc_admin_settings_info_priority'>\n                <div>\n                    " . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_PRIORITY . ":\n                </div>\n\n                <div>\n                    " . nc_admin_input_simple('Priority', intval($Array["Priority"]), 3, '', "maxlength='5'") . "\n                </div>\n            </div>\n\n            <div class='nc_admin_settings_info_checked'>\n                <div>\n                    " . nc_admin_checkbox_simple('Checked', 1, CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ON, $Array["Checked"] == 1 || !$CatalogueID, 'turnon') . "\n                </div>\n            </div>\n        </div>{$s_div_bar_action}");
    $fieldsets->set_suffix($nc_core->token->get_input() . "\n        <input type='hidden' name='CatalogueID' value='{$CatalogueID}' />\n        <input type='hidden' name='phase' value='{$phase}' />\n        <input type='hidden' name='type' value='{$type}' />\n        <input type='hidden' name='posting' value='1' />\n        <input type='hidden' name='action' value='{$bar_action}' />\n        <input type='submit' class='hidden' />\n    </form><br />" . nc_admin_js_resize());
    $fieldsets->new_fieldset('main_info', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MAININFO)->show($display['edit']);
    $fieldsets->new_fieldset('template', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_TEMPLATE)->add(nc_subdivision_form_design($Array, $CatalogueID, false))->show($display['design']);
    //$fieldsets->new_fieldset('mobile', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_SETTINGS)->show($display['edit'] && $bar_action != 'all');
    $fieldsets->new_fieldset('seo', '')->add(nc_subdivision_form_seo($Array, false))->show($display['seo']);
    $fieldsets->new_fieldset('access', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ACCESS)->add(nc_subdivision_show_access($Array, false))->show($display['system']);
    if ($nc_core->modules->get_by_keyword('minishop')) {
        $fieldsets->new_fieldset('shop_mode', $p_div_bar_action ? null : NETCAT_MODULE_MINISHOP_INFOBLOCK_MODE)->add("{$p_div_bar_action}<div>" . NETCAT_MODULE_MINISHOP_INFOBLOCK_GOOD_MODE . ":</div>" . nc_catalogue_form_shop_mode($CatalogueID))->show($display['edit'] . $s_div_bar_action);
    }
    if (nc_module_check_by_keyword("cache")) {
        $fieldsets->new_fieldset('cache', CONTROL_CONTENT_CATALOGUE_FUNCS_CACHE)->add(nc_subdivision_show_cache($Array, false))->show($display['system']);
    }
    if (nc_module_check_by_keyword("comments")) {
        $fieldsets->new_fieldset('comments', CONTROL_CONTENT_CATALOGUE_FUNCS_COMMENTS)->add(nc_subdivision_show_comments($Array, false))->show($display['system']);
    }
    ob_start();
    echo nc_admin_input(CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_NAME, 'Catalogue_Name', $Array["Catalogue_Name"], 32) . "\n   " . nc_admin_input(CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_DOMAIN, 'Domain', $Array["Domain"], 32) . "\n   {$p_div_bar_action}\n   <br />" . nc_admin_textarea_simple('Mirrors', $Array["Mirrors"], CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MIRRORS, 4, 10, '', '', 'no_cm') . "<br /><br />\n   " . nc_admin_textarea_simple('Robots', $Array["Robots"] ? $Array["Robots"] : "# NetCat Robots file\nUser-agent: *\nDisallow: /install/", CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ROBOTS, 4, 10) . "<br /><br />\n    " . nc_admin_textarea_simple('ncOfflineText', $Array["ncOfflineText"], CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_OFFLINE, 4, 10) . "<br /><br />\n\n    <table border='0' cellpadding=0 cellspacing=0 width=100%>\n        <tr>\n            <td>\n                " . CONTROL_CONTENT_SUBDIVISION_FUNCS_CATALOGUEFORM_LANG . ":</br>\n                " . nc_admin_input_simple('language', $Array[$lang_field], 50) . "<br/>\n            </td>\n        </tr>";
    if ($type == 2) {
        $subdivisions = $db->get_results("SELECT Subdivision_ID as value,\n                                             CONCAT(Subdivision_ID, '. ', Subdivision_Name) as description,\n                                             Parent_Sub_ID as parent\n                                        FROM Subdivision\n                                       WHERE Catalogue_ID='" . $CatalogueID . "'\n                                    ORDER BY Subdivision_ID", ARRAY_A);
        echo "\n        <tr>\n            <td>\n                <br />\n                <table border='0' cellspacing='0' width='100%' class='border-bottom'>\n                    <col width='40%'/><col/>\n                    <tr>\n                        <td>\n                            " . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_TITLEPAGE . "\n                        </td>\n                    <td>";
        if (!empty($subdivisions)) {
            echo "<select name='TitleSubID'>";
            echo nc_select_options($subdivisions, $Array["Title_Sub_ID"]);
            echo "</select>";
        } else {
            echo CONTROL_USER_NOONESECSINSITE;
        }
        echo "              </td>\n                    </tr>\n                    <tr>\n                        <td>\n                            " . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_NOTFOUND . "\n                        </td>\n                        <td>";
        if (!empty($subdivisions)) {
            echo "<select name='E404SubID'>";
            echo nc_select_options($subdivisions, $Array["E404_Sub_ID"]);
            echo "</select>";
        } else {
            echo CONTROL_USER_NOONESECSINSITE;
        }
        echo "</td>\n</tr>\n</table><br><br></td></tr>";
    }
    echo "</table>{$s_div_bar_action}";
    $fieldsets->main_info->add(ob_get_clean());
    $templates = $db->get_results("SELECT Template_ID as value,\n                                        CONCAT(Template_ID, '. ', Description) as description,\n                                        Parent_Template_ID as parent\n                                   FROM Template\n                               ORDER BY Priority, Template_ID", ARRAY_A);
    ob_start();
    echo "<tr><td>";
    if ($type == 1) {
        echo $p_div_bar_action;
        echo WIZARD_SITE_STEP_TWO_DESCRIPTION . "<br/><br/>";
        if ($Array["Title_Sub_ID"]) {
            $title_sub = $db->get_row("SELECT Subdivision_Name, EnglishName FROM Subdivision WHERE Subdivision_ID = '" . intval($Array["Title_Sub_ID"]) . "'", ARRAY_A);
        }
        if ($Array["E404_Sub_ID"]) {
            $e404_sub = $db->get_row("SELECT Subdivision_Name, EnglishName FROM Subdivision WHERE Subdivision_ID = '" . intval($Array["E404_Sub_ID"]) . "'", ARRAY_A);
        }
        echo "<legend><h3>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_TITLEPAGE . "</h3></legend>\n";
        echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_NAME . ":<br>\n";
        echo nc_admin_input_simple('TitleSubIDName', $title_sub['Subdivision_Name'] ? $title_sub['Subdivision_Name'] : CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_TITLEPAGE) . "<br><br>\n";
        echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_KEYWORD . ":<br>\n";
        echo nc_admin_input_simple('TitleSubIDKeyword', $title_sub['EnglishName'] ? $title_sub['EnglishName'] : "index") . "<br><br>\n";
        if (!empty($templates)) {
            echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_DTEMPLATE . ":<br>\n";
            echo "<select name='TitleTemplateID'>\n";
            echo "<option value='0'>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_DTEMPLATE_N . "</option>";
            echo nc_select_options($templates, $Array["Title_Sub_ID"]);
            echo "</select><br>\n";
        } else {
            echo CONTROL_TEMPLATE_NONE;
        }
        echo "<legend><h3>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_NOTFOUND . "</h3></legend>\n";
        echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_NAME . ":<br>\n";
        echo nc_admin_input_simple('E404SubIDName', $title_sub['Subdivision_Name'] ? $title_sub['Subdivision_Name'] : CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_NOTFOUND) . "<br><br>\n";
        echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_KEYWORD . ":<br>\n";
        echo nc_admin_input_simple('E404SubIDKeyword', $title_sub['EnglishName'] ? $title_sub['EnglishName'] : "404") . "<br><br>\n";
        if (!empty($templates)) {
            echo CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_DTEMPLATE . ":<br>\n";
            echo "<select name='E404TemplateID'>\n";
            echo "<option value='0'>" . CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_DTEMPLATE_N . "</option>";
            echo nc_select_options($templates, $Array["E404_Sub_ID"]);
            echo "</select><br>\n";
        } else {
            echo CONTROL_TEMPLATE_NONE;
        }
        echo $s_div_bar_action;
    }
    $fieldsets->template->add(ob_get_clean());
    $display_type_fieldset = new nc_admin_fieldset(CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_DISPLAYTYPE);
    ob_start();
    echo nc_get_modal_radio('DisplayType', array(array('attr' => array('value' => 'traditional'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_DISPLAYTYPE_TRADITIONAL), array('attr' => array('value' => 'shortpage'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_DISPLAYTYPE_SHORTPAGE), array('attr' => array('value' => 'longpage_vertical'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_DISPLAYTYPE_LONGPAGE_VERTICAL)), $Array['DisplayType']);
    $display_type_fieldset->add(ob_get_clean());
    $fieldsets->template->add($display_type_fieldset->result());
    ob_start();
    echo nc_get_modal_radio('ncMobile', array(array('attr' => array('value' => '0'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_SIMPLE), array('attr' => array('value' => '1'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE), array('attr' => array('value' => '2'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_ADAPTIVE)), $Array['ncMobile'] ? 1 : ($Array['ncResponsive'] ? 2 : 0));
    require_once $ADMIN_FOLDER . "related/format.inc.php";
    $field = new field_relation_catalogue();
    echo "\n\n    <span id='nc_mobilesrc'>\n        <br />\n        <span id='mobility_text'>\n        <font>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_FOR . ":</font>\n        <span id='cs_ncMobileSrc_caption' style='font-weight:bold;'>" . ($Array['ncMobileSrc'] ? listQuery($field->get_object_query($Array['ncMobileSrc']), $field->get_full_admin_template()) : '[нет]') . "</span>\n        </span>\n        <input id='cs_ncMobileSrc_value' name='ncMobileSrc' type='hidden' value='" . $Array['ncMobileSrc'] . "'>&nbsp;&nbsp;\n        <span class='mobility_notMobile' style='display: none; color: #aaa'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_FOR_NOTICE . "</span>\n        <span class='moblilty_links'>\n        <a href='#' onclick='window.open(\"" . $ADMIN_PATH . "related/select_catalogue.php?cs_type=rel_catalogue&amp;cs_field_name=ncMobileSrc\", \"nc_popup_ncMobileSrc\", \"width=800,height=500,menubar=no,resizable=no,scrollbars=yes,toolbar=no,resizable=yes\"); return false;'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_CHANGE . "</a>&nbsp;&nbsp;\n        <a href='#' onclick='document.getElementById(\"cs_ncMobileSrc_value\").value=\"\";document.getElementById(\"cs_ncMobileSrc_caption\").innerHTML = \"" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_NONE . "\";return false;'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_DELETE . "</a></span> <br /><br />\n        " . nc_admin_checkbox(CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_REDIRECT, 'ncMobileRedirect', $Array["ncMobileRedirect"], "class='ncMobileIdentity'") . "\n    </span>\n    <br />" . CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_CRITERION . "\n\n\n    <script type='text/javascipt'>\n    function nc_mobile_change() {\n        if (\$nc('input[name=ncMobile]').filter(':checked').val() == 1) {\n            \$nc('.ncMobileIdentity').each(function() {\n                \$nc(this).removeAttr('disabled');\n            })\n            \$nc('.moblilty_links, #cs_ncMobileSrc_caption').css('display', '');\n            \$nc('.mobility_notMobile').css('display', 'none');\n            \$nc('#mobility_text').css('color', '#505050');\n        } else {\n            \$nc('.ncMobileIdentity').each(function() {\n                \$nc(this).attr('disabled', 'disabled');\n            });\n            \$nc('.moblilty_links, #cs_ncMobileSrc_caption').css('display', 'none');\n            \$nc('.mobility_notMobile').css('display', '');\n            \$nc('#mobility_text').css('color', '#aaa');\n        }\n    }\n\n    \$nc(document).ready(function() {\n        nc_mobile_change();\n        \$nc('input[name=ncMobile]').change(function(){\n            nc_mobile_change();\n        });\n    });\n\n    </script>";
    echo nc_get_modal_radio('ncMobileIdentity', array(array('attr' => array('value' => '1', 'class' => 'ncMobileIdentity'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_USERAGENT), array('attr' => array('value' => '2', 'class' => 'ncMobileIdentity', 'id' => 'ncMobileCatalogue'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_SCREEN_RESOLUTION), array('attr' => array('value' => '3', 'class' => 'ncMobileIdentity'), 'desc' => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_ALL_CRITERION)), +$Array['ncMobileIdentity']);
    $mobile_fieldset = new nc_admin_fieldset(CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_MOBILE_SETTINGS);
    $mobile_fieldset->add(ob_get_clean());
    $fieldsets->template->add($mobile_fieldset->result());
    if ($type == 1) {
        $action = "add";
    }
    if ($type == 2) {
        $action = "change";
        $message = $CatalogueID;
    }
    require $ROOT_FOLDER . "message_fields.php";
    if ($fldCount) {
        $fieldsets->new_fieldset('ext_fields', CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_EXTFIELDS);
        ob_start();
        if ($type == 2) {
            $fieldQuery = join($fld, ",");
            $fldValue = $db->get_row("SELECT " . $fieldQuery . " FROM `Catalogue` WHERE `Catalogue_ID`='" . $CatalogueID . "'", ARRAY_N);
        }
        echo "<table border='0' cellpadding='6' cellspacing='0' width='100%'><tr><td><font>";
        require $ROOT_FOLDER . "message_edit.php";
        echo "</td></tr></table>";
        $fieldsets->ext_fields->add(ob_get_clean())->show($display['fields']);
    }
    echo $fieldsets->to_string();
    if ($type == 1) {
        $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWCATALOGUELIST_ADDSITE, "action" => "mainView.submitIframeForm()");
    } elseif ($type == 2) {
        $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_CATALOGUEFORM_SAVE, "align" => "right", "action" => "mainView.submitIframeForm()");
    }
    return 0;
}
Ejemplo n.º 2
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();
}
Ejemplo n.º 3
0
function nc_subdivision_form_system($sub_env)
{
    $nc_core = nc_Core::get_object();
    $sub_id = $sub_env['Subdivision_ID'];
    $lang_field = $nc_core->page->get_field_name('language');
    $sub_env = $nc_core->subdivision->get_by_id($sub_id);
    $field_main = new nc_admin_fieldset(CONTROL_CONTENT_SUBDIVISION_SYSTEM_FIELDS);
    $html = nc_admin_input(CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_EXTURL, 'ExternalURL', $sub_env['ExternalURL'], 50);
    $html .= nc_admin_input(CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_LANG, 'language', $sub_env['_db_' . $lang_field], 50);
    $html .= CONTROL_CONTENT_SUBDIVISION_SEO_CURRENT_VALUE . ": <b>" . $sub_env[$lang_field] . "</b></font><br/><br/>";
    $field_main->add($html);
    // доступ
    $field_access = new nc_admin_fieldset(CONTROL_CONTENT_SUBDIVISION_FUNCS_ACCESS);
    $field_access->add(nc_subdivision_show_access($sub_env));
    $result = $field_main->result() . $field_access->result();
    //rss
    global $isNaked;
    if (!$isNaked) {
        $all_cc_ids = $nc_core->db->get_col("SELECT `Sub_Class_ID` FROM `Sub_Class` WHERE `Subdivision_ID` = '" . intval($sub_id) . "' ");
        $count_cc = count($all_cc_ids);
        if ($count_cc) {
            $field_rss = new nc_admin_fieldset('RSS');
            foreach ($all_cc_ids as $cc_id) {
                $field_rss->add(nc_subclass_show_export('rss', $sub_id, $cc_id, $count_cc > 1, 1));
            }
            $result .= $field_rss->result();
        }
    }
    // cache
    if ($nc_core->modules->get_by_keyword('cache')) {
        $field_cache = new nc_admin_fieldset(CONTROL_CONTENT_SUBCLASS_FUNCS_CACHE);
        $field_cache->add(nc_subdivision_show_cache($sub_env));
        $result .= $field_cache->result();
    }
    // comments
    if ($nc_core->modules->get_by_keyword('comments')) {
        include_once $nc_core->MODULE_FOLDER . "comments/function.inc.php";
        $field_comments = new nc_admin_fieldset(CONTROL_CONTENT_SUBDIVISION_FUNCS_COMMENTS);
        $field_comments->add(nc_subdivision_show_comments($sub_env));
        $result .= $field_comments->result();
    }
    return $result;
}