function copy($name, $desc, $url) { $page = new Page(); $page->name = $name; $page->description = $desc; $page->url = $url; $page->template_id = $this->template_id; $page->save(); foreach ($this->posts()->get() as $oldPost) { $post = new Post(); $post->page_id = $page->id; $post->section_id = $oldPost->section_id; $post->name = $oldPost->name; $post->save(); foreach ($oldPost->contents()->get() as $oldContent) { $content = new Content(); $content->value = $oldContent->value; $content->post_id = $post->id; $content->item_id = $oldContent->item_id; $content->save(); } foreach ($oldPost->attachments()->get() as $oldAttachment) { $attachment = new Attachment(); $attachment->value = $oldAttachment->value; $attachment->name = $oldAttachment->name; $attachment->post_id = $post->id; $attachment->item_type_id = $oldAttachment->item_type_id; $attachment->save(); } } return $page; }
function post() { $pageId = Request::route('id1'); $sectionId = Request::route('id2'); $section = Section::find($sectionId); $inputs = $this->inputs(); $post = new Post(); $post->page_id = $pageId; $post->section_id = $sectionId; $post->name = $section->name; $post->description = $section->description; $post->save(); foreach ($inputs as $input) { $item = Item::find($input->id); $content = null; if (isset($content) === false) { $content = new Content(); $content->item_id = $item->id; $content->post_id = $post->id; $input->insert($content, Input::get("{$item->id}")); } // else { // $input->update($content, Input::get("$item->id")); // } $content->save(); } return Redirect::to("/admin/manage-pages/{$pageId}/content"); }
function show() { // dd(Page::all()->toArray()); $page = Page::orWhere(function ($query) { $query->where('url', '=', Request::path()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::path()); })->orWhere(function ($query) { $query->where('url', '=', Request::url()); })->orWhere(function ($query) { $query->where('url', '=', Request::route()->getPath()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::route()->getPath()); })->get()->first(); $ps = Post::where('page_id', '=', $page->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get(); $posts = []; foreach ($page->template()->first()->sections() as $sec) { $posts[$sec->name] = []; } foreach ($ps as $p) { $posts[$p->section()->first()->name][] = $p; } $pages = []; foreach (Page::all() as $pi) { $pages[$pi->name] = $pi; } $fn = str_replace('.blade.php', '', $page->template()->first()->filename); return View::make("aui/templates/" . $fn)->with('posts', $posts)->with('pages', $pages)->with('page', $page); }
function post() { $post = Post::find(Request::route('id2')); $pageId = Request::route('id1'); $post->delete(); return Redirect::to("/admin/manage-pages/{$pageId}/content"); }
function currentPost() { $postId = Request::route('id2'); if (isset($postId)) { return Post::find($postId); } else { return null; } }
function definition($def = []) { $is = []; $sectionId = Post::find(Request::route('id2'))->section()->first()->id; foreach (Item::where('section_id', '=', $sectionId)->get() as $item) { $content = $item->content()->where('post_id', '=', Request::route('id2'))->get()->first(); $is = $item->render($is, $content); } return parent::definition(['Form ID' => $this->getHeader() . "-form", 'Submit Button Text' => 'Save', 'Inputs' => $is]); }
function post() { foreach (json_decode(Input::get('json')) as $i) { $c = Post::find($i->id); $c->sort = $i->sort; $c->save(); } Session::flash('Success Message', 'Saved sort order'); return \Redirect::to("/admin/manage-pages/" . Request::route('id1') . "/content"); }
function def($postId) { $this->firstRow(); $this->addCell('#'); $this->addCell('Name'); $this->addCell('Actions'); $this->nextRow(); $pageId = Request::route('id1'); $post = Post::find($postId); foreach ($post->attachments()->get() as $att) { $this->addCell('1. '); $this->addCell($att->name); $this->addCellViews([(new ButtonItem())->cssClass("btn-default btn-sm")->target('_blank')->label('Download')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/download"), (new ButtonItem())->cssClass("btn-default btn-sm")->label('Edit')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/edit"), (new ButtonItem())->cssClass("btn-default btn-sm")->label('Delete')->defaultValue("/admin/manage-pages/" . $pageId . "/posts/" . $post->id . "/attachments/{$att->id}/delete")]); // $this->addCellView(); $this->nextRow(); } return parent::definition(); }
function dataAll() { return $this->table->whereIn("post_id", Post::where('page_id', '=', Request::route("id" . ($this->level - 1)))->lists('id'))->with('post')->with('itemType')->get(); }
function post() { $post = Post::find(Request::route('id2')); $pageId = Request::route('id1'); $sectionId = $post->section()->first()->id; $inputs = $this->inputs(Post::find(Request::route('id2'))); foreach ($inputs as $input) { $item = Item::find($input->id); $content = $item->content()->where('post_id', '=', $post->id)->get()->first(); if (isset($content) === false) { $content = new Content(); $content->item_id = $item->id; $content->post_id = $post->id; $input->insert($content, Input::get("{$item->id}")); } else { $input->update($content, Input::get("{$item->id}")); } $content->save(); } return Redirect::to("/admin/manage-pages/{$pageId}/content"); }
function show() { $puntoFeed = Feed::orWhere(function ($query) { $query->where('url', '=', Request::path()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::path()); })->orWhere(function ($query) { $query->where('url', '=', Request::url()); })->get()->first(); $feed = \Feed::make(); $feed->setTextLimit(10000); $feed->setView('punto-cms::rss'); // cache the feed for 60 minutes (second parameter is optional) if ($this->useCache) { $feed->setCache(0, $puntoFeed->name); } // check if there is cached feed and build new only if is not if (!$this->useCache || !$feed->isCached()) { // creating rss feed with our most recent 20 posts $posts = Post::where('page_id', '=', $puntoFeed->page_id)->where('section_id', '=', $puntoFeed->section_id)->orderBy('created_at', 'desc')->get(); // set your feed's title, description, link, pubdate and language $feed->title = $puntoFeed->name; $feed->description = ''; // $feed->logo = 'http://yoursite.tld/logo.jpg'; $feed->link = Request::url(); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' if (isset($posts[0])) { $feed->pubdate = $posts[0]->created_at; } $feed->lang = 'en'; $feed->setShortening(true); // true or false // $feed->setTextLimit(100); // maximum length of description text foreach ($posts as $post) { // set item's title, author, url, pubdate, description and content $desc = null; $title = null; if ($post->hasContent("Description")) { $desc = $post->findContent("Description")->value; } else { if ($post->hasContent("Title")) { $desc = $post->findContent("Title")->value; } else { if ($post->hasContent("Name")) { $desc = $post->findContent("Name")->value; } } } if ($post->hasContent("Title")) { $title = $post->findContent("Title")->value; } else { if ($post->hasContent("Name")) { $title = $post->findContent("Name")->value; } else { if ($post->hasContent("Description")) { $title = $post->findContent("Description")->value; } } } if ($desc !== null) { $feed->add($title, null, null, $post->created_at, $desc, null); } } } else { } // first param is the feed format // optional: second param is cache duration (value of 0 turns off caching) // optional: you can set custom cache key with 3rd param as string return $feed->render('rss'); }