// When more mobile themes come in, this should be changed. if (isset($_SESSION['prefs']['PREF_THEME']) && isset($_SESSION['valid_user']) && $_SESSION['valid_user'] === true) { //check if the theme is enabled $row = queryDB("SELECT status FROM %sthemes WHERE dir_name='%s'", array(TABLE_PREFIX, $_SESSION['prefs']['PREF_THEME']), true); if ($row['status'] == 0) { // get user defined default theme if the preference theme is disabled $default_theme = get_default_theme(); if (!is_dir(AT_SYSTEM_THEME_DIR . $default_theme) && !is_dir(AT_SUBSITE_THEME_DIR . $default_theme)) { $default_theme = get_system_default_theme(); } $_SESSION['prefs']['PREF_THEME'] = $default_theme; $msg->addError('THEME_PREVIEW_DISABLED'); } } // find out where PREF_THEME is located $main_theme_folder = get_main_theme_dir(is_customized_theme($_SESSION['prefs']['PREF_THEME'])); $savant->addPath('template', $main_theme_folder . $_SESSION['prefs']['PREF_THEME'] . '/'); require $main_theme_folder . '../themes/' . $_SESSION['prefs']['PREF_THEME'] . '/theme.cfg.php'; // Define the directory where the customized data lives (used by multi sites): // Main site: [ATutor-root] // Subsites: [ATutor-root]/sites/[Subsite-URL]/ $theme_path = ""; if (is_customized_theme($_SESSION['prefs']['PREF_THEME'])) { $theme_path = AT_SITES_DIR . $_SERVER['HTTP_HOST'] . '/'; } define('AT_CUSTOMIZED_DATA_DIR', AT_BASE_HREF . $theme_path); /**************************************************/ /* load in content manager */ /**************************************************/ if (isset($_SESSION['course_id'])) { $contentManager = new ContentManager($db, isset($_SESSION['course_id']) ? $_SESSION['course_id'] : $_GET['p_course']);
function export_theme($theme_dir) { require AT_INCLUDE_PATH . 'classes/zipfile.class.php'; /* for zipfile */ require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php'; /* for XML_HTMLSax */ require 'theme_template.inc.php'; /* for theme XML templates */ global $db; //identify current theme and then searches db for relavent info $sql = "SELECT * FROM " . TABLE_PREFIX . "themes WHERE dir_name = '{$theme_dir}'"; $result = mysql_query($sql, $db); $row = mysql_fetch_assoc($result); $dir = $row['dir_name'] . '/'; $title = $row['title']; $version = $row['version']; $type = $row['type']; $last_updated = $row['last_updated']; $extra_info = $row['extra_info']; //generate 'theme_info.xml' file based on info $info_xml = str_replace(array('{TITLE}', '{VERSION}', '{TYPE}', '{LAST_UPDATED}', '{EXTRA_INFO}'), array($title, $version, $type, $last_updated, $extra_info), $theme_template_xml); //zip together all the contents of the folder along with the XML file $zipfile = new zipfile(); $zipfile->create_dir($dir); //update installation folder $dir1 = get_main_theme_dir(intval($row["customized"])) . $dir; $zipfile->add_file($info_xml, $dir . 'theme_info.xml'); /* zip other required files */ $zipfile->add_dir($dir1, $dir); /*close & send*/ $zipfile->close(); //Name the Zip file and sends to user for download $zipfile->send_file(str_replace(array(' ', ':'), '_', $title)); }
function print_data_table($rows_themes, $type) { if (count($rows_themes) == 0) { return; } ?> <h3><?php if ($type == DESKTOP_DEVICE) { echo _AT('themes_for_desktop'); } else { echo _AT('themes_for_mobile'); } ?> </h3><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="get" name="form_<?php echo $type; ?> "> <input type="hidden" name="type" value="<?php echo $type; ?> " /> <table class="data" summary=""> <thead> <tr> <th scope="col"> </th> <th scope="col"><?php echo _AT('title'); ?> </th> <th scope="col"><?php echo _AT('status'); ?> </th> <th scope="col" class="hidecol700"><?php echo _AT('version'); ?> </th> <th scope="col" class="hidecol700"><?php echo _AT('directory_name'); ?> </th> <th scope="col" class="hidecol700"><?php echo _AT('description'); ?> </th> <th scope="col"><?php echo _AT('theme_screenshot'); ?> </th> </tr> </thead> <tfoot> <tr> <td colspan="7"> <input type="submit" name="preview" value="<?php echo _AT('preview'); ?> " /> <input type="submit" name="enable" value="<?php echo _AT('enable'); ?> " /> <input type="submit" name="disable" value="<?php echo _AT('disable'); ?> " /> <input type="submit" name="default" value="<?php echo _AT('set_default') . ' '; if ($type == DESKTOP_DEVICE) { echo _AT('desktop_theme'); } else { echo _AT('mobile_theme'); } ?> " /> <input type="submit" name="export" value="<?php echo _AT('export'); ?> " /> <input type="submit" name="delete" id="AT_del_btn" value="<?php echo _AT('delete'); ?> " /> </td> </tr> </tfoot> <tbody> <?php // For each theme: // 1. find out where the theme folder is. It could be from the main site or a subsite configuration folder. // 2. Disallow the deletion of the system themes if the request is from a subsite. This is achieved by using css class "AT_disable_del" foreach ($rows_themes as $row) { $customized = intval($row["customized"]); $main_theme_dir = get_main_theme_dir($customized); if ($customized == '1') { global $theme_path; } ?> <tr class="AT_theme_row <?php if (!$customized && defined('IS_SUBSITE') && IS_SUBSITE) { echo 'AT_disable_del'; } ?> "> <td valign="top"> <input type="radio" name="theme_dir" value="<?php echo $row['dir_name']; ?> " /> <input type="hidden" name="<?php echo $row['dir_name']; ?> _version" value="<?php echo $row['version']; ?> " /> </td> <td nowrap="nowrap" valign="top" ><label for="AT_t_<?php echo $row['dir_name']; ?> "><?php echo AT_print($row['title'], 'themes.title'); ?> </label></td> <td valign="top"><?php if ($row['status'] == 0) { echo _AT('disabled'); } else { if ($row['status'] == 1) { echo _AT('enabled'); } else { if ($type == DESKTOP_DEVICE && $row['status'] == 2 || $type == MOBILE_DEVICE && $row['status'] == 3) { echo '<strong>' . _AT('default') . '</strong>'; } } } ?> </td> <td valign="top" class="hidecol700"><?php echo $row['version']; ?> </td> <td valign="top" class="hidecol700"><code><?php echo $row['dir_name']; ?> /</code></td> <td valign="top" class="hidecol700"><?php echo $row['extra_info']; ?> </td> <td valign="top"> <?php if ($customized == '1') { ?> <?php if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.jpg')) { ?> <img src="<?php echo $theme_path; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.jpg" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } else { if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.gif')) { ?> <img src="<?php echo $theme_path; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.gif" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } else { if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.png')) { ?> <img src="<?php echo $theme_path; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.png" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } } } ?> <?php } else { ?> <?php if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.jpg')) { ?> <img src="<?php echo AT_BASE_HREF; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.jpg" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } else { if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.gif')) { ?> <img src="<?php echo AT_BASE_HREF; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.gif" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } } if (file_exists($main_theme_dir . $row['dir_name'] . '/screenshot.png')) { ?> <img src="<?php echo AT_BASE_HREF; ?> themes/<?php echo $row['dir_name']; ?> /screenshot.png" border="1" alt="<?php echo _AT('theme_screenshot'); ?> " /> <?php } ?> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> </form> <?php }