} !isset($currentUser->coreAccess['themes']) || $currentUser->coreAccess['themes'] == 'change' ? $_change_ = 1 : ($_change_ = 0); $smarty->assign("_change_", $_change_); $themes = themes::getAll("themes"); $allBrowsers = themes::$browsers; $usedBrowsers = array(); foreach ($themes as $value) { $themeNames[] = $value->themes['name']; } $filesystem = new FileSystemTree(G_THEMESPATH, true); foreach (new EfrontDirectoryOnlyFilterIterator(new ArrayIterator($filesystem->tree)) as $key => $value) { //Automatically import themes that don't have an equivalent database representation if (!in_array($value['name'], $themeNames)) { try { $file = new EfrontFile($value['path'] . "/theme.xml"); $xmlValues = themes::parseFile($file); $newTheme = themes::create($xmlValues); //$themes[$newTheme -> themes['id']] = $newTheme -> themes; } catch (Exception $e) { /*Don't halt for themes that can't be processed*/ } } } $themes = themes::getAll("themes"); foreach ($themes as $value) { $themeNames[] = $value->themes['name']; //$browserThemes[$value['id']] = $value['options']['browsers']; foreach ($allBrowsers as $browser => $foo) { if (isset($value->options['browsers'][$browser])) { $usedBrowsers[$browser] = $value->themes['id']; unset($allBrowsers[$browser]);
/** * (non-PHPdoc) * @see libraries/EfrontEntity#handleForm($form) */ public function handleForm($form) { if ($form->exportValue('remote_theme')) { $file = $form->exportValue('remote_theme'); if (!fopen($file, 'r')) { throw new EfrontFileException(_FILEDOESNOTEXIST . ': ' . $file, EfrontFileException::FILE_NOT_EXIST); } } else { try { $filesystem = new FileSystemTree(G_THEMESPATH, true); $themeFile = $filesystem->uploadFile('theme_file', G_THEMESPATH); $filesList = $themeFile->listContents(); if (mb_substr($filesList[0], 0, mb_strpos($filesList[0], "/")) == "default") { throw new Exception(_DEFAULTTHEMECANNOTBEIMPORTED, EfrontThemesException::DEFAULT_IMPORTED); } $themeFile->uncompress(false); //$pathInfo = pathinfo($themeFile['path']); //copy(G_DEFAULTTHEMEPATH.'css/css_global.php', $pathInfo['dirname'].'/'.$pathInfo['filename'].'/css/css_global.php'); $themeFile->delete(); $file = new EfrontFile($themeFile['directory'] . '/' . str_replace('.zip', '', $themeFile['name']) . "/theme.xml"); } catch (EfrontFileException $e) { //Don't halt if no file was uploaded (errcode = 4). Otherwise, throw the exception if ($e->getCode() != 4) { throw $e; } } } if ($file) { $xmlValues = themes::parseFile($file); if ($_GET['add']) { $theme = self::create($xmlValues); } /* else { $this -> options = array_merge($this -> options, $xmlValues); $this -> layout = $this -> persist(); } */ } //$smarty -> assign("T_RELOAD_ALL", 1); }
/** * Setup themes * * This function sets up all the required constants and initiates objects * accordingly, to initialize the current theme * * @since 3.6.0 */ function setupThemes() { /** The default theme path*/ define("G_DEFAULTTHEMEPATH", G_THEMESPATH . "default/"); /** The default theme url*/ define("G_DEFAULTTHEMEURL", "themes/default/"); try { $allThemes = themes::getAll(); if (isset($_GET['preview_theme'])) { try { $currentTheme = new themes($_GET['preview_theme']); } catch (Exception $e) { } } elseif (isset($_SESSION['s_theme'])) { if (!empty($allThemes[$_SESSION['s_theme']])) { $currentTheme = $allThemes[$_SESSION['s_theme']]; } else { $currentTheme = new themes($_SESSION['s_theme']); } } else { if (!empty($allThemes[$GLOBALS['configuration']['theme']])) { $currentTheme = $allThemes[$GLOBALS['configuration']['theme']]; } else { $currentTheme = new themes($GLOBALS['configuration']['theme']); } $browser = detectBrowser(); foreach ($allThemes as $value) { if (isset($value->options['browsers'][$browser])) { try { $browserTheme = $allThemes[$value->themes['id']]; $currentTheme = $browserTheme; } catch (Exception $e) { } } } foreach (eF_loadAllModules(true, true) as $module) { try { if ($moduleTheme = $module->onSetTheme($currentTheme)) { if (!$moduleTheme instanceof themes) { $currentTheme = new themes($moduleTheme); } else { $currentTheme = $moduleTheme; } } } catch (Exception $e) { } } $_SESSION['s_theme'] = $currentTheme->{$currentTheme->entity}['id']; } } catch (Exception $e) { try { $result = eF_getTableData("themes", "*", "name = 'default'"); if (sizeof($result) == 0) { throw new Exception(); //To be caught right below. This way, the catch() code gets executed either if the result is empty or if there is a db error } } catch (Exception $e) { $file = new EfrontFile(G_DEFAULTTHEMEPATH . "theme.xml"); themes::create(themes::parseFile($file)); } $currentTheme = new themes('default'); } $currentThemeName = $currentTheme->{$currentTheme->entity}['name']; /**The current theme*/ define("G_CURRENTTHEME", $currentThemeName); /** The current theme path*/ define("G_CURRENTTHEMEPATH", !isset($currentTheme->remote) || !$currentTheme->remote ? G_THEMESPATH . $currentTheme->{$currentTheme->entity}['path'] : $currentTheme->{$currentTheme->entity}['path']); /** The current theme url*/ define("G_CURRENTTHEMEURL", !isset($currentTheme->remote) || !$currentTheme->remote ? "themes/" . $currentTheme->themes['path'] : $currentTheme->{$currentTheme->entity}['path']); /** The external pages path*/ define("G_EXTERNALPATH", rtrim(G_CURRENTTHEMEPATH, '/') . "/external/"); is_dir(G_EXTERNALPATH) or mkdir(G_EXTERNALPATH, 0755); /** The external pages link*/ define("G_EXTERNALURL", rtrim(G_CURRENTTHEMEURL, '/') . "/external/"); if ($fp = fopen(G_CURRENTTHEMEPATH . "css/css_global.css", 'r')) { /** The current theme's css*/ define("G_CURRENTTHEMECSS", G_CURRENTTHEMEURL . "css/css_global.css?build=" . G_BUILD); fclose($fp); } else { /** The current theme's css*/ define("G_CURRENTTHEMECSS", G_DEFAULTTHEMEURL . "css/css_global.css?build=" . G_BUILD); } /** The folder where the template compiled and cached files are kept*/ define("G_THEMECACHE", G_ROOTPATH . "libraries/smarty/themes_cache/"); /** The folder of the current theme's compiled files*/ define("G_CURRENTTHEMECACHE", G_THEMECACHE . $currentThemeName . "/"); /** The full filesystem path of the images directory*/ define("G_IMAGESPATH", G_CURRENTTHEMEPATH . "images/"); /** The full filesystem path of the images directory, in the default theme*/ define("G_DEFAULTIMAGESPATH", G_DEFAULTTHEMEPATH . "images/"); /** The users' avatars directory*/ define("G_AVATARSPATH", G_IMAGESPATH . "avatars/"); if (is_dir(G_AVATARSPATH . "system_avatars/")) { /*system avatars path*/ define("G_SYSTEMAVATARSPATH", G_AVATARSPATH . "system_avatars/"); /*system avatars URL*/ define("G_SYSTEMAVATARSURL", G_CURRENTTHEMEURL . "images/avatars/system_avatars/"); } else { /*system avatars path*/ define("G_SYSTEMAVATARSPATH", G_DEFAULTTHEMEPATH . "images/avatars/system_avatars/"); /*system avatars URL*/ define("G_SYSTEMAVATARSURL", G_DEFAULTTHEMEURL . "images/avatars/system_avatars/"); } /** The logo path*/ define("G_LOGOPATH", G_DEFAULTIMAGESPATH . "logo/"); return $currentTheme; }