예제 #1
0
function AutoTheme_admin_updatecmsblocks($var)
{
    $var = atExportVar($var);
    extract($var);
    $themepath = at_gettheme_path($themedir);
    $themeconfig = atLoadThemeConfig($themepath);
    extract($themeconfig);
    if ($modops) {
        $themeblocks = $blockcontrol[$thememod][$modops];
    } else {
        $themeblocks = $blockcontrol['default'];
    }
    if (isset($order)) {
        $boxes = atGetBlockConfig($themeblocks);
        switch ($order) {
            case "up":
                $boxes[$box]['weight']--;
                break;
            case "down":
                $boxes[$box]['weight']++;
                break;
        }
        if ($boxes[$box]['weight'] <= 0) {
            $boxes[$box]['weight'] = 1;
        }
        foreach ($boxes as $bkey => $b) {
            if ($bkey != $box && $b['position'] == $boxes[$box]['position']) {
                $result[$bkey] = $b;
                switch ($order) {
                    case "up":
                        if ($b['weight'] == $boxes[$box]['weight']) {
                            $result[$bkey]['weight']++;
                        }
                        break;
                    case "down":
                        if ($b['weight'] == $boxes[$box]['weight']) {
                            $result[$bkey]['weight']--;
                        }
                        break;
                }
            }
        }
        $boxes = array_merge((array) $boxes, (array) $result);
    }
    if (isset($reset) && !$modops) {
        $boxes = atGetBlocks();
    } elseif (isset($reset) && $modops) {
        $boxes = array();
    }
    uasort($boxes, 'at_block_sort');
    $weight = 0;
    foreach ($boxes as $k => $v) {
        $result[$k]['position'] = $boxes[$k]['position'];
        $result[$k]['active'] = $boxes[$k]['active'];
        if ($boxes[$k]['position'] == $lastpos) {
            $weight++;
        } else {
            $weight = 1;
        }
        $result[$k]['weight'] = $weight;
        $lastpos = $boxes[$k]['position'];
    }
    $boxes = $result;
    if ($modops) {
        $blockcontrol[$thememod][$modops] = $boxes;
    } else {
        $blockcontrol['default'] = $boxes;
    }
    $var = compact("blockcontrol");
    atSaveThemeConfig($themedir, $var);
    Header("Location: " . AT_ADMINPAGE . "?module=AutoTheme&op=cmsblocks&themedir=" . htmlentities(urlencode($themedir)) . "&thememod={$thememod}&modops={$modops}");
    exit;
}
예제 #2
0
function atExportVar($var)
{
    if (is_array($var)) {
        foreach ($var as $k => $v) {
            $result[atExportVar($k)] = atExportVar($v);
        }
        return $result;
    }
    if (get_magic_quotes_gpc()) {
        $var = stripslashes($var);
    }
    return $var;
}