示例#1
0
    $total = intval($HTTP_POST_VARS['total']);
    for ($i = 0; $i < $total; $i++) {
        if (!empty($HTTP_POST_VARS['install_' . $i])) {
            $tpl[] = stripslashes($HTTP_POST_VARS['install_' . $i . '_style']);
            $num[] = intval($HTTP_POST_VARS['install_' . $i . '_num']);
        }
    }
    if (count($tpl)) {
        for ($i = 0; $i < count($tpl); $i++) {
            xs_install_style($tpl[$i], $num[$i]);
        }
        if (defined('REFRESH_NAVBAR')) {
            $template->assign_block_vars('left_refresh', array('ACTION' => append_sid('index.' . $phpEx . '?pane=left')));
        }
        if (defined('XS_MODS_CATEGORY_HIERARCHY')) {
            cache_themes();
        }
        xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']);
    }
}
// get all installed styles
$sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';
if (!($result = $db->sql_query($sql))) {
    xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
}
$style_rowset = $db->sql_fetchrowset($result);
// find all styles to install
$res = @opendir('../templates/');
$styles = array();
while (($file = readdir($res)) !== false) {
    if ($file !== '.' && $file !== '..' && @file_exists('../templates/' . $file . '/theme_info.cfg') && @file_exists('../templates/' . $file . '/' . $file . '.cfg')) {
示例#2
0
function build_theme_array($ignoretid = null, $parent = 0, $depth = 0)
{
    global $mybb, $lang, $list;
    static $theme_cache;
    if (!is_array($theme_cache)) {
        $themes = cache_themes();
        // Restrucure the theme array to something we can "loop-de-loop" with
        foreach ($themes as $key => $theme) {
            if ($key == "default") {
                continue;
            }
            $theme_cache[$theme['pid']][$theme['tid']] = $theme;
        }
        unset($theme);
    }
    if (!is_array($theme_cache[$parent]) || $ignoretid === $parent) {
        return;
    }
    foreach ($theme_cache[$parent] as $theme) {
        if ($ignoretid === $theme['tid']) {
            continue;
        }
        $list[$theme['tid']] = str_repeat("--", $depth) . $theme['name'];
        // Fetch & build any child themes
        build_theme_array($ignoretid, $theme['tid'], $depth + 1);
    }
    if (!$parent) {
        return $list;
    }
}