Exemplo n.º 1
0
 public function getAdd($parentPageId = 0, $groupId = 0)
 {
     $publishingOn = config('coaster::admin.publishing') > 0;
     $cabPublish = $publishingOn && Auth::action('pages.version-publish', ['page_id' => $parentPageId]) || !$publishingOn && Auth::action('pages.edit', ['page_id' => $parentPageId]);
     // set page data
     $page = new Page();
     if ($parentPageId && ($parent = Page::find($parentPageId))) {
         $page->parent = $parent->id;
         $page->template = $parent->child_template;
     } else {
         $page->parent = 0;
     }
     if ($groupId && ($group = PageGroup::find($groupId))) {
         $page->groups->add($group);
         $page->template = $group->default_template;
         $page->parent = $parentPageId ? $page->parent : -1;
     }
     $page->group_container = 0;
     $page->link = 0;
     $page->live = $cabPublish ? 1 : 0;
     $page->sitemap = 1;
     // get item name, or default to page
     $item_name = $page->groupItemsNames() ?: 'Page';
     // get page info tab contents
     $tab_headers = [];
     $tab_contents = [];
     list($tab_headers[0], $tab_contents[0]) = $page->tabInfo();
     $tab_data = ['headers' => View::make('coaster::partials.tabs.header', ['tabs' => $tab_headers])->render(), 'contents' => View::make('coaster::partials.tabs.content', ['tabs' => $tab_contents, 'item' => $item_name, 'new_page' => true, 'publishing' => $publishingOn, 'can_publish' => $cabPublish, 'page' => $page])->render()];
     $this->layoutData['content'] = View::make('coaster::pages.pages.add', ['page' => $page, 'item_name' => $item_name, 'tab' => $tab_data]);
 }