Example #1
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];
 }