function smarty_resource_artefact_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) { $name = explode(':', $tpl_name); $plugin_name = $name[0]; $plugin_path = $name[1]; $basedir = get_config('docroot') . 'artefact/' . $plugin_name . '/theme/'; foreach (theme_setup()->inheritance as $theme) { $filename = $basedir . $theme . '/' . $plugin_path; if (is_readable($filename)) { $tpl_timestamp = filemtime($filename); return true; } } return false; }
/** * Theme Functions * * * @package WordPress * @subpackage New Theme * @since New Theme v1.0 */ function custom_setup() { // launching operation cleanup add_action('init', 'head_cleanup'); // remove WP version from RSS add_filter('the_generator', 'rss_version'); // remove pesky injected css for recent comments widget add_filter('wp_head', 'remove_wp_widget_recent_comments_style', 1); // clean up comment styles in the head add_action('wp_head', 'remove_recent_comments_style', 1); // clean up gallery output in wp add_filter('gallery_style', 'gallery_style'); // enqueue base scripts and styles add_action('wp_enqueue_scripts', 'scripts_and_styles', 999); // launching this stuff after theme setup theme_setup(); // adding sidebars to Wordpress (these are created in functions.php) // add_action( 'widgets_init', 'theme_widgets_init' ); }
function smarty_resource_blocktype_get_filepath($tpl_name) { static $filepaths = array(); if (isset($filepaths[$tpl_name])) { return $filepaths[$tpl_name]; } $name = explode(':', $tpl_name); $artefactplugin = get_field('blocktype_installed', 'artefactplugin', 'name', $name[0]); $template_path = $name[1]; $basedir = get_config('docroot'); if ($artefactplugin) { $basedir .= 'artefact/' . $artefactplugin . '/blocktype/' . $name[0] . '/theme/'; } else { $basedir .= 'blocktype/' . $name[0] . '/theme/'; } foreach (theme_setup()->inheritance as $theme) { $filename = $basedir . $theme . '/' . $template_path; if (is_readable($filename)) { return $filepaths[$tpl_name] = $filename; } } return $filepaths[$tpl_name] = false; }
function smarty_resource_export_get_filepath($tpl_name) { static $filepaths = array(); if (isset($filepaths[$tpl_name])) { return $filepaths[$tpl_name]; } $name = explode(':', $tpl_name); $plugin = $name[0]; $template_path = $name[1]; $basedir = get_config('docroot'); $pluginbits = explode('/', $plugin); if (count($pluginbits) == 2) { $basedir .= 'artefact/' . $pluginbits[1] . '/export/' . $pluginbits[0] . '/theme/'; } else { $basedir .= 'export/' . $plugin . '/theme/'; } foreach (theme_setup()->inheritance as $theme) { $filename = $basedir . $theme . '/' . $template_path; if (is_readable($filename)) { return $filepaths[$tpl_name] = $filename; } } return $filepaths[$tpl_name] = false; }
$stradministration = get_string("administration"); $strconfiguration = get_string("configuration"); $strthemes = get_string("themes"); $strpreview = get_string("preview"); $strchoose = get_string("choose"); $strinfo = get_string("info"); $strtheme = get_string("theme"); $strthemesaved = get_string("themesaved"); $strscreenshot = get_string("screenshot"); $stroldtheme = get_string("oldtheme"); if ($choose and confirm_sesskey()) { if (!is_dir($CFG->themedir . '/' . $choose)) { error("This theme is not installed!"); } if (set_config("theme", $choose)) { theme_setup($choose); admin_externalpage_print_header(); print_heading(get_string("themesaved")); if (file_exists("{$choose}/README.html")) { print_simple_box_start("center"); readfile("{$choose}/README.html"); print_simple_box_end(); } else { if (file_exists("{$choose}/README.txt")) { print_simple_box_start("center"); $file = file("{$choose}/README.txt"); echo format_text(implode('', $file), FORMAT_MOODLE); print_simple_box_end(); } } print_continue("{$CFG->wwwroot}/");
FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id); $count = $count->max + 100; begin_sql(); foreach ($courses as $course) { set_field('course', 'sortorder', $count, 'id', $course->id); $count++; } commit_sql(); fix_course_sortorder($category->id); } } } if (!empty($CFG->allowcategorythemes)) { if (isset($category->theme)) { // specifying theme here saves us some dbqs theme_setup($category->theme); } } /// Print headings $numcategories = count_records("course_categories"); $stradministration = get_string("administration"); $strcategories = get_string("categories"); $strcategory = get_string("category"); $strcourses = get_string("courses"); $navlinks = array(); $navlinks[] = array('name' => $strcategories, 'link' => 'index.php', 'type' => 'misc'); $navlinks[] = array('name' => format_string($category->name), 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); if ($creatorediting) { if ($adminediting) { // modify this to treat this as an admin page
/** * This function is called by stylesheets to set up the header * approriately as well as the current path * * @uses $CFG * @param int $lastmodified ? * @param int $lifetime ? * @param string $thename ? */ function style_sheet_setup($lastmodified = 0, $lifetime = 300, $themename = '', $forceconfig = '', $lang = '') { global $CFG, $THEME; // Fix for IE6 caching - we don't want the filemtime('styles.php'), instead use now. $lastmodified = time(); header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified) . ' GMT'); header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); header('Cache-Control: max-age=' . $lifetime); header('Pragma: '); header('Content-type: text/css'); // Correct MIME type $DEFAULT_SHEET_LIST = array('styles_layout', 'styles_fonts', 'styles_color'); if (empty($themename)) { $themename = current_theme(); // So we have something. Normally not needed. } else { $themename = clean_param($themename, PARAM_SAFEDIR); } theme_setup($themename); if (!empty($forceconfig)) { // Page wants to use the config from this theme instead unset($THEME); include $CFG->themedir . '/' . $forceconfig . '/' . 'config.php'; } /// If this is the standard theme calling us, then find out what sheets we need if ($themename == 'standard') { if (!isset($THEME->standardsheets) or $THEME->standardsheets === true) { // Use all the sheets we have $THEME->sheets = $DEFAULT_SHEET_LIST; } else { if (empty($THEME->standardsheets)) { // We can stop right now! echo "/***** Nothing required from this stylesheet by main theme *****/\n\n"; exit; } else { // Use the provided subset only $THEME->sheets = $THEME->standardsheets; } } /// If we are a parent theme, then check for parent definitions } else { if (!empty($THEME->parent) && $themename == $THEME->parent) { if (!isset($THEME->parentsheets) or $THEME->parentsheets === true) { // Use all the sheets we have $THEME->sheets = $DEFAULT_SHEET_LIST; } else { if (empty($THEME->parentsheets)) { // We can stop right now! echo "/***** Nothing required from this stylesheet by main theme *****/\n\n"; exit; } else { // Use the provided subset only $THEME->sheets = $THEME->parentsheets; } } } } /// Work out the last modified date for this theme foreach ($THEME->sheets as $sheet) { if (file_exists($CFG->themedir . '/' . $themename . '/' . $sheet . '.css')) { $sheetmodified = filemtime($CFG->themedir . '/' . $themename . '/' . $sheet . '.css'); if ($sheetmodified > $lastmodified) { $lastmodified = $sheetmodified; } } } /// Get a list of all the files we want to include $files = array(); foreach ($THEME->sheets as $sheet) { $files[] = array($CFG->themedir, $themename . '/' . $sheet . '.css'); } if ($themename == 'standard') { // Add any standard styles included in any modules if (!empty($THEME->modsheets)) { // Search for styles.php within activity modules if ($mods = get_list_of_plugins('mod')) { foreach ($mods as $mod) { if (file_exists($CFG->dirroot . '/mod/' . $mod . '/styles.php')) { $files[] = array($CFG->dirroot, '/mod/' . $mod . '/styles.php'); } } } } if (!empty($THEME->blocksheets)) { // Search for styles.php within block modules if ($mods = get_list_of_plugins('blocks')) { foreach ($mods as $mod) { if (file_exists($CFG->dirroot . '/blocks/' . $mod . '/styles.php')) { $files[] = array($CFG->dirroot, '/blocks/' . $mod . '/styles.php'); } } } } if (!isset($THEME->courseformatsheets) || $THEME->courseformatsheets) { // Search for styles.php in course formats if ($mods = get_list_of_plugins('format', '', $CFG->dirroot . '/course')) { foreach ($mods as $mod) { if (file_exists($CFG->dirroot . '/course/format/' . $mod . '/styles.php')) { $files[] = array($CFG->dirroot, '/course/format/' . $mod . '/styles.php'); } } } } if (!isset($THEME->gradereportsheets) || $THEME->gradereportsheets) { // Search for styles.php in grade reports if ($reports = get_list_of_plugins('grade/report')) { foreach ($reports as $report) { if (file_exists($CFG->dirroot . '/grade/report/' . $report . '/styles.php')) { $files[] = array($CFG->dirroot, '/grade/report/' . $report . '/styles.php'); } } } } if (!empty($THEME->langsheets)) { // Search for styles.php within the current language if (file_exists($CFG->dirroot . '/lang/' . $lang . '/styles.php')) { $files[] = array($CFG->dirroot, '/lang/' . $lang . '/styles.php'); } } } if ($files) { /// Produce a list of all the files first echo '/**************************************' . "\n"; echo ' * THEME NAME: ' . $themename . "\n *\n"; echo ' * Files included in this sheet:' . "\n *\n"; foreach ($files as $file) { echo ' * ' . $file[1] . "\n"; } echo ' **************************************/' . "\n\n"; /// check if csscobstants is set if (!empty($THEME->cssconstants)) { require_once "{$CFG->libdir}/cssconstants.php"; /// Actually collect all the files in order. $css = ''; foreach ($files as $file) { $css .= '/***** ' . $file[1] . ' start *****/' . "\n\n"; $css .= file_get_contents($file[0] . '/' . $file[1]); $ccs .= '/***** ' . $file[1] . ' end *****/' . "\n\n"; } /// replace css_constants with their values echo replace_cssconstants($css); } else { /// Actually output all the files in order. if (empty($CFG->CSSEdit) && empty($THEME->CSSEdit)) { foreach ($files as $file) { echo '/***** ' . $file[1] . ' start *****/' . "\n\n"; @(include_once $file[0] . '/' . $file[1]); echo '/***** ' . $file[1] . ' end *****/' . "\n\n"; } } else { foreach ($files as $file) { echo '/* @group ' . $file[1] . ' */' . "\n\n"; if (strstr($file[1], '.css') !== FALSE) { echo '@import url("' . $CFG->themewww . '/' . $file[1] . '");' . "\n\n"; } else { @(include_once $file[0] . '/' . $file[1]); } echo '/* @end */' . "\n\n"; } } } } return $CFG->themewww . '/' . $themename; // Only to help old themes (1.4 and earlier) }
function report_session_error() { global $CFG, $FULLME; if (empty($CFG->lang)) { $CFG->lang = "en"; } // Set up default theme and locale theme_setup(); moodle_setlocale(); //clear session cookies if (check_php_version('5.2.0')) { //PHP 5.2.0 setcookie('MoodleSession' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly); setcookie('MoodleSessionTest' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly); } else { setcookie('MoodleSession' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure); setcookie('MoodleSessionTest' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure); } //increment database error counters if (isset($CFG->session_error_counter)) { set_config('session_error_counter', 1 + $CFG->session_error_counter); } else { set_config('session_error_counter', 1); } redirect($FULLME, get_string('sessionerroruser2', 'error'), 5); }
if (empty($category)) { redirect($CFG->wwwroot . '/course/index.php?categoryedit=on'); } else { redirect($CFG->wwwroot . '/course/category.php?categoryedit=on&id=' . $category->id); } } else { if ($data = $mform->get_data()) { $newcategory = new stdClass(); $newcategory->name = $data->name; $newcategory->description = $data->description; $newcategory->sortorder = 999; $newcategory->parent = $data->parent; // if $id = 0, the new category will be a top-level category if (!empty($data->theme) && !empty($CFG->allowcategorythemes)) { $newcategory->theme = $data->theme; theme_setup(); } if (empty($category) && has_capability('moodle/category:create', $context)) { // Create a new category if (!($newcategory->id = insert_record('course_categories', $newcategory))) { notify("Could not insert the new category '{$newcategory->name}' "); } else { $newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id); mark_context_dirty($newcategory->context->path); redirect('index.php?categoryedit=on'); } } elseif (has_capability('moodle/category:update', $context)) { $newcategory->id = $category->id; if ($newcategory->parent != $category->parent) { $parent_cat = get_record('course_categories', 'id', $newcategory->parent); move_category($newcategory, $parent_cat);
$access = optional_param('access', 0, PARAM_TEXT); $itemid = optional_param('itemid', 0, PARAM_INT); $action = optional_param('action', '', PARAM_ALPHA); $commentid = optional_param('commentid', 0, PARAM_INT); $deletecomment = optional_param('deletecomment', 0, PARAM_INT); $backtype = optional_param('backtype', 0, PARAM_TEXT); require_login(0, true); $item = block_exabis_eportfolio_get_item($itemid, $access); if (!$item) { print_error("bookmarknotfound", "block_exabis_eportfolio"); } if (!($user = get_record("user", "id", $item->userid))) { print_error("nouserforid", "block_exabis_eportfolio"); } // Set THEME (nadavkav) theme_setup($view->theme); if ($item->access->page == 'view') { if ($item->access->request == 'intern') { block_exabis_eportfolio_print_header("views"); } else { print_header(get_string("externaccess", "block_exabis_eportfolio"), get_string("externaccess", "block_exabis_eportfolio") . " " . fullname($user, $user->id)); } } elseif ($item->access->page == 'portfolio') { if ($item->access->request == 'intern') { if ($backtype && $item->userid == $USER->id) { block_exabis_eportfolio_print_header("bookmarks" . block_exabis_eportfolio_get_plural_item_type($backtype)); } else { block_exabis_eportfolio_print_header("sharedbookmarks"); } } else { print_header(get_string("externaccess", "block_exabis_eportfolio"), get_string("externaccess", "block_exabis_eportfolio") . " " . fullname($user, $user->id));
/** * This function returns the full path to an image * Always use it to get image paths * @param $imagelocation path to image relative to theme/$theme/static/ * @param $pluginlocation path to plugin relative to docroot */ function theme_get_path($location, $pluginlocation = '', $all = false) { $theme = theme_setup(); $list = array(); foreach ($theme->inheritance as $themedir) { if (is_readable(get_config('docroot') . $pluginlocation . 'theme/' . $themedir . '/static/' . $location)) { if ($all) { $list[$themedir] = get_config('docroot') . $pluginlocation . 'theme/' . $themedir . '/static/' . $location; } else { return get_config('docroot') . $pluginlocation . 'theme/' . $themedir . '/static/' . $location; } } } if ($all) { return $list; } }
/** * Collects all styles that would be included in calls to styles.php * from the various themes (standard, parent, current, etc). * * @return void **/ function page_theme_process_styles($lifetime = 300, $forceconfig = '', $lang = '') { global $CFG, $THEME; if (!empty($forceconfig)) { $current = $forceconfig; } else { $current = current_theme(); } // Determine if we need to Refresh the client cached stylesheet $headers = apache_request_headers(); $lastmodified = filemtime($CFG->themedir . '/.'); // themes change means styles are modified $timestamp = time(); $ETag = '' . ($timestamp - $timestamp % 3600); // Rounded to the hour if (isset($headers['If-None-Match']) and isset($headers['If-Modified-Since']) and strpos($headers['If-None-Match'], "{$ETag}") and gmdate("D, d M Y H:i:s", $lastmodified) == $headers['If-Modified-Since']) { // Send Not Modified headers with the same info as in style_sheet_setup header('HTTP/1.1 304 Not Modified'); header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified) . ' GMT'); header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); header('Cache-Control: max-age=' . $lifetime); header('Pragma: '); header('Content-type: text/css'); // Correct MIME type header('ETag: "' . $ETag . '"'); exit; } else { // Refresh the contents /// Process Style Sheets -------------------------------------------------- ob_start(); style_sheet_setup(time(), $lifetime, 'standard', $forceconfig, $lang); $standard = ob_get_contents(); ob_end_clean(); // Replace relative strings in standard $css = page_theme_fix_relative_urls($standard, 'standard'); theme_setup($current); $css .= "/**************************************\n"; $css .= " * THEME NAME: {$current} and parents *\n"; $css .= " **************************************/\n\n"; $parentsheets = page_theme_get_parent_styles($current); foreach ($parentsheets as $themename => $styles) { if ($themename == 'page') { $fixurls = false; } else { $fixurls = true; } $css .= page_theme_combine_css($styles, $themename, $fixurls); } $css .= page_theme_combine_css($THEME->sheets, $current, $current != 'page'); /// END Process Style Sheets ---------------------------------------------- // Append Necessary Headers for proper caching header('Content-length: ' . strlen($css)); header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified)); header('ETag: "' . $ETag . '"'); echo $css; // Now that header information is done send contents } }
/** * This function sets the $HTTPSPAGEREQUIRED global * (used in some parts of moodle to change some links) * and calculate the proper wwwroot to be used * * By using this function properly, we can ensure 100% https-ized pages * at our entire discretion (login, forgot_password, change_password) */ function httpsrequired() { global $CFG, $HTTPSPAGEREQUIRED; if (!empty($CFG->loginhttps)) { $HTTPSPAGEREQUIRED = true; $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot); $CFG->httpsthemewww = str_replace('http:', 'https:', $CFG->themewww); // change theme URLs to https theme_setup(); } else { $CFG->httpswwwroot = $CFG->wwwroot; $CFG->httpsthemewww = $CFG->themewww; } }
<?php // $Id: preview.php,v 1.6 2007/08/17 19:09:25 nicolasconnault Exp $ require_once "../config.php"; $preview = optional_param('preview', 'standard', PARAM_FILE); // which theme to show if (!file_exists($CFG->themedir . '/' . $preview)) { $preview = 'standard'; } if (!($site = get_site())) { error("Site doesn't exist!"); } require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); $CFG->theme = $preview; theme_setup($CFG->theme, array('forceconfig=' . $CFG->theme)); $stradministration = get_string("administration"); $strconfiguration = get_string("configuration"); $strthemes = get_string("themes"); $strpreview = get_string("preview"); $strsavechanges = get_string("savechanges"); $strtheme = get_string("theme"); $strthemesaved = get_string("themesaved"); $navlinks = array(); $navlinks[] = array('name' => $strthemes, 'link' => null, 'type' => 'misc'); $navlinks[] = array('name' => $strpreview, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("{$site->shortname}: {$strpreview}", $site->fullname, $navigation); print_simple_box_start('center', '80%'); print_heading($preview); print_simple_box_end();
/** * Should be used to provide the 'templatedir' directive to pieforms using a * template for layout. * * This depends on theme_setup(), so potentially should be in lib/web.php, but * for now it lives with the other pieform functions. * * @param string $file The file to be used as a pieform template, e.g. * "admin/site/files.php". This is the value you used as * the 'template' option for your pieform * @param string $pluginlocation Which plugin to search for the template, e.g. * artefact/file */ function pieform_template_dir($file, $pluginlocation = '') { $theme = theme_setup(); foreach ($theme->inheritance as $themedir) { $filepath = get_config('docroot') . $pluginlocation . '/theme/' . $themedir . '/pieforms/' . $file; if (is_readable($filepath)) { return dirname($filepath); } } throw new SystemException('No pieform template available: ' . $file); }
/** * This method is called when the page first moves out of the STATE_BEFORE_HEADER * state. This is our last change to initialise things. */ protected function starting_output() { global $SITE, $CFG; if (empty($CFG->rolesactive)) { $this->_course = new stdClass(); $this->_course->id = 1; moodle_setlocale(); theme_setup(); return; } if (!$this->_course) { $this->set_course($SITE); } $this->initialise_standard_body_classes(); $this->blocks->load_blocks(); }