コード例 #1
0
ファイル: function.inc.php プロジェクト: Blu2z/implsk
/**
 * функция удаляет макет
 *
 */
function DeleteTemplates()
{
    global $nc_core, $db, $UI_CONFIG;
    while (list($key, $val) = each($_POST)) {
        if (substr($key, 0, 6) != "Delete") {
            continue;
        }
        $val = intval($val);
        if (!$val) {
            continue;
        }
        $val = (int) $val;
        $File_Mode = nc_get_file_mode('Template', $val);
        if ($File_Mode) {
            $template_editor = new nc_template_editor($nc_core->TEMPLATE_FOLDER, $nc_core->db);
            $template_editor->load_template($val);
            $template_editor->delete_template();
        }
        $UI_CONFIG = new ui_config_template('delete', $val);
        $arr_templates = nc_get_template_children($val);
        if (count($arr_templates) > 1) {
            foreach ($arr_templates as $int_template_id) {
                // execute core action
                $nc_core->event->execute("dropTemplatePrep", $int_template_id);
                if (!$db->query("DELETE FROM `Template` WHERE `Template_ID` = '" . $int_template_id . "'")) {
                    $SelectArray = $db->get_var("select Description from Template where Template_ID='" . $int_template_id . "'");
                    nc_print_status(CONTROL_TEMPLATE_ERR_CANTDEL . " " . $SelectArray . ". " . TOOLS_PATCH_ERROR, 'error');
                } else {
                    // execute core action
                    $nc_core->event->execute("dropTemplate", $int_template_id);
                }
                DeleteSystemTableFiles('Template', $int_template_id);
                $UI_CONFIG->treeChanges['deleteNode'][] = "template-{$int_template_id}";
            }
        } else {
            // execute core action
            $nc_core->event->execute("dropTemplatePrep", $val);
            if (!$db->query("delete from Template where Template_ID='" . $val . "'")) {
                $SelectArray = $db->get_var("select Description from Template where Template_ID='" . $val . "'");
                nc_print_status(CONTROL_TEMPLATE_ERR_CANTDEL . " " . $SelectArray . ". " . TOOLS_PATCH_ERROR, 'error');
            } else {
                // execute core action
                $nc_core->event->execute("dropTemplate", $val);
            }
            DeleteSystemTableFiles('Template', $val);
            $UI_CONFIG->treeChanges['deleteNode'][] = "template-{$val}";
        }
    }
}
コード例 #2
0
ファイル: s_common.inc.php プロジェクト: Blu2z/implsk
/**
 * Получить идентификаторы всех дочерних макетов для макета с идентификатором $template
 * @param int $template идентификатор родительского макета
 * @return array массив с идентификаторами макетов
 *
 */
function nc_get_template_children($template)
{
    global $db;
    $template = intval($template);
    $array[] = $template;
    $template_array = $db->get_col("SELECT `Template_ID` FROM `Template` WHERE `Parent_Template_ID` = '" . $template . "'");
    if (!empty($template_array)) {
        foreach ($template_array as $key => $val) {
            $array = array_merge($array, nc_get_template_children($val));
        }
    }
    return $array;
}