Skip to content

Commit e9f1025

Browse files
committed
fix: Theme Resources Creation
1 parent f78c6d5 commit e9f1025

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
font-family: Arial, Helvetica, sans-serif;
3+
}
98.4 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("hi");

webfiori/framework/ThemeManager.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,32 +142,35 @@ public static function resetRegistered() {
142142
*/
143143
private static function registerResourcesRoutes(Theme $theme) {
144144
$assetsFolderName = 'assets';
145-
$publicPath = ROOT_PATH.DS.PUBLIC_FOLDER.DS.$assetsFolderName.DS;
146-
$themeResourcesPath = $theme->getAbsolutePath().DS.$assetsFolderName.DS;
147-
$themePublicPath = $publicPath.DS.$assetsFolderName.DS.$theme->getDirectoryName().DS.$theme->getVersion().DS;
145+
$publicPath = ROOT_PATH.DS.PUBLIC_FOLDER.DS.$assetsFolderName;
146+
$themeResourcesPath = $theme->getAbsolutePath().DS.$assetsFolderName;
147+
$themePublicPath = $publicPath.DS.$theme->getDirectoryName().DS.$theme->getVersion();
148148

149149
if (!is_dir($themePublicPath)) {
150150
mkdir($themePublicPath, 0777, true);
151-
$jsDir = $themeResourcesPath.$theme->getJsDirName();
152-
if (is_dir($jsDir)) {
153-
mkdir($themePublicPath.DS.$theme->getJsDirName());
154-
copy($jsDir, $themePublicPath.DS.$theme->getJsDirName());
155-
}
156-
$cssDir = $themeResourcesPath.$theme->getCssDirName();
157-
if (is_dir($cssDir)) {
158-
mkdir($themePublicPath.DS.$theme->getCssDirName());
159-
copy($cssDir, $themePublicPath.DS.$theme->getCssDirName());
160-
}
161-
$ImagesDir = $themeResourcesPath.$theme->getImagesDirName();
162-
if (is_dir($ImagesDir)) {
163-
mkdir($themePublicPath.DS.$theme->getImagesDirName());
164-
copy($ImagesDir, $themePublicPath.DS.$theme->getImagesDirName());
151+
}
152+
153+
if (is_dir($themeResourcesPath)) {
154+
self::copyDirectory($themeResourcesPath, $themePublicPath);
155+
}
156+
}
157+
158+
private static function copyDirectory($source, $destination) {
159+
$iterator = new \RecursiveIteratorIterator(
160+
new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
161+
\RecursiveIteratorIterator::SELF_FIRST
162+
);
163+
164+
foreach ($iterator as $item) {
165+
$destPath = $destination . DS . $iterator->getSubPathName();
166+
if ($item->isDir()) {
167+
if (!is_dir($destPath)) {
168+
mkdir($destPath, 0777, true);
169+
}
170+
} else {
171+
copy($item, $destPath);
165172
}
166173
}
167-
168-
self::createAssetsRoutes($theme->getDirectoryName(), $theme->getJsDirName());
169-
self::createAssetsRoutes($theme->getDirectoryName(), $theme->getCssDirName());
170-
self::createAssetsRoutes($theme->getDirectoryName(), $theme->getImagesDirName());
171174
}
172175
private static function createAssetsRoutes($themeDirName, $dir) {
173176
Router::closure([

0 commit comments

Comments
 (0)