当前位置: 首页>>代码示例>>PHP>>正文


PHP SPRequest::cleanArray方法代码示例

本文整理汇总了PHP中SPRequest::cleanArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::cleanArray方法的具体用法?PHP SPRequest::cleanArray怎么用?PHP SPRequest::cleanArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPRequest的用法示例。


在下文中一共展示了SPRequest::cleanArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 protected function search()
 {
     $this->_request = SPRequest::search('field_');
     $this->_request['search_for'] = str_replace('*', '%', SPRequest::string('sp_search_for', null));
     $this->_request['phrase'] = SPRequest::string('spsearchphrase', Sobi::Cfg('search.form_searchphrase_def', 'all'));
     $this->_request['phrase'] = strlen($this->_request['phrase']) ? $this->_request['phrase'] : Sobi::Cfg('search.form_searchphrase_def', 'all');
     $ssid = SPRequest::cmd('ssid', SPRequest::cmd('ssid', null, 'cookie'));
     $this->_fields = $this->loadFields();
     $searchForString = false;
     Sobi::Trigger('OnRequest', 'Search', array(&$this->_request));
     $searchLimit = Sobi::Cfg('search.result_limit', 1000);
     for ($i = 1; $i < 11; $i++) {
         $this->_resultsByPriority[$i] = array();
     }
     // if the visitor wasn't on the search page first
     if (!$ssid || SPRequest::int('reset', 0)) {
         $this->session($ssid);
     }
     /* clean request */
     if (count($this->_request)) {
         foreach ($this->_request as $i => $v) {
             if (is_array($v)) {
                 foreach ($v as $index => $value) {
                     $v[$index] = htmlspecialchars_decode($value, ENT_QUOTES);
                 }
                 $this->_request[$i] = SPRequest::cleanArray($v, true);
             } else {
                 $this->_request[$i] = $this->_db->escape($v);
             }
         }
     }
     /* sort fields by priority */
     usort($this->_fields, array('self', 'sortByPrio'));
     /* First the basic search ..... */
     /* if we have a string to search */
     if (strlen($this->_request['search_for']) && $this->_request['search_for'] != Sobi::Txt('SH.SEARCH_FOR_BOX')) {
         $searchForString = true;
         $this->_narrowing = true;
         switch ($this->_request['phrase']) {
             case 'exact':
                 $this->searchPhrase();
                 break;
             default:
             case 'all':
             case 'any':
                 $this->searchWords($this->_request['phrase'] == 'all');
                 break;
         }
         $this->_results = array_unique($this->_results);
     }
     Sobi::Trigger('AfterBasic', 'Search', array(&$this->_results, &$this->_resultsByPriority));
     /* ... now the extended search. Check which data we've received */
     if (count($this->_fields)) {
         $results = null;
         foreach ($this->_fields as $field) {
             if (isset($this->_request[$field->get('nid')]) && $this->_request[$field->get('nid')] != null) {
                 $this->_narrowing = true;
                 $fr = $field->searchData($this->_request[$field->get('nid')], Sobi::Section());
                 $priority = $field->get('priority');
                 if (is_array($fr)) {
                     $this->_resultsByPriority[$priority] = array_merge($this->_resultsByPriority[$priority], $fr);
                 }
                 /* if we didn't got any results before this array contains the results */
                 if (!is_array($results)) {
                     $results = $fr;
                 } else {
                     if (is_array($fr)) {
                         $results = array_intersect($results, $fr);
                     }
                 }
             }
         }
         /** Tue, Oct 21, 2014 10:18:37
          * No result is also a result so no "count"
          * */
         //			if ( is_array( $results ) && count( $results ) ) {
         if (is_array($results)) {
             /* if we had also a string to search we have to get the intersection */
             if ($searchForString) {
                 $this->_results = array_intersect($this->_results, $results);
             } else {
                 $this->_results = $results;
             }
         }
     }
     $this->verify();
     /** @since 1.1 - a method to narrow the search results down */
     if (count($this->_fields)) {
         // If we have any results already - the we are limiting results down
         // if we don't have results but we were already searching then skip - because there is nothing to narrow down
         // if we don't have results but we weren't searching for anything else - then we are narrowing down everything
         if (count($this->_results) || !$this->_narrowing) {
             foreach ($this->_fields as &$field) {
                 $request = isset($this->_request[$field->get('nid')]) ? $this->_request[$field->get('nid')] : null;
                 if ($request) {
                     $field->searchNarrowResults($request, $this->_results, $this->_resultsByPriority);
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:search.php


注:本文中的SPRequest::cleanArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。