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]);
     }
 }
 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));
 }
Example #3
0
 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];
 }