/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('RainLab.Pages', 'pages', 'pages'); try { if (!($this->theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } new PageList($this, 'pageList'); new MenuList($this, 'menuList'); new SnippetList($this, 'snippetList'); $theme = $this->theme; new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); } catch (Exception $ex) { $this->handleError($ex); } $this->addJs('/modules/backend/assets/js/october.treeview.js', 'core'); $this->addJs('/plugins/rainlab/pages/assets/js/pages-page.js'); $this->addJs('/plugins/rainlab/pages/assets/js/pages-snippets.js'); $this->addCss('/plugins/rainlab/pages/assets/css/pages.css'); // Preload the code editor class as it could be needed // before it loads dynamically. $this->addJs('/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js', 'core'); $this->bodyClass = 'compact-container side-panel-not-fixed'; $this->pageTitle = 'rainlab.pages::lang.plugin.name'; $this->pageTitleTemplate = '%s Pages'; }
/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('October.Cms', 'cms', true); try { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $this->theme = $theme; new TemplateList($this, 'pageList', function () use($theme) { return Page::listInTheme($theme, true); }); new TemplateList($this, 'partialList', function () use($theme) { return Partial::listInTheme($theme, true); }); new TemplateList($this, 'layoutList', function () use($theme) { return Layout::listInTheme($theme, true); }); new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); new ComponentList($this, 'componentList'); new AssetList($this, 'assetList'); } catch (Exception $ex) { $this->handleError($ex); } }
public function __construct($controller, $alias) { $this->alias = $alias; $this->theme = Theme::getEditTheme(); $this->dataIdPrefix = 'page-' . $this->theme->getDirName(); parent::__construct($controller, []); $this->bindToController(); }
public function __construct($controller, $alias) { $this->alias = $alias; $this->theme = Theme::getEditTheme(); parent::__construct($controller, []); $this->bindToController(); $this->checkUploadPostback(); }
/** * Restore the CMS page found in the mapping array, or disable the * maintenance mode. * @return void */ public function afterFetch() { if (($theme = Theme::getEditTheme()) && ($themeMap = array_get($this->attributes, 'theme_map')) && ($cmsPage = array_get($themeMap, $theme->getDirName()))) { $this->cms_page = $cmsPage; } else { $this->is_enabled = false; } }
public function getCodeOptions() { $result = []; $theme = Theme::getEditTheme(); $menus = PagesMenu::listInTheme($theme, true); foreach ($menus as $menu) { $result[$menu->code] = $menu->name; } return $result; }
protected function getTemplateScriptPath() { $theme = Theme::getEditTheme(); $assetPath = $theme->getPath() . '/assets'; $fileName = $this->template->getBaseFileName(); $jsPath = $assetPath . '/javascript'; if (!File::isDirectory($jsPath)) { $jsPath = $assetPath . '/js'; } return $jsPath . '/controllers/' . $fileName . '.js'; }
public function getPagesDropDown() { if (!$this->pages) { $theme = Theme::getEditTheme(); $pages = Page::listInTheme($theme, true); $this->pages = []; foreach ($pages as $page) { $this->pages[$page->baseFileName] = $page->title . ' (' . $page->url . ')'; } } return $this->pages; }
public function partials() { if (!$this->partials) { $theme = Theme::getEditTheme(); $partials = Prtl::listInTheme($theme, true); $options = []; foreach ($partials as $partial) { $options[$partial->baseFileName] = $partial->baseFileName; } asort($options); $this->partials = $options; } return $this->partials; }
public function __construct() { parent::__construct(); BackendMenu::setContext('JofrySutanto.CustomFields', 'customfields', 'customfields'); try { if (!($this->theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } new FieldGroupList($this, 'groupList'); $theme = $this->theme; } catch (Exception $ex) { $this->handleError($ex); } }
/** * Returns a list of layouts available in the theme. * This method is used by the form widget. * @return array Returns an array of strings. */ public function getLayoutOptions() { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $layouts = Layout::listInTheme($theme, true); $result = []; $result[null] = Lang::get('cms::lang.page.no_layout'); foreach ($layouts as $layout) { $baseName = $layout->getBaseFileName(); $result[$baseName] = strlen($layout->name) ? $layout->name : $baseName; } return $result; }
private static function listPages() { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $pages = Page::listInTheme($theme, true); $result = []; foreach ($pages as $page) { if ($page->show_menu == "1") { $result[$page->menu_order] = ['text' => $page->menu_text, 'path' => $page->getBaseFileName(), 'order' => $page->menu_order]; } } ksort($result); return $result; }
public function onRun() { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $currentPage = $this->page->baseFileName; $pages = Page::listInTheme($theme, true); $this->pagesList = $this->buildPagesList($pages); $breadcrumbList = $this->buildCrumbTrail($currentPage); $currentCrumb = array_slice($breadcrumbList, -1, 1, true); $currentCrumb = array_shift($currentCrumb); $this->page['breadcrumbs'] = $breadcrumbList; $this->page['currentCrumb'] = $currentCrumb; return; }
public function getPageUrlOptions() { $currentTheme = Theme::getEditTheme(); $allThemePages = Page::listInTheme($currentTheme, true); $options = []; foreach ($allThemePages as $p) { $options['url=' . $p->url . '&type=cms_pages'] = $p->title; } $tree = StaticPageClass::buildMenuTree($currentTheme); foreach ($tree as $key => $page) { if (isset($page['title']) && isset($page['url'])) { $options['url=' . $page['url'] . '&type=pages_plugin'] = $page['title']; } } return $options; }
public function register() { \Event::listen('backend.form.extendFields', function ($widget) { if (!$widget->model instanceof \Cms\Classes\Page) { return; } if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $pages = Page::all()->sort(function ($a, $b) { return strcasecmp($a->title, $b->title); }); $pageOptions = $this->buildPageOptions($pages); $widget->addFields(['settings[child_of]' => ['label' => 'Child Of', 'type' => 'dropdown', 'tab' => 'Breadcrumbs', 'span' => 'left', 'options' => $pageOptions, 'comment' => 'The parent of this page. Set to "None" if root page'], 'settings[hide_crumb]' => ['label' => 'Hide Breadcrumbs', 'type' => 'checkbox', 'tab' => 'Breadcrumbs', 'span' => 'right', 'comment' => 'Hide the breadcrumb trail on this page'], 'settings[crumb_title]' => ['label' => 'Crumb Title (Optional)', 'type' => 'text', 'tab' => 'Breadcrumbs', 'span' => 'left', 'comment' => 'Title text for this pages crumb, by default will use page title'], 'settings[remove_crumb_trail]' => ['label' => 'Remove From Breadcrumbs', 'type' => 'checkbox', 'tab' => 'Breadcrumbs', 'span' => 'right', 'comment' => 'Do not show this page in the breadcrumb trail'], 'settings[crumbElementTitle]' => ['label' => 'Crumb Title From Id (Optional)', 'type' => 'text', 'tab' => 'Breadcrumbs', 'span' => 'left', 'comment' => 'Use a DOM element as the crumb title for this page. Must be a a unique #id on the page.'], 'settings[crumb_disabled]' => ['label' => 'Disabled', 'type' => 'checkbox', 'tab' => 'Breadcrumbs', 'span' => 'right', 'comment' => 'Disable the link and add the disabled class to this crumb item in the breadcrumb list']], 'primary'); }); }
/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('Shahin.Pages', 'pages', 'pages'); try { if (!($this->theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } new MenuList($this, 'menuList'); $theme = $this->theme; new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); } catch (Exception $ex) { $this->handleError($ex); } }
private static function listPages() { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $pages = Page::listInTheme($theme, true); $result = []; foreach ($pages as $page) { $page->fill(['menu_text']); $page->fill(['menu_order']); if ($page->not_show_menu != "1" && !empty($page->menu_order)) { $result[$page->menu_order] = ['text' => $page->menu_text != '' ? $page->menu_text : $page->title, 'path' => $page->getBaseFileName(), 'order' => $page->menu_order != '' ? $page->menu_order : 1]; } } ksort($result); return $result; }
public function __construct($controller, $alias, callable $dataSource) { $this->alias = $alias; $this->dataSource = $dataSource; $this->theme = Theme::getEditTheme(); parent::__construct($controller, []); if (!Request::isXmlHttpRequest()) { $this->resetSelection(); } $configFile = 'config_' . snake_case($alias) . '.yaml'; $config = $this->makeConfig($configFile); foreach ($config as $field => $value) { if (property_exists($this, $field)) { $this->{$field} = $value; } } $this->bindToController(); }
/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('RainLab.Pages', 'pages', 'pages'); try { if (!($this->theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } new PageList($this, 'pageList'); new MenuList($this, 'menuList'); new SnippetList($this, 'snippetList'); new TemplateList($this, 'contentList', function () { return $this->getContentTemplateList(); }); } catch (Exception $ex) { $this->handleError($ex); } }
public function register() { \Event::listen('backend.form.extendFields', function ($widget) { if (PluginManager::instance()->hasPlugin('RainLab.Pages') && $widget->model instanceof \RainLab\Pages\Classes\Page) { $widget->addFields(['viewBag[seo_title]' => ['label' => 'Meta Title', 'type' => 'text', 'tab' => 'cms::lang.editor.meta'], 'viewBag[seo_description]' => ['label' => 'Meta Description', 'type' => 'textarea', 'size' => 'tiny', 'tab' => 'cms::lang.editor.meta'], 'viewBag[seo_keywords]' => ['label' => 'Meta Keywords', 'type' => 'textarea', 'size' => 'tiny', 'tab' => 'cms::lang.editor.meta'], 'viewBag[canonical_url]' => ['label' => 'Canonical URL', 'type' => 'text', 'tab' => 'cms::lang.editor.meta', 'span' => 'left'], 'viewBag[redirect_url]' => ['label' => 'Redirect URL', 'type' => 'text', 'tab' => 'cms::lang.editor.meta', 'span' => 'right'], 'viewBag[robot_index]' => ['label' => 'Robot Index', 'type' => 'dropdown', 'tab' => 'cms::lang.editor.meta', 'options' => $this->getIndexOptions(), 'default' => 'index', 'span' => 'left'], 'viewBag[robot_follow]' => ['label' => 'Robot Follow', 'type' => 'dropdown', 'tab' => 'cms::lang.editor.meta', 'options' => $this->getFollowOptions(), 'default' => 'follow', 'span' => 'right']], 'primary'); } if (PluginManager::instance()->hasPlugin('RainLab.Blog') && $widget->model instanceof \RainLab\Blog\Models\Post) { $widget->addFields(['seo_title' => ['label' => 'Meta Title', 'type' => 'text', 'tab' => 'SEO'], 'seo_description' => ['label' => 'Meta Description', 'type' => 'textarea', 'size' => 'tiny', 'tab' => 'SEO'], 'seo_keywords' => ['label' => 'Meta Keywords', 'type' => 'textarea', 'size' => 'tiny', 'tab' => 'SEO'], 'canonical_url' => ['label' => 'Canonical URL', 'type' => 'text', 'tab' => 'SEO', 'span' => 'left'], 'redirect_url' => ['label' => 'Redirect URL', 'type' => 'text', 'tab' => 'SEO', 'span' => 'right'], 'robot_index' => ['label' => 'Robot Index', 'type' => 'dropdown', 'tab' => 'SEO', 'options' => $this->getIndexOptions(), 'default' => 'index', 'span' => 'left'], 'robot_follow' => ['label' => 'Robot Follow', 'type' => 'dropdown', 'tab' => 'SEO', 'options' => $this->getFollowOptions(), 'default' => 'follow', 'span' => 'right']], 'secondary'); } if (!$widget->model instanceof \Cms\Classes\Page) { return; } if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $widget->addFields(['settings[seo_keywords]' => ['label' => 'Meta Keywords', 'type' => 'textarea', 'tab' => 'cms::lang.editor.meta', 'size' => 'tiny', 'placeholder' => "hello"], 'settings[canonical_url]' => ['label' => 'Canonical URL', 'type' => 'text', 'tab' => 'cms::lang.editor.meta', 'span' => 'left'], 'settings[redirect_url]' => ['label' => 'Redirect URL', 'type' => 'text', 'tab' => 'cms::lang.editor.meta', 'span' => 'right'], 'settings[robot_index]' => ['label' => 'Robot Index', 'type' => 'dropdown', 'tab' => 'cms::lang.editor.meta', 'options' => $this->getIndexOptions(), 'default' => 'index', 'span' => 'left'], 'settings[robot_follow]' => ['label' => 'Robot Follow', 'type' => 'dropdown', 'tab' => 'cms::lang.editor.meta', 'options' => $this->getFollowOptions(), 'default' => 'follow', 'span' => 'right']], 'primary'); }); }
public function onQeditSave() { $page = post('page'); if (!empty($page)) { $theme = Theme::getEditTheme()->getDirName(); $type = $this->property('type'); if ($type != 'content') { $original = File::get('themes/' . $page); $setting = substr($original, 0, strrpos($original, '==') + 2) . "\n"; $content = $setting . post('content'); } else { $content = post('content'); } file_put_contents('themes/' . $page, $content); Flash::success(Lang::get('cms::lang.template.saved')); } else { Flash::warning(Lang::get('indikator.qedit::lang.widget.error_page')); } }
/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('October.Cms', 'cms', 'pages'); try { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $this->theme = $theme; new TemplateList($this, 'pageList', function () use($theme) { return Page::listInTheme($theme, true); }); new TemplateList($this, 'partialList', function () use($theme) { return Partial::listInTheme($theme, true); }); new TemplateList($this, 'layoutList', function () use($theme) { return Layout::listInTheme($theme, true); }); new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); new ComponentList($this, 'componentList'); new AssetList($this, 'assetList'); } catch (Exception $ex) { $this->handleError($ex); } $this->addJs('/modules/cms/assets/js/october.cmspage.js', 'core'); $this->addJs('/modules/cms/assets/js/october.dragcomponents.js', 'core'); $this->addCss('/modules/cms/assets/css/october.components.css', 'core'); // Preload Ace editor modes explicitly, because they could be changed dynamically // depending on a content block type $this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/ace.js', 'core'); $aceModes = ['markdown', 'plain_text', 'html', 'less', 'css', 'scss', 'sass', 'javascript']; foreach ($aceModes as $mode) { $this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/mode-' . $mode . '.js', 'core'); } $this->bodyClass = 'compact-container side-panel-not-fixed'; $this->pageTitle = Lang::get('cms::lang.cms.menu_label'); }
/** * Update action. Add the theme object to the page vars. */ public function update($recordId = null, $context = null) { $this->bodyClass = 'compact-container'; try { if (!($editTheme = Theme::getEditTheme())) { throw new ApplicationException('Unable to find the active theme.'); } $result = $this->asExtension('FormController')->update($recordId, $context); $model = $this->formGetModel(); $theme = Theme::load($model->theme); /* * Not editing the active sitemap definition */ if ($editTheme->getDirName() != $theme->getDirName()) { return $this->redirectToThemeSitemap($editTheme); } $this->vars['theme'] = $theme; $this->vars['themeName'] = $theme->getConfigValue('name', $theme->getDirName()); $this->vars['sitemapUrl'] = URL::to('/sitemap.xml'); return $result; } catch (Exception $ex) { $this->handleError($ex); } }
public function boot() { Event::listen('backend.form.extendFields', function ($form) { /* * Check for the installed plugin if install then extends fields for that. */ if ($form->model instanceof \AnandPatel\WysiwygEditors\Models\Settings) { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } if (PluginManager::instance()->hasPlugin('RainLab.Pages')) { $form->addFields(['static_page_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.spages.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.spages.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('RainLab.Blog')) { $form->addFields(['blog_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.blog.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.blog.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Richlove.Blog')) { $form->addFields(['blog_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.blog.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.blog.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Radiantweb.Problog')) { $form->addFields(['radiant_problog_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.problog.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.problog.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Radiantweb.Proevents')) { $form->addFields(['radiant_proevents_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.proevent.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.proevent.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Autumn.Pages')) { $form->addFields(['autumn_page_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.apages.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.apages.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Indikator.Content')) { $form->addFields(['content_plus_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.cplus.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.cplus.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Indikator.News')) { $form->addFields(['news_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.news.label', 'type' => 'switch', 'span' => 'auto', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.news.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } } if (Settings::get('cms_content_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Content') { useWysiwyg($form); } else { if (Settings::get('cms_partial_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Partial') { useWysiwyg($form); } else { if (Settings::get('cms_layout_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Layout') { useWysiwyg($form); } else { if (Settings::get('cms_page_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Page') { useWysiwyg($form); } else { if (Settings::get('others_as_wysiwyg', false)) { if (get_class($form->config->model) != 'Cms\\Classes\\Layout' && get_class($form->config->model) != 'Cms\\Classes\\Page' && get_class($form->config->model) != 'Cms\\Classes\\Content' && get_class($form->config->model) != 'Cms\\Classes\\Partial') { useWysiwyg($form); } } else { if (Settings::get('static_page_as_wysiwyg', false) && $form->model instanceof \RainLab\Pages\Classes\Page) { useWysiwyg($form); } if (Settings::get('blog_as_wysiwyg', false) && $form->model instanceof \RainLab\Blog\Models\Post) { useWysiwyg($form); } if (Settings::get('blog_as_wysiwyg', false) && $form->model instanceof \Richlove\Blog\Models\Post) { useWysiwyg($form); } if (Settings::get('radiant_problog_as_wysiwyg', false) && $form->model instanceof \Radiantweb\Problog\Models\Post) { useWysiwyg($form); } if (Settings::get('radiant_proevents_as_wysiwyg', false) && $form->model instanceof \Radiantweb\Proevents\Models\Event) { useWysiwyg($form); } if (Settings::get('autumn_page_as_wysiwyg', false) && $form->model instanceof \Autumn\Pages\Models\Page) { useWysiwyg($form); } if (Settings::get('content_plus_as_wysiwyg', false) && ($form->model instanceof \Indikator\Content\Models\Blog || $form->model instanceof \Indikator\Content\Models\News || $form->model instanceof \Indikator\Content\Models\Portfolio || $form->model instanceof \Indikator\Content\Models\Slideshow || $form->model instanceof \Indikator\Content\Models\Testimonials)) { useWysiwyg($form); } if (Settings::get('news_as_wysiwyg', false) && $form->model instanceof \Indikator\News\Models\Posts) { useWysiwyg($form); } } } } } } }); function useWysiwyg($form) { $replacable = ['codeeditor', 'Eein\\Wysiwyg\\FormWidgets\\Trumbowyg', 'richeditor', 'RainLab\\Blog\\FormWidgets\\BlogMarkdown', 'Richlove\\Blog\\FormWidgets\\BlogMarkdown']; foreach ($form->getFields() as $field) { if (!empty($field->config['type']) && in_array($field->config['type'], $replacable)) { if (Settings::instance()->editor == 'richeditor') { $field->config['type'] = $field->config['widget'] = 'richeditor'; } else { $field->config['type'] = $field->config['widget'] = 'AnandPatel\\WysiwygEditors\\FormWidgets\\Editor'; } return; } } } }
/** * Loops over each payment type and ensures the editing theme has a payment form partial, * if the partial does not exist, it will create one. * @return void */ public static function createPartials() { $partials = Partial::lists('baseFileName', 'baseFileName'); $paymentMethods = TypeModel::all(); foreach ($paymentMethods as $paymentMethod) { $class = $paymentMethod->class_name; if (!$class || get_parent_class($class) != 'Responsiv\\Pay\\Classes\\GatewayBase') { continue; } $partialName = 'pay/' . strtolower(class_basename($class)); $partialExists = array_key_exists($partialName, $partials); if (!$partialExists) { $filePath = dirname(File::fromClass($class)) . '/' . strtolower(class_basename($class)) . '/payment_form.htm'; self::createPartialFromFile($partialName, $filePath, Theme::getEditTheme()); } } }
protected function getPageContent($page) { $theme = Theme::getEditTheme(); $result = CmsController::render($page, ['code' => LARAVEL_START], $theme); return $result; }
public function boot() { \App::register('Barryvdh\\Elfinder\\ElfinderServiceProvider'); $this->publishes([__DIR__ . '/config/elfinder.php' => config_path('elfinder.php')]); Event::listen('backend.form.extendFields', function ($form) { /* * Check for the installed plugin if install then extends fields for that. */ if ($form->model instanceof \AnandPatel\WysiwygEditors\Models\Settings) { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } if (PluginManager::instance()->hasPlugin('Radiantweb.Problog')) { $form->addFields(['radiant_problog_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.problog.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.problog.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Radiantweb.Proevents')) { $form->addFields(['radiant_proevents_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.proevent.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.proevent.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('RainLab.Pages')) { $form->addFields(['static_page_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.spages.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.spages.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('RainLab.Blog')) { $form->addFields(['blog_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.blog.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.blog.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } if (PluginManager::instance()->hasPlugin('Autumn.Pages')) { $form->addFields(['autumn_page_as_wysiwyg' => ['label' => 'anandpatel.wysiwygeditors::lang.form.apages.label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'anandpatel.wysiwygeditors::lang.form.apages.comment', 'tab' => 'anandpatel.wysiwygeditors::lang.form.tab.content']], 'primary'); } } if (Settings::get('cms_content_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Content') { useWysiwyg($form); } else { if (Settings::get('cms_partial_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Partial') { useWysiwyg($form); } else { if (Settings::get('cms_layout_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Layout') { useWysiwyg($form); } else { if (Settings::get('cms_page_as_wysiwyg', false) && get_class($form->config->model) == 'Cms\\Classes\\Page') { useWysiwyg($form); } else { if (Settings::get('others_as_wysiwyg', false)) { if (get_class($form->config->model) != 'Cms\\Classes\\Layout' && get_class($form->config->model) != 'Cms\\Classes\\Page' && get_class($form->config->model) != 'Cms\\Classes\\Content' && get_class($form->config->model) != 'Cms\\Classes\\Partial') { useWysiwyg($form); } } else { if (Settings::get('radiant_problog_as_wysiwyg', false) && $form->model instanceof \Radiantweb\Problog\Models\Post) { useWysiwyg($form); } if (Settings::get('radiant_proevents_as_wysiwyg', false) && $form->model instanceof \Radiantweb\Proevents\Models\Event) { useWysiwyg($form); } if (Settings::get('blog_as_wysiwyg', false) && $form->model instanceof \RainLab\Blog\Models\Post) { useWysiwyg($form); } if (Settings::get('autumn_page_as_wysiwyg', false) && $form->model instanceof \Autumn\Pages\Models\Page) { useWysiwyg($form); } if (Settings::get('static_page_as_wysiwyg', false) && $form->model instanceof \RainLab\Pages\Classes\Page) { useWysiwyg($form); } } } } } } }); function useWysiwyg($form) { $replacable = ['codeeditor', 'Eein\\Wysiwyg\\FormWidgets\\Trumbowyg', 'richeditor', 'RainLab\\Blog\\FormWidgets\\BlogMarkdown']; foreach ($form->getFields() as $field) { if (!empty($field->config['type'])) { if (in_array($field->config['type'], $replacable)) { if (Settings::instance()->editor == 'richeditor') { $field->config['type'] = $field->config['widget'] = 'richeditor'; } else { $field->config['type'] = $field->config['widget'] = 'AnandPatel\\WysiwygEditors\\FormWidgets\\Editor'; } return; } } } } }
public static function clearCache() { $theme = Theme::getEditTheme(); $router = new Router($theme); $router->clearCache(); StaticPage::clearMenuCache($theme); SnippetManager::clearCache($theme); }
/** * Returns a list of options for the Reference drop-down menu in the * menu item configuration form, when the Static Page item type is selected. * @return array Returns an array */ protected static function listStaticPageMenuOptions() { $theme = Theme::getEditTheme(); $pageList = new PageList($theme); $pageTree = $pageList->getPageTree(true); $iterator = function ($pages) use(&$iterator) { $result = []; foreach ($pages as $pageInfo) { $pageName = $pageInfo->page->getViewBag()->property('title'); $fileName = $pageInfo->page->getBaseFileName(); if (!$pageInfo->subpages) { $result[$fileName] = $pageName; } else { $result[$fileName] = ['title' => $pageName, 'items' => $iterator($pageInfo->subpages)]; } } return $result; }; return $iterator($pageTree); }
/** * Set the theme to the editing one. * @return self */ public function inEditTheme() { return $this->inTheme(Theme::getEditTheme()); }