/** Edit Page */
 public function editPage($pageId = 0, $contentId = false)
 {
     $page = Page::find($pageId);
     if (!$page) {
         return Redirect::route('cmsEdit');
     }
     if (!ctype_digit(strval($pageId))) {
         throw new Exception('Invalid page-ID! Must be an integer value');
     }
     if ($pageId <= 0) {
         throw new Exception($pageId . ' is not a valid page-ID');
     }
     if (is_numeric($contentId) and $contentId > 0) {
         $page = Page::join("content", "content.page_id", "=", "pages.id")->where(function ($query) use($contentId) {
             $query->where('content.content_id', '=', $contentId);
         })->first();
         if (empty($page->id)) {
             throw new Exception('Invalid Content-ID');
         }
     } else {
         $page = Page::find($pageId);
         if (empty($page->id)) {
             throw new Exception('Invalid page-ID');
         }
         $page->title = $page->content->title;
         $page->body = $page->content->body;
         $page->content_id = $page->content->content_id;
     }
     View::share("title", Lang::get('cms::m.edit-page') . " - " . $page->content->title);
     return View::make('cms::edit.pages.edit-page', array("rules" => $this->rules['page'], "page" => $page, "history" => Page::history($pageId), "current_content_id" => $page->content_id));
 }
Example #2
0
 /**
  * @param string $keywords
  * @param bool $extended TRUE = search also in body text, otherwise only in meta (title and such)
  * @return mixed
  */
 public static function search($keywords = "", $extended = false)
 {
     $result = "";
     if (!empty($keywords)) {
         /* Query Builder */
         $result = Page::join("content", "content.page_id", "=", "pages.id")->where(function ($query) use($keywords, $extended) {
             foreach (explode(" ", $keywords) as $keyword) {
                 $query->where("content.title", "LIKE", "%" . $keyword . "%");
                 if ($extended) {
                     $query->where("content.body", "LIKE", "%" . $keyword . "%");
                 }
             }
         })->published()->groupBy("content.page_id")->orderBy("content.updated_at", "desc")->get();
         return $result;
     }
 }