Retrieves a list of models based on the current search/filter conditions.
public search ( ) : CActiveDataProvider | ||
리턴 | CActiveDataProvider | the data provider that can return the models based on the search/filter conditions. |
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); }
function search($terms) { $posts = Post::search($terms)->get(); return View::make('pages.frontpage', ['posts' => $posts]); }
* Search */ Route::get(array('search', 'search/(:any)', 'search/(:any)/(:num)'), function ($slug = '', $offset = 1) { // mock search page $page = new Page(); $page->id = 0; $page->title = 'Search'; $page->slug = 'search'; // get search term $term = filter_var($slug, FILTER_SANITIZE_STRING); Session::put(slug($term), $term); //$term = Session::get($slug); //this was for POST only searches // revert double-dashes back to spaces $term = str_replace('--', ' ', $term); if ($offset > 0) { list($total, $posts) = Post::search($term, $offset, Config::meta('posts_per_page')); } else { return Response::create(new Template('404'), 404); } // search templating vars Registry::set('page', $page); Registry::set('page_offset', $offset); Registry::set('search_term', $term); Registry::set('search_results', new Items($posts)); Registry::set('total_posts', $total); return new Template('search'); }); Route::post('search', function () { // search and save search ID $term = filter_var(Input::get('term', ''), FILTER_SANITIZE_STRING); // replace spaces with double-dash to pass through url
<?php require_once '../lib/YahooMeme.class.php'; $meme = new Meme(); print "<h2>[info about bigo]</h2> <br />"; print $meme->get("bigodines")->toString(true); print "<h2>[people following bigodines]</h2> <br/>"; $repo = new MemeRepository(); foreach ($repo->following("bigodines") as $row) { print $row->toString() . "<br />"; } print "<h2>[bigo latest 5 posts]</h2>"; foreach ($meme->get("bigodines")->getPosts(0, 5) as $row) { print $row->toString() . "<br />\n"; } print "<h2>[meme popular posts]</h2> <br />"; $post = new Post(); foreach ($post->popular() as $row) { print $row->toString() . "<br />"; } print "<h2>[latest 5 posts from meme]</h2> <br />"; foreach ($post->search('sort:cdate', 0, 5) as $row) { print $row->toString() . "<br />\n"; }
* Search */ Route::get(array('search', 'search/(:any)', 'search/(:any)/(:num)'), function ($slug = '', $offset = 1) { // mock search page $page = new Page(); $page->id = 0; $page->title = 'Search'; $page->slug = 'search'; // get search term $term = filter_var($slug, FILTER_SANITIZE_STRING); Session::put(slug($term), $term); //$term = Session::get($slug); //this was for POST only searches // revert double-dashes back to spaces $term = str_replace('--', ' ', $term); if ($offset > 0) { list($total, $posts) = Post::search($term, $offset, Post::perPage()); } else { return Response::create(new Template('404'), 404); } // search templating vars Registry::set('page', $page); Registry::set('page_offset', $offset); Registry::set('search_term', $term); Registry::set('search_results', new Items($posts)); Registry::set('total_posts', $total); return new Template('search'); }); Route::post('search', function () { // search and save search ID $term = filter_var(Input::get('term', ''), FILTER_SANITIZE_STRING); // replace spaces with double-dash to pass through url
$page->id = 0; $page->title = 'Search'; $page->slug = 'search'; if ($offset <= 0) { return Response::create(new Template('404'), 404); } // Convert custom escaped characters and escape MySQL special characters. // http://stackoverflow.com/questions/712580/list-of-special-characters-for-sql-like-clause $term = str_replace(array('-sl-', '-bsl-', '-sp-', '%', '_'), array('/', '\\\\', ' ', '\\%', '\\_'), $slug); // Posts, pages, or all if ($whatSearching === 'posts') { list($total, $results) = Post::search($term, $offset, Post::perPage()); } elseif ($whatSearching === 'pages') { list($total, $results) = Page::search($term, $offset); } else { $postResults = Post::search($term, $offset, Post::perPage()); $pageResults = Page::search($term, $offset); $total = $postResults[0] + $pageResults[0]; $results = array_merge($postResults[1], $pageResults[1]); } // search templating vars $safeTerm = eq(str_replace(array('\\\\', '\\%', '\\_'), array('\\', '%', '_'), $term)); Registry::set('page', $page); Registry::set('page_offset', $offset); Registry::set('search_term', $safeTerm); Registry::set('search_results', new Items($results)); Registry::set('total_posts', $total); return new Template('search'); }); Route::post('search', function () { // Search term, placeholders for / and \
public function actionJobs() { $model = new Post('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Post'])) { $model->attributes = $_GET['Post']; } //send model object for search $this->render('jobs', array('dataProvider' => $model->search(), 'model' => $model)); }
/** * search * * @return Response */ public function search() { $query = Input::get('q'); $page = Input::get('page'); $posts = []; if ($query) { $posts = Post::search($query); } if (count($posts)) { $url = sprintf('/search?q=%s&page=:page', rawurlencode($query)); $paginator = Paginator::get($posts, $page, $url); } else { $paginator = null; } $html = Layout::find('search')->render(['search' => true, 'query' => $query, 'paginator' => $paginator]); return Response::make($html); }
public function search($slug) { $posts = Post::search($slug); REST::returnJson(['status' => 'search', 'posts' => $posts]); }