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() { $page = new Page(); $page->name = Input::get('name'); $page->description = Input::get('description'); $page->url = Input::get('url'); $page->template_id = Input::get('template_id'); $page->language_id = Input::get('language_id'); $page->save(); return Redirect::to("/admin/manage-pages/" . $page->id . "/content"); }
public static function routes() { foreach (Page::get() as $page) { if (isset($page->url) && $page->url !== '') { Route::get($page->url, 'PageRoute@show'); } } }
function post() { foreach (json_decode(Input::get('json')) as $i) { $c = Page::find($i->id); $c->sort = $i->sort; $c->save(); } Session::flash('Success Message', 'Saved sort order'); return \Redirect::to("/admin/edit-pages"); }
function __construct() { parent::controllerClass('Feeds'); parent::headerPlural('Feeds'); parent::headerSingular('Feed'); parent::baseRoute('/admin/feeds'); parent::ajaxBaseRoute('/ajax/admin/feeds'); parent::table(new Feed()); parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Name', 'id' => 'name'], ['title' => 'URL', 'id' => 'url'], ['title' => 'Page', 'id' => 'page.name'], ['title' => 'Section', 'id' => 'section.name']]); parent::inputs(function ($row) { return ['name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'url' => (new TextBox())->id('url')->label('URL')->defaultValue($row ? $row->url : ''), 'page_id' => (new DropDown())->id('page_id')->nullable(false)->label('Page')->idField('id')->nameField('name')->rows(Page::get())->defaultValue($row ? $row->page_id : ''), 'section_id' => (new DropDown())->id('section_id')->nullable(false)->label('Section')->idField('id')->nameField('name')->rows(Section::get())->defaultValue($row ? $row->section_id : '')]; }); parent::tableName('feed'); }
function definition($def = []) { $items = []; $pages = null; if (Auth::user()->userPages()->count() === 0) { $pages = Page::orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get(); } else { $pages = Page::whereIn('id', Auth::user()->userPages()->lists('page_id'))->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get(); } $pages->each(function ($page) use(&$items) { $labels = []; $items["{$page->id}"] = array_merge(['title' => $page->name, 'description' => $page->description, 'href' => "/admin/manage-pages/{$page->id}/content", 'label1' => $page->template()->get()->first()->name, 'label2' => $page->url], $labels); }); return ['id' => 'page-list', 'items' => $items]; }
function __construct() { parent::controllerClass('UserPages'); parent::headerPlural('User Pages'); parent::headerSingular('User Page'); parent::baseRoute('/admin/users/{id1}/pages'); parent::ajaxBaseRoute('/ajax/admin/users/{id1}/pages'); parent::table(new UserPage()); $this->level = 2; parent::attributes([['title' => 'User', 'id' => 'user.username'], ['title' => 'Page', 'id' => 'page.name']]); parent::inputs(function ($row) { $parentId = Request::route("id" . ($this->level - 1)); return ['user_id' => (new MetaItem())->id('user_id')->defaultValue($parentId), 'page_id' => (new DropDown())->id('page_id')->nullable(false)->idField('id')->nameField('name')->defaultValue($row ? $row->page_id : '')->label('Page')->rows(Page::get())]; }); $this->parentHeader = 'User'; parent::tableName('user_page'); }
function __construct() { parent::controllerClass('EditPagesAttachments'); parent::headerPlural('Page Documents'); parent::headerSingular('Page Document'); parent::baseRoute('/admin/edit-pages/{id1}/attachments'); parent::ajaxBaseRoute('/ajax/admin/edit-pages/{id1}/attachments'); parent::table(new Attachment()); $this->level = 2; parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Post', 'id' => 'post.name'], ['title' => 'Name', 'id' => 'name'], ['title' => 'Type', 'id' => 'item_type.name']]); parent::inputs(function ($row) { $parentId = Request::route("id" . ($this->level - 1)); $page = Page::find($parentId); return ['name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'post_id' => (new DropDown())->id('post_id')->nullable(true)->label('Post')->idField('id')->nameField('name')->rows(Post::where('page_id', '=', $page->id)->get())->defaultValue($row ? $row->post_id : ''), 'file' => (new FileInput())->id('value')->valueField('value')->label('File')->filename($row ? $row->value : '')->defaultValue($row ? $row->value : ''), 'item_type_id' => (new DropDown())->id('item_type_id')->nullable(false)->label('Type')->idField('id')->nameField('name')->rows(ItemType::whereIn('short_name', ["image", "file"])->get())->defaultValue($row ? $row->item_type_id : '')]; }); $this->parentHeader = 'Edit Page'; parent::tableName('attachment'); }
function __construct() { parent::controllerClass('EditPagesPosts'); parent::headerPlural('Page Posts'); parent::headerSingular('Page Post'); parent::baseRoute('/admin/edit-pages/{id1}/posts'); parent::ajaxBaseRoute('/ajax/admin/edit-pages/{id1}/posts'); parent::table(new Post()); $this->level = 2; $this->useEditButton = false; parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Post Name', 'id' => 'name'], ['title' => 'Category', 'id' => 'section.name']]); parent::inputs(function ($row) { $parentId = Request::route("id" . ($this->level - 1)); $page = Page::find($parentId); return ['page_id' => (new MetaItem())->id('page_id')->defaultValue($parentId), 'name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'description' => (new PlainTextAreaBox())->id('description')->label('Description')->defaultValue($row ? $row->description : ''), 'section_id' => (new DropDown())->id('section_id')->nullable(false)->label('Category')->idField('id')->nameField('name')->rows(Section::where('single', '=', 0)->where('template_id', '=', $page->template()->first()->id)->get())->defaultValue($row ? $row->section_id : '')]; }); $this->parentHeader = 'Edit Page'; parent::tableName('post-section'); }
function show() { $page = Page::find(Request::route('id1')); $views = []; $views[] = (new HeadingItem())->label($page->name)->views([(new ButtonItem())->target('_blank')->label("Open Page")->defaultValue($page->url)]); foreach ($page->template()->first()->sections()->get() as $sec) { $secViews = []; $header = "{$sec->name}"; $secButtons = []; $icon = null; foreach ($page->posts()->where('section_id', '=', $sec->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get() as $post) { $buttons = []; $buttons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"]; $buttons[] = ["label" => 'Delete', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/delete"]; if ($sec->single == 0) { $secViews[] = ViewUtils::box($post->name_formatted, (new PageSummaryPostsForm())->postViews($post->id), null, null, true, $buttons, 'fa-angle-double-right'); } else { $header = $post->section()->first()->name; //$post->name_formatted." - ". $secViews[] = ViewUtils::plain((new PageSummaryPostsForm())->postViews($post->id)); $secButtons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"]; // $secButtons[] = ["label"=>'Delete', "href"=>"/admin/manage-pages/".$page->id."/posts/".$post->id."/delete"]; $icon = 'fa-angle-double-right'; } } if ($sec->single == 0) { $secButtons[] = ["label" => 'Add Post', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"]; $secButtons[] = ["label" => 'Sort', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/sort"]; $icon = 'fa-bars'; } else { if (count($secViews) === 0) { $secButtons[] = ["label" => 'Create', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"]; } } $views[] = ViewUtils::box($header, $secViews, null, null, false, $secButtons, $icon); } // dd($page->posts()->first()->name); return ViewUtils::page($views); }
function show() { $page = Page::find(Request::route('id1')); return View::make('punto-cms::page-preview')->with('page', $page); }
function post() { $page = Page::find(Request::route("id1"))->copy(Input::get('name'), Input::get('description'), Input::get('url')); return Redirect::to("/admin/edit-pages/" . $page->id . "/view"); }
function openPage() { $url = Page::find(Request::route("id{$this->level}"))->url; return Redirect::to($url); }