當前位置: 首頁>>代碼示例>>PHP>>正文


PHP flexicontent_db::removeInvalidWords方法代碼示例

本文整理匯總了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();
//.........這裏部分代碼省略.........
開發者ID:noxidsoft,項目名稱:flexicontent-cck,代碼行數:101,代碼來源:category.php

示例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) {
開發者ID:nettdotkomm,項目名稱:flexicontent-cck,代碼行數:67,代碼來源:flexiadvsearch.php

示例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));
//.........這裏部分代碼省略.........
開發者ID:nettdotkomm,項目名稱:flexicontent-cck,代碼行數:101,代碼來源:favourites.php

示例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));
//.........這裏部分代碼省略.........
開發者ID:jakesyl,項目名稱:flexicontent,代碼行數:101,代碼來源:category.php


注:本文中的flexicontent_db::removeInvalidWords方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。