Пример #1
0
 public static function get_template_list($includeTemplate = 0)
 {
     $templates = array();
     $theme = self::find(config('coaster::frontend.theme'));
     if (!empty($theme)) {
         foreach ($theme->templates()->where('hidden', '=', 0)->get() as $template) {
             $templates[$template->id] = !empty($template->label) ? $template->label : $template->template;
             $templateFile[$template->template] = $template->id;
         }
     }
     // fix template issues on theme switching
     if (!empty($includeTemplate) && empty($templates[$includeTemplate])) {
         $includeTemplateModel = Template::find($includeTemplate);
         if (empty($includeTemplateModel)) {
             $templates[$includeTemplate] = 'Non existent template';
         } else {
             $altTheme = Theme::find($includeTemplateModel->theme_id);
             $altThemeName = $altTheme ? $altTheme->theme : 'Non Existent';
             if (!empty($templateFile[$includeTemplateModel->template])) {
                 $templates[$includeTemplate] = $templates[$templateFile[$includeTemplateModel->template]] . ' (warning - from \'' . $altThemeName . '\' theme, frontend will use template from \'' . $theme->theme . '\' theme)';
             } else {
                 $templates[$includeTemplate] = (!empty($includeTemplateModel->label) ? $includeTemplateModel->label : $includeTemplateModel->template) . ' (error - from \'' . $altThemeName . '\' theme, choose other template from current theme)';
             }
         }
     }
     asort($templates);
     return $templates;
 }
 public function getIndex()
 {
     // load theme global blocks
     $blocks = array();
     $theme = Theme::find(config('coaster::frontend.theme'));
     if (!empty($theme)) {
         $blocks = Theme::theme_blocks($theme->id);
     }
     // load tab contents from categories & blocks (with default block contents)
     $default_blocks = PageBlockDefault::preloadArray();
     list($tab_headers, $tab_contents) = Block::getTabs($blocks, $default_blocks);
     $tab_headers = array_filter($tab_headers);
     ksort($tab_headers);
     $tab_data = ['headers' => View::make('coaster::partials.tabs.header', ['tabs' => $tab_headers])->render(), 'contents' => View::make('coaster::partials.tabs.content', ['tabs' => $tab_contents, 'item' => 'Site-wide Content', 'new_page' => false, 'publishing' => false, 'can_publish' => true])->render()];
     $this->layoutData['title'] = 'Site-wide Content';
     $this->layoutData['content'] = View::make('coaster::pages.blocks', ['tab' => $tab_data]);
 }
Пример #3
0
 /**
  * Display form settings
  * Template selector should only should if custom template selected (otherwise deprecated)
  * @param string $postContent
  * @return string
  */
 public function edit($postContent)
 {
     $formData = $this->_defaultData($postContent);
     $formData->template = $formData->template == $this->_block->name ? 0 : $formData->template;
     $this->_editViewData['pageList'] = Page::get_page_list();
     $this->_editViewData['formTemplates'] = [0 => '-- Use view from template --'];
     $theme = Theme::find(config('coaster::frontend.theme'));
     if (!empty($theme)) {
         $forms = base_path('/resources/views/themes/' . $theme->theme . '/blocks/forms');
         if (is_dir($forms)) {
             foreach (scandir($forms) as $form) {
                 if (!is_dir($forms . DIRECTORY_SEPARATOR . $form)) {
                     $form_file = explode('.', $form);
                     if (!empty($form_file[0])) {
                         $this->_editViewData['formTemplates'][$form_file[0]] = $form_file[0] . (strpos(file_get_contents($forms . DIRECTORY_SEPARATOR . $form), 'captcha') ? ' (supports captcha)' : ' (does not support captcha)');
                     }
                 }
             }
         }
     }
     return parent::edit($formData);
 }
 public function getEdit($themeId)
 {
     AssetBuilder::add('cms-main', ['/ace/ace.js']);
     $theme = Theme::find($themeId);
     $tvbp = base_path('resources/views/themes/' . $theme->theme);
     $tcssbp = base_path('public/themes/' . $theme->theme . '/css');
     $ret = Theme::getViewFolderTree($tvbp);
     $filetree = View::make('coaster::partials.themes.filetree', ['directory' => $ret, 'theme' => $theme]);
     $css_filetree_data = Theme::getViewFolderTree($tcssbp);
     $css_filetree = View::make('coaster::partials.themes.filetree', ['directory' => $css_filetree_data, 'theme' => $theme]);
     $this->layoutData['content'] = View::make('coaster::pages.themes.edit', ['theme' => $theme, 'filetree' => $filetree, 'css_filetree' => $css_filetree]);
 }
Пример #5
0
 /**
  * Load theme name, template name and content type to return
  */
 public function _loadPageTemplate()
 {
     $theme = Theme::find(config('coaster::frontend.theme'));
     $lowestLevelPage = count($this->pageLevels) > 0 ? end($this->pageLevels) : null;
     $this->theme = !empty($theme) && is_dir(base_path('/resources/views/themes/' . $theme->theme)) ? $theme->theme : 'default';
     $this->template = $lowestLevelPage ? Template::name($this->previewVersion ? $this->previewVersion->template : $lowestLevelPage->template) : '';
     $this->contentType = $this->feedExtension ? Feed::getMimeType($this->feedExtension) : 'text/html; charset=UTF-8';
 }