public function results() { $keywords = Input::get('words'); $this->data['words'] = strip_tags($keywords); $this->data['results'] = Post::search($keywords); if (count($this->data['results']) === 1) { return Illuminate\Support\Facades\Redirect::to(WebAPL\Language::url('topost/' . $this->data['results'][0]->id)); } WebAPL\Template::setPageTitle("Search: {$this->data['words']}", true); PageController::loadGeneralResources(); $this->layout->content = View::make('sections.search.results', $this->data); }
public function route($query = '') { $parts = explode('/', $query); if ($parts) { $uri = end($parts); $this->data['page'] = Post::findURI($uri, 1); if ($this->data['page']) { PostResources::init(); // Verify if page is redirectable if ($this->data['page']->redirect_to) { $redirect_url = Post::getFullURI($this->data['page']->redirect_to); if ($redirect_url) { return Redirect::to($redirect_url); } } // Verify if page is redirectable if ($this->data['page']->redirect_to) { $redirect_url = Post::getFullURI($this->data['page']->redirect_to); if ($redirect_url) { return Redirect::to($redirect_url); } } Template::clearBreadCrumbs(); Template::addBreadCrumb("/", varlang('acasa')); // Get pages resources $this->data['parents'] = Post::getParents($this->data['page']['parent'], 1); $this->data['parent'] = Post::findID($this->data['page']['parent'], 1); $this->data['colevels'] = Post::findWithParent($this->data['page']['parent']); $this->data['super_parent'] = array_first($this->data['parents'], function ($key, $item) { return $item['parent'] == 0; }); // get real page URI $segments = array(); $parrents_ids = array($this->data['page']->id); foreach (array_reverse($this->data['parents']) as $parrent) { $segments[] = $parrent['uri']; $parrents_ids[] = $parrent['id']; Template::addBreadCrumb(Post::getURL(implode('/', $segments)), $parrent['title']); } $segments[] = $this->data['page']['uri']; Template::addBreadCrumb(Post::getURL($query), $this->data['page']['title']); $realURI = implode('/', $segments); // Verify if real uri is correct if ($realURI === $query) { // get global data View::share(array('active_page_id' => $this->data['page']->id, 'parrents_ids' => $parrents_ids, 'super_parent' => $this->data['super_parent'])); // Verify if this page is clone if ($this->data['page']->clone_id) { $clone = Post::findID($this->data['page']->clone_id, 1); if ($clone) { $this->data['page'] = $clone; } } // Set page title $this->data['top_title'] = $this->data['page']['title']; WebAPL\Template::setPageTitle($this->data['page']['title']); $this->data['page_url'] = WebAPL\Language::url("page/" . $realURI); // Get page files if ($this->data['page']->show_files) { $this->data['page']['files'] = Files::where(array('module_name' => 'page', 'module_id' => $this->data['page']->id, 'type' => 'document'))->remember(SettingsModel::one('cachelife'))->get(); } else { $this->data['page']['files'] = array(); } // register one view Post::oneView($this->data['page']['id']); Template::setMetaMultiple(array('og:title' => $this->data['page']->title, 'description' => $this->data['page']->text, 'og:description' => $this->data['page']->text), true); // load page PageController::loadGeneralResources(); View::share('page', $this->data['page']); if ($this->data['page']->general_node) { return $this->loadHome(); } else { return $this->loadPage(); } } else { throw new Exception("Query '{$query}' is not valid", 404); } } else { throw new Exception("Page with uri '{$uri}' not found", 404); } } else { throw new Exception("No valid page URI", 404); } }