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

This commit is contained in:
Petr Skoda
2009-12-25 14:14:55 +00:00
parent 4c90714106
commit 9b2735f93c
5 changed files with 18 additions and 48 deletions
+3 -1
View File
@@ -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();
}
/**
+10 -42
View File
@@ -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;
}
+1 -1
View File
@@ -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 .= '<link rel="stylesheet" type="text/css" href="' . $url->out() . '" />' . "\n";
$this->page->requires->css($url->out(), true);
}
// Get the theme javascript
+2 -2
View File
@@ -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 = <<<EOF
/** Unfortunately IE6/7 does not support more than 4096 selectors in one CSS file, which means we have to use some ugly hacks :-( **/
@import url(styles.php?theme=$themename&rev=$rev&type=yui);
@import url(styles.php?theme=$themename&rev=$rev&type=yui2);
@import url(styles.php?theme=$themename&rev=$rev&type=plugins);
@import url(styles.php?theme=$themename&rev=$rev&type=parents);
@import url(styles.php?theme=$themename&rev=$rev&type=theme);
+2 -2
View File
@@ -56,8 +56,8 @@ if ($type === 'editor') {
$css = $theme->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])) {