本文整理汇总了PHP中search类的典型用法代码示例。如果您正苦于以下问题:PHP search类的具体用法?PHP search怎么用?PHP search使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了search类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjectPoolBySolrQuery
static function getObjectPoolBySolrQuery($solr_query = null)
{
include_once drupal_get_path('module', 'apiary_project') . '/workflow/include/search.php';
$solr_search = new search();
$specimen_list = array();
if (strpos(strtolower($solr_query), 'q=') > -1) {
} else {
$solr_query = 'q=' . $solr_query;
}
if (strpos(strtolower($solr_query), '&rows=') > -1) {
} else {
$solr_query .= '&rows=10000';
}
$solr_results = $solr_search->doSearch($solr_query);
if ($solr_results != false) {
$solr_sxml = new SimpleXMLElement($solr_results);
foreach ($solr_sxml->result[0]->doc as $doc) {
foreach ($doc->children() as $sxml_node) {
$node_value = (string) $sxml_node;
if (strpos($node_value, 'ap-specimen:') > -1) {
if (!array_search($node_value, $specimen_list)) {
array_push($specimen_list, $node_value);
}
}
}
}
}
return $specimen_list;
}
示例2: generate_rss
public function generate_rss($context, $hash)
{
global $opac_url_base, $dbh;
$this->notices_list = array();
$mc = unserialize($context);
$search = new search($mc["search_type"]);
$search->unserialize_search(serialize($mc["serialized_search"]));
$table = $search->make_search();
$q = "select distinct notice_id from {$table} ";
$res = pmb_mysql_query($q, $dbh);
if (pmb_mysql_num_rows($res)) {
while ($row = pmb_mysql_fetch_object($res)) {
$this->notices_list[] = $row->notice_id;
}
}
$flux = new newrecords_flux(0);
$flux->setRecords($this->notices_list);
$flux->setLink($opac_url_base . "s.php?h={$hash}");
$flux->setDescription(strip_tags($mc["human_query"]));
$flux->xmlfile();
if (!$flux->envoi) {
return;
}
@header('Content-type: text/xml');
echo $flux->envoi;
}
示例3: page_not_found
public function page_not_found()
{
global $router;
$params = $router->params;
unset($params['controller']);
unset($params['action']);
$terms = empty($params[0]) ? '' : $params[0];
expCSS::pushToHead(array("unique" => "search-results", "link" => $this->asset_path . "css/results.css"));
$search = new search();
$page = new expPaginator(array('model' => 'search', 'controller' => $this->params['controller'], 'action' => $this->params['action'], 'records' => $search->getSearchResults(implode(' ', $params)), 'order' => 'score', 'dir' => 'DESC'));
assign_to_template(array('page' => $page, 'terms' => $terms));
}
示例4: getTextBySection
public function getTextBySection($section)
{
global $db;
$id = is_object($section) ? $section->id : $section;
$refs = $db->selectObjects('sectionref', 'section=' . $id);
ob_start();
$mods = array();
foreach ($refs as $ref) {
$loc = null;
$loc->mod = $ref->module;
$loc->src = $ref->source;
$loc->int = $ref->internal;
if (!empty($loc->src)) {
if ($ref->module == 'containermodule') {
foreach ($db->selectObjects('container', "external='" . serialize($loc) . "'") as $mod) {
$mods[] = $mod;
$modloc = unserialize($mod->internal);
expTheme::showAction($modloc->mod, 'index', $modloc->src, array('view' => $mod->view, 'title' => $mod->title));
}
} else {
foreach ($db->selectObjects('container', "internal='" . serialize($loc) . "'") as $mod) {
$mods[] = $mod;
}
}
}
}
$text = search::removeHTML(ob_get_contents());
ob_end_clean();
return $text;
}
示例5: search
function search()
{
system::setParam("page", "srch");
if (!empty($_GET["text"])) {
$words = htmlspecialchars(addslashes($_GET["text"]));
$offset = 1;
if (isset($this->get["offset"])) {
$offset = intval($this->get["offset"]);
}
$cacheID = "SEARCH_RES|{$words}|typeArticle|blogsearchoffset_{$offset}";
$this->smarty->assign("searchWord", $words);
if (mb_strlen($words) <= 2) {
$this->smarty->assign("smallWord", true);
return false;
}
$this->smarty->setCacheID($cacheID);
if (!$this->smarty->isCached()) {
$res = search::searchWithType($words, "article");
if ($res->getNumRows() > 0) {
$posts = $res->fetchAll();
$this->smarty->assign("searchRes", $posts);
}
}
} else {
system::redirect('/');
}
}
示例6: activate
static function activate() {
// Update the root item. This is a quick hack because the search module is activated as part
// of the official install, so this way we don't start off with a "your index is out of date"
// banner.
search::update(model_cache::get("item", 1));
search::check_index();
}
示例7: check_index
/**
* @return string An error message suitable for inclusion in the task log
*/
static function check_index()
{
list($remaining) = search::stats();
if ($remaining) {
site_status::warning(t('Your search index needs to be updated. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date");
}
}
示例8: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("search_records", "items.id", "search_records.item_id", "left")->where("search_records.item_id", "IS", null)->or_where("search_records.dirty", "=", 1)->find_all(100) as $item) {
// The query above can take a long time, so start the timer after its done
// to give ourselves a little time to actually process rows.
if (!isset($start)) {
$start = microtime(true);
}
search::update($item);
$completed++;
if (microtime(true) - $start > 0.75) {
break;
}
}
list($remaining, $total, $percent) = search::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("search_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
}
}
示例9: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("search_records", "items.id", "search_records.item_id", "left")->where("search_records.item_id", null)->orwhere("search_records.dirty", 1)->find_all() as $item) {
if (microtime(true) - $start > 1.5) {
break;
}
search::update($item);
$completed++;
}
list($remaining, $total, $percent) = search::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("search_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
}
}
示例10: fetch
public function fetch()
{
$search = new search();
$data_deal = $search->get_goods_of_day();
$data_new['blocks'] = $search->get_new_goods();
$this->template->add_template("header");
$this->template->set_global(array("tree_html" => $this->get_tree(), "site" => $this->this_site), "header");
$header = $this->template->parse("header");
$this->template->add_template("footer");
$footer = $this->template->parse("footer");
$this->template->add_template("index");
$this->template->set_global(array("header" => $header, "footer" => $footer, "site" => $this->this_site), "index");
$this->template->set_block("deal_of_day", $data_deal[1], "index");
$this->template->set_block("deal_yesterday", $data_deal[0], "index");
$this->template->set_block("deal_tomorrow", $data_deal[1], "index");
$this->template->set_block("new_goods", $data_new, "index");
echo $this->template->parse("index");
}
示例11: fetch
public function fetch()
{
$start = microtime();
/* Генерация хедера */
$this->template->add_template("header");
$this->template->set_global(array("site" => $this->this_site, "tree_html" => $this->get_tree()), "header");
$header = $this->template->parse("header");
/*Генерация футера*/
$this->template->add_template("footer");
$footer = $this->template->parse("footer");
/********************************************/
//print_r($this->args);
$t_name = '';
if ($this->args['good'] != 0) {
$t_name = "shop_cart";
} elseif ($this->args['group'] != 0) {
$t_name = "classes";
} elseif ($this->args['node'] != 0 && $this->args['class'] != 0) {
$t_name = "goods";
} elseif ($this->args['node'] != 0 || $this->args['searchword'] != '') {
$t_name = "goods";
}
$path = $this->search->get_path($this->args);
$this->template->add_template("chain", "catalog");
$this->template->set_block("path_data", array("data" => $path), "chain", "catalog");
$path_html = $this->template->parse("chain", "catalog");
$current_url = $this->make_current_url();
$this->template->add_template($t_name, "catalog");
$this->template->set(array("footer" => $footer, "header" => $header, "site" => $this->this_site), $t_name, "catalog");
$data = $this->search->get_info($this->args);
$this->template->add_template("pager", "catalog");
$this->template->set_global(array("current_url" => $current_url), "pager", "catalog");
$this->template->set_block("data", $data['pager'], "pager", "catalog");
$pager = $this->template->parse("pager", "catalog");
$this->template->set_global(array("site" => $this->this_site, "path_html" => $path_html), $t_name, "catalog");
if ($pager) {
$this->template->set_global(array("pager_html" => $pager), $t_name, "catalog");
}
//print_r($data);
$this->template->set_block("data", $data, $t_name, "catalog");
//print_r($this->template);
echo $this->template->parse($t_name, "catalog");
echo "\n\ntotal time = " . 1000 * (microtime() - $start) . " ms";
}
示例12: action_search
public function action_search()
{
$urlparams = array('search' => optional_param('search', null, PARAM_TEXT), 'group' => optional_param('group', 0, PARAM_INT), 'page' => optional_param('page', 1, PARAM_INT), 'role' => optional_param('role', 0, PARAM_INT), 'type' => optional_param('type', base::TYPE_ALL, PARAM_INT));
if (optional_param('resetbutton', 0, PARAM_ALPHA)) {
redirect(new \moodle_url('/mod/mediagallery/view.php', array('action' => 'search', 'id' => $this->cm->id)));
}
$params = array_merge($urlparams, array('collection' => $this->collection, 'courseid' => $this->course->id, 'context' => $this->context));
$search = new search($params);
$results = $search->get_results();
if (optional_param('exportbutton', 0, PARAM_ALPHA)) {
return $search->download_csv();
}
$form = new form\search(null, array('context' => $this->context, 'collection' => $this->collection), 'post', '', array('id' => 'searchform'));
$pageurl = new \moodle_url('/mod/mediagallery/search.php', $urlparams);
$perpage = 0;
$totalcount = 0;
$renderable = new output\searchresults\renderable($results, $pageurl, $totalcount, $params['page'], $perpage);
return $this->renderer->search_page($form, $renderable);
}
示例13: get_value
public function get_value()
{
global $dbh;
if (!count($this->value)) {
if ($this->parameters['equation']) {
$equ = new equation($this->parameters['equation']);
$search = new search();
$search->unserialize_search($equ->requete);
$table = $search->make_search();
$result = pmb_mysql_query("select * from " . $table, $dbh);
if (pmb_mysql_num_rows($result)) {
while ($row = pmb_mysql_fetch_object($result)) {
$this->value[] = $row->notice_id;
}
}
}
}
return $this->value;
}
示例14: get_siblings
static function get_siblings($q, $album, $limit, $offset)
{
if (!isset($limit)) {
$limit = 100;
}
if (!isset($offset)) {
$offset = 1;
}
$result = search::search_within_album(search::add_query_terms($q), $album, $limit, $offset);
return $result[1];
}
示例15: get_datas
public function get_datas()
{
//on commence par récupérer l'identifiant retourné par le sélecteur...
if ($this->parameters['selector'] != "") {
for ($i = 0; $i < count($this->selectors); $i++) {
if ($this->selectors[$i]['name'] == $this->parameters['selector']) {
$selector = new $this->parameters['selector']($this->selectors[$i]['id']);
break;
}
}
$values = $selector->get_value();
$searcher = new search(false);
$current_search = $searcher->serialize_search();
$searcher->destroy_global_env();
global $search;
$search = array();
$search[] = "d_" . $values['cp'];
$op = "op_0_d_" . $values['cp'];
$field = "field_0_d_" . $values['cp'];
global ${$op}, ${$field};
${$op} = "EQ";
${$field} = $values['cp_val'];
$table = $searcher->make_search();
$query = "select notice_id from " . $table;
$result = pmb_mysql_query($query);
$records = array();
if (pmb_mysql_num_rows($result)) {
while ($row = pmb_mysql_fetch_object($result)) {
$records[] = $row->notice_id;
}
}
$searcher->unserialize_search($current_search);
$records = $this->filter_datas("notices", $records);
if ($this->parameters['nb_max_elements'] > 0) {
$records = array_slice($records, 0, $this->parameters['nb_max_elements']);
}
$return = array('title' => 'Liste de Notices', 'records' => $records);
return $return;
}
return false;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:41,代码来源:cms_module_common_datasource_records_by_cp_val.class.php