本文整理汇总了PHP中do_search函数的典型用法代码示例。如果您正苦于以下问题:PHP do_search函数的具体用法?PHP do_search怎么用?PHP do_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_search函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugin_search_action
function plugin_search_action()
{
global $post, $vars;
$_title_search = _('Search for word(s)');
$_title_result = _('Search result of $1');
$_msg_searching = _('Key words are case-insenstive, and are searched for in all pages.');
if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
$s_word = isset($post['word']) ? htmlspecialchars($post['word']) : '';
} else {
$s_word = isset($vars['word']) ? htmlspecialchars($vars['word']) : '';
}
if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
unset($vars['word']);
// Stop using $_msg_word at lib/html.php
die_message('Search words too long');
}
$type = isset($vars['type']) ? $vars['type'] : '';
$base = isset($vars['base']) ? $vars['base'] : '';
if ($s_word != '') {
// Search
$msg = str_replace('$1', $s_word, $_title_result);
$body = do_search($vars['word'], $type, FALSE, $base);
} else {
// Init
unset($vars['word']);
// Stop using $_msg_word at lib/html.php
$msg = $_title_search;
$body = '<br />' . "\n" . $_msg_searching . "\n";
}
// Show search form
$bases = $base == '' ? array() : array($base);
$body .= plugin_search_search_form($s_word, $type, $bases);
return array('msg' => $msg, 'body' => $body);
}
示例2: plugin_search_action
function plugin_search_action()
{
global $post, $vars, $_title_result, $_title_search, $_msg_searching;
if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
$s_word = isset($post['word']) ? htmlsc($post['word']) : '';
} else {
$s_word = isset($vars['word']) ? htmlsc($vars['word']) : '';
}
if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
unset($vars['word']);
// Stop using $_msg_word at lib/html.php
die_message('Search words too long');
}
$type = isset($vars['type']) ? $vars['type'] : '';
$base = isset($vars['base']) ? $vars['base'] : '';
if ($s_word != '') {
// Search
$msg = str_replace('$1', $s_word, $_title_result);
$body = do_search($vars['word'], $type, false, $base);
} else {
// Init
unset($vars['word']);
// Stop using $_msg_word at lib/html.php
$msg = $_title_search;
$body = '<br />' . "\n" . $_msg_searching . "\n";
}
// Show search form
$bases = $base == '' ? array() : array($base);
$body .= plugin_search_search_form($s_word, $type, $bases);
return array('msg' => $msg, 'body' => $body);
}
示例3: do_search
// The order is not exactly the votes
// but a time-decreasing function applied to the number of votes
$sql = "select link_id, counter*(1-(unix_timestamp(now())-unix_timestamp(link_date))*0.5/172800) as value from links, link_clicks, sub_statuses where sub_statuses.id = " . SitesMgr::my_id() . " AND link_id = link AND status='published' and date > '{$min_date}' and link_clicks.id = link order by value desc limit 25";
} else {
/////
// All the others
/////
// The link_status to search
if (!empty($_REQUEST['status'])) {
$status = $db->escape(clean_input_string(trim($_REQUEST['status'])));
} else {
// By default it searches on all
if ($_REQUEST['q']) {
$status = 'all';
include mnminclude . 'search.php';
$search_ids = do_search(true);
if ($search_ids['ids']) {
$search = ' link_id in (' . implode(',', $search_ids['ids']) . ')';
}
} else {
$status = 'published';
}
}
switch ($status) {
case 'published':
$order_field = 'date';
$link_date = 'date';
$title = $site_info->name . ': ' . _('publicadas');
break;
case 'queued':
$title = $site_info->name . ': ' . _('en cola');
示例4: search_relations
public function search_relations()
{
do_search(false, false, true);
}
示例5:
<div class="clearerleft"> </div>
</div>
<div class="Question">
<label><?php echo $lang["resourceid"]?></label><div class="Fixed"><?php echo $resource["ref"]?></div>
<div class="clearerleft"> </div>
</div>
<?php
// -------- Related Resources (must be able to search for this to work)
if ($share_resource_include_related && $enable_related_resources && checkperm("s") && ($k==""))
{
$result=do_search("!related" . $ref);
if (count($result)>0)
{
?>
<div class="Question" id="sharerelatedresources">
<label><?php echo $lang["sharerelatedresources"]?></label>
<input type="hidden" name="sharerelatedresources" id="sharerelatedresourcesfield" value="" >
<div class="sharerelatedresources">
<?php
for ($n=0;$n<count($result);$n++)
{
$related_restype=$result[$n]["resource_type"];
$related_restypes[]=$related_restype;
}
//reduce array to unique values
示例6: is_collection_approved
function is_collection_approved($collection)
{
if (is_array($collection)) {
$result = $collection;
} else {
$result = do_search("!collection" . $collection, "", "relevance", 0, -1, "desc", false, "", false, "");
}
if (!is_array($result) || count($result) == 0) {
return true;
}
$collectionstates = array();
global $collection_allow_not_approved_share;
for ($n = 0; $n < count($result); $n++) {
$archivestatus = $result[$n]["archive"];
if ($archivestatus < 0 && !$collection_allow_not_approved_share) {
return false;
}
$collectionstates[] = $archivestatus;
}
return array_unique($collectionstates);
}
示例7: hook
<?php hook("purchase_extra_options"); ?>
<?php if ($showbuy) { ?>
<p><input type="submit" name="submit" value=" <?php echo $lang["buynow"]?> "></p>
<?php } ?>
</form>
</div>
<?php
}
else
{
# ----------------------------------- Show the PayPal integration instead ------------------------------------
$pricing_discounted=$pricing; # Copy the pricing, which may be group specific
include "../include/config.php"; # Reinclude the config so that $pricing is now the default, and we can work out group discounts
$resources=do_search("!collection" . $usercollection);
$n=1;
$paypal="";
$totalprice=0;
$totalprice_ex_discount=0;
foreach ($resources as $resource)
{
$sizes=get_image_sizes($resource["ref"]);
$title=get_data_by_field($resource["ref"],$view_title_field);
foreach ($sizes as $size)
{
if (getval("select_" . $resource["ref"],"")==$size["id"])
{
$name=$size["name"];
$id=$size["id"];
if ($id=="") {$id="hpr";}
示例8: search_public_collections
<?php
//echo "testing sp2<br/>";
# Perform the search
if (!isset($collections)) {
$collections = search_public_collections($search, "theme", "ASC", !$search_includes_themes, !$search_includes_public_collections, false);
}
if (substr($search, 0, 11) != "!collection" && $collections != "") {
for ($n = 0; $n < count($collections); $n++) {
$resources = do_search("!collection" . $collections[$n]['ref'], "", "relevance", "", 5);
$hook_result = hook("process_search_results", "", array("result" => $resources, "search" => "!collection" . $collections[$n]['ref']));
if ($hook_result !== false) {
$resources = $hook_result;
}
$pub_url = "search.php?search=" . urlencode("!collection" . $collections[$n]["ref"]);
if ($display == "thumbs") {
?>
<div class="ResourcePanelShell" id="ResourceShell">
<div class="ResourcePanel">
<table border="0" class="ResourceAlign"><?php
hook("publicresulttop");
?>
<tr><td>
<div style="position: relative;height:140px;">
<a onClick="return CentralSpaceLoad(this,true);" href="<?php
echo $pub_url;
?>
" title="<?php
echo htmlspecialchars(str_replace(array("\"", "'"), "", i18n_get_collection_name($collections[$n])));
示例9: explode
else {
jQuery("#showresourcecount").hide();
}
});
</script>
<?php
if ($promoted_resource) {
global $link, $view_title_field;
$search_string = explode('?', $link);
parse_str(str_replace("&", "&", $search_string[1]), $search_string);
$search = isset($search_string["search"]) ? $search_string["search"] : "";
$restypes = isset($search_string["restypes"]) ? $search_string["restypes"] : "";
$order_by = isset($search_string["order_by"]) ? $search_string["order_by"] : "";
$archive = isset($search_string["archive"]) ? $search_string["archive"] : "";
$sort = isset($search_string["sort"]) ? $search_string["sort"] : "";
$resources = do_search($search, $restypes, $order_by, $archive, -1, $sort);
?>
<div class="Question" id="promotedresource">
<label for="promoted_image">
<?php
echo $lang["dashtileimage"];
?>
</label>
<select class="stdwidth" id="previewimage" name="promoted_image">
<?php
foreach ($resources as $resource) {
?>
<option value="<?php
echo htmlspecialchars($resource["ref"]);
?>
" <?php
示例10: hook_search
//.........这里部分代码省略.........
* - 'extra': An array of optional extra information items.
* - 'snippet': An excerpt or preview to show with the result (can be
* generated with search_excerpt()).
* - 'status': An associative array with the key-value pairs:
* - 'remaining': The number of items left to index.
* - 'total': The total number of items to index.
*
* @ingroup search
*/
function hook_search($op = 'search', $keys = NULL)
{
switch ($op) {
case 'name':
return t('Content');
case 'reset':
db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME);
return;
case 'status':
$total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
$remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0"));
return array('remaining' => $remaining, 'total' => $total);
case 'admin':
$form = array();
// Output form for defining rank factor weights.
$form['content_ranking'] = array('#type' => 'fieldset', '#title' => t('Content ranking'));
$form['content_ranking']['#theme'] = 'node_search_admin';
$form['content_ranking']['info'] = array('#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>');
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
foreach (module_invoke_all('ranking') as $var => $values) {
$form['content_ranking']['factors']['node_rank_' . $var] = array('#title' => $values['title'], '#type' => 'select', '#options' => $options, '#default_value' => variable_get('node_rank_' . $var, 0));
}
return $form;
case 'search':
// Build matching conditions
list($join1, $where1) = _db_rewrite_sql();
$arguments1 = array();
$conditions1 = 'n.status = 1';
if ($type = search_query_extract($keys, 'type')) {
$types = array();
foreach (explode(',', $type) as $t) {
$types[] = "n.type = '%s'";
$arguments1[] = $t;
}
$conditions1 .= ' AND (' . implode(' OR ', $types) . ')';
$keys = search_query_insert($keys, 'type');
}
if ($category = search_query_extract($keys, 'category')) {
$categories = array();
foreach (explode(',', $category) as $c) {
$categories[] = "tn.tid = %d";
$arguments1[] = $c;
}
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
$join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
$keys = search_query_insert($keys, 'category');
}
if ($languages = search_query_extract($keys, 'language')) {
$categories = array();
foreach (explode(',', $languages) as $l) {
$categories[] = "n.language = '%s'";
$arguments1[] = $l;
}
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
$keys = search_query_insert($keys, 'language');
}
// Get the ranking expressions.
$rankings = _node_rankings();
// When all search factors are disabled (ie they have a weight of zero),
// The default score is based only on keyword relevance.
if ($rankings['total'] == 0) {
$total = 1;
$arguments2 = array();
$join2 = '';
$select2 = 'i.relevance AS score';
} else {
$total = $rankings['total'];
$arguments2 = $rankings['arguments'];
$join2 = implode(' ', $rankings['join']);
$select2 = '(' . implode(' + ', $rankings['score']) . ') AS score';
}
// Do search.
$find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2);
// Load results.
$results = array();
foreach ($find as $item) {
// Build the node body.
$node = node_load($item->sid);
$node = node_build_content($node, 'search_result');
$node->body = drupal_render($node->content);
// Fetch comments for snippet.
$node->body .= module_invoke('comment', 'node', $node, 'update_index');
// Fetch terms for snippet.
$node->body .= module_invoke('taxonomy', 'node', $node, 'update_index');
$extra = module_invoke_all('node_search_result', $node);
$results[] = array('link' => url('node/' . $item->sid, array('absolute' => TRUE)), 'type' => check_plain(node_type_get_name($node)), 'title' => $node->title, 'user' => theme('username', $node), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $total ? $item->score / $total : 0, 'snippet' => search_excerpt($keys, $node->body));
}
return $results;
}
}
示例11: getvalescaped
$offset = getvalescaped("saved_offset", 0);
setcookie("saved_offset", $offset);
$order_by = getvalescaped("saved_order_by", "relevance");
setcookie("saved_order_by", $order_by);
$archive = getvalescaped("saved_archive", 0);
setcookie("saved_archive", $archive);
}
$refs = array();
#echo "search=$search";
# Special query? Ignore restypes
if (strpos($search, "!") !== false) {
$restypes = "";
}
# Story only? Display as list
#if ($restypes=="2") {$display="list";}
$result = do_search($search, $restypes, "relevance", $archive, 100, "desc", false, $starsearch);
//echo $result[0];
# Create a title for the feed
$searchstring = "search={$search}&restypes={$restypes}&archive={$archive}&starsearch={$starsearch}";
$feed_title = $applicationname . " - " . xml_entities(get_search_title($searchstring));
$r = new RSSFeed($feed_title, $baseurl, str_replace("%search%", xml_entities($searchstring), $lang["filtered_resource_update_for"]));
// rss fields can include any of thumbs, smallthumbs, list, xlthumbs display fields, or data_joins.
$all_field_info = get_fields_for_search_display($rss_fields);
$n = 0;
foreach ($rss_fields as $display_field) {
# Find field in selected list
for ($m = 0; $m < count($all_field_info); $m++) {
if ($all_field_info[$m]["ref"] == $display_field) {
$field_info = $all_field_info[$m];
$df[$n]['ref'] = $display_field;
$df[$n]['name'] = $field_info['name'];
示例12: hook
?>
<?php
}
/*end if a collection search and compact_style - action selector*/
?>
<?php
}
}
?>
<?php
hook("beforesearchresults");
# Archive link
if ($archive == 0 && strpos($search, "!") === false && $archive_search) {
$arcresults = do_search($search, $restypes, $order_by, 2, 0);
if (is_array($arcresults)) {
$arcresults = count($arcresults);
} else {
$arcresults = 0;
}
if ($arcresults > 0) {
?>
<div class="SearchOptionNav"><a href="<?php
echo $baseurl_short;
?>
pages/search.php?search=<?php
echo urlencode($search);
?>
&archive=2" onClick="return CentralSpaceLoad(this);">> <?php
echo $lang["view"];
示例13: exit
#
# Api_search setup page
#
// Do the include and authorization checking ritual -- don't change this section.
include '../../../include/db.php';
include '../../../include/authenticate.php';
if (!checkperm('a')) {
exit($lang['error-permissiondenied']);
}
include '../../../include/general.php';
include '../../../include/search_functions.php';
// Specify the name of this plugin and the heading to display for the page.
$plugin_name = 'api_search';
$plugin_page_heading = $lang['api_search_configuration'];
// Build the $page_def array of descriptions of each configuration variable the plugin uses.
$result = do_search('', '', 'relevance', 0, 1);
if (isset($result[0])) {
$list = "";
foreach ($result[0] as $key => $value) {
$list .= $key . ", ";
}
}
$list = rtrim(trim($list), ",");
$page_def[] = config_add_text_input('api_search_exclude_fields', $lang['api_search_exclude_fields']);
$page_def[] = config_add_html($lang['api_search_excludable_fields'] . ": {$list}");
// Do the page generation ritual -- don't change this section.
$upload_status = config_gen_setup_post($page_def, $plugin_name);
include '../../../include/header.php';
config_gen_setup_html($page_def, $plugin_name, $upload_status, $plugin_page_heading);
include '../../../include/footer.php';
示例14: do_search
function do_search($search, $restypes = "", $order_by = "relevance", $archive = 0, $fetchrows = -1, $sort = "desc", $access_override = false, $starsearch = 0, $ignore_filters = false, $return_disk_usage = false)
{
debug("search={$search} restypes={$restypes} archive={$archive}");
# globals needed for hooks
global $sql, $order, $select, $sql_join, $sql_filter, $orig_order, $checkbox_and, $collections_omit_archived, $search_sql_double_pass_mode;
# Takes a search string $search, as provided by the user, and returns a results set
# of matching resources.
# If there are no matches, instead returns an array of suggested searches.
# $restypes is optionally used to specify which resource types to search.
# $access_override is used by smart collections, so that all all applicable resources can be judged regardless of the final access-based results
# resolve $order_by to something meaningful in sql
$orig_order = $order_by;
global $date_field;
$order = array("relevance" => "score {$sort}, user_rating {$sort}, hit_count {$sort}, field{$date_field} {$sort},r.ref {$sort}", "popularity" => "user_rating {$sort},hit_count {$sort},field{$date_field} {$sort},r.ref {$sort}", "rating" => "r.rating {$sort}, user_rating {$sort}, score {$sort},r.ref {$sort}", "date" => "field{$date_field} {$sort},r.ref {$sort}", "colour" => "has_image {$sort},image_blue {$sort},image_green {$sort},image_red {$sort},field{$date_field} {$sort},r.ref {$sort}", "country" => "country {$sort},r.ref {$sort}", "title" => "title {$sort},r.ref {$sort}", "file_path" => "file_path {$sort},r.ref {$sort}", "resourceid" => "r.ref {$sort}", "resourcetype" => "resource_type {$sort},r.ref {$sort}", "titleandcountry" => "title {$sort},country {$sort}", "random" => "RAND()");
if (!in_array($order_by, $order) && substr($order_by, 0, 5) == "field") {
$order[$order_by] = "{$order_by} {$sort}";
}
hook("modifyorderarray");
# Recognise a quoted search, which is a search for an exact string
$quoted_string = false;
if (substr($search, 0, 1) == "\"" && substr($search, -1, 1) == "\"") {
$quoted_string = true;
$search = substr($search, 1, -1);
}
$order_by = $order[$order_by];
$keywords = split_keywords($search);
$search = trim($search);
# -- Build up filter SQL that will be used for all queries
$sql_filter = "";
# append resource type filtering
if ($restypes != "") {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$restypes_x = explode(",", $restypes);
$sql_filter .= "resource_type in ('" . join("','", $restypes_x) . "')";
}
if ($starsearch != "" && $starsearch != 0) {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "user_rating >= '{$starsearch}'";
}
# If returning disk used by the resources in the search results ($return_disk_usage=true) then wrap the returned SQL in an outer query that sums disk usage.
$sql_prefix = "";
$sql_suffix = "";
if ($return_disk_usage) {
$sql_prefix = "select sum(disk_usage) total_disk_usage,count(*) total_resources from (";
$sql_suffix = ") resourcelist";
}
# append resource type restrictions based on 'T' permission
# look for all 'T' permissions and append to the SQL filter.
global $userpermissions;
$rtfilter = array();
for ($n = 0; $n < count($userpermissions); $n++) {
if (substr($userpermissions[$n], 0, 1) == "T") {
$rt = substr($userpermissions[$n], 1);
if (is_numeric($rt) && !$access_override) {
$rtfilter[] = $rt;
}
}
}
if (count($rtfilter) > 0) {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "resource_type not in (" . join(",", $rtfilter) . ")";
}
# append "use" access rights, do not show restricted resources unless admin
if (!checkperm("v") && !$access_override) {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "r.access<>'2'";
}
# append archive searching (don't do this for collections or !listall, archived resources can still appear in these searches)
if (substr($search, 0, 8) != "!listall" && substr($search, 0, 11) != "!collection" || $collections_omit_archived && !checkperm("e2")) {
global $pending_review_visible_to_all;
if ($archive == 0 && $pending_review_visible_to_all) {
# If resources pending review are visible to all, when listing only active resources include
# pending review (-1) resources too.
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "(archive='0' or archive=-1)";
} else {
# Append normal filtering.
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "archive='{$archive}'";
}
}
# append ref filter - never return the batch upload template (negative refs)
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "r.ref>0";
# ------ Advanced 'custom' permissions, need to join to access table.
$sql_join = "";
//.........这里部分代码省略.........
示例15: switch
#
#
#
#
#
#
#
#
#
# admin-employee-rem.php :: Remove employees from db
##
require "settings.php";
if (isset($_POST["key"])) {
switch ($_POST["key"]) {
case "search":
$OUTPUT = do_search();
break;
default:
$OUTPUT = "Invalid use.";
}
} else {
$OUTPUT = get_search();
}
require "template.php";
##
# Functions
##
function get_search()
{
$display = "\n\t\t\t<h2>Search for Training</h2>\n\t\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<form action='" . SELF . "' method=post>\n\t\t\t\t<input type=hidden name=key value='search'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Search String</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type=text name=search_string size='50'></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type=submit value='Search'></td>\n\t\t\t\t</tr>\n\t\t\t</form>\n\t\t\t</table>\n\t\t";
return $display;