mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
allow overriding the default templates
Allow templates to be distributed as plugins Prevent any folder named skel or something_skel, or not containing any of the folders that bake is expecting, from being considered a theme.
This commit is contained in:
parent
3b1664b7dd
commit
c629d2c820
1 changed files with 25 additions and 4 deletions
|
@ -53,20 +53,41 @@ class TemplateTask extends Shell {
|
||||||
**/
|
**/
|
||||||
function _findThemes() {
|
function _findThemes() {
|
||||||
$paths = App::path('shells');
|
$paths = App::path('shells');
|
||||||
array_unshift($paths, CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS);
|
$core = array_pop($paths);
|
||||||
|
$core = str_replace('libs' . DS, '', $core);
|
||||||
|
$paths[] = $core;
|
||||||
|
$Folder =& new Folder($core . 'templates' . DS . 'default');
|
||||||
|
$contents = $Folder->read();
|
||||||
|
$themeFolders = $contents[0];
|
||||||
|
|
||||||
|
$pluginPaths = App::path('plugins');
|
||||||
|
foreach($pluginPaths as $path) {
|
||||||
|
$paths[] = $path . 'vendors' . DS . 'shells' . DS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEMPORARY TODO remove when all paths are DS terminated
|
||||||
|
foreach($paths as &$path) {
|
||||||
|
$path = rtrim($path, DS) . DS;
|
||||||
|
}
|
||||||
|
|
||||||
$themes = array();
|
$themes = array();
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
$Folder =& new Folder($path . 'templates', false);
|
$Folder =& new Folder($path . 'templates', false);
|
||||||
$contents = $Folder->read();
|
$contents = $Folder->read();
|
||||||
$subDirs = $contents[0];
|
$subDirs = $contents[0];
|
||||||
foreach ($subDirs as $dir) {
|
foreach ($subDirs as $dir) {
|
||||||
if (empty($dir) || $dir == 'skel') {
|
if (empty($dir) || preg_match('@^skel$|_skel$@', $dir)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$Folder =& new Folder($path . 'templates' . DS . $dir);
|
||||||
|
$contents = $Folder->read();
|
||||||
|
$subDirs = $contents[0];
|
||||||
|
if (array_intersect($contents[0], $themeFolders)) {
|
||||||
$templateDir = $path . 'templates' . DS . $dir . DS;
|
$templateDir = $path . 'templates' . DS . $dir . DS;
|
||||||
$themes[$dir] = $templateDir;
|
$themes[$dir] = $templateDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $themes;
|
return $themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue