-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made php7+ as a requirement. php5.6 will no longer be maintained by p…
…hp as of December this year. added a callback method for template output #5790
- Loading branch information
1 parent
b757454
commit 6e30f9b
Showing
18 changed files
with
234 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
<?php | ||
class ControllerEventTheme extends Controller { | ||
public function index(&$route, &$args, &$template) { | ||
|
||
echo $template; | ||
|
||
// If there is a template file we render | ||
if ($template) { | ||
// include and register Twig auto-loader | ||
Twig_Autoloader::register(); | ||
|
||
// specify where to look for templates | ||
$loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE); | ||
|
||
$config = array('autoescape' => false); | ||
|
||
if ($this->config->get('template_cache')) { | ||
$config['cache'] = DIR_CACHE; | ||
} | ||
|
||
// initialize Twig environment | ||
$twig = new \Twig_Environment($loader, $config); | ||
|
||
return $twig->createTemplate($template)->render($args); | ||
} | ||
} | ||
|
||
public function override(&$route, &$args, &$template) { | ||
if (!$this->config->get('theme_' . $this->config->get('config_theme') . '_status')) { | ||
exit('Error: A theme has not been assigned to this store!'); | ||
} | ||
|
||
echo 'hi'; | ||
|
||
// If the default theme is selected we need to know which directory its pointing to | ||
// If the default theme is selected we need to know which directory its pointing to | ||
if ($this->config->get('config_theme') == 'default') { | ||
$theme = $this->config->get('theme_default_directory'); | ||
$directory = $this->config->get('theme_default_directory'); | ||
} else { | ||
$theme = $this->config->get('config_theme'); | ||
$directory = $this->config->get('config_theme'); | ||
} | ||
|
||
if (is_file(DIR_TEMPLATE . $directory . '/template/' . $route . '.twig')) { | ||
$this->config->set('template_directory', $directory . '/template/'); | ||
} elseif (is_file(DIR_TEMPLATE . 'default/template/' . $route . '.twig')) { | ||
$this->config->set('template_directory', 'default/template/'); | ||
} | ||
|
||
// If there is a theme override we should get it | ||
$this->load->model('design/theme'); | ||
|
||
$theme_info = $this->model_design_theme->getTheme($route, $theme); | ||
|
||
if ($theme_info) { | ||
|
||
// If you want to modify the output of the template we add a | ||
$proxy = new Proxy(); | ||
|
||
$template = html_entity_decode($theme_info['code'], ENT_QUOTES, 'UTF-8'); | ||
// Attach to the template | ||
$template->addFilter($proxy); | ||
|
||
$proxy->callback = function ($code) use ($route, $args, $directory) { | ||
// If there is a theme override we should get it | ||
$this->load->model('design/theme'); | ||
|
||
$theme_info = $this->model_design_theme->getTheme($route, $directory); | ||
|
||
} elseif (is_file(DIR_TEMPLATE . $theme . '/template/' . $route . '.twig')) { | ||
$this->config->set('template_directory', $theme . '/template/'); | ||
} elseif (is_file(DIR_TEMPLATE . 'default/template/' . $route . '.twig')) { | ||
$this->config->set('template_directory', 'default/template/'); | ||
} | ||
if ($theme_info) { | ||
return html_entity_decode($theme_info['code'], ENT_QUOTES, 'UTF-8'); | ||
} else { | ||
// Because we are using a proxy the arguments will always be an array. | ||
return $code[0]; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
// Site | ||
$_['site_url'] = ''; | ||
$_['site_ssl'] = false; | ||
|
||
// Url | ||
$_['url_autostart'] = true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php | ||
// Registry | ||
$registry = new Registry(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.