mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-07-31 18:30:20 +02:00
Themes Plugin: added ability to add parameters for chunks.
This commit is contained in:
@@ -156,7 +156,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* Chunk frontend class
|
||||
* Chunk class
|
||||
*/
|
||||
class Chunk {
|
||||
|
||||
@@ -166,13 +166,16 @@
|
||||
* @param string $name Chunk name
|
||||
* @param string $theme Theme name
|
||||
*/
|
||||
public static function get($name, $theme = null) {
|
||||
public static function get($name, $vars = array(), $theme = null) {
|
||||
|
||||
// Redefine vars
|
||||
$name = (string) $name;
|
||||
$current_theme = ($theme === null) ? null : (string) $theme;
|
||||
$current_theme = ($theme === null) ? Option::get('theme_site_name') : (string) $theme;
|
||||
|
||||
if ($current_theme == null) $current_theme = Option::get('theme_site_name');
|
||||
// Extract vars
|
||||
extract($vars);
|
||||
|
||||
// Chunk path
|
||||
$chunk_path = THEMES_SITE . DS . $current_theme . DS;
|
||||
|
||||
// Is chunk exist ?
|
||||
@@ -181,10 +184,9 @@
|
||||
// Is chunk minified
|
||||
if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php') or
|
||||
filemtime(THEMES_SITE . DS . $current_theme . DS . $name .'.chunk.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php')) {
|
||||
$buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $name .'.chunk.php');
|
||||
$buffer = Minify::html($buffer);
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php', $buffer);
|
||||
}
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php',
|
||||
Minify::html(file_get_contents(THEMES_SITE. DS . $current_theme . DS . $name .'.chunk.php')));
|
||||
}
|
||||
|
||||
// Include chunk
|
||||
include MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php';
|
||||
|
Reference in New Issue
Block a user