Beispiel #1
0
function applet_repairnested()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    $tables = array();
    $tables[0]['name'] = 'cms_category';
    $tables[0]['title'] = $_LANG['AD_ARTICLES_TREE'];
    $tables[0]['differ'] = '';
    $tables[1]['name'] = 'cms_photo_albums';
    $tables[1]['title'] = $_LANG['AD_ALBUMS_TREE'];
    $tables[1]['differ'] = '';
    $tables[3]['name'] = 'cms_board_cats';
    $tables[3]['title'] = $_LANG['AD_DESK_TREE'];
    $tables[3]['differ'] = '';
    $tables[4]['name'] = 'cms_uc_cats';
    $tables[4]['title'] = $_LANG['AD_CATALOG_TREE'];
    $tables[4]['differ'] = '';
    $tables[5]['name'] = 'cms_menu';
    $tables[5]['title'] = $_LANG['AD_MENU_TREE'];
    $tables[5]['differ'] = '';
    $tables[6]['name'] = 'cms_forums';
    $tables[6]['title'] = $_LANG['AD_FORUMS_TREE'];
    $tables[6]['differ'] = '';
    if ($inCore->isComponentInstalled('maps')) {
        $tables[7]['name'] = 'cms_map_cats';
        $tables[7]['title'] = $_LANG['AD_MAPS_TREE'];
        $tables[7]['differ'] = '';
    }
    if ($inCore->isComponentInstalled('video')) {
        $tables[8]['name'] = 'cms_video_category';
        $tables[8]['title'] = $_LANG['AD_VIDEO_TREE'];
        $tables[8]['differ'] = '';
    }
    if ($inCore->isComponentInstalled('shop')) {
        $tables[9]['name'] = 'cms_shop_cats';
        $tables[9]['title'] = $_LANG['AD_SHOP_TREE'];
        $tables[9]['differ'] = '';
    }
    if (cmsCore::inRequest('tables')) {
        if (is_array($_POST['tables'])) {
            foreach ($_POST['tables'] as $table_id) {
                if (cmsCore::request('go_repair', 'int', 0)) {
                    repairNestedSet($tables[(int) $table_id]);
                } else {
                    if (cmsCore::request('go_repair_tree', 'int', 0)) {
                        if (tree_all_ns($tables[(int) $table_id]['name']) !== false) {
                            cmsCore::addSessionMessage($tables[(int) $table_id]['title'] . ' ' . $_LANG['AD_RESTORED'], 'success');
                        }
                    }
                }
            }
        }
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_CHECKING_TREES'];
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_CHECKING_TREES'], 'index.php?view=repairnested');
    $GLOBALS['cp_page_head'][] = '<script type="text/javascript" src="/admin/js/repair.js"></script>';
    $errors_found = false;
    echo '<h3>' . $_LANG['AD_TREE_FULL'] . '</h3>';
    echo '<div style="margin:20px; margin-top:0px;">';
    echo '<form method="post" action="" id="repairform">';
    echo '<input id="go_repair" type="hidden" name="go_repair" value="0">';
    echo '<input id="go_repair_tree" type="hidden" name="go_repair_tree" value="0">';
    echo '<table cellpadding="2">';
    foreach ($tables as $id => $table) {
        $errors = checkNestedSet($table);
        echo '<tr>';
        echo '<td width="15">' . ($errors ? '<input type="checkbox" name="tables[]" value="' . $id . '" checked="checked"/>' : '') . '</td>';
        echo '<td><div>';
        echo '<span>' . $table['title'] . '</span> &mdash; ' . ($errors ? '<span style="color:red">' . $_LANG['AD_ERROR_FOUND'] . '</span>' : '<span style="color:green">' . $_LANG['AD_NO_ERROR_FOUND'] . '</span>');
        echo '</div></td>';
        echo '</tr>';
        if ($errors) {
            $errors_found = true;
        }
    }
    echo '</table>';
    echo '</div>';
    if ($errors_found) {
        echo '<div style="margin-bottom:20px">';
        echo '<input type="button"  onclick="repairTreesRoot()" value="' . $_LANG['AD_REPAIR'] . '"> ';
        echo '<input type="button"  onclick="repairTrees()" value="' . $_LANG['AD_REPAIR_TOTREE'] . '">';
        echo '</div>';
    }
    cmsPage::displayLangJS(array('AD_REPAIR_CONFIRM', 'AD_REPAIR_TOTREE_CONFIRM'));
}
Beispiel #2
0
function applet_repairnested()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    $tables = array(array('name' => 'cms_category', 'title' => $_LANG['AD_ARTICLES_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_category')), array('name' => 'cms_photo_albums', 'title' => $_LANG['AD_ALBUMS_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_photo_albums')), array('name' => 'cms_board_cats', 'title' => $_LANG['AD_DESK_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_board_cats')), array('name' => 'cms_uc_cats', 'title' => $_LANG['AD_CATALOG_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_uc_cats')), array('name' => 'cms_menu', 'title' => $_LANG['AD_MENU_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_menu')), array('name' => 'cms_forums', 'title' => $_LANG['AD_FORUMS_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_forums')));
    if ($inCore->isComponentInstalled('maps')) {
        $tables[] = array('name' => 'cms_map_cats', 'title' => $_LANG['AD_MAPS_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_map_cats'));
    }
    if ($inCore->isComponentInstalled('video')) {
        $tables[] = array('name' => 'cms_video_category', 'title' => $_LANG['AD_VIDEO_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_video_category'));
    }
    if ($inCore->isComponentInstalled('shop')) {
        $tables[] = array('name' => 'cms_shop_cats', 'title' => $_LANG['AD_SHOP_TREE'], 'differ' => '', 'error' => checkNestedSet('cms_shop_cats'));
    }
    if (cmsCore::inRequest('tables')) {
        if (is_array($_POST['tables'])) {
            foreach ($_POST['tables'] as $table_id) {
                if (cmsCore::request('go_repair', 'int', 0)) {
                    repairNestedSet($tables[(int) $table_id]);
                } else {
                    if (cmsCore::request('go_repair_tree', 'int', 0)) {
                        if (tree_all_ns($tables[(int) $table_id]['name']) !== false) {
                            cmsCore::addSessionMessage($tables[(int) $table_id]['title'] . ' ' . $_LANG['AD_RESTORED'], 'success');
                        }
                    }
                }
            }
        }
    }
    cmsCore::c('page')->setTitle($_LANG['AD_CHECKING_TREES']);
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_CHECKING_TREES'], 'index.php?view=repairnested');
    cmsCore::c('page')->addHeadJS('admin/js/repair.js');
    $errors_found = false;
    cmsCore::c('page')->initTemplate('applets', 'repairnested')->display();
    cmsPage::displayLangJS(array('AD_REPAIR_CONFIRM', 'AD_REPAIR_TOTREE_CONFIRM'));
}