Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

user/linkcategorylist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: linkcategorylist.php 7517 2001-09-27 12:49:48Z th $
5 //
6 // Created on: <26-Oct-2000 15:02:09 ce>
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/eztemplate.php" );
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/ezlist.php" );
30
31
32 // include_once( "ezlink/classes/ezlinkcategory.php" );
33 // include_once( "ezlink/classes/ezlink.php" );
34 // include_once( "ezlink/classes/ezhit.php" );
35 // include_once( "ezlink/classes/ezlinktype.php" );
36 // include_once( "ezsitemanager/classes/ezsection.php" );
37
38 if ( !isset( $Offset ) )
39 $Offset = 0;
40
41 if ( !isset( $LinkCategoryID ) )
42 $LinkCategoryID = false;
43
44 // List all the categories
45 $linkCategory = new eZLinkCategory();
46 $linkCategory->get( $LinkCategoryID );
47
48 // section
49
50 if ( is_numeric( $linkCategory->sectionID() ) )
51 {
52 $GlobalSectionID = $linkCategory->sectionID();
53 // init the section
54 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
55 $sectionObject->setOverrideVariables();
56 }
57
58
59
60 $ini =& eZINI::instance( 'site.ini' );
61 $Language = $ini->variable( "eZLinkMain", "Language" );
62 $UserLimit = $ini->variable( "eZLinkMain", "UserLinkLimit" );
63 $languageIni = new eZINI( "kernel/ezlink/user/intl/". $Language . "/linkcategorylist.php.ini", false );
64
65
66 $t = new eZTemplate( "kernel/ezlink/user/" . $ini->variable( "eZLinkMain", "TemplateDir" ),
67 "kernel/ezlink/user/intl", $Language, "linkcategorylist.php" );
68
69 $t->setAllStrings();
70
71 $t->set_file( "link_page_tpl", "linkcategorylist.tpl" );
72
73 $t->set_block( "link_page_tpl", "headline_tpl", "headline_item" );
74 $t->set_block( "link_page_tpl", "category_name_tpl", "category_name_item" );
75
76 $t->set_block( "link_page_tpl", "category_list_tpl", "category_list" );
77 $t->set_block( "category_list_tpl", "category_item_tpl", "category_item" );
78
79 $t->set_block( "category_item_tpl", "image_item_tpl", "image_item" );
80 $t->set_block( "category_item_tpl", "no_image_tpl", "no_image" );
81
82 $t->set_block( "link_page_tpl", "link_list_tpl", "link_list" );
83 $t->set_block( "link_list_tpl", "link_item_tpl", "link_item" );
84
85 $t->set_block( "link_item_tpl", "link_image_item_tpl", "link_image_item" );
86 $t->set_block( "link_item_tpl", "attribute_list_tpl", "attribute_list" );
87
88 $t->set_block( "attribute_list_tpl", "attribute_tpl", "attribute" );
89 $t->set_block( "attribute_list_tpl", "attribute_value_tpl", "attribute_value" );
90 $t->set_block( "attribute_list_tpl", "attribute_header_tpl", "attribute_header" );
91
92 $t->set_block( "link_page_tpl", "path_item_tpl", "path_item" );
93
94
95 $t->set_var( "attribute_header", "" );
96 $t->set_var( "attribute_value", "" );
97
98 // Path
99 $pathArray = $linkCategory->path();
100
101 $t->set_var( "path_item", "" );
102 foreach ( $pathArray as $path )
103 {
104 $t->set_var( "category_id", $path[0] );
105 $t->set_var( "category_name", $path[1] );
106 $t->parse( "path_item", "path_item_tpl", true );
107 }
108
109 if ( !isset( $path[1] ) or !$path[1] )
110 {
111 $t->parse( "headline_item", "headline_tpl" );
112 $t->set_var( "category_name_item", "" );
113 }
114 else
115 {
116 $t->parse( "category_name_item", "category_name_tpl" );
117 $t->set_var( "headline_item", "" );
118 }
119
120 $linkCategory_array = $linkCategory->getByParent( $LinkCategoryID );
121
122 if ( empty( $linkCategory_array ) or count( $linkCategory_array ) == 0 )
123 {
124 $t->set_var( "categories", "" );
125 $t->set_var( "category_list", "" );
126 }
127 else
128 {
129 $i = 0;
130 foreach( $linkCategory_array as $categoryItem )
131 {
132 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
133
134 $link_category_id = $categoryItem->id();
135 $t->set_var( "linkcategory_id", $link_category_id );
136 $t->set_var( "linkcategory_name", $categoryItem->name() );
137 $t->set_var( "linkcategory_description", $categoryItem->description() );
138 $t->set_var( "linkcategory_parent", $categoryItem->parent() );
139
140 $image =& $categoryItem->image();
141
142 $t->set_var( "image_item" , "" );
143
144 if ( $image )
145 {
146 $imageWidth =& $ini->variable( "eZLinkMain", "CategoryImageWidth" );
147 $imageHeight =& $ini->variable( "eZLinkMain", "CategoryImageHeight" );
148
149 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
150
151 $imageURL = "/" . $variation->imagePath();
152 $imageWidth = $variation->width();
153 $imageHeight = $variation->height();
154 $imageCaption = $image->caption();
155
156 $t->set_var( "image_width", $imageWidth );
157 $t->set_var( "image_height", $imageHeight );
158 $t->set_var( "image_url", $imageURL );
159 $t->set_var( "image_caption", $imageCaption );
160 $t->set_var( "no_image", "" );
161 $t->parse( "image_item", "image_item_tpl" );
162 }
163 else
164 {
165 $t->parse( "no_image", "no_image_tpl" );
166 $t->set_var( "image_item", "" );
167 }
168
169 $categories = $languageIni->variable( "strings", "categories" );
170
171 $t->set_var( "categories", $categories );
172
173 $i++;
174 $t->parse( "category_item", "category_item_tpl", true );
175 }
176 $t->parse( "category_list", "category_list_tpl", true );
177 }
178
179
180 // List all the links in the category
181 $links = $linkCategory->links( $Offset, $UserLimit );
182 $linkCount = $linkCategory->linkCount();
183 if ( count( $links ) == 0 )
184 {
185 if ( $LinkCategoryID == 0 )
186 {
187 $t->set_var( "link_list", "" );
188 }
189 else
190 {
191 $t->set_var( "links", "" );
192 $t->set_var( "link_list", "" );
193 }
194
195 }
196 else
197 {
198 $i = 0;
199 foreach ( $links as $linkItem )
200 {
201 if ( ( $i % 2 ) == 0 )
202 {
203 $t->set_var( "td_class", "bglight" );
204 }
205 else
206 {
207 $t->set_var( "td_class", "bgdark" );
208 }
209 $t->set_var( "link_id", $linkItem->id() );
210 $t->set_var( "link_name", $linkItem->name() );
211 $t->set_var( "link_description", $linkItem->description() );
212 $t->set_var( "link_keywords", $linkItem->keywords() );
213 $t->set_var( "link_created", $linkItem->created() );
214 $t->set_var( "link_modified", $linkItem->modified() );
215 $t->set_var( "link_accepted", $linkItem->accepted() );
216 $t->set_var( "link_url", $linkItem->url() );
217
218 $image =& $linkItem->image();
219
220 $t->set_var( "link_image_item", "" );
221
222 if ( $image )
223 {
224 $imageWidth =& $ini->variable( "eZLinkMain", "LinkImageWidth" );
225 $imageHeight =& $ini->variable( "eZLinkMain", "LinkImageHeight" );
226
227 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
228
229 $imageURL = "/" . $variation->imagePath();
230 $imageWidth = $variation->width();
231 $imageHeight = $variation->height();
232 $imageCaption = $image->caption();
233
234 $t->set_var( "image_width", $imageWidth );
235 $t->set_var( "image_height", $imageHeight );
236 $t->set_var( "image_url", $imageURL );
237 $t->set_var( "image_caption", $imageCaption );
238
239 $t->parse( "link_image_item", "link_image_item_tpl" );
240 }
241
242 $hit = new eZHit();
243 $hits = $hit->getLinkHits( $linkItem->id() );
244 $t->set_var( "link_hits", $hits );
245
246 $links = $languageIni->variable( "strings", "links" );
247 $t->set_var( "links", $links );
248 $i++;
249 $t->set_var( "attribute", "" );
250 // attribute list
251 $type = $linkItem->type();
252 if ( $type )
253 {
254 $attributes = $type->attributes();
255 for( $i2 = 0; $i2 < count( $attributes ); $i2++ )
256 {
257 if ( ( $i2 % 2 ) == 0 )
258 {
259 $t->set_var( "begin_tr", "<tr>" );
260 $t->set_var( "end_tr", "" );
261 }
262 else
263 {
264 $t->set_var( "begin_tr", "" );
265 $t->set_var( "end_tr", "</tr>" );
266 }
267
268 $value =& $attributes[$i2]->value( $linkItem );
269 $t->set_var( "attribute_id", $attributes[$i2]->id( ) );
270 $t->set_var( "attribute_name", $attributes[$i2]->name( ) );
271 $t->set_var( "attribute_unit", $attributes[$i2]->unit( ) );
272 $t->set_var( "attribute_value_var", $value );
273
274 if ( ( is_numeric( $value ) and ( $value > 0 ) ) || ( !is_numeric( $value ) and $value != "" ) )
275 {
276 $t->parse( "attribute", "attribute_value_tpl", true );
277 }
278 }
279 }
280
281 if ( isset( $attributes ) && count( $attributes ) > 0 and $type )
282 {
283 $t->parse( "attribute_list", "attribute_list_tpl" );
284 }
285 else
286 {
287 $t->set_var( "attribute_list", "" );
288 }
289 $t->parse( "link_item", "link_item_tpl", true );
290 }
291 $t->parse( "link_list", "link_list_tpl", true );
292 }
293
294 eZList::drawNavigator( $t, $linkCount, $UserLimit, $Offset, "link_page_tpl" );
295
296 $t->set_var( "link_start", $Offset + 1 );
297 $t->set_var( "link_end", min( $Offset + $UserLimit, $linkCount ) );
298 $t->set_var( "link_total", $linkCount );
299
300 $t->set_var( "linkcategory_id", $LinkCategoryID );
301
302 $t->pparse( "output", "link_page_tpl" );
303
304 ?>
$i
$i
Definition: admin/adlist.php:91
$sectionObject
$sectionObject
Definition: articleheaderlist.php:49
eZHit
Definition: ezhit.php:40
eZINI
Reads and writes .ini style configuration files.
eZLinkCategory
Definition: ezlinkcategory.php:37
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
$type
$type
Definition: classes/admin/linkselect.php:220
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$image
$image
Definition: user/articlelist.php:242
$UserLimit
$UserLimit
Definition: user/linkcategorylist.php:62
$ini
if(is_numeric( $linkCategory->sectionID())) $ini
Definition: user/linkcategorylist.php:60
$linkCategory
$linkCategory
Definition: user/linkcategorylist.php:45
$languageIni
$languageIni
Definition: user/linkcategorylist.php:63
$t
$t
Definition: user/linkcategorylist.php:66
$links
$links
Definition: user/linkcategorylist.php:181
$pathArray
$pathArray
Definition: user/linkcategorylist.php:99
$Language
$Language
Definition: user/linkcategorylist.php:61
$linkCategory_array
$linkCategory_array
Definition: user/linkcategorylist.php:120
$linkCount
$linkCount
Definition: user/linkcategorylist.php:182
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.