/** * load the application template based on the application, cmd and theme name * * @return array */ public function loadApplicationTemplate() { $application = isset($_GET['app']) ? contrexx_input2raw($_GET['app']) : ''; $section = preg_match('#^Media\\d+# i', $application) ? 'Media' : $application; $cmd = isset($_GET['area']) && $_GET['area'] != '' ? contrexx_input2raw($_GET['area']) : 'default'; $template = isset($_GET['template']) ? contrexx_input2raw($_GET['template']) : ''; $result = array('files' => array(), 'area' => '', 'path' => ''); $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository(); if (!empty($section)) { if ($template > 0) { $theme = $themeRepo->findOneBy(array('id' => $template)); } else { $theme = $themeRepo->getDefaultTheme(); } $themeFolderName = $theme->getFoldername(); $moduleFolderName = contrexx_isCoreModule($application) ? 'core_modules' : 'modules'; $themePath = ASCMS_THEMES_PATH . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $section . '/Template/Frontend'; if (file_exists($themePath)) { $templateFiles = $this->readDirs($themePath); foreach ($templateFiles as $templateFile) { if (preg_match('#^' . ucfirst($cmd) . '_custom_# i', $templateFile) && preg_match('#\\.html# i', $templateFile)) { $result['files'][] = $templateFile; } } } $result['area'] = ucfirst($cmd); $result['path'] = '/themes/' . $themeFolderName . '/' . $moduleFolderName . '/' . $section . '/Template/Frontend'; $additionalArguments = new \Cx\Core\Model\RecursiveArrayAccess(array()); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $evm = $cx->getEvents(); $evm->triggerEvent('wysiwygCssReload', array(array('skin' => $template), $additionalArguments)); $result['wysiwygCssReload'] = $additionalArguments->toArray(); } return $result; }