Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezforum/user/search.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: search.php 9499 2002-05-02 13:36:52Z bf $
5 //
6 // Created on: <12-Oct-2000 20:33:02 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 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/ezlocale.php" );
29 // include_once( "classes/ezhttptool.php" );
30 // include_once( "classes/ezlist.php" );
31 // include_once( "classes/eztemplate.php" );
32
33 // include_once( "ezforum/classes/ezforum.php" );
34
35 // include_once( "ezuser/classes/ezuser.php" );
36
37 $ini =& eZINI::instance( 'site.ini' );
38
39 $Language = $ini->variable( "eZForumMain", "Language" );
40 $NewMessageLimit = $ini->variable( "eZForumMain", "NewMessageLimit" );
41 $Limit = $ini->variable( "eZForumMain", "SearchUserLimit" );
42
43 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
44 "kernel/ezforum/user/intl", $Language, "search.php" );
45
46 $t->setAllStrings();
47
48 $t->set_file( "search_tpl", "search.tpl" );
49
50 $t->set_block( "search_tpl", "message_tpl", "message" );
51 $t->set_block( "search_tpl", "empty_result_tpl", "empty_result" );
52 $t->set_block( "search_tpl", "search_result_tpl", "search_result" );
53
54 $t->set_block( "message_tpl", "new_icon_tpl", "new_icon" );
55 $t->set_block( "message_tpl", "old_icon_tpl", "old_icon" );
56
57
58 if ( !isset( $Offset ) )
59 $Offset = 0;
60
61 $t->set_var( "url_text", "" );
62 $t->set_var( "search_result", "" );
63
64 $db =& eZDB::globalDatabase();
65
66 if ( isset( $SearchText ) and !isset( $QueryString ) )
67 $QueryString = $SearchText;
68
69 if ( $QueryString != "" )
70 {
71 $tmpQueryString = str_replace( "<", "&lt;", $QueryString );
72 $tmpQueryString = str_replace( ">", "&gt;", $tmpQueryString );
73
74 $t->set_var( "url_text", $tmpQueryString );
75
76 $forum = new eZForum();
77
78 // do a search in all forums
79 $messages = $forum->search( $QueryString, $Offset, $Limit, $total_count );
80
81 $locale = new eZLocale( $Language );
82
83 $level = 0;
84 $i = 0;
85
86 if ( count( $messages ) > 0 )
87 {
88 foreach ( $messages as $message )
89 {
90 if ( ( $i % 2 ) == 0 )
91 $t->set_var( "td_class", "bglight" );
92 else
93 $t->set_var( "td_class", "bgdark" );
94
95 $t->set_var( "message_topic", $message->topic() );
96 $t->set_var( "postingtime", $locale->format( $message->postingTime() ) );
97 $t->set_var( "message_id", $message->id() );
98
99 $messageAge = round( $message->age() / ( 60 * 60 * 24 ) );
100 if ( $messageAge <= $NewMessageLimit )
101 {
102 $t->parse( "new_icon", "new_icon_tpl" );
103 $t->set_var( "old_icon", "" );
104 }
105 else
106 {
107 $t->parse( "old_icon", "old_icon_tpl" );
108 $t->set_var( "new_icon", "" );
109 }
110
111 $author = $message->user();
112
113 if ( $author->id() == 0 )
114 {
115 $t->set_var( "user", $ini->variable( "eZForumMain", "AnonymousPoster" ) );
116 }
117 else
118 {
119 $t->set_var( "user", $author->firstName() . " " . $author->lastName() );
120 }
121
122 $t->parse( "message", "message_tpl", true );
123 $i++;
124 }
125 }
126
127 if ( count( $messages ) == 0 )
128 {
129 $t->parse( "empty_result", "empty_result_tpl" );
130 }
131 else
132 {
133 $t->parse( "search_result", "search_result_tpl", true );
134 $t->set_var( "empty_result", "" );
135 }
136 }
137 else
138 {
139 $t->parse( "empty_result", "empty_result_tpl" );
140 }
141
142 eZList::drawNavigator( $t, $total_count, $Limit, $Offset, "search_tpl" );
143
144 $t->set_var( "forum_start", $Offset + 1 );
145 $t->set_var( "forum_end", min( $Offset + $Limit, $total_count ) );
146 $t->set_var( "forum_total", $total_count );
147
148 $t->set_var( "url_query_string", urlencode( $QueryString ) );
149
150 $t->pparse("output","search_tpl");
151
152 ?>
$locale
$locale
Definition: admin/adlist.php:127
$i
$i
Definition: admin/adlist.php:91
$author
$author
Definition: admin/articleedit.php:834
$forum
$forum
Definition: admin/forumlist.php:50
$level
$level
Definition: admin/message.php:106
$message
$message
Definition: admin/message.php:51
$total_count
$total_count
Definition: browserlist.php:54
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZForum
Definition: ezforum.php:44
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZTemplate
Definition: eztemplate.php:107
$SearchText
$SearchText
Definition: ezaddress/admin/typelist.php:143
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$Limit
$Limit
Definition: ezforum/user/search.php:41
$db
$db
Definition: ezforum/user/search.php:64
$t
$t
Definition: ezforum/user/search.php:43
$NewMessageLimit
$NewMessageLimit
Definition: ezforum/user/search.php:40
$Language
$Language
Definition: ezforum/user/search.php:39
$ini
$ini
Definition: ezforum/user/search.php:37
$messages
$messages
Definition: homepage.php:328
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.