本文整理汇总了PHP中flexicontent_db::removeInvalidWords方法的典型用法代码示例。如果您正苦于以下问题:PHP flexicontent_db::removeInvalidWords方法的具体用法?PHP flexicontent_db::removeInvalidWords怎么用?PHP flexicontent_db::removeInvalidWords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexicontent_db
的用法示例。
在下文中一共展示了flexicontent_db::removeInvalidWords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildTextSearch
/**
* Method to build the part of WHERE clause related to Alpha Index
*
* @access private
* @return array
*/
function _buildTextSearch()
{
global $fc_catview;
$app = JFactory::getApplication();
$option = JRequest::getVar('option');
$cparams = $this->_params;
$db = $this->_db;
static $text_search = null;
if ($text_search !== null) {
return $text_search;
}
$text_search = '';
// Get value of search text ('filter') from URL or SESSION (which is set new value if not already set)
// *** Commented out to get variable only by HTTP GET or POST
// thus supporting FULL PAGE CACHING (e.g. Joomla's system plugin 'Cache')
/*if (!$this->_layout) {
$text = $app->getUserStateFromRequest( $option.'.category'.$this->_id.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='author') {
$text = $app->getUserStateFromRequest( $option.'.author'.$this->_authorid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='mcats') {
$text = $app->getUserStateFromRequest( $option.'.mcats'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='myitems') {
$text = $app->getUserStateFromRequest( $option.'.myitems'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='favs') {
$text = $app->getUserStateFromRequest( $option.'favs'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='tags') {
$text = $app->getUserStateFromRequest( $option.'tags'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else {
$text = JRequest::getString('filter', '', 'default');
}*/
// ****************************************
// Create WHERE clause part for Text Search
// ****************************************
$text = JRequest::getString('filter', JRequest::getString('q', ''), 'default');
// Check for LIKE %word% search, for languages without spaces
$filter_word_like_any = $cparams->get('filter_word_like_any', 0);
$phrase = $filter_word_like_any ? JRequest::getWord('searchphrase', JRequest::getWord('p', 'any'), 'default') : JRequest::getWord('searchphrase', JRequest::getWord('p', 'exact'), 'default');
$si_tbl = 'flexicontent_items_ext';
$search_prefix = $cparams->get('add_search_prefix') ? 'vvv' : '';
// SEARCH WORD Prefix
$text = !$search_prefix ? trim($text) : preg_replace('/(\\b[^\\s]+\\b)/u', $search_prefix . '$0', trim($text));
$words = preg_split('/\\s\\s*/u', $text);
if (strlen($text)) {
$ts = 'ie';
$escaped_text = $db->escape($text, true);
$quoted_text = $db->Quote($escaped_text, false);
switch ($phrase) {
case 'natural':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ') ';
break;
case 'natural_expanded':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' WITH QUERY EXPANSION) ';
break;
case 'exact':
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 0);
}
if (empty($words)) {
// All words are stop-words or too short, we could try to execute a query that only contains a LIKE %...% , but it would be too slow
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$_text_match = ' 0=1 ';
} else {
// speed optimization ... 2-level searching: first require ALL words, then require exact text
$newtext = '+' . implode(' +', $words);
$quoted_text = $db->escape($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$exact_text = $db->Quote('%' . $escaped_text . '%', false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) AND ' . $ts . '.search_index LIKE ' . $exact_text;
}
break;
case 'all':
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 1);
}
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$newtext = '+' . implode('* +', $words) . '*';
$quoted_text = $db->escape($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) ';
break;
case 'any':
default:
// Check for LIKE %word% search, for languages without spaces
if ($filter_word_like_any) {
$_text_match = ' LOWER (' . $ts . '.search_index) LIKE ' . $db->Quote('%' . $escaped_text . '%', false);
} else {
$stopwords = array();
$shortwords = array();
//.........这里部分代码省略.........
示例2: onContentSearch
//.........这里部分代码省略.........
$searchFlexicontent = JText::_('FLEXICONTENT');
// REMOVED / COMMENTED OUT this feature:
// Require any OR all Filters ... this can be user selectable
//$show_filtersop = $params->get('show_filtersop', 1);
//$default_filtersop = $params->get('default_filtersop', 'all');
//$FILTERSOP = !$show_filtersop ? $default_filtersop : JRequest::getVar('filtersop', $default_filtersop);
// ****************************************
// Create WHERE clause part for Text Search
// ****************************************
$si_tbl = !$txtmode ? 'flexicontent_items_ext' : 'flexicontent_advsearch_index';
$search_prefix = JComponentHelper::getParams('com_flexicontent')->get('add_search_prefix') ? 'vvv' : '';
// SEARCH WORD Prefix
$text = preg_replace('/(\\b[^\\s,\\.]+\\b)/u', $search_prefix . '$0', trim($text));
if (strlen($text)) {
$ts = !$txtmode ? 'ie' : 'ts';
$escaped_text = $db->escape($text, true);
$quoted_text = $db->Quote($escaped_text, false);
switch ($phrase) {
case 'natural':
if ($filter_word_like_any) {
$_text_match = ' LOWER (' . $ts . '.search_index) LIKE ' . $db->Quote('%' . $escaped_text . '%', false);
} else {
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ') ';
}
break;
case 'natural_expanded':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' WITH QUERY EXPANSION) ';
break;
case 'exact':
$words = preg_split('/\\s\\s*/u', $text);
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 0);
}
if (empty($words)) {
// All words are stop-words or too short, we could try to execute a query that only contains a LIKE %...% , but it would be too slow
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$_text_match = ' 0=1 ';
} else {
// speed optimization ... 2-level searching: first require ALL words, then require exact text
$newtext = '+' . implode(' +', $words);
$quoted_text = $db->escape($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$exact_text = $db->Quote('%' . $escaped_text . '%', false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) AND ' . $ts . '.search_index LIKE ' . $exact_text;
}
break;
case 'all':
$words = preg_split('/\\s\\s*/u', $text);
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 1);
}
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$newtext = '+' . implode('* +', $words) . '*';
$quoted_text = $db->escape($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) ';
break;
case 'any':
default:
if ($filter_word_like_any) {
示例3: _buildItemWhere
/**
* Method to build the WHERE clause
*
* @access private
* @return string
*/
function _buildItemWhere()
{
$user = JFactory::getUser();
$db = JFactory::getDBO();
// Get the view's parameters
$cparams = $this->_params;
// Date-Times are stored as UTC, we should use current UTC time to compare and not user time (requestTime),
// thus the items are published globally at the time the author specified in his/her local clock
//$app = JFactory::getApplication();
//$now = FLEXI_J16GE ? $app->requestTime : $app->get('requestTime'); // NOT correct behavior it should be UTC (below)
//$date = JFactory::getDate();
//$now = FLEXI_J16GE ? $date->toSql() : $date->toMySQL(); // NOT good if string passed to function that will be cached, because string continuesly different
$_nowDate = 'UTC_TIMESTAMP()';
//$db->Quote($now);
$nullDate = $db->getNullDate();
// First thing we need to do is to select only the requested FAVOURED items
$where = ' WHERE fav.userid = ' . (int) $user->get('id');
// Get privilege to view non viewable items (upublished, archived, trashed, expired, scheduled).
// NOTE: ACL view level is checked at a different place
if (FLEXI_J16GE) {
$ignoreState = $user->authorise('flexicontent.ignoreviewstate', 'com_flexicontent');
} else {
if (FLEXI_ACCESS) {
$ignoreState = $user->gid < 25 ? FAccess::checkComponentAccess('com_flexicontent', 'ignoreviewstate', 'users', $user->gmid) : 1;
} else {
$ignoreState = $user->gid > 19;
}
}
// author has 19 and editor has 20
if (!$ignoreState) {
// Limit by publication state. Exception: when displaying personal user items or items modified by the user
$where .= ' AND ( i.state IN (1, -5) OR ( i.created_by = ' . $user->id . ' AND i.created_by != 0 ) )';
//.' OR ( i.modified_by = '.$user->id.' AND i.modified_by != 0 ) )';
// Limit by publish up/down dates. Exception: when displaying personal user items or items modified by the user
$where .= ' AND ( ( i.publish_up = ' . $this->_db->Quote($nullDate) . ' OR i.publish_up <= ' . $_nowDate . ' ) OR ( i.created_by = ' . $user->id . ' AND i.created_by != 0 ) )';
//.' OR ( i.modified_by = '.$user->id.' AND i.modified_by != 0 ) )';
$where .= ' AND ( ( i.publish_down = ' . $this->_db->Quote($nullDate) . ' OR i.publish_down >= ' . $_nowDate . ' ) OR ( i.created_by = ' . $user->id . ' AND i.created_by != 0 ) )';
//.' OR ( i.modified_by = '.$user->id.' AND i.modified_by != 0 ) )';
}
$where .= !FLEXI_J16GE ? ' AND i.sectionid = ' . FLEXI_SECTION : '';
/*
* If we have a filter, and this is enabled... lets tack the AND clause
* for the filter onto the WHERE clause of the item query.
*/
// ****************************************
// Create WHERE clause part for Text Search
// ****************************************
$text = JRequest::getString('filter', JRequest::getString('q', ''), 'default');
// Check for LIKE %word% search, for languages without spaces
$filter_word_like_any = $cparams->get('filter_word_like_any', 0);
$phrase = $filter_word_like_any ? JRequest::getWord('searchphrase', JRequest::getWord('p', 'any'), 'default') : JRequest::getWord('searchphrase', JRequest::getWord('p', 'exact'), 'default');
$si_tbl = 'flexicontent_items_ext';
$search_prefix = $cparams->get('add_search_prefix') ? 'vvv' : '';
// SEARCH WORD Prefix
$text = !$search_prefix ? trim($text) : preg_replace('/(\\b[^\\s,\\.]+\\b)/u', $search_prefix . '$0', trim($text));
$words = preg_split('/\\s\\s*/u', $text);
if (strlen($text)) {
$ts = 'ie';
$escaped_text = FLEXI_J16GE ? $db->escape($text, true) : $db->getEscaped($text, true);
$quoted_text = $db->Quote($escaped_text, false);
switch ($phrase) {
case 'natural':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ') ';
break;
case 'natural_expanded':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' WITH QUERY EXPANSION) ';
break;
case 'exact':
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 0);
}
if (empty($words)) {
// All words are stop-words or too short, we could try to execute a query that only contains a LIKE %...% , but it would be too slow
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$_text_match = ' 0=1 ';
} else {
// speed optimization ... 2-level searching: first require ALL words, then require exact text
$newtext = '+' . implode(' +', $words);
$quoted_text = FLEXI_J16GE ? $db->escape($newtext, true) : $db->getEscaped($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$exact_text = $db->Quote('%' . $escaped_text . '%', false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) AND ' . $ts . '.search_index LIKE ' . $exact_text;
}
break;
case 'all':
$stopwords = array();
$shortwords = array();
if (!$search_prefix) {
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 1);
}
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
//.........这里部分代码省略.........
示例4: _buildFiltersWhere
/**
* Method to build the part of WHERE clause related to Alpha Index
*
* @access private
* @return array
*/
function _buildFiltersWhere()
{
global $fc_catview;
$app = JFactory::getApplication();
$option = JRequest::getVar('option');
$cparams = $this->_params;
$db = $this->_db;
$filters_where = array();
// Get value of search text ('filter') from URL or SESSION (which is set new value if not already set)
// *** Commented out to get variable only by HTTP GET or POST
// thus supporting FULL PAGE CACHING (e.g. Joomla's system plugin 'Cache')
/*if (!$this->_layout) {
$text = $app->getUserStateFromRequest( $option.'.category'.$this->_id.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='author') {
$text = $app->getUserStateFromRequest( $option.'.author'.$this->_authorid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='mcats') {
$text = $app->getUserStateFromRequest( $option.'.mcats'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='myitems') {
$text = $app->getUserStateFromRequest( $option.'.myitems'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='favs') {
$text = $app->getUserStateFromRequest( $option.'favs'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else if ($this->_layout=='tags') {
$text = $app->getUserStateFromRequest( $option.'tags'.$this->_menu_itemid.'.filter', 'filter', '', 'string' );
} else {
$text = JRequest::getString('filter', '', 'default');
}*/
// ****************************************
// Create WHERE clause part for Text Search
// ****************************************
$text = JRequest::getString('filter', '', 'default');
//$text = $this->_params->get('use_search') ? $text : '';
// Check for LIKE %word% search, for languages without spaces
$filter_word_like_any = $cparams->get('filter_word_like_any', 0);
if ($filter_word_like_any) {
$phrase = JRequest::getVar('searchphrase', 'any', 'default');
} else {
$phrase = JRequest::getVar('searchphrase', 'exact', 'default');
}
$si_tbl = 'flexicontent_items_ext';
$text = trim($text);
if (strlen($text)) {
$ts = 'ie';
$escaped_text = FLEXI_J16GE ? $db->escape($text, true) : $db->getEscaped($text, true);
$quoted_text = $db->Quote($escaped_text, false);
switch ($phrase) {
case 'natural':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ') ';
break;
case 'natural_expanded':
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' WITH QUERY EXPANSION) ';
break;
case 'exact':
$words = preg_split('/\\s\\s*/u', $text);
$stopwords = array();
$shortwords = array();
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 0);
if (empty($words)) {
// All words are stop-words or too short, we could try to execute a query that only contains a LIKE %...% , but it would be too slow
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$_text_match = ' 0=1 ';
} else {
// speed optimization ... 2-level searching: first require ALL words, then require exact text
$newtext = '+' . implode(' +', $words);
$quoted_text = FLEXI_J16GE ? $db->escape($newtext, true) : $db->getEscaped($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$exact_text = $db->Quote('%' . $escaped_text . '%', false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) AND ' . $ts . '.search_index LIKE ' . $exact_text;
}
break;
case 'all':
$words = preg_split('/\\s\\s*/u', $text);
$stopwords = array();
$shortwords = array();
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 1);
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
$newtext = '+' . implode('* +', $words) . '*';
$quoted_text = FLEXI_J16GE ? $db->escape($newtext, true) : $db->getEscaped($newtext, true);
$quoted_text = $db->Quote($quoted_text, false);
$_text_match = ' MATCH (' . $ts . '.search_index) AGAINST (' . $quoted_text . ' IN BOOLEAN MODE) ';
break;
case 'any':
default:
// Check for LIKE %word% search, for languages without spaces
if ($filter_word_like_any) {
$_text_match = ' LOWER (' . $ts . '.search_index) LIKE ' . $db->Quote('%' . $escaped_text . '%', false);
} else {
$words = preg_split('/\\s\\s*/u', $text);
$stopwords = array();
$shortwords = array();
$words = flexicontent_db::removeInvalidWords($words, $stopwords, $shortwords, $si_tbl, 'search_index', $isprefix = 1);
JRequest::setVar('ignoredwords', implode(' ', $stopwords));
JRequest::setVar('shortwords', implode(' ', $shortwords));
//.........这里部分代码省略.........