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


PHP Search::instance方法代码示例

本文整理汇总了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;
 }
开发者ID:rasstroen,项目名称:metro,代码行数:7,代码来源:Search.php

示例2: newInstance

 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:7,代码来源:Search.php

示例3: newInstance

 public static function newInstance($expired = false)
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self($expired);
     }
     return self::$instance;
 }
开发者ID:nsswaga,项目名称:OSClass,代码行数:7,代码来源:Search.php

示例4: getContentBody

 function getContentBody()
 {
     return '';
     $search = Input::instance()->get('search', '');
     $r = Search::instance()->search($search);
     return View::factory('search/results', $r)->render();
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:7,代码来源:AbstractSearchResultsPlugin.php

示例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);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:8,代码来源:search.php

示例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 &darr;&nbsp;<a href="#form2" title="scroll down">scroll down</a>&nbsp;&darr;');
 }
开发者ID:ascseb,项目名称:kosearch,代码行数:12,代码来源:search_example.php

示例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;
 }
开发者ID:ortodesign,项目名称:cms,代码行数:20,代码来源:headline.php

示例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;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:10,代码来源:search.php

示例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;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:27,代码来源:headline.php

示例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;
	}
开发者ID:jacobemerick,项目名称:web,代码行数:16,代码来源:SearchController.class.inc.php

示例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);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:13,代码来源:section.php

示例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;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:10,代码来源:search.php

示例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');
});
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:31,代码来源:init.php


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