本文整理汇总了PHP中split_keywords函数的典型用法代码示例。如果您正苦于以下问题:PHP split_keywords函数的具体用法?PHP split_keywords怎么用?PHP split_keywords使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split_keywords函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: highlightkeywords
function highlightkeywords($text, $search, $partial_index = false, $field_name = "", $keywords_index = 1)
{
# do not highlight if the field is not indexed, so it is clearer where results came from.
if ($keywords_index != 1) {
return $text;
}
# Highlight searched keywords in $text
# Optional - depends on $highlightkeywords being set in config.php.
global $highlightkeywords;
# Situations where we do not need to do this.
if (!isset($highlightkeywords) || $highlightkeywords == false || $search == "" || $text == "") {
return $text;
}
# Generate the cache of search keywords (no longer global so it can test against particular fields.
# a search is a small array so I don't think there is much to lose by processing it.
$hlkeycache = array();
$wildcards_found = false;
$s = split_keywords($search);
for ($n = 0; $n < count($s); $n++) {
if (strpos($s[$n], ":") !== false) {
$c = explode(":", $s[$n]);
# only add field specific keywords
if ($field_name != "" && $c[0] == $field_name) {
$hlkeycache[] = $c[1];
}
} else {
$keyword = $s[$n];
global $stemming;
if ($stemming && function_exists("GetStem")) {
$keyword = GetStem($keyword);
}
if (strpos($keyword, "*") !== false) {
$wildcards_found = true;
$keyword = str_replace("*", "", $keyword);
}
$hlkeycache[] = $keyword;
}
}
# Parse and replace.
return str_highlight($text, $hlkeycache, STR_HIGHLIGHT_SIMPLE);
}
示例2: get_resource_top_keywords
}
</script>
<form method="post" action="<?php
echo $baseurl_short;
?>
pages/find_similar.php" id="findsimilar">
<input type="hidden" name="resource_type" value="<?php
echo $resource["resource_type"];
?>
">
<input type="hidden" name="countonly" id="countonly" value="">
<?php
$keywords = get_resource_top_keywords($ref, 30);
$keywords = array_values(array_unique($keywords));
$searchwords = split_keywords($search);
for ($n = 0; $n < count($keywords); $n++) {
?>
<div class="SearchSimilar"><input type=checkbox id="similar_search_<?php
echo urlencode($keywords[$n]);
?>
" name="keyword_<?php
echo urlencode($keywords[$n]);
?>
" value="yes"
<?php
if (in_array($keywords[$n], $searchwords)) {
?>
checked<?php
}
?>
示例3: index_collection
function index_collection($ref, $index_string = '')
{
# Update the keywords index for this collection
sql_query("delete from collection_keyword where collection='{$ref}'");
# Remove existing keywords
# Define an indexable string from the name, themes and keywords.
global $index_collection_titles;
if ($index_collection_titles) {
$indexfields = 'c.ref,c.name,c.keywords';
} else {
$indexfields = 'c.ref,c.keywords';
}
global $index_collection_creator;
if ($index_collection_creator) {
$indexfields .= ',u.fullname';
}
// if an index string wasn't supplied, generate one
if (!strlen($index_string) > 0) {
$indexarray = sql_query("select {$indexfields} from collection c join user u on u.ref=c.user and c.ref = '{$ref}'");
for ($i = 0; $i < count($indexarray); $i++) {
$index_string = "," . implode(',', $indexarray[$i]);
}
}
$keywords = split_keywords($index_string, true);
for ($n = 0; $n < count($keywords); $n++) {
if (trim($keywords[$n]) == "") {
continue;
}
$keyref = resolve_keyword($keywords[$n], true);
sql_query("insert into collection_keyword values ('{$ref}','{$keyref}')");
}
// return the number of keywords indexed
return $n;
}
示例4: get_keyword_from_option
function get_keyword_from_option($option)
{
# For the given field option, return the keyword that will be indexed.
$keywords = split_keywords("," . $option);
global $stemming;
if ($stemming && function_exists('GetStem')) {
$keywords[1] = GetStem($keywords[1]);
}
return $keywords[1];
}
示例5: get_keyword_from_option
function get_keyword_from_option($option)
{
# For the given field option, return the keyword that will be indexed.
$keywords=split_keywords("," . $option);
return $keywords[1];
}
示例6: getvalescaped
# Append extra search parameters
$country = getvalescaped("country", "");
if ($country != "") {
$search = ($search == "" ? "" : join(", ", split_keywords($search)) . ", ") . "country:" . $country;
}
$year = getvalescaped("year", "");
if ($year != "") {
$search = ($search == "" ? "" : join(", ", split_keywords($search)) . ", ") . "year:" . $year;
}
$month = getvalescaped("month", "");
if ($month != "") {
$search = ($search == "" ? "" : join(", ", split_keywords($search)) . ", ") . "month:" . $month;
}
$day = getvalescaped("day", "");
if ($day != "") {
$search = ($search == "" ? "" : join(", ", split_keywords($search)) . ", ") . "day:" . $day;
}
if (strpos($search, "!") === false) {
setcookie("search", $search);
}
# store the search in a cookie if not a special search
$offset = getvalescaped("offset", 0);
if (strpos($search, "!") === false) {
setcookie("saved_offset", $offset);
}
if (!is_numeric($offset) || $offset < 0) {
$offset = 0;
}
######## CAMILLO
#$order_by=getvalescaped("order_by","relevance");if (strpos($search,"!")===false) {setcookie("saved_order_by",$order_by);}
$order_by = getvalescaped("order_by", "date");
示例7: refine_searchstring
function refine_searchstring($search)
{
#
# DISABLED TEMPORARILY
#
# This causes an issue when using advanced search with check boxes.
# A keyword containing spaces will break the search when used with another keyword.
#
# This function solves several issues related to searching.
# it eliminates duplicate terms, helps the field content to carry values over into advanced search correctly, fixes a searchbar bug where separators (such as in a pasted filename) cause an initial search to fail, separates terms for searchcrumbs.
global $use_refine_searchstring;
if (!$use_refine_searchstring) {
return $search;
}
if (substr($search, 0, 1) == "\"" && substr($search, -1, 1) == "\"") {
return $search;
}
// preserve string search functionality.
global $noadd;
$search = str_replace(",-", ", -", $search);
$search = str_replace("", "", $search);
// remove any zero width spaces.
$keywords = split_keywords($search);
$orfields = get_OR_fields();
// leave checkbox type fields alone
$fixedkeywords = array();
foreach ($keywords as $keyword) {
if (strpos($keyword, ":") > 0) {
$keywordar = explode(":", $keyword, 2);
$keyname = $keywordar[0];
if (substr($keyname, 0, 1) != "!") {
if (!in_array($keyname, $orfields)) {
$keyvalues = explode(" ", str_replace($keywordar[0] . ":", "", $keywordar[1]));
} else {
$keyvalues = array($keywordar[1]);
}
foreach ($keyvalues as $keyvalue) {
if (!in_array($keyvalue, $noadd)) {
$fixedkeywords[] = $keyname . ":" . $keyvalue;
}
}
} else {
if (!in_array($keyword, $noadd)) {
$keywords = explode(" ", $keyword);
$fixedkeywords[] = $keywords[0];
}
}
// for searches such as !list
} else {
if (!in_array($keyword, $noadd)) {
$fixedkeywords[] = $keyword;
}
}
}
$keywords = $fixedkeywords;
$keywords = array_unique($keywords);
$search = implode(", ", $keywords);
$search = str_replace(",-", " -", $search);
// support the omission search
return $search;
}
示例8: substr
$values=explode(" ",$value);
foreach ($values as $value)
{
# Standard field
$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . substr($key,6) . ":" . $value;
}
}
}
}
$year=getvalescaped("year","");
if ($year!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "year:" . $year;}
$month=getvalescaped("month","");
if ($month!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "month:" . $month;}
$day=getvalescaped("day","");
if ($day!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "day:" . $day;}
}
$searchresourceid = "";
if (is_numeric(trim(getvalescaped("searchresourceid","")))){
$searchresourceid = trim(getvalescaped("searchresourceid",""));
$search = "!resource$searchresourceid";
}
hook("searchstringprocessing");
# Fetch and set the values
//setcookie("search",$search); # store the search in a cookie if not a special search
$offset=getvalescaped("offset",0);if (strpos($search,"!")===false) {setcookie("saved_offset",$offset);}
if ((!is_numeric($offset)) || ($offset<0)) {$offset=0;}
示例9: hook
}
# Also strip date related fields.
$simple_fields[] = "year";
$simple_fields[] = "month";
$simple_fields[] = "day";
hook("simplesearch_stripsimplefields");
# Process all keywords, putting set fieldname/value pairs into an associative array ready for setting later.
# Also build a quicksearch string.
# Recognise a quoted search, which is a search for an exact string
$quoted_string = false;
if (substr($quicksearch, 0, 1) == "\"" && substr($quicksearch, -1, 1) == "\"") {
$quoted_string = true;
$quicksearch = substr($quicksearch, 1, -1);
}
$quicksearch = refine_searchstring($quicksearch);
$keywords = split_keywords($quicksearch);
$set_fields = array();
$simple = array();
for ($n = 0; $n < count($keywords); $n++) {
if (trim($keywords[$n]) != "") {
if (strpos($keywords[$n], ":") !== false) {
$s = explode(":", $keywords[$n]);
if (isset($set_fields[$s[0]])) {
$set_fields[$s[0]] .= " " . $s[1];
} else {
$set_fields[$s[0]] = $s[1];
}
if (!in_array($s[0], $simple_fields)) {
$simple[] = trim($keywords[$n]);
}
} else {
示例10: 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, $recent_search_daylimit = "", $go = false)
{
debug("search={$search} {$go} {$fetchrows} restypes={$restypes} archive={$archive} daylimit={$recent_search_daylimit}");
# globals needed for hooks
global $sql, $order, $select, $sql_join, $sql_filter, $orig_order, $checkbox_and, $collections_omit_archived, $search_sql_double_pass_mode, $usergroup;
$alternativeresults = hook("alternativeresults", "", array($go));
if ($alternativeresults) {
return $alternativeresults;
}
$modifyfetchrows = hook("modifyfetchrows", "", array($fetchrows));
if ($modifyfetchrows) {
$fetchrows = $modifyfetchrows;
}
# 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") {
if (!is_numeric(str_replace("field", "", $order_by))) {
exit("Order field incorrect.");
}
$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);
$modified_keywords = hook('dosearchmodifykeywords', '', array($keywords));
if ($modified_keywords) {
$keywords = $modified_keywords;
}
# -- Build up filter SQL that will be used for all queries
$sql_filter = "";
# append resource type filtering
if ($restypes != "" && substr($restypes, 0, 6) != "Global") {
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 ($recent_search_daylimit != "") {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "creation_date > (curdate() - interval " . $recent_search_daylimit . " DAY)";
}
# The ability to restrict access by the user that created the resource.
global $resource_created_by_filter;
if (isset($resource_created_by_filter) && count($resource_created_by_filter) > 0) {
$created_filter = "";
foreach ($resource_created_by_filter as $filter_user) {
if ($filter_user == -1) {
global $userref;
$filter_user = $userref;
}
# '-1' can be used as an alias to the current user. I.e. they can only see their own resources in search results.
if ($created_filter != "") {
$created_filter .= " or ";
}
$created_filter .= "created_by = '" . $filter_user . "'";
}
if ($created_filter != "") {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "(" . $created_filter . ")";
}
}
# Geo zone exclusion
# A list of upper/lower long/lat bounds, defining areas that will be excluded from geo search results.
# Areas are defined as southwest lat, southwest long, northeast lat, northeast long
global $geo_search_restrict;
if (count($geo_search_restrict) > 0 && substr($search, 0, 4) == "!geo") {
foreach ($geo_search_restrict as $zone) {
if ($sql_filter != "") {
$sql_filter .= " and ";
}
$sql_filter .= "(geo_lat is null or geo_long is null or not(geo_lat >= '" . $zone[0] . "' and geo_lat<= '" . $zone[2] . "'";
$sql_filter .= "and geo_long >= '" . $zone[1] . "' and geo_long<= '" . $zone[3] . "'))";
}
}
# 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.
//.........这里部分代码省略.........