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


PHP Search::query方法代码示例

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


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

示例1: run

 public static function run($scope, $query)
 {
     self::$enterprise = 'enterprise' === $scope;
     if (' ' !== $query[0]) {
         return '';
     }
     $query = ltrim($query);
     self::$query = $query;
     self::$parts = $parts = explode(' ', $query);
     Workflow::init(self::$enterprise, $query);
     if (Workflow::checkUpdate()) {
         self::addUpdateCommands();
         return Workflow::getItemsAsXml();
     }
     if (self::$enterprise && !Workflow::getBaseUrl()) {
         self::addEnterpriseUrlCommand();
         return Workflow::getItemsAsXml();
     }
     if (!Workflow::getAccessToken() || !(self::$user = Workflow::requestApi('/user'))) {
         self::addLoginCommands();
         return Workflow::getItemsAsXml();
     }
     Workflow::stopServer();
     $isSystem = isset($query[0]) && $query[0] == '>';
     $isMy = 'my' == $parts[0] && isset($parts[1]);
     $isUser = isset($query[0]) && $query[0] == '@';
     $isRepo = false;
     $queryUser = null;
     if ($isUser) {
         $queryUser = ltrim($parts[0], '@');
     } elseif (($pos = strpos($parts[0], '/')) !== false) {
         $queryUser = substr($parts[0], 0, $pos);
         $isRepo = true;
     }
     if ($isSystem) {
         self::addSystemCommands();
         Workflow::sortItems();
     } else {
         if ($isMy) {
             self::addMyCommands();
         } elseif ($isUser && isset($parts[1])) {
             self::addUserSubCommands($queryUser);
         } elseif (!$isUser && $isRepo && isset($parts[1])) {
             self::addRepoSubCommands();
         } else {
             self::addDefaultCommands($isUser, $isRepo, $queryUser);
         }
         Workflow::sortItems();
         if ($query) {
             if (!$isUser && $isRepo && isset($parts[1])) {
                 $repoQuery = substr($query, strlen($parts[0]) + 1);
                 Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
             }
             $path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
             $name = self::$enterprise ? 'GitHub Enterprise' : 'GitHub';
             Workflow::addItem(Item::create()->title("Search {$name} for '{$query}'")->icon('search')->arg('/' . $path)->autocomplete(false), false);
         }
     }
     return Workflow::getItemsAsXml();
 }
开发者ID:rfoxfa,项目名称:local-files,代码行数:60,代码来源:search.php

示例2: indexAction

 public function indexAction()
 {
     $key = $this->getRequest()->get('kw');
     $orderby = $this->getRequest()->get('od');
     $page = $this->getRequest()->get('page', 1);
     // $router = \Yaf\Dispatcher::getInstance()->getRouter();
     // $config = \Yaf\Application::app()->getConfig();
     $search = new Search();
     $search->setQ($key);
     $search->setPage($page);
     if (!empty($orderby)) {
         $search->setSortby($orderby);
     }
     $res = $search->query();
     $pages = 1;
     $films = null;
     if ($res) {
         $pages = empty($res['pages']) ? 1 : $res['pages'];
         if (isset($res['matches'])) {
             foreach ($res['matches'] as $match) {
                 $ids[] = $match['id'];
             }
             $conn = new MyPDO();
             $films = $conn->table('film')->select('*')->where('id in (' . implode(',', $ids) . ')')->orderBy('order by find_in_set (id, \'' . implode(',', $ids) . '\')')->execute();
         }
     }
     $this->_view->assign('films', $films);
     $this->_view->assign('kw', $key);
     $this->_view->assign('orderby', $orderby);
     $this->_view->assign('page', $page);
     $this->_view->assign('pages', $pages);
 }
开发者ID:RaiseFree,项目名称:btsousuo,代码行数:32,代码来源:Search.php

示例3: solrSearch

 /**
  * Search with solr & prepare data for output
  *
  * @param $p options
  * @param $prepare bool
  */
 private function solrSearch($p, $prepare = false)
 {
     // skip grid params
     unset($p->grid);
     $p->fl = 'id, pid, path, name, template_type, system, ' . 'size, date, date_end, oid, cid, cdate, uid, udate, case_id, acl_count, ' . 'case, template_id, task_u_assignee, status, task_d_closed, versions, ' . 'case_violation_resolved, case_violation_unresolved, cfg, type, nid, ' . 'search_hash, case_hash';
     $s = new Search();
     return $s->query($p);
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:14,代码来源:Instance.php

示例4: index

 public function index($arguments)
 {
     Layout::set('title', 'Search');
     if (empty($_POST['query'])) {
         return Error::set('No search query found.');
     }
     $query = substr(trim(htmlentities($_POST['query'], ENT_QUOTES, 'ISO8859-1', false)), 0, 250);
     $results = Search::query($query);
     if ($results['hits']['total'] == 0) {
         return Error::set('No results found.');
     }
     $this->view['results'] = array();
     $news = new news(ConnectionFactory::get('mongo'));
     $articles = new articles(ConnectionFactory::get('mongo'));
     $lectures = new lectures(ConnectionFactory::get('mongo'));
     $i = 1;
     if (empty($results['hits']['hits'])) {
         return;
     }
     foreach ($results['hits']['hits'] as $result) {
         $entry = $result['_source'];
         switch ($entry['type']) {
             case 'news':
                 $post = $news->get($result['_id'], false, true);
                 if (empty($post)) {
                     continue;
                 }
                 $post['type'] = 'news';
                 array_push($this->view['results'], $post);
                 break;
             case 'article':
                 $article = $articles->get($result['_id'], false, true);
                 if (empty($article)) {
                     continue;
                 }
                 $article['type'] = 'article';
                 array_push($this->view['results'], $article);
                 break;
             case 'lecture':
                 $lecture = $lectures->get($result['_id'], false, true);
                 if (empty($lecture)) {
                     continue;
                 }
                 $lecture['type'] = 'lecture';
                 array_push($this->view['results'], $lecture);
                 break;
         }
         if ($i == 5) {
             break;
         }
         ++$i;
     }
 }
开发者ID:Zandemmer,项目名称:HackThisSite-Old,代码行数:53,代码来源:search.php

示例5: run

 public static function run($query)
 {
     self::$query = $query;
     self::$parts = $parts = explode(' ', $query);
     Workflow::init($query);
     if (Workflow::checkUpdate()) {
         self::addUpdateCommands();
         return Workflow::getItemsAsXml();
     }
     if (!Workflow::getConfig('access_token') || !(self::$user = Workflow::requestGithubApi('/user'))) {
         self::addLoginCommands();
         return Workflow::getItemsAsXml();
     }
     Workflow::stopServer();
     $isSystem = isset($query[0]) && $query[0] == '>';
     $isMy = 'my' == $parts[0] && isset($parts[1]);
     $isUser = isset($query[0]) && $query[0] == '@';
     $isRepo = false;
     $queryUser = null;
     if ($isUser) {
         $queryUser = ltrim($parts[0], '@');
     } elseif (($pos = strpos($parts[0], '/')) !== false) {
         $queryUser = substr($parts[0], 0, $pos);
         $isRepo = true;
     }
     if ($isSystem) {
         self::addSystemCommands();
         Workflow::sortItems();
     } else {
         if ($isMy) {
             self::addMyCommands();
         } elseif ($isUser && isset($parts[1])) {
             self::addUserSubCommands($queryUser);
         } elseif (!$isUser && $isRepo && isset($parts[1])) {
             self::addRepoSubCommands();
         } else {
             self::addDefaultCommands($isUser, $isRepo, $queryUser);
         }
         Workflow::sortItems();
         if ($query) {
             if (!$isUser && $isRepo && isset($parts[1])) {
                 $repoQuery = substr($query, strlen($parts[0]) + 1);
                 Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('https://github.com/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
             }
             $path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
             Workflow::addItem(Item::create()->title("Search GitHub for '{$query}'")->icon('search')->arg('https://github.com/' . $path)->autocomplete(false), false);
         }
     }
     return Workflow::getItemsAsXml();
 }
开发者ID:regedor,项目名称:alfred-github-workflow,代码行数:50,代码来源:search.php

示例6: results

 public function results($query)
 {
     if (!empty($query)) {
         // cleanup, convert, replace, strip...
         $query = Fari_Decode::url($query);
         $query = preg_replace('~\\s{2,}~', ' ', implode(' ', explode('-', strtolower($query))));
         $query = substr($query, -1) == ' ' ? substr($query, 0, -1) : $query;
         // trailing space
         $query = substr($query, 0, 1) == ' ' ? substr($query, 1) : $query;
         // leading space
         $this->view->query = $query = Fari_Escape::alpha($query);
         $this->view->keywords = implode('-', explode(' ', $query));
         // implode back to have clean keywords
     } else {
         $this->redirect('/');
         die;
     }
     // fetch the result and add relevance to it
     $this->view->result = Search::query($query);
     $this->view->display('results');
 }
开发者ID:radekstepan,项目名称:Knowledgebase,代码行数:21,代码来源:search.php

示例7: thread_post_get

function thread_post_get()
{
    global $DB;
    $Search = new Search();
    $offset = cmd(3, true) ? cmd(3, true) * 100 : 0;
    $res = $Search->query(cmd(2), "thread_post", $offset);
    $ids = array_keys($res['matches']);
    $page = cmd(3, true) + 1;
    $Query = new BoardQuery();
    $View = new BoardView();
    $View->type(VIEW_THREAD_SEARCH);
    $View->title("Search Thread Posts: " . htmlentities(cmd(2)));
    $View->subtitle(number_format($res['total']) . " results found showing " . ($offset ? $offset : 1) . "-" . ($offset + 100) . SPACE . ARROW_RIGHT . SPACE . "page: {$page}");
    $View->header(false);
    require_once DIR . "module/search/.content/main.php";
    $View->header_menu();
    if ($res['total'] == 0) {
        $ids = array(0);
    }
    $DB->query($Query->view_thread(false, cmd(3, true), cmd(4, true), $ids));
    $View->data($DB->load_all());
    $View->thread();
    $View->footer();
}
开发者ID:jmichaelward,项目名称:pgBoard,代码行数:24,代码来源:get.php

示例8: pagelist

 public function pagelist($where, $template = null, $order = null, $under = null, $filter = null, $keyword = null, $param = "q", $inclusive = false)
 {
     $p = new \Phile\Repository\Page();
     $settings = \Phile\Registry::get('Phile_Settings');
     if ($order) {
         $settings = array_merge($settings, array('pages_order' => $order));
     }
     if (!$template) {
         $template = "pagelist-default";
         $this->templateDir = PLUGINS_DIR . "infostreams/pagelistSnippet/Templates";
     }
     $all = $p->findAll($settings);
     $list = array();
     if (is_array($where)) {
         // user provided a list of pages
         // - we obtain those from '$all' to make sure any provided sorting order is applied
         $where = array_map('trim', $where);
         foreach ($all as $p) {
             if (in_array($p->getUrl(), $where)) {
                 $list[] = $p;
             }
         }
     } else {
         // user provided a keyword, such as 'all', 'below' or 'search'
         switch ($where) {
             default:
             case "below":
             case "search":
                 $root = null;
                 if ($under) {
                     $p = new \Phile\Repository\Page();
                     $root = $p->findByPath($under);
                 }
                 // for 'search', we support providing an 'under' argument
                 if ($where == "search" && $root == null) {
                     // however, if it isn't provided, we default to searching all pages
                     $list = $all;
                     break;
                 }
                 if (!$root) {
                     $root = $this->currentPage;
                 }
                 $root_dir = dirname($root->getFilePath());
                 $inclusive = $this->isTrue($inclusive);
                 foreach ($all as $p) {
                     if (strpos($p->getFilePath(), $root_dir) !== false) {
                         if ($inclusive || !$inclusive && $p->getFilePath() != $root->getFilePath()) {
                             $list[] = $p;
                         }
                     }
                 }
                 break;
             case "all":
                 $list = $all;
                 break;
         }
         // once we have obtained a base list of pages, we can search and filter
         if ($where == "search") {
             if (array_key_exists($param, $_GET)) {
                 // retrieve the keyword so we know what to search for,
                 $keyword = urldecode($_GET[$param]);
                 // ... and then remove it from the $_GET array to make sure
                 // that we don't run the search again if we come across a page
                 // that contains another (pagelist: search) snippet.
                 //
                 // This fixes https://github.com/infostreams/pagelist-snippet/issues/4
                 unset($_GET[$param]);
                 $search = new Search($list);
                 $list = $search->query($keyword);
             } else {
                 $list = array();
             }
         }
     }
     if (!is_null($filter) && is_array($filter)) {
         // apply filter to filter by meta tag
         $filter_count = count($filter);
         foreach ($list as $i => $p) {
             $match_count = 0;
             foreach ($filter as $k => $v) {
                 // Check if each filter matches.
                 // Filters can be specified as regular expressions.
                 if (preg_match('/' . trim($v, '/') . '/', $p->getMeta()->{$k})) {
                     $match_count++;
                 }
             }
             if ($match_count != $filter_count) {
                 // if one or more filters don't match, then remove this page from the list
                 unset($list[$i]);
             }
         }
         // renumber filtered list
         $list = array_values($list);
     }
     // if the user provides a keyword to filter/search, do that now
     if (!is_null($keyword)) {
         foreach ($list as $i => $l) {
             if ($l == $this->currentPage) {
                 unset($list[$i]);
                 break;
//.........这里部分代码省略.........
开发者ID:infostreams,项目名称:pagelist-snippet,代码行数:101,代码来源:PagelistSnippet.php

示例9: query

    public function query($query)
    {
        $dir = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR;
        $jsonDir = $dir . "json";
        $indexDir = $dir . "index";
        // Percorre os indices
        $files = scandir($jsonDir);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $indexName = substr($file, 0, -5);
            $index = Lucene\Lucene::open($indexDir . DIRECTORY_SEPARATOR . $indexName);
            // Abre index
            $hits = $index->find($query);
            // Executa query
            // Lista resultados
            foreach ($hits as $hit) {
                $document = $hit->getDocument();
                // return a Zend\Search\Lucene\Field object
                // from the Zend\Search\Lucene\Document
                echo "<h3>" . $document->getFieldValue('url') . "</h3><br />";
                //echo "<p>" . $hit->text . "</p><br /><br />";
            }
        }
    }
}
$q = !empty($_GET['q']) ? $_GET['q'] : 'CBF';
$sc = new Search();
$sc->query($q);
开发者ID:highestgoodlikewater,项目名称:InformationRetrieval,代码行数:30,代码来源:Search.php

示例10: catch

    } else {
        if (!empty($_GET["location"])) {
            $title = $_GET["location"];
        } else {
            if (!empty($_GET["date"])) {
                $title = $_GET["date"];
            } else {
                if (!empty($_GET["user"])) {
                    $title = $_GET["user"];
                }
            }
        }
    }
}
try {
    $Search->setInclude($_GET["q"]);
    $Search->setTags($_GET["tags"]);
    $Search->setLocation($_GET["location"]);
    $Search->setDate($_GET["date"]);
    $Search->setUser($_GET["user"]);
} catch (Exception $e) {
    echo $e->getMessage();
}
if (!isset($Feed)) {
    $Feed = new Feed($Database);
}
$eventCount = 0;
foreach ($Search->query() as $status) {
    require $baseDir . 'includes/templates/feed_box.php';
    $eventCount++;
}
开发者ID:alexkonetchy,项目名称:social-calendar,代码行数:31,代码来源:search_results.php


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