* @param moodle_page $page
* @param core_renderer $output
*/
- function setup_core_javascript(moodle_page $page, core_renderer $output) {
+ protected function setup_core_javascript(moodle_page $page, core_renderer $output) {
global $CFG;
// JavaScript should always work with $CFG->httpswwwroot rather than $CFG->wwwroot.
* Returns basic YUI3 JS loading code.
* YUI3 is using autoloading of both CSS and JS code.
*
+ * Major benefit of this compared to standard js/csss loader is much improved
+ * caching, better browser cache utilisation, much fewer http requests.
+ *
* @return string
*/
protected function get_yui3lib_headcode() {
/**
* Returns basic YUI2 JS loading code.
* It can be called manually at any time.
+ * If called manually the result needs to be output using echo().
+ *
+ * Major benefit of this compared to standard js loader is much improved
+ * caching, better browser cache utilisation, much fewer http requests.
+ *
+ * All YUI2 CSS is loaded automatically.
*
* @return string JS embedding code
*/
public function get_yui2lib_code() {
- // All YUI2 CSS is loaded automatically
+ global $CFG;
+
if ($this->headdone) {
$code = $this->yui2loader->script_embed();
} else {
$code = $this->yui2loader->script();
+ if ($this->yui2loader->combine) {
+ $skinurl = $this->yui2loader->comboBase . $CFG->yui2version . '/build/assets/skins/sam/skin.css';
+ } else {
+ $skinurl = $this->yui2loader->base . 'assets/skins/sam/skin.css';
+ }
+ // please note this is a temporary hack until we fully migrate to later YUI3 that has all the widgets
+ // we can not use moodle_url because the url fomrat for combo loader is "a bit" non-standard
+ $code .= "\n".'<link rel="stylesheet" type="text/css" href="'.$skinurl.'" />'."\n";
}
$code = str_replace('&', '&', $code);
$code = str_replace('&', '&', $code);
$rev = theme_get_revision();
$urls = array();
- //TODO: MDL-21242 add here link to full YUI2 skin.css - get the url from the $page->requires instance
if ($rev > -1) {
$params = array('theme'=>$this->name,'rev'=>$rev);
file_put_contents($candidatesheet, serialize($css));
}
- $url = $CFG->httpswwwroot.'/theme/styles_debug.php';
- $urls = array();
- $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'yui2'));
+ $baseurl = $CFG->httpswwwroot.'/theme/styles_debug.php';
foreach ($css['plugins'] as $plugin=>$unused) {
- $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'plugin', 'subtype'=>$plugin));
+ $urls[] = new moodle_url($baseurl, array('theme'=>$this->name,'type'=>'plugin', 'subtype'=>$plugin));
}
foreach ($css['parents'] as $parent=>$sheets) {
foreach ($sheets as $sheet=>$unused2) {
- $urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'parent', 'subtype'=>$parent, 'sheet'=>$sheet));
+ $urls[] = new moodle_url($$baseurl, array('theme'=>$this->name,'type'=>'parent', 'subtype'=>$parent, 'sheet'=>$sheet));
}
}
foreach ($css['theme'] as $sheet=>$unused) {
- $urls[] = new moodle_url($url, array('sheet'=>$sheet, 'theme'=>$this->name, 'type'=>'theme')); // sheet first in order to make long urls easier to read
+ $urls[] = new moodle_url($baseurl, array('sheet'=>$sheet, 'theme'=>$this->name, 'type'=>'theme')); // sheet first in order to make long urls easier to read
}
}
public function css_content() {
global $CFG;
- $css = array('yui2'=>array(), 'plugins'=>array(), 'parents'=>array(), 'theme'=>array());
-
- // legacy YUI2 stylesheets, YUI3 stylesheets are loaded on the fly
- $yui2_sheets = "\n\n/*** Standard YUI2 sheets ***/\n\n";
- $yui2_sheets .= file_get_contents("$CFG->libdir/yui/$CFG->yui2version/build/assets/skins/sam/skin.css");
- //TODO: MDL-21242 move this YUI2 CSS hack to css_urls(), the page requirements manager should return the correct yui_combo.php?2.x.x/build/skinks/sam/skin.css
-
- // search for all images in yui2 CSS and serve them through the yui_image.php script
- $css['yui2'][] = preg_replace('/([a-z-]+)\.(png|gif)/', 'yui_image.php?file='.$CFG->yui2version.'/$1.$2', $yui2_sheets);
+ $css = array('plugins'=>array(), 'parents'=>array(), 'theme'=>array());
// get all plugin sheets
$excludes = null;
$type = min_optional_param('type', 'all', 'SAFEDIR');
$rev = min_optional_param('rev', 0, 'INT');
-if (!in_array($type, array('all', 'ie', 'editor', 'yui2', 'plugins', 'parents', 'theme'))) {
+if (!in_array($type, array('all', 'ie', 'editor', 'plugins', 'parents', 'theme'))) {
header('HTTP/1.0 404 not found');
die('Theme was not found, sorry.');
}
$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=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);
$css = unserialize($css);
-if ($type === 'yui2') {
- send_uncached_css(reset($css['yui2']));
-
-} else if ($type === 'plugin') {
+if ($type === 'plugin') {
if (isset($css['plugins'][$subtype])) {
send_uncached_css($css['plugins'][$subtype]);
}