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 getEdit($groupId) { $group = PageGroup::preload($groupId); if ($group->exists) { $templateSelectOptions = [0 => '-- No default --'] + Theme::get_template_list($group->default_template); $blockList = Block::idToLabelArray(); $this->layoutData['content'] = View::make('coaster::pages.groups.edit', ['group' => $group, 'defaultTemplate' => $group->default_template, 'templateSelectOptions' => $templateSelectOptions, 'blockList' => $blockList]); } }
/** * @param $blockId * @param $pageId * @return static|null */ public static function getBlockOnPage($blockId, $pageId) { if ($page = Page::find($pageId)) { $blocksByCat = Template::template_blocks(config('coaster::frontend.theme'), $page->template); } else { $blocksByCat = Theme::theme_blocks(config('coaster::frontend.theme')); } foreach ($blocksByCat as $blocks) { foreach ($blocks as $block) { if ($block->id == $blockId) { return static::find($blockId); } } } return null; }
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]); }
public static function template_blocks($theme, $template) { $blocks = Theme::theme_blocks($theme, $template); $selected_template = self::find($template); if (!empty($selected_template)) { $template_blocks = $selected_template->blocks()->get(); foreach ($template_blocks as $template_block) { if (!isset($blocks[$template_block->category_id])) { $blocks[$template_block->category_id] = array(); } $blocks[$template_block->category_id][$template_block->id] = $template_block; } } // order theme/template blocks properly foreach ($blocks as $cat_id => $block_cat) { uasort($blocks[$cat_id], array('self', 'order_blocks')); } return $blocks; }
/** * 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 getIndex() { $database_structure = $this->_db_messages(); $search_data = PageSearchData::orderBy('updated_at', 'asc')->first(); if (!empty($search_data)) { $last_indexed_search = DateTimeHelper::display($search_data->updated_at); } else { $last_indexed_search = false; } $update = Auth::action('system.update'); if ($update) { $settings = Setting::where('hidden', '=', '0')->orWhere('editable', '=', 1)->get(); } else { $settings = Setting::where('hidden', '=', '0')->get(); } foreach ($settings as $k => $setting) { if (!$update) { $settings[$k]->editable = 0; } $note = ''; switch ($setting->name) { case 'frontend.language': $custom = new \stdClass(); $custom->selected = $setting->value; $custom->options = Language::selectArray(); break; case 'frontend.theme': $custom = new \stdClass(); $custom->selected = $setting->value; $custom->options = Theme::selectArray(); break; case 'admin.default_template': $custom = new \stdClass(); $custom->selected = $setting->value; $custom->options = Theme::get_template_list($setting->value); break; case 'frontend.language_fallback': case 'frontend.strong_tags': case 'admin.advanced_permissions': case 'admin.publishing': $custom = new \stdClass(); $custom->selected = $setting->value; $custom->options = [1 => 'On', 0 => 'Off']; break; case 'admin.title_block': $custom = new \stdClass(); $custom->selected = $setting->value; $custom->options = Block::nameToNameArray(); break; case 'site.pages': $total_pages = Page::get_total(); $note = 'set to 0 for no limit - currently ' . $total_pages . ' normal pages in use'; break; case 'site.groups': $total_pages = Page::get_total(true); $note = 'set to 0 for no limit on group pages - currently ' . $total_pages . ' pages in use'; break; case 'site.secure_folders': $note = 'list of comma separated folders, will copy files to secure folders and vice versa on update'; break; default: $custom = null; } if (empty($custom)) { $settings[$k]->value = $setting->value; } else { $settings[$k]->value = $custom; } $settings[$k]->note = !empty($note) ? $note : null; $settings[$k]->name = str_replace('.', $this->dot_replace, $setting->name); } $upgrade = new \stdClass(); $upgrade->from = config('coaster::site.version'); $upgrade->to = Setting::latestTag(); $upgrade->required = version_compare(config('coaster::site.version'), Setting::latestTag(), '<'); $this->layoutData['content'] = View::make('coaster::pages.system', array('database_structure' => $database_structure, 'last_indexed_search' => $last_indexed_search, 'site_details' => $settings, 'can_index_search' => Auth::action('system.search'), 'can_validate' => Auth::action('system.validate-db'), 'can_upgrade' => Auth::action('system.upgrade'), 'upgrade' => $upgrade)); }
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]); }
/** * 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'; }
public function tabInfo() { $contents = ''; $publishingOn = config('coaster::admin.publishing') > 0; $canPublish = $publishingOn && Auth::action('pages.version-publish', ['page_id' => $this->id]) || !$publishingOn; // page parent (only updated for new pages) if (!$this->id) { $parentPages = [-1 => '-- None --', 0 => '-- Top Level Page --'] + static::get_page_list(['links' => false, 'exclude_home' => true, 'group_pages' => false]); if (!array_key_exists($this->parent, $parentPages)) { $this->parent = -1; } } else { $parentPages = null; } // beacons selection (only updated for existing pages) if ($this->id && Auth::action('themes.beacons-update')) { $beaconSelect = BlockBeacon::getDropdownOptions($this->id); $beaconSelect = empty($beaconSelect->options) ? null : $beaconSelect; } else { $beaconSelect = null; } // page name, url $pageLang = $this->id ? PageLang::where('page_id', '=', $this->id)->where('language_id', '=', Language::current())->first() : new PageLang(); $fullUrls = [-1 => '?', 0 => '/']; foreach (Path::all() as $pageId => $details) { $fullUrls[$pageId] = rtrim($details->fullUrl, '/') . '/'; } $urlPrefixes = $this->parentPathIds(); foreach ($urlPrefixes as $pageId => $urlPrefix) { if (!key_exists($pageId, $fullUrls)) { $fullUrls[$pageId] = '?'; } } $contents .= View::make('coaster::partials.tabs.page_info.page_info', ['page' => $this, 'page_lang' => $pageLang, 'parentPages' => $parentPages, 'beacon_select' => $beaconSelect, 'urlArray' => $fullUrls, 'urlPrefixes' => $urlPrefixes, 'publishing_on' => $publishingOn, 'can_publish' => $canPublish])->render(); // groups $groups = PageGroup::all(); if (!$groups->isEmpty() || config('coaster::site.groups') !== '') { $contents .= View::make('coaster::partials.tabs.page_info.groups', ['page' => $this, 'groups' => $groups])->render(); } //template if (empty($this->template)) { $this->template = config('coaster::admin.default_template'); $parentPage = static::find($this->parent); if ($parentPage && ($parentTemplate = Template::find($parentPage->template))) { $this->template = $parentTemplate->child_template; } } $templateData = Template::find($this->template); $templates = Theme::get_template_list($this->template); $templateSelectHidden = !empty($templateData) ? $templateData->hidden : false; // menu selection $menus = Menu::all(); if (!$menus->isEmpty() && Auth::action('menus')) { $in_menus = $this->id ? MenuItem::get_page_menus($this->id) : []; foreach ($menus as $k => $menu) { $menus[$k]->in_menu = in_array($menu->id, $in_menus); } } else { $menus = []; } $contents .= View::make('coaster::partials.tabs.page_info.display_info', ['page' => $this, 'template' => $this->template, 'templates' => $templates, 'templateSelectHidden' => $templateSelectHidden, 'menus' => $menus, 'can_publish' => $canPublish])->render(); // live options, sitemap $liveOptions = [0 => 'Not Live (Hidden)', 1 => 'Live (Ignores Dates)', 2 => 'Live Between Specific Dates/Times']; $sitemapOptions = [0 => 'Excluded From Sitemap', 1 => 'Included in Sitemap (If Page Live)']; $contents .= View::make('coaster::partials.tabs.page_info.live_options', ['page' => $this, 'liveOptions' => $liveOptions, 'sitemapOptions' => $sitemapOptions, 'disabled' => !$canPublish])->render(); return ['Page Info', $contents]; }
public function installTheme() { $details = Request::all(); $error = false; if (!empty($details['theme'])) { if (!($error = Theme::unzip($details['theme'] . '.zip', false))) { $withPageData = !empty($details['page-data']) ? 1 : 0; $result = Theme::install($details['theme'], ['withPageData' => $withPageData]); if ($result['error']) { $error = $result['response']; } if (($usedThemeSetting = Setting::where('name', '=', 'frontend.theme')->first()) && ($theme = Theme::where('theme', '=', $details['theme'])->first())) { $usedThemeSetting->value = $theme->id; $usedThemeSetting->save(); } } } if ($error) { FormMessage::add('theme', $error); $this->setupTheme(); } else { include __DIR__ . '/../../Http/routes/admin.php'; Install::setInstallState('complete-welcome'); $this->layoutData['title'] = 'Install Complete'; $this->layoutData['content'] = View::make('coaster::pages.install', ['stage' => 'complete']); } }