当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::search方法代码示例

本文整理汇总了PHP中Post::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::search方法的具体用法?PHP Post::search怎么用?PHP Post::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Post的用法示例。


在下文中一共展示了Post::search方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: results

 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);
 }
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:12,代码来源:SearchController.php

示例2: search

 function search($terms)
 {
     $posts = Post::search($terms)->get();
     return View::make('pages.frontpage', ['posts' => $posts]);
 }
开发者ID:Geekathon,项目名称:reddit-clone,代码行数:5,代码来源:PageController.php

示例3: function

 * 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
开发者ID:gautamkrishnar,项目名称:Anchor-CMS-openshift-quickstart,代码行数:31,代码来源:site.php

示例4: Meme

<?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";
}
开发者ID:bigodines,项目名称:meme-php,代码行数:24,代码来源:simpleExample.php

示例5: function

 * 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
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:31,代码来源:site.php

示例6: Template

    $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 \
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:31,代码来源:site.php

示例7: actionJobs

 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));
 }
开发者ID:djeyakumar,项目名称:aircpit,代码行数:11,代码来源:PostController.php

示例8: search

 /**
  * 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);
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:22,代码来源:SiteController.php

示例9: search

 public function search($slug)
 {
     $posts = Post::search($slug);
     REST::returnJson(['status' => 'search', 'posts' => $posts]);
 }
开发者ID:AndreAntunesVieira,项目名称:EstacaoGamer,代码行数:5,代码来源:PostsController.php


注:本文中的Post::search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。