Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/user/search.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: search.php 9891 2003-09-04 16:13:04Z br $
5 //
6 // Created on: <28-Oct-2000 15:56:58 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlocale.php" );
31
32 // include_once( "ezarticle/classes/ezarticlecategory.php" );
33 // include_once( "ezarticle/classes/ezarticle.php" );
34 // include_once( "classes/ezlist.php" );
35
36 $Language = $ini->variable( "eZArticleMain", "Language" );
37 $Limit = $ini->variable( "eZArticleMain", "SearchListLimit" );
38 $SearchWithinSections = $ini->variable( "eZArticleMain", "SearchWithinSections" );
39
40 // init the section
41 if ( isset ($SectionIDOverride) )
42 {
43 $GlobalSectionID = $SectionIDOverride;
44 // include_once( "ezsitemanager/classes/ezsection.php" );
45
46 $sectionObject =& eZSection::globalSectionObject( $SectionIDOverride );
47 $sectionObject->setOverrideVariables();
48 }
49 else
50 {
51 $SectionIDOverride = false;
52 }
53
54 $t = new eZTemplate( "kernel/ezarticle/user/" . $ini->variable( "eZArticleMain", "TemplateDir" ),
55 "kernel/ezarticle/user/intl/", $Language, "search.php" );
56
57 $t->setAllStrings();
58
59 // $t->set_file( "article_list_page_tpl", "search.tpl" );
60
61 $t->set_file( array(
62 "article_list_page_tpl" => "search.tpl"
63 ) );
64
65 // article
66 $t->set_block( "article_list_page_tpl", "article_list_tpl", "article_list" );
67 $t->set_block( "article_list_tpl", "article_item_tpl", "article_item" );
68
69 // Init url variables - for eZList...
70 $t->set_var( "url_start_stamp", urlencode( "+" ) );
71 $t->set_var( "url_stop_stamp", urlencode( "+" ) );
72 $t->set_var( "url_category_array", urlencode( "+" ) );
73 $t->set_var( "url_contentswriter_id", urlencode( "+" ) );
74 $t->set_var( "url_photographer_id", urlencode( "+" ) );
75
76 if ( isset($_REQUEST['StartMonth']) && isset($_REQUEST['StartDay']) && isset($_REQUEST['StartYear']) &&
77 checkdate ( $_REQUEST['StartMonth'], $_REQUEST['StartDay'], $_REQUEST['StartYear'] ) )
78 {
79 $startDate = new eZDateTime( $_REQUEST['StartYear'], $_REQUEST['StartMonth'], $_REQUEST['StartDay'],
80 $_REQUEST['StartHour'], $_REQUEST['StartMinute'], 0 );
81 $StartStamp = $startDate->timeStamp();
82 }
83 if ( isset($_REQUEST['StopMonth']) && isset($_REQUEST['StopDay']) && isset($_REQUEST['StopYear']) &&
84 checkdate ( $StopMonth, $StopDay, $StopYear ) )
85 {
86 $stopDate = new eZDateTime( $_REQUEST['StopYear'], $_REQUEST['StopMonth'], $_REQUEST['StopDay'],
87 $_REQUEST['StopHour'], $_REQUEST['StopMinute'], 0 );
88 $StopStamp = $stopDate->timeStamp();
89 }
90
91 $t->set_var( "search_text", "" );
92
93 if ( isset( $CategoryID ) )
94 {
95 $category = new eZArticleCategory( $CategoryID );
96 }
97 else
98 {
99 $category = new eZArticleCategory();
100 }
101
102 $t->set_var( "current_category_id", $category->id() );
103 $t->set_var( "current_category_name", $category->name() );
104 $t->set_var( "current_category_description", $category->description() );
105
106 $tmpSearchText = str_replace( "<", "&lt;", $_REQUEST['SearchText'] );
107 $tmpSearchText = str_replace( ">", "&gt;", $tmpSearchText );
108 $t->set_var( "search_text", $tmpSearchText );
109
110 $Offset = isset ( $_REQUEST['Offset'] )?isset ( $_REQUEST['Offset'] ):0;
111
112 // articles
113 $paramsArray = array();
114 if ( isset($_REQUEST['SearchText']) )
115 {
116 /* if ( isset( $StartStamp ) )
117 {
118 $paramsArray["FromDate"] = $StartStamp;
119 $t->set_var( "url_start_stamp", urlencode( $StartStamp ) );
120 }
121
122 if ( isset( $StopStamp ) )
123 {
124 $paramsArray["ToDate"] = $StopStamp;
125 $t->set_var( "url_stop_stamp", urlencode( $StopStamp ) );
126 } */
127
128 if ( $SearchWithinSections == "enabled" )
129 {
130 if ( isset( $SectionsList ) )
131 {
132 $paramsArray["SectionsList"] = $SectionsList;
133 }
134 else
135 {
136 $paramsArray["SectionsList"] = "$SectionIDOverride";
137 }
138 }
139
140 if( isset($_REQUEST['ContentsWriterID']) )
141 {
142 $paramsArray["AuthorID"] = $_REQUEST['ContentsWriterID'];
143 $t->set_var( "url_contentswriter_id", htmlspecialchars( $_REQUEST['ContentsWriterID'] ) );
144 }
145
146 if( isset($_REQUEST['PhotographerID'] ))
147 {
148 $paramsArray["PhotographerID"] = $_REQUEST['PhotographerID'];
149 $t->set_var( "url_photographer_id", htmlspecialchars( $_REQUEST['PhotographerID'] ) );
150 }
151
152 if( isset($_REQUEST['CategoryArray']) && is_array( $_REQUEST['CategoryArray'] ) &&
153 count( $_REQUEST['CategoryArray'] ) > 0 && !in_array( 0, $_REQUEST['CategoryArray'] ) )
154 {
155 $paramsArray["Categories"] = $_REQUEST['CategoryArray'];
156
157 // fix output string for URL
158 $t->set_var( "url_category_array", htmlspecialchars( implode( "-", $_REQUEST['CategoryArray'] ) ) );
159 }
160 /*
161 echo "StartStamp: ".$StartStamp."<br>";
162 echo "StopStamp: ".$StopStamp."<br>";
163 echo "SectionID: ".$SectionIDOverride."<br>";
164 echo "ContentWriterID: ".$ContentsWriterID."<br>";
165 echo "PhotographerID: ".$PhotographerID."<br>";
166 echo "<pre>";
167 print_r ( $paramsArray );
168 echo "</pre>";
169 exit(); */
170
171 $t->set_var( "search_text", $tmpSearchText );
172
173 $article = new eZArticle();
174 $totalCount = 0;
175 $articleList = $article->search( $_REQUEST['SearchText'], "time", false, $Offset, $Limit, $paramsArray, $totalCount );
176
177 $t->set_var( "url_text", htmlspecialchars( $_REQUEST['SearchText'] ) );
178 }
179
180 // if ( ( $MaxSearchForArticles != 0 ) && ( $MaxSearchForArticles < $totalCount ) )
181
182 if ( isset( $articleList ) && count ( $articleList ) > 0 )
183 {
184 $locale = new eZLocale( $Language );
185 $i=0;
186 $t->set_var( "article_list", "" );
187 foreach ( $articleList as $article )
188 {
189 $t->set_var( "article_name", $article->name() );
190
191 $t->set_var( "article_id", $article->id() );
192
193 $t->set_var( "category_id", $article->GetCategory( $SectionIDOverride ) );
194
195 if ( ( $i % 2 ) == 0 )
196 {
197 $t->set_var( "td_class", "bglight" );
198 }
199 else
200 {
201 $t->set_var( "td_class", "bgdark" );
202 }
203
204 $published = $article->published();
205
206 $t->set_var( "article_published", $locale->format( $published ) );
207
208 $t->parse( "article_item", "article_item_tpl", true );
209 $i++;
210 }
211 }
212
213 //echo "<pre>";
214 //print_r ( $t );
215
216 //echo "totalCount:".$totalCount."<br>";
217 //echo "Limit:".$Limit."<br>";
218 //echo "Offset:".$Offset."<br>";
219 //echo "</pre>";
220 //exit();
221
222 eZList::drawNavigator( $t, $totalCount, $Limit, $Offset, "article_list_page_tpl" );
223
224
225 if ( isset( $articleList ) && count( $articleList ) > 0 )
226 $t->parse( "article_list", "article_list_tpl" );
227 else
228 $t->set_var( "article_list", "" );
229
230 if ( $totalCount == 0 )
231 $t->set_var( "article_start", 0 );
232 else
233 $t->set_var( "article_start", $Offset + 1 );
234
235 $t->set_var( "article_end", min( $Offset + $Limit, $totalCount ) );
236 $t->set_var( "article_total", $totalCount );
237
238 if ( isset ($SectionIDOverride) ) $t->set_var( "section_id", $SectionIDOverride );
239
240 $t->pparse( "output", "article_list_page_tpl" );
241
242 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$locale
$locale
Definition: admin/adlist.php:127
$i
$i
Definition: admin/adlist.php:91
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$sectionObject
$sectionObject
Definition: articleheaderlist.php:49
$article
$article
Definition: articlelog.php:45
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticle
Definition: ezarticle.php:82
eZDateTime
Definition: ezdatetime.php:55
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
$ini
$ini
Definition: classes/admin/linklist.php:64
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$totalCount
$totalCount
Definition: ezarticle/admin/formlist.php:73
$Limit
$Limit
Definition: ezarticle/user/search.php:37
$paramsArray
$paramsArray
Definition: ezarticle/user/search.php:113
$SearchWithinSections
$SearchWithinSections
Definition: ezarticle/user/search.php:38
$t
$t
Definition: ezarticle/user/search.php:54
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$Language
$Language
Definition: ezarticle/user/search.php:36
$tmpSearchText
$tmpSearchText
Definition: ezarticle/user/search.php:106
$articleList
$articleList
Definition: pendinglist.php:112
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.