Commit 78946b9b authored by Petr Skoda's avatar Petr Skoda
Browse files

MDL-20204 first batch of major theme changes, some regressions are still...

MDL-20204 first batch of major theme changes, some regressions are still there, expect more changes and improvements soon; see tracker for details and list of subtasks
parent e09ef36a
This diff is collapsed.
This diff is collapsed.
......@@ -39,7 +39,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*
* @property-read string $generaltype the general type of page this is. For example 'normal', 'popup', 'home'.
* @property-read string $pagelayout the general type of page this is. For example 'normal', 'popup', 'home'.
* Allows the theme to display things differently, if it wishes to.
* @property-read string $title the title that should go in the <head> section of the HTML of this page.
* @property-read string $heading the main heading that should be displayed at the top of the <body>.
......@@ -99,7 +99,14 @@ class moodle_page {
protected $_pagetype = null;
protected $_generaltype = 'normal';
protected $_pagelayout = 'normal';
/**
* List of theme layeout options, these are ignored by core.
* To be used in individual theme layout files only.
* @var array
*/
protected $_layout_options = array();
protected $_subpage = '';
......@@ -156,7 +163,7 @@ class moodle_page {
* This is simply to improve backwards compatability. If old code relies on
* a page class that implements print_header, or complex logic in
* user_allowed_editing then we stash an instance of that other class here,
* and delegate to it in certani situations.
* and delegate to it in certain situations.
*/
protected $_legacypageobject = null;
......@@ -284,12 +291,20 @@ class moodle_page {
}
/**
* Please do not call this method directly, use the ->generaltype syntax. {@link __get()}.
* Please do not call this method directly, use the ->pagelayout syntax. {@link __get()}.
* @return string the general type of page this is. For example 'normal', 'popup', 'home'.
* Allows the theme to display things differently, if it wishes to.
*/
public function get_generaltype() {
return $this->_generaltype;
public function get_pagelayout() {
return $this->_pagelayout;
}
/**
* Please do not call this method directly, use the ->layout_tions syntax. {@link __get()}.
* @return returns arrys with options for layout file
*/
public function get_layout_options() {
return $this->_layout_options;
}
/**
......@@ -373,7 +388,7 @@ class moodle_page {
* @return blocks_manager the blocks manager object for this page.
*/
public function get_blocks() {
global $CFG, $THEME;
global $CFG;
if (is_null($this->_blocks)) {
if (!empty($CFG->blockmanagerclass)) {
$classname = $CFG->blockmanagerclass;
......@@ -549,7 +564,7 @@ class moodle_page {
*/
public function debug_summary() {
$summary = '';
$summary .= 'General type: ' . $this->generaltype . '. ';
$summary .= 'General type: ' . $this->pagelayout . '. ';
if (!during_initial_install()) {
$summary .= 'Context ' . print_context_name($this->context) . ' (context id ' . $this->context->id . '). ';
}
......@@ -682,14 +697,13 @@ class moodle_page {
}
/**
* @param string $generaltype the general type of page this is. For example 'popup', 'home'.
* @param string $pagelayout the page layout this is. For example 'popup', 'home'.
* This properly defaults to 'normal', so you only need to call this function if
* you want something different. The exact range of supported page types is not
* strictly defined, this value is just passed to the theme. However, at the moment
* only 'normal', 'popup' amd 'home' are used.
* you want something different. The exact range of supported layouts is specified
* in the standard theme.
*/
public function set_generaltype($generaltype) {
$this->_generaltype = $generaltype;
public function set_pagelayout($pagelayout) {
$this->_pagelayout = $pagelayout;
}
/**
......@@ -951,10 +965,8 @@ class moodle_page {
if (!empty($CFG->loginhttps)) {
$HTTPSPAGEREQUIRED = true;
$CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
$CFG->httpsthemewww = str_replace('http:', 'https:', $CFG->themewww);
} else {
$CFG->httpswwwroot = $CFG->wwwroot;
$CFG->httpsthemewww = $CFG->themewww;
}
}
......@@ -995,21 +1007,6 @@ class moodle_page {
// Show the messaging popup, if there are messages.
message_popup_window();
// Add any stylesheets required using the horrible legacy mechanism.
if (!empty($CFG->stylesheets)) {
debugging('Some code on this page is using the horrible legacy mechanism $CFG->stylesheets to include links to ' .
'extra stylesheets. This is deprecated. Please use $PAGE->requires->css(...) instead.', DEBUG_DEVELOPER);
foreach ($CFG->stylesheets as $stylesheet) {
$this->requires->css($stylesheet, true);
}
}
// Require theme stylesheets.
$stylesheets = $this->theme->get_stylesheet_urls();
foreach ($stylesheets as $stylesheet) {
$this->requires->css($stylesheet, true);
}
$this->initialise_standard_body_classes();
}
......@@ -1035,15 +1032,14 @@ class moodle_page {
if (is_null($this->_theme)) {
$themename = $this->resolve_theme();
$this->_theme = theme_config::load($themename);
$this->_layout_options = $this->_theme->pagelayout_options($this->pagelayout);
}
$this->_theme->setup_blocks($this->generaltype, $this->blocks);
$this->_theme->setup_blocks($this->pagelayout, $this->blocks);
if ($this === $PAGE) {
$THEME = $this->_theme;
$OUTPUT = $this->_theme->get_renderer('core', $this);
// Support legacy code.
$this->_theme->setup_legacy_pix_paths();
}
$this->_wherethemewasinitialised = debug_backtrace();
......
......@@ -33,7 +33,7 @@
require '../config.php';
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/lib/session-test.php'));
$PAGE->set_generaltype('form');
$PAGE->set_pagelayout('form');
error('session test not reimplemented yet'); //DO NOT localize or use print_error()!
//
......
......@@ -26,6 +26,14 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// special support for highly optimised scripts that do not need libraries and DB connection
if (defined('ABORT_AFTER_CONFIG')) {
if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
require_once("$CFG->dirroot/lib/configonlylib.php");
return;
}
}
/**
* Holds the core settings that affect how Moodle works. Some of its fields
* are set in config.php, and the rest are loaded from the config table.
......@@ -94,7 +102,7 @@ global $PAGE;
global $COURSE;
/**
* $OUTPUT is an instance of moodle_core_renderer or one of its subclasses. Use
* $OUTPUT is an instance of core_renderer or one of its subclasses. Use
* it to generate HTML for output.
*
* $OUTPUT is initialised the first time it is used. See {@link bootstrap_renderer}
......@@ -202,15 +210,9 @@ $CFG->config_php_settings = (array)$CFG;
// Set up some paths.
$CFG->libdir = $CFG->dirroot .'/lib';
if (!isset($CFG->themedir)) {
$CFG->themedir = $CFG->dirroot.'/theme';
$CFG->themewww = $CFG->wwwroot.'/theme';
}
// Set httpswwwroot default value (this variable will replace $CFG->wwwroot
// inside some URLs used in HTTPSPAGEREQUIRED pages.
$CFG->httpswwwroot = $CFG->wwwroot;
$CFG->httpsthemewww = $CFG->themewww;
require_once($CFG->libdir .'/setuplib.php'); // Functions that MUST be loaded first
......
......@@ -665,8 +665,6 @@ get_string('experimental', 'admin', NULL);
get_string('experimentalsettings', 'admin', NULL);
get_string('enableglobalsearch', 'admin', NULL);
get_string('configenableglobalsearch', 'admin', NULL);
get_string('smartpix', 'admin', NULL);
get_string('configsmartpix', 'admin', NULL);
get_string('enablehtmlpurifier', 'admin', NULL);
get_string('configenablehtmlpurifier', 'admin', NULL);
get_string('experimentalsplitrestore', 'admin', NULL);
......
......@@ -665,8 +665,6 @@ old_get_string('experimental', 'admin', NULL);
old_get_string('experimentalsettings', 'admin', NULL);
old_get_string('enableglobalsearch', 'admin', NULL);
old_get_string('configenableglobalsearch', 'admin', NULL);
old_get_string('smartpix', 'admin', NULL);
old_get_string('configsmartpix', 'admin', NULL);
old_get_string('enablehtmlpurifier', 'admin', NULL);
old_get_string('configenablehtmlpurifier', 'admin', NULL);
old_get_string('experimentalsplitrestore', 'admin', NULL);
......
This diff is collapsed.
......@@ -177,9 +177,9 @@ class moodle_page_test extends UnitTestCase {
public function test_set_state_normal_path() {
$this->testpage->set_context(get_context_instance(CONTEXT_SYSTEM));
$this->testpage->set_course($this->create_a_course());
$this->testpage->set_course($this->create_a_course());
$this->assertEqual(moodle_page::STATE_BEFORE_HEADER, $this->testpage->state);
$this->assertEqual(moodle_page::STATE_BEFORE_HEADER, $this->testpage->state);
$this->testpage->set_state(moodle_page::STATE_PRINTING_HEADER);
$this->assertEqual(moodle_page::STATE_PRINTING_HEADER, $this->testpage->state);
......@@ -377,16 +377,16 @@ class moodle_page_test extends UnitTestCase {
$this->assertEqual('a title', $this->testpage->title);
}
public function test_default_generaltype() {
public function test_default_pagelayout() {
// Exercise SUT and Validate
$this->assertEqual('normal', $this->testpage->generaltype);
$this->assertEqual('normal', $this->testpage->pagelayout);
}
public function test_set_generaltype() {
public function test_set_pagelayout() {
// Exercise SUT
$this->testpage->set_generaltype('type');
$this->testpage->set_pagelayout('type');
// Validate
$this->assertEqual('type', $this->testpage->generaltype);
$this->assertEqual('type', $this->testpage->pagelayout);
}
}
......
......@@ -949,7 +949,7 @@ function upgrade_started($preinstall=false) {
} else {
if (!CLI_SCRIPT and !$PAGE->headerprinted) {
$strupgrade = get_string('upgradingversion', 'admin');
$PAGE->set_generaltype('maintenance');
$PAGE->set_pagelayout('maintenance');
upgrade_get_javascript();
$PAGE->set_title($strupgrade.' - Moodle '.$CFG->target_release);
$PAGE->set_heading($strupgrade);
......
......@@ -1909,69 +1909,8 @@ function user_login_string($course=NULL, $user=NULL) {
return $loggedinas;
}
/**
* Tests whether $THEME->rarrow, $THEME->larrow have been set (theme/-/config.php).
* If not it applies sensible defaults.
*
* Accessibility: right and left arrow Unicode characters for breadcrumb, calendar,
* search forum block, etc. Important: these are 'silent' in a screen-reader
* (unlike &gt; &raquo;), and must be accompanied by text.
*
* @global object
* @uses $_SERVER
*/
function check_theme_arrows() {
global $THEME;
if (!isset($THEME->rarrow) and !isset($THEME->larrow)) {
// Default, looks good in Win XP/IE 6, Win/Firefox 1.5, Win/Netscape 8...
// Also OK in Win 9x/2K/IE 5.x
$THEME->rarrow = '►'; // &#x25BA;
$THEME->larrow = '◄'; // &#x25C4;
if (empty($_SERVER['HTTP_USER_AGENT'])) {
$uagent = '';
} else {
$uagent = $_SERVER['HTTP_USER_AGENT'];
}
if (false !== strpos($uagent, 'Opera')
|| false !== strpos($uagent, 'Mac')) {
// Looks good in Win XP/Mac/Opera 8/9, Mac/Firefox 2, Camino, Safari.
// Not broken in Mac/IE 5, Mac/Netscape 7 (?).
$THEME->rarrow = '▶'; // &#x25B6;
$THEME->larrow = '◀'; // &#x25C0;
}
elseif (false !== strpos($uagent, 'Konqueror')) {
$THEME->rarrow = '→'; // &rarr;
$THEME->larrow = '←'; // &larr;
}
elseif (isset($_SERVER['HTTP_ACCEPT_CHARSET'])
&& false === stripos($_SERVER['HTTP_ACCEPT_CHARSET'], 'utf-8')) {
// (Win/IE 5 doesn't set ACCEPT_CHARSET, but handles Unicode.)
// To be safe, non-Unicode browsers!
$THEME->rarrow = '&gt;';
$THEME->larrow = '&lt;';
}
/// RTL support - in RTL languages, swap r and l arrows
if (right_to_left()) {
$t = $THEME->rarrow;
$THEME->rarrow = $THEME->larrow;
$THEME->larrow = $t;
}
} else {
if (strpos($THEME->rarrow, '&')===0 && strrpos($THEME->rarrow, ';')===strlen($THEME->rarrow)-1) {
$THEME->rarrow = html_entity_decode($THEME->rarrow, ENT_QUOTES, 'utf-8');
}
if (strpos($THEME->larrow, '&')===0 && strrpos($THEME->larrow, ';')===strlen($THEME->larrow)-1) {
$THEME->larrow = html_entity_decode($THEME->larrow, ENT_QUOTES, 'utf-8');
}
}
}
/**
* Return the right arrow with text ('next'), and optionally embedded in a link.
* See function above, check_theme_arrows.
*
* @global object
* @param string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
......@@ -1982,7 +1921,6 @@ function check_theme_arrows() {
*/
function link_arrow_right($text, $url='', $accesshide=false, $addclass='') {
global $THEME;
check_theme_arrows();
$arrowclass = 'arrow ';
if (! $url) {
$arrowclass .= $addclass;
......@@ -2007,7 +1945,6 @@ function link_arrow_right($text, $url='', $accesshide=false, $addclass='') {
/**
* Return the left arrow with text ('previous'), and optionally embedded in a link.
* See function above, check_theme_arrows.
*
* @global object
* @param string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
......@@ -2018,7 +1955,6 @@ function link_arrow_right($text, $url='', $accesshide=false, $addclass='') {
*/
function link_arrow_left($text, $url='', $accesshide=false, $addclass='') {
global $THEME;
check_theme_arrows();
$arrowclass = 'arrow ';
if (! $url) {
$arrowclass .= $addclass;
......@@ -2802,7 +2738,7 @@ function redirect($url, $message='', $delay=-1) {
}
// Include a redirect message, even with a HTTP redirect, because that is recommended practice.
$PAGE->set_generaltype('embedded'); // No header and footer needed
$PAGE->set_pagelayout('embedded'); // No header and footer needed
$CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page.
echo $OUTPUT->redirect_message($encodedurl, $message, $delay, $debugdisableredirect);
exit;
......@@ -2908,7 +2844,7 @@ function print_maintenance_message() {
global $CFG, $SITE, $PAGE, $OUTPUT;
$PAGE->set_pagetype('maintenance-message');
$PAGE->set_generaltype('maintenance');
$PAGE->set_pagelayout('maintenance');
$PAGE->set_title(strip_tags($SITE->fullname));
$PAGE->set_heading($SITE->fullname);
echo $OUTPUT->header();
......
......@@ -4,9 +4,7 @@ from:
http://developer.yahoo.com/yui
Changes:
* MDL-20007 - commented out some styles from reset-fonts-grids.css,
this is just a temporary hack, we need to find better long term solution
Changes: NONE
Added to Moodle 13 July 2006
Updated to YUI 0.12.0, 23 November 2006
......
......@@ -32,6 +32,7 @@ $testcookies = optional_param('testcookies', 0, PARAM_BOOL); // request cookie t
$context = get_context_instance(CONTEXT_SYSTEM);
$PAGE->set_course($SITE);
$PAGE->set_pagelayout('form');
/// Initialize variables
$errormsg = '';
......
......@@ -52,7 +52,7 @@
}
if ($user->deleted) {
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_title(get_string('discussion', 'message').': '.fullname($user));
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('userdeleted'), 1);
......@@ -72,7 +72,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo get_string('discussion', 'message').': '.fullname($user) ?></title>
<link rel="shortcut icon" href="<?php echo $CFG->wwwroot.'/theme/'.$PAGE->theme->name; ?>/favicon.ico" />
<link rel="shortcut icon" href="<?php echo $CFG->wwwroot.'/theme/'.$PAGE->theme->name; ?>/pix/favicon.ico" />
</head>
<frameset rows="110,*,0,220">
<noframes><body><?php
......@@ -160,7 +160,7 @@
$userfullname = fullname($user);
$mefullname = fullname($USER);
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_title(get_string('discussion', 'message').': '.fullname($user));
echo $OUTPUT->header();
......
......@@ -68,7 +68,7 @@ $PAGE->set_url($url);
/// Popup a window if required and quit (usually from external links).
if ($popup) {
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$OUTPUT->header();
echo $PAGE->requires->js_function_call('openpopup', Array('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0))->asap();
redirect("$CFG->wwwroot/", '', 0);
......@@ -99,7 +99,7 @@ if ($tab == 'contacts') {
$PAGE->set_periodic_refresh_delay($CFG->message_contacts_refresh);
}
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
echo $OUTPUT->header();
echo '<table cellspacing="2" cellpadding="2" border="0" width="95%" class="boxaligncenter">';
......
......@@ -25,7 +25,7 @@ require('../config.php');
@header('Content-Type: text/html; charset=utf-8');
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/message/messages.php'));
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
echo $OUTPUT->header();
......
......@@ -36,7 +36,7 @@ if (empty($CFG->messaging)) {
print_error('disabled', 'message');
}
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/message/refresh.php'));
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
......
......@@ -37,7 +37,7 @@ if (empty($CFG->messaging)) {
if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
$PAGE->set_title('send');
$PAGE->requires->js('message/message.js');
......
......@@ -86,7 +86,7 @@ if ($unblockcontact and confirm_sesskey()) {
}
//$PAGE->set_title('Message History');
$PAGE->set_generaltype('popup');
$PAGE->set_pagelayout('popup');
echo $OUTPUT->header();
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
echo '<td width="100">';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment