mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-04 04:07:59 +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 {
|
class Chunk {
|
||||||
|
|
||||||
@@ -166,13 +166,16 @@
|
|||||||
* @param string $name Chunk name
|
* @param string $name Chunk name
|
||||||
* @param string $theme Theme 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;
|
$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;
|
$chunk_path = THEMES_SITE . DS . $current_theme . DS;
|
||||||
|
|
||||||
// Is chunk exist ?
|
// Is chunk exist ?
|
||||||
@@ -181,10 +184,9 @@
|
|||||||
// Is chunk minified
|
// Is chunk minified
|
||||||
if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php') or
|
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')) {
|
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');
|
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php',
|
||||||
$buffer = Minify::html($buffer);
|
Minify::html(file_get_contents(THEMES_SITE. DS . $current_theme . DS . $name .'.chunk.php')));
|
||||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php', $buffer);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Include chunk
|
// Include chunk
|
||||||
include MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php';
|
include MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $name . '.chunk.php';
|
||||||
|
Reference in New Issue
Block a user