From 9b2735f93cc81b943fd8f7be02d4f196a669cae5 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 25 Dec 2009 14:14:55 +0000 Subject: [PATCH] MDL-21188 removing support for yui pix folders in themes because it is not compatible with autoloading in YUI3 and also loading of any YUI from external sites through combo scripts --- lib/ajax/ajaxlib.php | 4 +++- lib/outputlib.php | 52 ++++++++--------------------------------- lib/outputrenderers.php | 2 +- theme/styles.php | 4 ++-- theme/styles_debug.php | 4 ++-- 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 763b997a4d..966665d7f2 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -133,6 +133,8 @@ class page_requirements_manager { // This file helps to minimise number of http requests //$this->yui3loader->comboBase = $CFG->httpswwwroot . '/theme/yuicomboloader.php?'; + + $this->yui3loader->load('cssreset', 'cssbase', 'cssfonts', 'cssgrids'); } /** @@ -463,7 +465,7 @@ class page_requirements_manager { * @return string */ protected function get_yui3lib_code() { - return $this->yui3loader->script(); + return $this->yui3loader->css().$this->yui3loader->script(); } /** diff --git a/lib/outputlib.php b/lib/outputlib.php index 59a62ba25d..3c0fcb70bf 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -591,7 +591,7 @@ class theme_config { $css = $this->css_content(); $url = $CFG->httpswwwroot.'/theme/styles_debug.php'; $urls = array(); - $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'yui')); + $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'yui2')); foreach ($css['plugins'] as $plugin=>$unused) { $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'plugin', 'subtype'=>$plugin)); } @@ -614,16 +614,10 @@ class theme_config { public function css_content() { global $CFG; - $css = array('yui'=>array(), 'plugins'=>array(), 'parents'=>array(), 'theme'=>array()); + $css = array('yui2'=>array(), 'plugins'=>array(), 'parents'=>array(), 'theme'=>array()); - //YUI sheets - $yui_sheets = "/*** YUI3 reset sheets and grids ***/\n\n"; - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui3version/cssreset/reset-min.css"); - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui3version/cssbase/base-min.css"); - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui3version/cssfonts/fonts-min.css"); - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui3version/cssgrids/grids-min.css"); - - $yui_sheets .= "\n\n/*** Standard YUI2 sheets ***/\n\n"; + // legacy YUI2 stylesheets, YUI3 stylesheets are loaded on the fly + $yui2_sheets = "\n\n/*** Standard YUI2 sheets ***/\n\n"; $items = new DirectoryIterator("$CFG->libdir/yui/$CFG->yui2version/assets/skins/sam"); foreach ($items as $item) { if ($item->isDot() or !$item->isFile()) { @@ -633,28 +627,13 @@ class theme_config { if (substr($filename, -4) !== '.css') { continue; } - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui2version/assets/skins/sam/$filename"); + $yui2_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui2version/assets/skins/sam/$filename"); } unset($item); unset($items); - $yui_sheets .= "\n\n/*** Standard YUI3 sheets ***/\n\n"; - $items = new DirectoryIterator("$CFG->libdir/yui/$CFG->yui3version/assets/skins/sam"); - foreach ($items as $item) { - if ($item->isDot() or !$item->isFile()) { - continue; - } - $filename = $item->getFilename(); - if (substr($filename, -4) !== '.css') { - continue; - } - $yui_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui3version/assets/skins/sam/$filename"); - } - unset($item); - unset($items); - - $yui_sheets = preg_replace('/([a-z-]+)\.(png|gif)/', '[[pix:yui|$1]]', $yui_sheets); - $css['yui'][] = $this->post_process($yui_sheets); + $yui2_sheets = preg_replace('/([a-z-]+)\.(png|gif)/', '[[pix:yui2|$1]]', $yui2_sheets); + $css['yui2'][] = $this->post_process($yui2_sheets); // get all plugin sheets $excludes = null; @@ -898,20 +877,9 @@ class theme_config { } return null; - } else if ($component === 'yui') { - // yui CSS files are parsed automatically and altered on the fly - if ($imagefile = $this->image_exists("$this->dir/pix_yui/$image")) { - return $imagefile; - } - foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last - if ($imagefile = $this->image_exists("$parent_config->dir/pix_yui/$image")) { - return $imagefile; - } - } - if ($imagefile = $this->image_exists("$CFG->libdir/yui/$CFG->yui3version/assets/skins/sam/$image")) { - // YUI3 takes precedence - return $imagefile; - } + } else if ($component === 'yui2') { + // YUI2 is here for legacy reasons only, YUI3 images are not handled here + // yui images need to be overriden with CSS using proper selectors if ($imagefile = $this->image_exists("$CFG->libdir/yui/$CFG->yui2version/assets/skins/sam/$image")) { return $imagefile; } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 3426b809dd..6c971bf322 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -362,7 +362,7 @@ class core_renderer extends renderer_base { // any other custom CSS can not be overridden via themes and is highly discouraged $urls = $this->page->theme->css_urls(); foreach ($urls as $url) { - $output .= '' . "\n"; + $this->page->requires->css($url->out(), true); } // Get the theme javascript diff --git a/theme/styles.php b/theme/styles.php index a68fc2bf91..c4ea5204bd 100644 --- a/theme/styles.php +++ b/theme/styles.php @@ -32,7 +32,7 @@ $themename = min_optional_param('theme', 'standard', 'SAFEDIR'); $type = min_optional_param('type', 'all', 'SAFEDIR'); $rev = min_optional_param('rev', 0, 'INT'); -if (!in_array($type, array('all', 'ie', 'editor', 'yui', 'plugins', 'parents', 'theme'))) { +if (!in_array($type, array('all', 'ie', 'editor', 'yui2', 'plugins', 'parents', 'theme'))) { header('HTTP/1.0 404 not found'); die('Theme was not found, sorry.'); } @@ -116,7 +116,7 @@ function send_ie_css($themename, $rev) { $css = <<css_content(); -if ($type === 'yui') { - send_uncached_css(reset($css['yui'])); +if ($type === 'yui2') { + send_uncached_css(reset($css['yui2'])); } else if ($type === 'plugin') { if (isset($css['plugins'][$subtype])) { -- 2.39.5