/** * Get all found template paths * * @param string $template Template name * @param string $format Format (xhtml or html5) * @return array All template paths for the specified template */ public static function getTemplates($template, $format = 'html5') { $templates = array(); try { $theme = \ThemeModel::findAll(array('order' => 'name')); } catch (\Exception $e) { $theme = null; } while ($theme && $theme->next()) { if ($theme->templates != '') { if (file_exists(TL_ROOT . '/' . $theme->templates . '/' . $template . '.' . $format)) { $templates[] = TL_ROOT . '/' . $theme->templates . '/' . $template . '.' . $format; } } } if (file_exists(TL_ROOT . '/templates/' . $template . '.' . $format)) { $templates[] = TL_ROOT . '/templates/' . $template . '.' . $format; } // Add templates of inactive themes to the bottom of the templates array $allFiles = glob(TL_ROOT . '/templates/*/' . $template . '.' . $format) ?: array(); foreach ($allFiles as $file) { if (!in_array($file, $templates)) { $templates[] = $file; } } if (count($templates)) { return $templates; } return array(parent::getTemplate($template, $format)); }
public function getModules($mcw) { // Get all modules from DB $modules = array($GLOBALS['TL_LANG']['merger2']['legend_article'] => array('article' => $GLOBALS['TL_LANG']['merger2']['article'], 'inherit_articles' => $GLOBALS['TL_LANG']['merger2']['inherit_articles'], 'inherit_all_articles' => $GLOBALS['TL_LANG']['merger2']['inherit_all_articles'], 'inherit_articles_fallback' => $GLOBALS['TL_LANG']['merger2']['inherit_articles_fallback'], 'inherit_all_articles_fallback' => $GLOBALS['TL_LANG']['merger2']['inherit_all_articles_fallback'])); $themeCollection = \ThemeModel::findAll(array('order' => 'name')); while ($themeCollection->next()) { $modules[$themeCollection->name] = array(); $moduleCollection = \ModuleModel::findBy('pid', $themeCollection->id, array('order' => 'name')); if ($moduleCollection) { while ($moduleCollection->next()) { $modules[$themeCollection->name][$moduleCollection->id] = $moduleCollection->name; } } } return $modules; }
/** * prepare */ public function prepare() { // load backenduser $this->import('BackendUser', 'User'); // check permission if ($this->User->isAdmin || $this->User->hasAccess('themes', 'modules')) { // check if table exists if (!$this->Database->tableExists('tl_theme')) { return; } // get all existing themes $objThemes = \ThemeModel::findAll(array('order' => 'name')); // if there is at minimum one theme if (!is_null($objThemes) && $objThemes->count()) { // prepare array return $arrDirectEntry = array(); // set counter $intCounter = 1; // set icons array $arrIcons = array('css' => 'tl_style_sheet', 'modules' => 'tl_module', 'layout' => 'tl_layout'); // do this foreach theme while ($objThemes->next()) { // set the theme url and title $arrDirectEntry[$intCounter]['name']['url'] = 'contao/main.php?do=themes&act=edit&id=' . $objThemes->id; $arrDirectEntry[$intCounter]['name']['title'] = $objThemes->name; $arrDirectEntry[$intCounter]['name']['link'] = strlen($objThemes->name) > 10 ? substr($objThemes->name, 0, 8) . '...' : $objThemes->name; // foreach icons foreach ($arrIcons as $strIcon => $strTableName) { // check detail permissions if ($this->User->isAdmin || $this->User->hasAccess($strIcon, 'themes')) { // set the icon url and title $arrDirectEntry[$intCounter]['icons'][$strIcon]['url'] = 'contao/main.php?do=themes&id=' . $objThemes->id . '&table=' . $strTableName; $arrDirectEntry[$intCounter]['icons'][$strIcon]['title'] = $strIcon; $arrDirectEntry[$intCounter]['icons'][$strIcon]['icon'] = $strIcon; } } // add one to counter $intCounter++; } // add to direcentries service $this->import('DirectEntries'); $this->DirectEntries->addDirectEntry('design', 'themes', $arrDirectEntry); } } }
protected function buildOptions(\Model\Collection $collection) { while ($collection->next()) { $theme = \ThemeModel::findByPk($collection->pid); switch ($collection->type) { case 'code': $label = $collection->code_snippet_title; break; case 'url': $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->url); break; case 'file': if ($collection->filesource == $GLOBALS['TL_CONFIG']['uploadPath'] && version_compare(VERSION, '3', '>=')) { $file = version_compare(VERSION, '3.2', '>=') ? \FilesModel::findByUuid($collection->file) : \FilesModel::findByPk($collection->file); if ($file) { $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $file->path); break; } } else { $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $collection->file); break; } // no break // no break default: $label = '?'; } if (strlen($collection->cc)) { $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">[' . $collection->cc . ']</span>'; } $filterRules = File::renderFilterRules($collection->row()); if ($filterRules) { $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">' . $filterRules . '</span>'; } $image = 'assets/theme-plus/images/' . $collection->type . '.png'; $options[$theme->name][$collection->id] = ($image ? $this->generateImage($image, $label, 'style="vertical-align:-3px"') . ' ' : '') . $label; } return $options; }
/** * Return all template files of a particular group as array * * @param string $strPrefix The template name prefix (e.g. "ce_") * @param integer $intTheme The ID of the theme * * @return array An array of template names */ public static function getTemplateGroup($strPrefix, $intTheme = 0) { $strTplFolder = 'templates'; $arrTemplates = \TemplateLoader::getPrefixedFiles($strPrefix); // Check for a theme templates folder if ($intTheme > 0) { $objTheme = \ThemeModel::findByPk($intTheme); if ($objTheme !== null && $objTheme->templates != '') { $strTplFolder = $objTheme->templates; } } // Scan the templates directory $arrFiles = array_values(preg_grep('/^' . $strPrefix . '/', scan(TL_ROOT . '/' . $strTplFolder))); if (!empty($arrFiles)) { foreach ($arrFiles as $strFile) { $arrTemplates[] = basename($strFile, strrchr($strFile, '.')); } } natcasesort($arrTemplates); $arrTemplates = array_values(array_unique($arrTemplates)); return $arrTemplates; }
public static function getTemplateGroup($strPrefix, $intThemeId = null) { $arrTemplates = array(); // Get the default templates foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) { $arrTemplates[$strTemplate] = $strTemplate; } $arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*'); // Add the customized templates if (is_array($arrCustomized)) { foreach ($arrCustomized as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[$strTemplate])) { $arrTemplates[$strTemplate] = $strTemplate; } } } // Do not look for back end templates in theme folders (see #5379) if ($strPrefix == 'be_' || $strPrefix == 'mail_') { return $arrTemplates; } $arrDefault = $arrTemplates; $arrTemplates = array('safeTpl' => $arrDefault, 'unsafeTpl' => array()); // Try to select the themes (see #5210) try { $objTheme = \ThemeModel::findAll(array('order' => 'name')); } catch (\Exception $e) { $objTheme = null; } // Add the theme templates if ($objTheme === null) { return $arrTemplates; } while ($objTheme->next()) { $strGroup = $objTheme->id == $intThemeId ? 'safeTpl' : 'unsafeTpl'; if ($objTheme->templates == '') { continue; } $arrThemeTemplates = glob(TL_ROOT . '/' . $objTheme->templates . '/' . $strPrefix . '*'); if (!is_array($arrThemeTemplates)) { continue; } foreach ($arrThemeTemplates as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[$strGroup][$strTemplate])) { $arrTemplates[$strGroup][$strTemplate] = $strTemplate . ' (' . sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name) . ')'; } else { $arrTemplates[$strGroup][$strTemplate] .= ' (' . sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name) . ')'; } } } return $arrTemplates; }
/** * Return all template files of a particular group as array * * @param string $strPrefix The template name prefix (e.g. "ce_") * * @return array An array of template names */ public static function getTemplateGroup($strPrefix) { $arrTemplates = array(); // Get the default templates foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) { $arrTemplates[$strTemplate][] = 'root'; } $arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*'); // Add the customized templates if (is_array($arrCustomized)) { foreach ($arrCustomized as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); $arrTemplates[$strTemplate][] = $GLOBALS['TL_LANG']['MSC']['global']; } } // Do not look for back end templates in theme folders (see #5379) if ($strPrefix != 'be_' && $strPrefix != 'mail_') { // Try to select the themes (see #5210) try { $objTheme = \ThemeModel::findAll(array('order' => 'name')); } catch (\Exception $e) { $objTheme = null; } // Add the theme templates if ($objTheme !== null) { while ($objTheme->next()) { if ($objTheme->templates != '') { $arrThemeTemplates = glob(TL_ROOT . '/' . $objTheme->templates . '/' . $strPrefix . '*'); if (is_array($arrThemeTemplates)) { foreach ($arrThemeTemplates as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[$strTemplate])) { $arrTemplates[$strTemplate][] = $objTheme->name; } else { $arrTemplates[$strTemplate][] = $objTheme->name; } } } } } } } // Show the template sources (see #6875) foreach ($arrTemplates as $k => $v) { $v = array_filter($v, function ($a) { return $a != 'root'; }); if (empty($v)) { $arrTemplates[$k] = $k; } else { $arrTemplates[$k] = $k . ' (' . implode(', ', $v) . ')'; } } // Sort the template names ksort($arrTemplates); return $arrTemplates; }
private function getTemplatePathes(ContaoTwigConfig $config) { $arrTemplatePaths = array(); // Add the layout templates directory if ($config->isEnableThemeTemplatesLoader() && TL_MODE == 'FE') { global $objPage; $strTemplateGroup = str_replace(array('../', 'templates/'), '', $objPage->templateGroup); if ($strTemplateGroup != '') { $arrTemplatePaths[] = TL_ROOT . '/templates/' . $strTemplateGroup; } } else { if (TL_MODE == 'BE') { $themeCollection = \ThemeModel::findAll(); if ($themeCollection) { while ($themeCollection->next()) { if ($themeCollection->templates) { $arrTemplatePaths[] = TL_ROOT . '/' . $themeCollection->templates; } } } } } // Add the global templates directory if ($config->isEnableGlobalTemplatesLoader()) { $arrTemplatePaths[] = TL_ROOT . '/templates'; } $this->addModuleTemplatePathes($config, $arrTemplatePaths); return $arrTemplatePaths; }
/** * List an file * * @param array * * @return string */ public function listFileFor($row, $layoutField = false) { switch ($row['type']) { case 'code': $label = $row['code_snippet_title']; break; case 'url': $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $row['url']); break; case 'file': if ($row['filesource'] == $GLOBALS['TL_CONFIG']['uploadPath'] && version_compare(VERSION, '3', '>=')) { $file = version_compare(VERSION, '3.2', '>=') ? \FilesModel::findByUuid($row['file']) : \FilesModel::findByPk($row['file']); if ($file) { $label = preg_replace('#/([^/]+)$#', '/<strong>$1</strong>', $file->path); break; } } else { $label = preg_replace('#([^/]+)$#', '<strong>$1</strong>', $row['file']); break; } default: $label = '?'; } if ($row['inline']) { \Controller::loadLanguageFile('tl_theme_plus_file'); $label = sprintf('<span title="%s">‹›</span> %s', htmlentities($GLOBALS['TL_LANG']['tl_theme_plus_file']['inline'], ENT_QUOTES, 'UTF-8'), $label); } else { if ($row['standalone']) { \Controller::loadLanguageFile('tl_theme_plus_file'); $label = sprintf('<span title="%s">×</span> %s', htmlentities($GLOBALS['TL_LANG']['tl_theme_plus_file']['standalone'], ENT_QUOTES, 'UTF-8'), $label); } } if (strlen($row['position'])) { $label = '[' . strtoupper($row['position']) . '] ' . $label; } if (strlen($row['cc'])) { $label .= ' <span style="padding-left: 3px; color: #B3B3B3;">[' . $row['cc'] . ']</span>'; } $filterRules = static::renderFilterRules($row); if ($filterRules) { $label .= sprintf('<br><span style="margin-left: 20px; padding-left: 3px; color: #B3B3B3;">[%s]</span>', $filterRules); } if ($layoutField) { $assignedLayouts = []; $themes = \ThemeModel::findAll(['order' => 'name']); foreach ($themes as $theme) { $assignedThemeLayouts = []; $layouts = \LayoutModel::findBy('pid', $theme->id, ['order' => 'name']); foreach ($layouts as $layout) { $files = deserialize($layout->{$layoutField}, true); if (in_array($row['id'], $files)) { $assignedThemeLayouts[$layout->id] = $layout->name; } } if (count($assignedThemeLayouts)) { $assignedLayouts[$theme->name] = $assignedThemeLayouts; } } if (count($assignedLayouts)) { $label .= '<ul style="margin-left: 20px; padding-left: 3px; color: #B3B3B3;">'; foreach ($assignedLayouts as $theme => $layouts) { $label .= '<li>'; $label .= sprintf('<strong>%s</strong>', $theme); $label .= '<ul>'; foreach ($layouts as $id => $layout) { $label .= sprintf('<li> ↳ <a href="%s">%s</a></li>', \Backend::addToUrl('table=tl_layout&act=edit&id=' . $id), $layout); } $label .= '</ul>'; $label .= '</li>'; } $label .= '</ul>'; } } $image = 'assets/theme-plus/images/' . $row['type'] . '.png'; return '<div>' . ($image ? $this->generateImage($image, $label, 'style="vertical-align:-3px"') . ' ' : '') . $label . "</div>\n"; }
public function generateCSS(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular) { $db = \Database::getInstance(); $lessFolder = 'assets/css'; $options = array('compress' => true, 'cache_dir' => TL_ROOT . '/' . $lessFolder); $objFiles = unserialize($objLayout->external_css); if (!$objFiles || !is_array($objFiles)) { return; } $objFiles = $db->query("SELECT * FROM tl_external_css WHERE id IN(" . implode(',', $objFiles) . ") ORDER BY sorting")->fetchAllAssoc(); $arrFiles = array(); if ($objFiles) { foreach ($objFiles as $file) { if ($file['type'] == 'url' && $file['url']) { $GLOBALS['TL_HEAD'][] = \Template::generateStyleTag($file['url'], '', false); } if ($file['type'] == 'file') { $obj = \FilesModel::findByUuid($file['file']); if ($obj) { $arrFiles[] = $obj->path; } else { if (is_file($file['file'])) { $arrFiles[] = $file['file']; } } } } } if (isset($GLOBALS['TL_HOOKS']['addExternalCssFiles']) && is_array($GLOBALS['TL_HOOKS']['addExternalCssFiles'])) { foreach ($GLOBALS['TL_HOOKS']['addExternalCssFiles'] as $callback) { $this->import($callback[0]); $arrFiles = $this->{$callback}[0]->{$callback}[1]($arrFiles); } } if ($arrFiles) { $tmpFiles = array(); foreach ($arrFiles as $file) { if (is_readable($file)) { $tmpFiles[TL_ROOT . '/' . $file] = '/' . dirname($file); } } } else { return; } $variables = array(); $arrVars = array(); $objTheme = \ThemeModel::findByPk($objLayout->pid); if ($objTheme->vars) { $arrVars = deserialize($objTheme->vars); foreach ($arrVars as $var) { $k = preg_replace('/\\$/', '@', $var['key'], 1); if ($k[0] != '@') { $k = '@' . $k; } $variables[$k] = $var['value']; } } if (isset($GLOBALS['TL_HOOKS']['addExternalCssVariables']) && is_array($GLOBALS['TL_HOOKS']['addExternalCssVariables'])) { foreach ($GLOBALS['TL_HOOKS']['addExternalCssVariables'] as $callback) { $this->import($callback[0]); $variables = $this->{$callback}[0]->{$callback}[1]($variables); } } $arrFiles = $tmpFiles; if ($_COOKIE['BE_USER_AUTH']) { $DB = \Database::getInstance(); $Session = $DB->prepare('SELECT pid FROM tl_session WHERE name="BE_USER_AUTH" AND hash=?')->limit(1)->execute($_COOKIE['BE_USER_AUTH']); $User = \Database::getInstance()->prepare('SELECT external_css_livereload FROM tl_user WHERE id=?')->execute($Session->pid)->fetchAssoc(); if ($User['external_css_livereload']) { $arrParsed = array(); $strFiles = ''; $strAjaxFiles = array(); foreach ($arrFiles as $file => $path) { $reloadFile = false; $parser = new \Less_Parser(); $parser->parseFile($file, $path); $css = $parser->getCss(); $filename = str_replace('.less', '.css', basename($file)); $path = $lessFolder . '/' . $filename; $oldCss = ''; if (is_file($path)) { $oldCss = file_get_contents($path); if ($oldCss != $css) { file_put_contents($path, $css); $reloadFile = true; } } else { file_put_contents($path, $css); } $filetime = filemtime($path); $fileClass = 'external_css_' . standardize($filename); $fileSRC = '<link class="' . $fileClass . '" rel="stylesheet" href="' . $path . '?v=' . $filetime . '" />'; $strFiles .= $fileSRC; if ($reloadFile) { $strAjaxFiles[] = array('class' => $fileClass, 'src' => $fileSRC, 'path' => $path . '?v=' . $filetime); } } if (\Input::get('action') == 'getLiveCSS') { echo json_encode(array('files' => $strAjaxFiles)); die; } $GLOBALS['TL_HEAD'][] = $strFiles; $GLOBALS['TL_JQUERY'][] = '<script src="system/modules/external_css/assets/j/livereload.js"></script>'; return; } } $file = \Less_Cache::Get($arrFiles, $options, $variables); if (!$file) { return; } $filePath = $lessFolder . '/' . $file; $imgs = array(); $strCss = file_get_contents($filePath); $re = '/url\\(\\s*[\'"]?(\\S*\\.(?:jpe?g|gif|png))[\'"]?\\s*\\)[^;}]*?/i'; if (preg_match_all($re, $strCss, $matches)) { $imgs = $matches[1]; } $embedFile = str_replace('.css', '_embed.css', $filePath); if (!is_file($embedFile)) { $arrParsed = array(); $strCss = file_get_contents($filePath); foreach ($imgs as $img) { $imgPath = TL_ROOT . $img; if (in_array($img, $arrParsed)) { continue; } if (is_file($imgPath)) { $size = filesize($imgPath); $mb = $size / 1048576; if ($mb < 0.2) { $ext = pathinfo($imgPath, PATHINFO_EXTENSION); $b64 = file_get_contents($imgPath); $b64 = base64_encode($b64); $base64 = 'data:image/' . $ext . ';base64,' . $b64; $strCss = str_replace($img, $base64, $strCss); $arrParsed[] = $img; } } } file_put_contents($embedFile, $strCss); } $filePath = $embedFile; $GLOBALS['TL_HEAD'][] = \Template::generateStyleTag(\Controller::addStaticUrlTo($filePath), '', false); }
/** * Generate the html for the toolbar */ protected function generateToolbar($strContent) { // get themes $objThemes = \ThemeModel::findAll(array('order' => 'name')); // vertical or horizontal $id = $this->User->om_toolbar == 1 ? 'toolbar' : 'toolbarHorizontal'; $class = version_compare(VERSION . '.' . BUILD, '3.3.0', '<') ? '' : 'contao33'; // open container $strToolbar = '<div id="' . $id . '" class="' . $class . '"><h1>Tools</h1>'; // add button - id search //$strToolbar .= '<a class="button" href="contao/main.php?do=id_search" title="'.$GLOBALS['TL_LANG']['om_backend']['id_search'].'"><img class="pngfix" src="system/modules/om_backend/html/find.png" width="16" height="16" alt="'.$GLOBALS['TL_LANG']['om_backend']['id_search'].'" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\'ID-Suche\',\'url\':this.href});return false"></a>'; $strToolbar .= '<a class="button" href="contao/main.php?do=id_search" title="' . $GLOBALS['TL_LANG']['om_backend']['id_search'] . '"><img class="pngfix" src="system/modules/om_backend/html/find.png" width="16" height="16" alt="' . $GLOBALS['TL_LANG']['om_backend']['id_search'] . '"></a>'; // add button - update database $strToolbar .= '<a class="button" href="contao/main.php?do=repository_manager&update=database" title="' . $GLOBALS['TL_LANG']['om_backend']['update_database'] . '"><img class="pngfix" src="system/modules/repository/themes/default/images/dbcheck16.png" width="16" height="16" alt="' . $GLOBALS['TL_LANG']['om_backend']['update_database'] . '"></a>'; // add button - new template $strToolbar .= '<a class="button" href="contao/main.php?do=tpl_editor&key=new_tpl&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . $GLOBALS['TL_LANG']['om_backend']['new_template'] . '"><img class="pngfix" src="system/modules/om_backend/assets/icons/page_add.png" width="16" height="16" alt="' . $GLOBALS['TL_LANG']['om_backend']['new_template'] . '"></a>'; // add button - sync $strToolbar .= '<a class="button" href="contao/main.php?do=files&act=sync&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . $GLOBALS['TL_LANG']['om_backend']['sync_files'] . '"><img class="pngfix" src="system/themes/default/images/sync.gif" width="16" height="16" alt="' . $GLOBALS['TL_LANG']['om_backend']['sync_files'] . '"></a>'; // exist a theme? if (is_object($objThemes) && $objThemes->count() > 0) { // add css, modules and layouts while ($objThemes->next()) { // add separator $strToolbar .= '<div class="separator"></div>'; // add buttons $strToolbar .= '<a class="button" href="contao/main.php?do=themes&table=tl_style_sheet&id=' . $objThemes->id . '&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . sprintf($GLOBALS['TL_LANG']['om_backend']['stylesheets'], $objThemes->name) . '"><img src="system/themes/default/images/css.gif" width="17" height="16" alt="Stylesheets"></a>'; $strToolbar .= '<a class="button" href="contao/main.php?do=themes&table=tl_module&id=' . $objThemes->id . '&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . sprintf($GLOBALS['TL_LANG']['om_backend']['modules'], $objThemes->name) . '"><img src="system/themes/default/images/modules.gif" width="16" height="16" alt="Module"></a>'; $strToolbar .= '<a class="button" href="contao/main.php?do=themes&table=tl_layout&id=' . $objThemes->id . '&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . sprintf($GLOBALS['TL_LANG']['om_backend']['layouts'], $objThemes->name) . '"><img src="system/themes/default/images/layout.gif" width="14" height="16" alt="Seitenlayouts"></a>'; if (version_compare(VERSION . '.' . BUILD, '3.4.0', '>=')) { $strToolbar .= '<a class="button" href="contao/main.php?do=themes&table=tl_image_size&id=' . $objThemes->id . '&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . sprintf($GLOBALS['TL_LANG']['om_backend']['image_size'], $objThemes->name) . '"><img src="system/themes/default/images/sizes.gif" width="14" height="16" alt="Bildgrößen"></a>'; } } } // generate save buttons if (strpos($strContent, 'class="tl_submit_container"') !== false && strpos($strContent, 'name="save"') !== FALSE) { // button save if (strpos($strContent, 'name="save"') !== FALSE) { $arrButtons[] = 'save'; } // button save and close if (strpos($strContent, 'name="saveNclose"') !== FALSE) { $arrButtons[] = 'saveNclose'; } // button save and create if (strpos($strContent, 'name="saveNcreate"') !== FALSE) { $arrButtons[] = 'saveNcreate'; } // button save and back if (strpos($strContent, 'name="saveNback"') !== FALSE) { $arrButtons[] = 'saveNback'; } // add alls buttons and separator if (is_array($arrButtons)) { // add separator $strToolbar .= '<div class="separator"></div>'; // add buttons foreach ($arrButtons as $button) { $strToolbar .= '<a class="button" onclick="document.getElementById(\'' . $button . '\').click(); return false;" title="' . $GLOBALS['TL_LANG']['MSC'][$button] . '"><img src="system/modules/om_backend/assets/icons/' . $button . '.png" width="14" height="16" alt="' . $GLOBALS['TL_LANG']['MSC'][$button] . '"></a>'; } } } // edit multiple ? if (strpos($strContent, 'class="header_edit_all"') !== false) { // get parameter $id = strlen(\Input::get('id')) ? '&id' . \Input::get('id') : ''; $table = strlen(\Input::get('table')) ? '&table=' . \Input::get('table') : ''; // add separator and button $strToolbar .= '<div class="separator"></div>'; $strToolbar .= '<a class="button" href="contao/main.php?do=' . \Input::get('do') . $table . $id . '&act=select&rt=' . $_SESSION['REQUEST_TOKEN'] . '" title="' . sprintf($GLOBALS['TL_LANG']['om_backend']['stylesheets'], $objThemes->name) . '"><img src="system/themes/default/images/all.gif" width="17" height="16" alt="Stylesheets"></a>'; } // edit multiple buttons if (strpos($strContent, 'class="tl_submit_container"') !== false && strpos($strContent, 'name="edit"') !== FALSE) { // html button names $arrButtonNames = array('delete', 'cut', 'copy', 'override', 'edit', 'alias'); // check for buttons foreach ($arrButtonNames as $buttonName) { // button save if (strpos($strContent, 'name="' . $buttonName . '"') !== FALSE) { $arrButtons[] = $buttonName; } } // add alls buttons and separator if (is_array($arrButtons)) { // add separator $strToolbar .= '<div class="separator"></div>'; // add buttons foreach ($arrButtons as $button) { $strToolbar .= '<a class="button" onclick="document.getElementById(\'' . $button . '\').click(); return false;" title="' . $GLOBALS['TL_LANG']['om_backend']['button_' . $button] . '"><img src="system/modules/om_backend/assets/icons/folder_' . $button . '.png" width="14" height="16" alt="' . $GLOBALS['TL_LANG']['om_backend']['button_' . $button] . '"></a>'; } } } // close container $strToolbar .= '</div>'; return $strToolbar; }
/** * List template from all themes, show theme name * @param string * @param int * @return array */ public static function getTemplates($strPrefix) { $arrTemplates = array(); // Get the default templates foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) { $arrTemplates[$strTemplate] = $strTemplate; } $arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*'); // Add the customized templates if (is_array($arrCustomized)) { foreach ($arrCustomized as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[$strTemplate])) { $arrTemplates[''][$strTemplate] = $strTemplate; } } } // Do not look for back end templates in theme folders (see #5379) if ($strPrefix == 'be_') { return $arrTemplates; } // Try to select the shop configs try { $objConfig = Config::findAll(array('order' => 'name')); } catch (\Exception $e) { $objConfig = null; } // Add the shop config templates if (null !== $objConfig) { while ($objConfig->next()) { if ($objConfig->templateGroup != '') { $strFolder = sprintf($GLOBALS['TL_LANG']['MSC']['templatesConfig'], $objConfig->name); $arrConfigTemplates = glob(TL_ROOT . '/' . $objConfig->templateGroup . '/' . $strPrefix . '*'); if (is_array($arrConfigTemplates)) { foreach ($arrConfigTemplates as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[''][$strTemplate])) { $arrTemplates[$strFolder][$strTemplate] = $strTemplate; } } } } } } // Try to select the themes (see #5210) try { $objTheme = \ThemeModel::findAll(array('order' => 'name')); } catch (\Exception $e) { $objTheme = null; } // Add the theme templates if (null !== $objTheme) { while ($objTheme->next()) { if ($objTheme->templates != '') { $strFolder = sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name); $arrThemeTemplates = glob(TL_ROOT . '/' . $objTheme->templates . '/' . $strPrefix . '*'); if (is_array($arrThemeTemplates)) { foreach ($arrThemeTemplates as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[''][$strTemplate])) { $arrTemplates[$strFolder][$strTemplate] = $strTemplate; } } } } } } return $arrTemplates; }