Skip to content

Commit

Permalink
Merge branch 'MDL-59148-master-7' of git://github.com/andrewnicols/mo…
Browse files Browse the repository at this point in the history
…odle
  • Loading branch information
dmonllao committed Jun 28, 2017
2 parents 0248d16 + 0e9911e commit 185455d
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 72 deletions.
22 changes: 21 additions & 1 deletion lib/csslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ function css_send_cached_css_content($csscontent, $etag) {
die;
}

/**
* Sends CSS directly and disables all caching.
* The Content-Length of the body is also included, but the script is not ended.
*
* @param string $css The CSS content to send
* @param int $expiry The anticipated expiry of the file
*/
function css_send_temporary_css($css) {
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
header('Content-Disposition: inline; filename="styles_debug.php"');
header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
header('Accept-Ranges: none');
header('Content-Type: text/css; charset=utf-8');
header('Content-Length: ' . strlen($css));

echo $css;
}

/**
* Sends CSS directly without caching it.
*
Expand Down Expand Up @@ -382,4 +402,4 @@ function css_send_unmodified($lastmodified, $etag) {
function css_send_css_not_found() {
header('HTTP/1.0 404 not found');
die('CSS was not found, sorry.');
}
}
30 changes: 29 additions & 1 deletion lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ class theme_config {
*/
public $editor_sheets = array();

/**
* @var bool Whether a fallback version of the stylesheet will be used
* whilst the final version is generated.
*/
public $usefallback = false;

/**
* @var array The names of all the javascript files this theme that you would
* like included from head, in order. Give the names of the files without .js.
Expand Down Expand Up @@ -724,7 +730,7 @@ private function __construct($config) {
}

$configurable = array(
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets',
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'usefallback',
'javascripts', 'javascripts_footer', 'parents_exclude_javascripts',
'layouts', 'enable_dock', 'enablecourseajax', 'requiredblocks',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'uarrow', 'darrow',
Expand Down Expand Up @@ -1102,6 +1108,19 @@ public function set_css_content_cache($csscontent) {
return $cache->set($key, $csscontent);
}

/**
* Return whether the post processed CSS content has been cached.
*
* @return bool Whether the post-processed CSS is available in the cache.
*/
public function has_css_cached_content() {

$key = $this->get_css_cache_key();
$cache = cache::make('core', 'postprocessedcss');

return $cache->has($key);
}

/**
* Return cached post processed CSS content.
*
Expand Down Expand Up @@ -2218,6 +2237,15 @@ public function set_rtl_mode($inrtl = true) {
$this->rtlmode = $inrtl;
}

/**
* Whether the theme is being served in RTL mode.
*
* @return bool True when in RTL mode.
*/
public function get_rtl_mode() {
return $this->rtlmode;
}

/**
* Checks if file with any image extension exists.
*
Expand Down
1 change: 1 addition & 0 deletions theme/boost/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$THEME->name = 'boost';
$THEME->sheets = [];
$THEME->editor_sheets = [];
$THEME->usefallback = true;
$THEME->scss = function($theme) {
return theme_boost_get_main_scss_content($theme);
};
Expand Down
1 change: 1 addition & 0 deletions theme/more/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$THEME->doctype = 'html5';
$THEME->sheets = array('custom');
$THEME->lessfile = 'moodle';
$THEME->usefallback = true;
$THEME->parents_exclude_sheets = array('bootstrapbase' => array('moodle'), 'clean' => array('custom'));
$THEME->lessvariablescallback = 'theme_more_less_variables';
$THEME->extralesscallback = 'theme_more_extra_less';
Expand Down
Loading

0 comments on commit 185455d

Please sign in to comment.