public function getList($pageId = 0)
 {
     $page = Page::find($pageId);
     if (!empty($page)) {
         $block_cats = Template::template_blocks(config('coaster::frontend.theme'), $page->template);
         foreach ($block_cats as $block_cat) {
             foreach ($block_cat as $block) {
                 if ($block->type == 'gallery') {
                     $gallery_blocks[] = $block;
                 }
             }
         }
     }
     if (isset($gallery_blocks)) {
         if (count($gallery_blocks) == 1) {
             return \redirect()->route('coaster.admin.gallery.edit', ['pageId' => $pageId, 'blockId' => $gallery_blocks[0]->id]);
         }
         $page_lang_data = PageLang::preload($pageId);
         if (!empty($page_lang_data)) {
             $name = $page_lang_data->name;
             if ($page->parent != 0) {
                 $parent_lang_data = PageLang::preload($page->parent);
                 $name = $parent_lang_data->name . " / " . $name;
             }
         } else {
             $name = '';
         }
         $this->layoutData['content'] = View::make('coaster::pages.gallery.list', array('page_name' => $name, 'page_id' => $pageId, 'galleries' => $gallery_blocks));
     } else {
         $this->layoutData['content'] = 'No Galleries Found';
     }
     return null;
 }
Example #2
0
 /**
  * @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 publish($set_live = false, $ignore_auth = false)
 {
     $page_lang = PageLang::where('page_id', '=', $this->page_id)->where('language_id', '=', Language::current())->first();
     $page = Page::find($this->page_id);
     $publishingOn = config('coaster::admin.publishing') > 0 ? true : false;
     $haveAuth = $ignore_auth || ($publishingOn && Auth::action('pages.version-publish', ['page_id' => $this->page_id]) || !$publishingOn && Auth::action('pages.edit', ['page_id' => $this->page_id]));
     if (!empty($page_lang) && !empty($page) && $haveAuth) {
         $page_lang->live_version = $this->version_id;
         $page_lang->save();
         PageSearchData::updateText(strip_tags($page_lang->name), 0, $page->id);
         $page->template = $this->template;
         if ($set_live && $page->live == 0) {
             if (!empty($page->live_start) || !empty($page->live_end)) {
                 $page->live = 2;
             } else {
                 $page->live = 1;
             }
         }
         $page->save();
         return 1;
     }
     return 0;
 }
 public function postDelete($pageId)
 {
     if ($page = Page::find($pageId)) {
         return json_encode($page->delete());
     }
     return Response::make('Page with ID ' . $pageId . ' not found', 500);
 }
Example #5
0
 public function createPost($data)
 {
     $pageLang = PageLang::where('name', '=', $data->title->rendered)->first();
     $uporc = 'updated';
     if (empty($pageLang)) {
         $uporc = 'created';
         $page = new Page();
         $pageLang = new PageLang();
     } else {
         $page = Page::find($pageLang->page_id);
         $comments = $this->getComments($data, $page);
         $latestVersion = PageVersion::latest_version($page->id, true);
         if (!empty($latestVersion)) {
             $latestVersion->publish();
         }
         if (!empty($data->yoast)) {
             $this->getMetas($data->yoast, $data, $page->id);
         }
         $res = new \stdClass();
         $res->message = 'Post ' . $uporc . ': ' . $pageLang->name;
         $res->oldLink = $data->link;
         $res->newLink = Path::getFullUrl($page->id);
         $res->categories = 'UPDATE RUN';
         $res->tags = 'UPDATE RUN';
         return $res;
     }
     $page->live = 2;
     $page->live_start = $this->carbonDate($data->date)->format("Y-m-d H:i:s");
     $page->created_at = $this->carbonDate($data->date);
     $page->updated_at = $this->carbonDate($data->modified);
     $page->parent = $this->groupPage->id;
     $page->template = $this->group->default_template;
     $page->save();
     $page->groups()->sync([$this->group->id]);
     $comments = $this->getComments($data, $page);
     $categories = $this->getCategory($data->_embedded->{"wp:term"}, $page->id);
     // Page Lang
     $pageLang->live_version = 0;
     $pageLang->page_id = $page->id;
     $pageLang->language_id = Language::current();
     $pageLang->name = $data->title->rendered;
     $pageLang->url = str_slug($pageLang->name);
     $pageLang->save();
     $tags = $this->syncTags($page, $data->_embedded->{"wp:term"});
     $date_block = Block::where('name', '=', 'post_date')->first();
     if (!empty($date_block)) {
         $date_block->setPageId($page->id)->getTypeObject()->save($this->carbonDate($data->date)->format("Y-m-d H:i:s"));
     }
     $title_block = Block::where('name', '=', config('coaster::admin.title_block'))->first();
     if (!empty($title_block)) {
         $title_block->setPageId($page->id)->getTypeObject()->save($pageLang->name);
     }
     $content_block = Block::where('name', '=', 'content')->first();
     if (!empty($content_block)) {
         $content_block->setPageId($page->id)->getTypeObject()->save($this->processContent($data->content->rendered));
     }
     $leadText_block = Block::where('name', '=', 'lead_text')->first();
     if (!empty($leadText_block)) {
         $leadText_block->setPageId($page->id)->getTypeObject()->save($data->excerpt->rendered);
     }
     $latestVersion = PageVersion::latest_version($page->id, true);
     if (!empty($latestVersion)) {
         $latestVersion->publish();
     }
     if (!empty($data->yoast)) {
         $this->getMetas($data->yoast, $data, $page->id);
     }
     $res = new \stdClass();
     $res->message = 'Post ' . $uporc . ': ' . $pageLang->name;
     $res->oldLink = $data->link;
     $res->newLink = Path::getFullUrl($page->id);
     $res->categories = $categories;
     $res->tags = $tags;
     return $res;
 }