[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <24-Apr-2002 16:06:53 bf> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 28 29 include_once ( "kernel/common/template.php" ); 30 31 include_once ( "kernel/classes/ezsearch.php" ); 32 include_once ( "kernel/classes/ezsearchlog.php" ); 33 34 /*! 35 Get search limit 36 */ 37 function pageLimit( $searchPageLimit ) 38 { 39 switch ( $searchPageLimit ) 40 { 41 case 1: 42 return 5; 43 44 case 2: 45 default: 46 return 10; 47 48 case 3: 49 return 20; 50 51 case 4: 52 return 30; 53 54 case 5: 55 return 50; 56 } 57 } 58 59 $http =& eZHTTPTool::instance(); 60 61 $Module =& $Params["Module"]; 62 $Offset = $Params['Offset']; 63 64 if ( !is_numeric( $Offset ) ) 65 $Offset = 0; 66 67 $tpl =& templateInit(); 68 69 $ini =& eZINI::instance(); 70 $useSearchCode = $ini->variable( 'SearchSettings', 'SearchViewHandling' ) == 'default'; 71 $logSearchStats = $ini->variable( 'SearchSettings', 'LogSearchStats' ) == 'enabled'; 72 73 $searchPageLimit = 2; 74 if ( $http->hasVariable( 'SearchPageLimit' ) ) 75 { 76 $searchPageLimit = $http->variable( 'SearchPageLimit' ); 77 } 78 79 $pageLimit = pageLimit( $searchPageLimit ); 80 81 $maximumSearchLimit = $ini->variable( 'SearchSettings', 'MaximumSearchLimit' ); 82 if ( $pageLimit > $maximumSearchLimit ) 83 $pageLimit = $maximumSearchLimit; 84 85 $searchText = ''; 86 if ( $http->hasVariable( "SearchText" ) ) 87 { 88 $searchText = $http->variable( "SearchText" ); 89 } 90 91 $searchSectionID = -1; 92 if ( $http->hasVariable( "SectionID" ) ) 93 { 94 $searchSectionID = $http->variable( "SectionID" ); 95 } 96 97 $searchTimestamp = false; 98 if ( $http->hasVariable( 'SearchTimestamp' ) and 99 $http->variable( 'SearchTimestamp' ) ) 100 { 101 $searchTimestamp = $http->variable( 'SearchTimestamp' ); 102 } 103 104 $searchType = "fulltext"; 105 if ( $http->hasVariable( "SearchType" ) ) 106 { 107 $searchType = $http->variable( "SearchType" ); 108 } 109 110 $subTreeArray = array(); 111 if ( $http->hasVariable( "SubTreeArray" ) ) 112 { 113 if ( is_array( $http->variable( "SubTreeArray" ) ) ) 114 $subTreeList = $http->variable( "SubTreeArray" ); 115 else 116 $subTreeList = array( $http->variable( "SubTreeArray" ) ); 117 foreach ( $subTreeList as $subTreeItem ) 118 { 119 if ( $subTreeItem > 0 ) 120 $subTreeArray[] = $subTreeItem; 121 } 122 } 123 124 $Module->setTitle( "Search for: $searchText" ); 125 126 if ( $useSearchCode ) 127 { 128 $sortArray = array( array( 'attribute', true, 153 ), array( 'priority', true ) ); 129 $searchResult = eZSearch::search( $searchText, array( "SearchType" => $searchType, 130 "SearchSectionID" => $searchSectionID, 131 "SearchSubTreeArray" => $subTreeArray, 132 'SearchTimestamp' => $searchTimestamp, 133 "SearchLimit" => $pageLimit, 134 "SearchOffset" => $Offset ) ); 135 } 136 137 if ( $searchSectionID != -1 ) 138 { 139 include_once ( 'kernel/common/eztemplatedesignresource.php' ); 140 $res =& eZTemplateDesignResource::instance(); 141 $res->setKeys( array( array( 'section', $searchSectionID ) ) ); 142 } 143 144 $viewParameters = array( 'offset' => $Offset ); 145 146 $searchData = false; 147 $tpl->setVariable( "search_data", $searchData ); 148 $tpl->setVariable( "search_section_id", $searchSectionID ); 149 $tpl->setVariable( "search_subtree_array", $subTreeArray ); 150 $tpl->setVariable( 'search_timestamp', $searchTimestamp ); 151 $tpl->setVariable( "search_text", $searchText ); 152 $tpl->setVariable( 'search_page_limit', $searchPageLimit ); 153 154 $tpl->setVariable( "view_parameters", $viewParameters ); 155 $tpl->setVariable( 'use_template_search', !$useSearchCode ); 156 157 if ( $http->hasVariable( 'Mode' ) && $http->variable( 'Mode' ) == 'browse' ) 158 { 159 if( !isset( $searchResult ) ) 160 $searchResult = eZSearch::search( $searchText, array( "SearchType" => $searchType, 161 "SearchSectionID" => $searchSectionID, 162 "SearchSubTreeArray" => $subTreeArray, 163 'SearchTimestamp' => $searchTimestamp, 164 "SearchLimit" => $pageLimit, 165 "SearchOffset" => $Offset ) ); 166 $sys = eZSYS::instance(); 167 $searchResult['RequestedURI'] = "content/search"; 168 // $searchResult['RequestedURISuffix'] = $sys->serverVariable( "QUERY_STRING" ); 169 170 171 $searchResult['RequestedURISuffix'] = 'SearchText=' . urlencode ( $searchText ) . ( ( $searchTimestamp > 0 ) ? '&SearchTimestamp=' . $searchTimestamp : '' ) . '&Mode=browse'; 172 return $Module->run( 'browse',array(),array( "NodeList" => $searchResult, 173 "Offset" => $Offset ) ); 174 } 175 176 // --- Compatability code start --- 177 if ( $useSearchCode ) 178 { 179 $tpl->setVariable( "offset", $Offset ); 180 $tpl->setVariable( "page_limit", $pageLimit ); 181 $tpl->setVariable( "search_text_enc", urlencode( $searchText ) ); 182 $tpl->setVariable( "search_result", $searchResult["SearchResult"] ); 183 $tpl->setVariable( "search_count", $searchResult["SearchCount"] ); 184 $tpl->setVariable( "stop_word_array", $searchResult["StopWordArray"] ); 185 } 186 else 187 { 188 $tpl->setVariable( "offset", false ); 189 $tpl->setVariable( "page_limit", false ); 190 $tpl->setVariable( "search_text_enc", false ); 191 $tpl->setVariable( "search_result", false ); 192 $tpl->setVariable( "search_count", false ); 193 $tpl->setVariable( "stop_word_array", false ); 194 } 195 // --- Compatability code end --- 196 197 $Result = array(); 198 $Result['content'] =& $tpl->fetch( "design:content/search.tpl" ); 199 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Search' ), 200 'url' => false ) ); 201 if ( !$useSearchCode ) 202 { 203 $searchData = $tpl->variable( "search_data" ); 204 } 205 else 206 { 207 $searchData = $searchResult; 208 } 209 210 if ( $logSearchStats and trim( $searchText ) != "" ) 211 eZSearchLog::addPhrase( $searchText, $searchData["SearchCount"] ); 212 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |