本文整理匯總了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)) {
//.........這裏部分代碼省略.........