Example #1
0
<?php

/*  $Id: styles.php,v 1.8 2006/04/07 15:07:54 moodler Exp $ */
/// Every theme should contain a copy of this script.  It lets us
/// set up variables and so on before we include the raw CSS files.
/// The output of this script should be a completely standard CSS file.
/// THERE SHOULD BE NO NEED TO MODIFY THIS FILE!!  USE CONFIG.PHP INSTEAD.
$lifetime = 600;
// Seconds to cache this stylesheet
$nomoodlecookie = true;
// Cookies prevent caching, so don't use them
require_once "../../config.php";
// Load up the Moodle libraries
$themename = basename(dirname(__FILE__));
// Name of the folder we are in
$forceconfig = optional_param('forceconfig', '', PARAM_FILE);
// Get config from this theme
style_sheet_setup(time(), $lifetime, $themename, $forceconfig);
Example #2
0
 * string or suiable error code. If not, it redirects the user back to
 * where they came from.                                               (2)
 *
 * @package   blocks-accessibility                                      (3)
 * @copyright 2009 Mark Johnson                                        (4)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5)
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/accessibility/lib.php';
header('Cache-Control: no-cache');
if (!isset($USER->defaultfontsize)) {
    ob_start();
    // Buffer the output so we're not really creating a stylesheet.
    style_sheet_setup(time(), 0, 'standard');
    // Generate the stylesheets for the base and current themes
    style_sheet_setup(time(), 0, $CFG->theme);
    $styles = ob_get_contents();
    // Get the generated sheets from the buffer
    ob_end_clean();
    $size = array();
    if (preg_match('/body\\s?\\{[^\\}]*font[^:]*:([\\d]{1,3})(px|%)[^\\}]*}/', $styles, $size) > 0) {
        // If there's a value in the stylesheet for the font size in pixels or percent
        $defaultsize = $size[1];
        // use it
    } else {
        $defaultsize = 100;
        // Otherwise, use 100 as a sensible default
    }
    if ($size[2] == '%' || $defaultsize == 100) {
        $USER->defaultfontsize = get_size($defaultsize);
    } else {
<?php

/*  $Id: docstyles.php,v 1.1 2009/12/21 00:54:52 michaelpenne Exp $ */
/// We use PHP so we can do value substitutions into the styles
$nomoodlecookie = true;
require_once "../../config.php";
$themename = optional_param('themename', NULL, PARAM_SAFEDIR);
$themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename);
///
/// You can hardcode colours in this file if you
/// don't care about this.
?>
body {
    background-color:#FFFFFF;
}
p, a {
    font-size:small;
}

h1, h2, h3 {
    padding-left:0px;
    background-color:transparent;
    color:#000000;
}

h1 {
    font-size:1.7em; 
    margin:0.5em 0 0;
}

h2 {
Example #4
0
/**
 * 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
    }
}