示例#1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  */
 public function show($id)
 {
     // if exist external content then send it to browser, increment views
     $external_content = $this->showPage->checkAndGetContentFromHtmlFile(app('veer')->siteId, $id);
     if (!empty($external_content)) {
         \Veer\Models\Page::where('id', '=', $id)->increment('views');
         return \Response::make($external_content, 200)->header('Content-type', 'text/html');
     }
     $page = $this->showPage->getPage($id, app('veer')->siteId);
     if (!is_object($page)) {
         return Redirect::route('page.index');
     }
     $page->increment('views');
     $page->load(array('images' => function ($q) {
         return $q->orderBy('pivot_id', 'asc');
     }, 'tags', 'attributes', 'downloads', 'userlists', 'user'));
     $page->imagesIds = collect($page->images->getDictionary());
     if ($page->show_comments == 1) {
         $this->showPage->loadComments($page, 'page');
     }
     $paginator_and_sorting = get_paginator_and_sorting();
     $data = array("page" => $page, "subpages" => $this->showPage->withChildPages(app('veer')->siteId, $page->id, $paginator_and_sorting), "parentpages" => $this->showPage->withParentPages(app('veer')->siteId, $page->id, $paginator_and_sorting), "products" => $this->showPage->withProducts(app('veer')->siteId, $page->id, $paginator_and_sorting), "categories" => $this->showPage->withCategories(app('veer')->siteId, $page->id), "template" => $this->template);
     $blade_path = $this->template . '.pages.' . $id;
     $viewLink = $this->template . '.page';
     // page with special design
     if ($page->original == 1 && \View::exists($blade_path)) {
         $viewLink = $blade_path;
     }
     $view = viewx($viewLink, $data);
     $this->view = $view;
     return $view;
 }
示例#2
0
 public function add($data, $relation = null, $attach_id = null, $returnId = true)
 {
     $prefix = 'fl';
     $model = null;
     switch ($relation) {
         case 'products':
             $model = \Veer\Models\Product::find($attach_id);
             $prefix = 'prd';
             break;
         case 'pages':
             $model = \Veer\Models\Page::find($attach_id);
             $prefix = 'pg';
             break;
         case 'categories':
             $model = \Veer\Models\Category::find($attach_id);
             $prefix = 'ct';
             break;
         case 'users':
             $model = \Veer\Models\User::find($attach_id);
             $prefix = 'usr';
             break;
     }
     $id = $this->upload('image', 'uploadImage', $attach_id, $model, $prefix, null, is_object($model) ? false : true, $data);
     return $returnId ? $id : $this;
 }
示例#3
0
 /**
  * Query Builder: 
  * 
  * - who: 1 Page
  * - with: 
  * - to whom: make() | page/{id}
  */
 public function getPage($id, $siteId = null)
 {
     $field = !is_numeric($id) ? "url" : "id";
     $page = \Veer\Models\Page::where($field, '=', $id);
     if (!empty($siteId)) {
         $page = $page->excludeHidden()->sitevalidation($siteId);
     }
     return $page->first();
 }
示例#4
0
 /**
  * Handle user login events.
  */
 public function getNeighbours($event = null)
 {
     $this->pageId = $event;
     $this->data['exists'] = false;
     $this->data['previous'] = \Veer\Models\Page::where('id', '<', $this->pageId)->sitevalidation(app('veer')->siteId)->excludeHidden()->select('title', 'id', 'url')->orderBy('id', 'desc')->first();
     $this->data['next'] = \Veer\Models\Page::where('id', '>', $this->pageId)->sitevalidation(app('veer')->siteId)->excludeHidden()->select('title', 'id', 'url')->orderBy('id', 'asc')->first();
     if (count($this->data['previous']) > 0 || count($this->data['next']) > 0) {
         $this->data['exists'] = true;
     }
     app('veer')->loadedComponents['event']['neighbours'] = $this->data;
 }
示例#5
0
 protected function getPages($category, $queueCategory)
 {
     return \Veer\Models\Page::whereHas('categories', function ($q) use($category) {
         $q->where(function ($query) use($category) {
             $query->where('categories_id', '=', $category);
         });
     })->whereHas('categories', function ($q) use($queueCategory) {
         $q->where(function ($query) use($queueCategory) {
             $query->where('categories_id', '=', $queueCategory);
         });
     })->with(array('images' => function ($query) {
         $query->orderBy('pivot_id', 'asc');
     }))->sitevalidation(app('veer')->siteId)->where('hidden', '=', 1)->orderBy('manual_order', 'asc')->orderBy('created_at', 'asc')->take($this->number_of_items)->select('id', 'url', 'title', 'small_txt', 'views', 'created_at', 'users_id', 'hidden')->get();
 }
示例#6
0
 /**
  * Add page or product to user list
  */
 public function addToList($type = null, $id = null)
 {
     if (!empty($id)) {
         switch ($type) {
             case "product":
                 $e = \Veer\Models\Product::sitevalidation(app('veer')->siteId)->where('id', '=', $id)->checked()->first();
                 break;
             case "page":
                 $e = \Veer\Models\Page::sitevalidation(app('veer')->siteId)->where('id', '=', $id)->excludeHidden()->first();
                 break;
         }
         if (is_object($e)) {
             $this->savingEntity($e, \Auth::id(), \Input::get('name', '[basket]'));
         }
     }
     return $this->showUser->getUserLists(app('veer')->siteId, \Auth::id(), app('session')->getId(), \Input::get('name', '[basket]'));
 }
示例#7
0
 public function fire($job, $data)
 {
     $ids = array_get($data, 'ids', null);
     if (empty($ids) || !is_array($ids)) {
         return $job->fail();
     }
     $notfound = true;
     foreach ($ids as $id) {
         $page = \Veer\Models\Page::find($id);
         if (is_object($page)) {
             $page->hidden = false;
             $page->save();
             $notfound = false;
         }
     }
     if ($notfound == true) {
         return $job->fail();
     }
     // leave it here
     if (isset($data['repeatJob']) && $data['repeatJob'] > 0) {
         $job->release($data['repeatJob'], 'minutes');
     }
 }
示例#8
0
 /**
  * Sort pages. Max 24 per batch (depends on pagination).
  *
  * @param array $data
  * @return \Veer\Services\Administration\Elements\Page
  */
 public function sort($data)
 {
     if (empty($data) || !is_array($data)) {
         return $this;
     }
     $url_params = array_get($data, '_refurl');
     $parse_str = $data;
     if (!empty($url_params)) {
         parse_str(starts_with($url_params, '?') ? substr($url_params, 1) : $url_params, $parse_str);
         if (!empty($parse_str['page'])) {
             \Input::merge(['page' => $parse_str['page']]);
         }
     }
     $parse_str += ['filter' => null, 'filter_id' => null, 'sort' => null, 'sort_direction' => null, 'page' => 1];
     $pages = new \Veer\Services\Show\Page();
     $oldsorting = $pages->getAllPages([[$parse_str['filter'] => $parse_str['filter_id']], [$parse_str['sort'] => $parse_str['sort_direction']]]);
     if (is_object($oldsorting)) {
         $bottom_sort = $oldsorting[count($oldsorting) - 1]->manual_order;
         $sort = $oldsorting[0]->manual_order;
         foreach ($this->sortElementsEntities($oldsorting, $data) as $id) {
             if ($sort < $bottom_sort && $parse_str['sort_direction'] == 'desc') {
                 $sort = $bottom_sort;
             }
             if ($sort > $bottom_sort && $parse_str['sort_direction'] == 'asc') {
                 $sort = $bottom_sort;
             }
             \Veer\Models\Page::where('id', '=', $id)->update(['manual_order' => $sort]);
             if ($parse_str['sort_direction'] == 'desc') {
                 $sort--;
             } else {
                 $sort++;
             }
         }
     }
     return $this;
 }
 /**
  * @group request
  */
 public function testRequestSort()
 {
     $all = \Veer\Models\Page::take(24)->get()->sortBy('manual_order');
     if ($all->count() <= 2) {
         $this->testRepeatAdd();
         $all = \Veer\Models\Page::take(24)->get()->sortBy('manual_order');
     }
     $first = $all->first();
     $last = $all->last();
     $this->sendAdminRequest(['action' => 'sort', 'oldindex' => $all->count() - 1, 'newindex' => 0, 'parentid' => '', '_refurl' => '?sort=manual_order&sort_direction=asc&page=1', 'sort' => 'manual_order', 'sort_direction' => 'asc']);
     $all = \Veer\Models\Page::take(24)->get()->sortBy('manual_order');
     $new_first = $all->first();
     $this->assertResponseOk();
     $this->assertNotEquals($first->id, $new_first->id);
     $this->assertEquals($last->id, $new_first->id);
 }
示例#10
0
 /**
  * Register Pages
  * 
  * 
  * @param string $src
  */
 protected function registerPages($src)
 {
     $this->loadedComponents['page'][$src] = \Veer\Models\Page::find($src);
 }