本文整理汇总了PHP中cmsFramework::getIgnoredSearchWords方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::getIgnoredSearchWords方法的具体用法?PHP cmsFramework::getIgnoredSearchWords怎么用?PHP cmsFramework::getIgnoredSearchWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::getIgnoredSearchWords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
function search()
{
$urlSeparator = "_";
//Used for url parameters that pass something more than just a value
$simplesearch_custom_fields = 1;
// Search custom fields in simple search
$simplesearch_query_type = 'all';
// any|all
$min_word_chars = 3;
// Only words with min_word_chars or higher will be used in any|all query types
$category_ids = '';
$criteria_ids = Sanitize::getString($this->params, 'criteria');
$dir_id = Sanitize::getString($this->params, 'dir', '');
$accepted_query_types = array('any', 'all', 'exact');
$query_type = Sanitize::getString($this->params, 'query');
$keywords = urldecode(Sanitize::getString($this->params, 'keywords'));
$scope = Sanitize::getString($this->params, 'scope');
$author = urldecode(Sanitize::getString($this->params, 'author'));
$ignored_search_words = $keywords != '' ? cmsFramework::getIgnoredSearchWords() : array();
if (!in_array($query_type, $accepted_query_types)) {
$query_type = 'all';
// default value if value used is not recognized
}
// Build search where statement for standard fields
$wheres = array();
# SIMPLE SEARCH
if ($keywords != '' && $scope == '') {
// $scope = array("Listing.title","Listing.introtext","Listing.fulltext","Review.comments","Review.title");
$scope = array("Listing.title", "Listing.introtext", "Listing.fulltext", "Listing.metakey");
$words = array_unique(explode(' ', $keywords));
// Include custom fields
if ($simplesearch_custom_fields == 1) {
$tbcols = $this->_db->getTableFields(array('#__jreviews_content'));
$fields = array_keys($tbcols['#__jreviews_content']);
$ignore = array("email", "contentid", "featured");
// TODO: find out which fields have predefined selection values to get the searchable values instead of reference
}
$whereFields = array();
foreach ($scope as $contentfield) {
$whereContentFields = array();
foreach ($words as $word) {
if (strlen($word) >= $min_word_chars && !in_array($word, $ignored_search_words)) {
$word = urldecode(trim($word));
$whereContentFields[] = " {$contentfield} LIKE " . $this->quoteLike($word);
}
}
if (!empty($whereContentFields)) {
$whereFields[] = " (" . implode($simplesearch_query_type == 'all' ? ') AND (' : ') OR (', $whereContentFields) . ')';
}
}
if ($simplesearch_custom_fields == 1) {
// add custom fields to where statement
foreach ($fields as $field) {
$whereCustomFields = array();
foreach ($words as $word) {
$word = urldecode($word);
if (strlen($word) >= $min_word_chars && !in_array($word, $ignored_search_words)) {
if (!in_array($field, $ignore)) {
$whereCustomFields[] = "{$field} LIKE " . $this->quoteLike($word);
}
}
}
if (!empty($whereCustomFields) && !in_array($field, $ignore)) {
$whereFields[] = "\n(" . implode($simplesearch_query_type == 'all' ? ') AND (' : ') OR (', $whereCustomFields) . ')';
}
}
}
if (!empty($whereFields)) {
$wheres[] = "\n(" . implode(') OR (', $whereFields) . ')';
}
} else {
# ADVANCED SEARCH
// Process core content fields and reviews
if ($keywords != '' && $scope != '') {
$allowedContentFields = array("title", "introtext", "fulltext", "reviews", "metakey");
$scope = explode($urlSeparator, $scope);
$scope[] = 'metakey';
switch ($query_type) {
case 'exact':
foreach ($scope as $contentfield) {
if (in_array($contentfield, $allowedContentFields)) {
$w = array();
if ($contentfield == 'reviews') {
$w[] = " Review.comments LIKE " . $this->quoteLike($keywords);
$w[] = " Review.title LIKE " . $this->quoteLike($keywords);
} else {
$w[] = " Listing.{$contentfield} LIKE " . $this->quoteLike($keywords);
}
$whereContentOptions[] = "\n" . implode(' OR ', $w);
}
}
$wheres[] = implode(' OR ', $whereContentOptions);
break;
case 'any':
case 'all':
default:
$words = array_unique(explode(' ', $keywords));
$whereFields = array();
foreach ($scope as $contentfield) {
if (in_array($contentfield, $allowedContentFields)) {
//.........这里部分代码省略.........