本文整理汇总了PHP中Search::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::instance方法的具体用法?PHP Search::instance怎么用?PHP Search::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::instance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!Search::$instance) {
Search::$instance = new Search();
}
return Search::$instance;
}
示例2: newInstance
public static function newInstance()
{
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
示例3: newInstance
public static function newInstance($expired = false)
{
if (!self::$instance instanceof self) {
self::$instance = new self($expired);
}
return self::$instance;
}
示例4: getContentBody
function getContentBody()
{
return '';
$search = Input::instance()->get('search', '');
$r = Search::instance()->search($search);
return View::factory('search/results', $r)->render();
}
示例5: get_keyword
public function get_keyword()
{
$keyword = $this->param('keyword', NULL, TRUE);
$modules = $this->param('modules', NULL);
$driver = $this->param('driver', NULL);
$data = Search::instance($driver)->find_by_keyword($keyword, FALSE, $modules);
$this->response($data);
}
示例6: addurl
public function addurl()
{
// use a local file for purpose of demo.
$filename = MODPATH . "kosearch" . DIRECTORY_SEPARATOR . "examples" . DIRECTORY_SEPARATOR . "kohana_home.html";
// Note: the Search class is responsible for loading the Zend libraries, so as we
// want to instantiate Zend_Search_Lucene_Document_Html prior to calling singleton,
// we must first call Search::instance()->load_search_libs();
Search::instance()->load_search_libs();
$doc = Zend_Search_Lucene_Document_Html::loadHTMLFile($filename, TRUE, "utf-8");
Search::instance()->addDocument($doc);
$this->index('Kohana page successfully added ↓ <a href="#form2" title="scroll down">scroll down</a> ↓');
}
示例7: _search_by_keyword
/**
*
* @param Database_Query $query
*/
protected function _search_by_keyword(Database_Query $query, $only_title = FALSE)
{
if ($this->search_key === NULL or trim($this->search_key) == '') {
return $query;
}
$keyword = $this->_ctx->get($this->search_key);
if (empty($keyword)) {
return $query;
}
$ids = Search::instance()->find_by_keyword($keyword, $only_title, 'ds_' . $this->ds_id, NULL);
$ids = Arr::get($ids, 'ds_' . $this->ds_id);
if (!empty($ids)) {
return $query->where('d.id', 'in', array_keys($ids));
}
return $query;
}
示例8: count_total
/**
*
* @return integer
*/
public function count_total()
{
$keyword = $this->keyword();
$this->_total = Search::instance()->count_by_keyword($keyword, FALSE, $this->modules());
return $this->_total;
}
示例9: search_by_keyword
/**
* Метод используется для поиска по документам по ключевому слову.
*
* Ключевое слово передается в качестве $_GET запроса с ключем "keyword"
*
* @param Database_Query $query
* @return Database_Query
*/
public function search_by_keyword(Database_Query $query)
{
$keyword = Request::initial()->query('keyword');
if (empty($keyword)) {
return $query;
}
if ($this->_section->is_indexable()) {
$ids = Search::instance()->find_by_keyword($keyword, FALSE, 'ds_' . $this->_section->id(), NULL);
$ids = Arr::get($ids, 'ds_' . $this->_section->id());
if (!empty($ids)) {
$query->where('d.id', 'in', array_keys($ids));
} else {
$query->where('d.id', '=', 0);
}
} else {
$query->where_open()->where('d.id', 'like', '%' . $keyword . '%')->or_where('d.header', 'like', '%' . $keyword . '%')->where_close();
}
return $query;
}
示例10: get_search_result
private function get_search_result()
{
if(!isset($this->search_result))
{
global $container;
$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
$posts = $repository->getActivePosts();
$this->search_result = Search::instance()
->setQuery($this->query)
->setResult($posts)
->setWeight(self::$SEARCH_WEIGHTS)
->perform();
}
return $this->search_result;
}
示例11: remove_from_index
/**
* Удаление документов из поискового индекса
*
* @param array $ids
* @return \Datasource_Section
*/
public function remove_from_index(array $ids = NULL)
{
if (!$this->is_indexable()) {
return $this;
}
Search::instance()->remove_from_index('ds_' . $this->id(), $ids);
}
示例12: count_total
/**
*
* @return integer
*/
public function count_total()
{
$keyword = $this->_ctx->get($this->search_key);
$this->_total = Search::instance()->count_by_keyword($keyword, FALSE, 'pages');
return $this->_total;
}
示例13: foreach
foreach ($parts as $id => $content) {
$part = ORM::factory('page_part', (int) $id);
if ((bool) $part->is_indexable) {
$indexable_content .= ' ' . $part->content;
}
if ($content == $part->content) {
continue;
}
$part->values(array('content' => $content))->save();
}
if (in_array($page->status_id, Model_Page_Front::get_statuses())) {
Search::instance()->add_to_index('pages', $page->id, $page->title, $indexable_content, '', array('uri' => $page->get_uri()));
} else {
Search::instance()->remove_from_index('pages', $page->id);
}
});
Observer::observe('update_search_index', function () {
$pages = ORM::factory('page')->find_all();
foreach ($pages as $page) {
$indexable_content = '';
$parts = ORM::factory('page_part')->where('page_id', '=', $page->id)->where('is_indexable', '=', 1)->find_all();
foreach ($parts as $part) {
$indexable_content .= ' ' . $part->content;
}
Search::instance()->add_to_index('pages', $page->id, $page->title, $indexable_content, '', array('uri' => $page->get_uri()));
}
});
// Чистка кеша частей страниц при редактирвании или удалении страницы
Observer::observe(array('page_add_after_save', 'page_edit_after_save', 'page_delete'), function ($page) {
Cache::instance()->delete_tag('page_parts');
});