/** * Themes admin page * * @param App $a * @return string */ function admin_page_themes(&$a) { $allowed_themes_str = get_config('system', 'allowed_themes'); $allowed_themes_raw = explode(',', $allowed_themes_str); $allowed_themes = array(); if (count($allowed_themes_raw)) { foreach ($allowed_themes_raw as $x) { if (strlen(trim($x))) { $allowed_themes[] = trim($x); } } } $themes = array(); $files = glob('view/theme/*'); /* */ if ($files) { foreach ($files as $file) { $f = basename($file); $is_experimental = intval(file_exists($file . '/experimental')); $is_supported = 1 - intval(file_exists($file . '/unsupported')); $is_allowed = intval(in_array($f, $allowed_themes)); if ($is_allowed or $is_supported or get_config("system", "show_unsupported_themes")) { $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed); } } } if (!count($themes)) { notice(t('No themes found.')); return ''; } /** * Single theme */ if ($a->argc == 3) { $theme = $a->argv[2]; if (!is_dir("view/theme/{$theme}")) { notice(t("Item not found.")); return ''; } if (x($_GET, "a") && $_GET['a'] == "t") { check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't'); // Toggle theme status toggle_theme($themes, $theme, $result); $s = rebuild_theme_table($themes); if ($result) { install_theme($theme); info(sprintf('Theme %s enabled.', $theme)); } else { uninstall_theme($theme); info(sprintf('Theme %s disabled.', $theme)); } set_config('system', 'allowed_themes', $s); goaway($a->get_baseurl(true) . '/admin/themes'); return ''; // NOTREACHED } // display theme details require_once 'library/markdown.php'; if (theme_status($themes, $theme)) { $status = "on"; $action = t("Disable"); } else { $status = "off"; $action = t("Enable"); } $readme = Null; if (is_file("view/theme/{$theme}/README.md")) { $readme = file_get_contents("view/theme/{$theme}/README.md"); $readme = Markdown($readme); } else { if (is_file("view/theme/{$theme}/README")) { $readme = "<pre>" . file_get_contents("view/theme/{$theme}/README") . "</pre>"; } } $admin_form = ""; if (is_file("view/theme/{$theme}/config.php")) { require_once "view/theme/{$theme}/config.php"; if (function_exists("theme_admin")) { $admin_form = theme_admin($a); } } $screenshot = array(get_theme_screenshot($theme), t('Screenshot')); if (!stristr($screenshot[0], $theme)) { $screenshot = null; } $t = get_markup_template("admin_plugins_details.tpl"); return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Themes'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), '$plugin' => $theme, '$status' => $status, '$action' => $action, '$info' => get_theme_info($theme), '$function' => 'themes', '$admin_form' => $admin_form, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$screenshot' => $screenshot, '$readme' => $readme, '$form_security_token' => get_form_security_token("admin_themes"))); } /** * List themes */ $xthemes = array(); if ($themes) { foreach ($themes as $th) { $xthemes[] = array($th['name'], $th['allowed'] ? "on" : "off", get_theme_info($th['name'])); } } $t = get_markup_template("admin_plugins.tpl"); return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Themes'), '$submit' => t('Save Settings'), '$baseurl' => $a->get_baseurl(true), '$function' => 'themes', '$plugins' => $xthemes, '$experimental' => t('[Experimental]'), '$unsupported' => t('[Unsupported]'), '$form_security_token' => get_form_security_token("admin_themes"))); }
/** main entry point for update wizard (called from /program/main_admin.php) * * This routine takes care of executing update routines for both the core * program and modules, themes, etc. It is called automagically whenever * the core program version in the database is different from the version * in the file {@lnk version.php} (see also {@link main_admin()}). * * It can also be called manually via 'job=update'. When no specific * task is specified, this routine shows the overview of versions for * core, modules, themes, etc. Whenever a component is NOT up to date, * an [Update] button is displayed. If a component IS up to date, we * simply display the word 'OK'. This implies that when everything is up * to date, the overview simply displays a list of OK's and the user * is 'free to go'. * * The actual updates for modules, themes, etc. is done via the various * subsystems themselves, e.g. by calling htmlpage_upgrade() in the file * /program/modules/htmlpage/htmlpage_install.php. The updates for the * core program are actually performed from this file right here, see * {@link update_core_2010120800()} below for an example. * * Note that we give a core update high priority: if the core * is not up to date, nothing will work, except updating the core. * * @param object &$output collects the html output * @return void results are returned as output in $output */ function job_update(&$output) { global $CFG, $WAS_SCRIPT_NAME, $USER; $output->set_helptopic('update'); $task = get_parameter_string('task', TASK_UPDATE_OVERVIEW); if ($task == TASK_UPDATE_OVERVIEW) { update_show_overview($output); } elseif ($task == TASK_UPDATE_CORE) { update_core($output); update_show_overview($output); } elseif (intval($CFG->version) != intval(WAS_VERSION)) { $output->add_message(t('update_core_warnning_core_goes_first', 'admin')); update_show_overview($output); } else { $key = get_parameter_string('key', ''); switch ($task) { case TASK_INSTALL_LANGUAGE: install_language($output, $key); update_show_overview($output); break; case TASK_UPDATE_LANGUAGE: update_language($output, $key); update_show_overview($output); break; case TASK_INSTALL_MODULE: install_module($output, $key); update_show_overview($output); break; case TASK_UPDATE_MODULE: update_module($output, $key); update_show_overview($output); break; case TASK_INSTALL_THEME: install_theme($output, $key); update_show_overview($output); break; case TASK_UPDATE_THEME: update_theme($output, $key); update_show_overview($output); break; default: $s = utf8_strlen($task) <= 50 ? $task : utf8_substr($task, 0, 44) . ' (...)'; $message = t('task_unknown', 'admin', array('{TASK}' => htmlspecialchars($s))); $output->add_message($message); logger('tools: unknown task: ' . htmlspecialchars($s)); update_show_overview($output); break; } } }