Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

companytypelist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: companytypelist.php 9529 2002-05-14 11:17:05Z jhe $
5 //
6 // Created on: <23-Oct-2000 17:53:46 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 Viser firma typer.
29 */
30
31 // include_once( "classes/INIFile.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34 $Language = $ini->variable( "eZContactMain", "Language" );
35 $MaxCompanyList = $ini->variable( "eZContactMain", "MaxCompanyList" );
36 $CompanyOrder = $ini->variable( "eZContactMain", "CompanyOrder" );
37
38 // include_once( "classes/eztemplate.php" );
39 // include_once( "classes/ezlist.php" );
40 // include_once( "ezcontact/classes/ezcompanytype.php" );
41 // include_once( "ezcontact/classes/ezcompany.php" );
42 // include_once( "ezuser/classes/ezuser.php" );
43 // include_once( "ezuser/classes/ezusergroup.php" );
44 // include_once( "ezuser/classes/ezpermission.php" );
45
46 if ( empty( $TypeID ) )
47 {
48 $TypeID = 0;
49 }
50
51 $type = new eZCompanyType();
52 $type->get( $TypeID );
53
54 $company = new eZCompany();
55
56 $user =& eZUser::currentUser();
57 if ( !is_a( $user, "eZUser" ) )
58 {
59 // include_once( "classes/ezhttptool.php" );
60 eZHTTPTool::header( "Location: /contact/nopermission/login" );
61 exit();
62 }
63
64 if ( !eZPermission::checkPermission( $user, "eZContact", "CompanyList" ) )
65 {
66 // include_once( "classes/ezhttptool.php" );
67 eZHTTPTool::header( "Location: /contact/nopermission/company/list" );
68 exit();
69 }
70
71 if ( !$type->id() && $TypeID != 0 )
72 {
73 header( "HTTP/1.0 404 Not Found" );
74 // include_once( "classes/ezhttptool.php" );
75 eZHTTPTool::header( "Location: /contact/company/list/" );
76 exit();
77 }
78 else
79 {
80 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
81 "kernel/ezcontact/admin/intl/", $Language, "companytype.php" );
82 $t->setAllStrings();
83
84 $t->set_file( "type_page", "companytypelist.tpl" );
85
86 $t->set_block( "type_page", "current_type_tpl", "current_type" );
87 $t->set_block( "type_page", "view_tpl", "view" );
88 $t->set_block( "type_page", "list_tpl", "list" );
89 $t->set_block( "type_page", "not_root_tpl", "not_root" );
90 $t->set_block( "type_page", "type_list_tpl", "type_list" );
91
92 $t->set_block( "type_list_tpl", "type_item_tpl", "type_item" );
93 $t->set_block( "type_item_tpl", "type_edit_button_tpl", "type_edit_button" );
94 $t->set_block( "type_item_tpl", "type_delete_button_tpl", "type_delete_button" );
95
96 $t->set_block( "type_page", "type_new_button_tpl", "type_new_button" );
97
98 $t->set_block( "type_page", "category_list_tpl", "category_list" );
99
100 $t->set_block( "type_page", "no_type_item_tpl", "no_type_item" );
101 $t->set_block( "type_page", "no_category_item_tpl", "no_category_item" );
102 $t->set_block( "type_page", "path_tpl", "path" );
103 $t->set_block( "path_tpl", "path_item_tpl", "path_item" );
104 $t->set_block( "current_type_tpl", "image_item_tpl", "image_item" );
105 $t->set_block( "type_page", "company_item_tpl", "company_item" );
106 $t->set_block( "company_item_tpl", "image_view_tpl", "image_view" );
107 $t->set_block( "type_page", "no_companies_tpl", "no_companies" );
108 $t->set_block( "type_page", "companies_table_tpl", "companies_table" );
109 $t->set_block( "companies_table_tpl", "company_stats_header_tpl", "company_stats_header" );
110
111 $t->set_block( "company_item_tpl", "no_image_tpl", "no_image" );
112 $t->set_block( "company_item_tpl", "company_view_button_tpl", "company_view_button" );
113 $t->set_block( "company_item_tpl", "no_company_view_button_tpl", "no_company_view_button" );
114 $t->set_block( "company_item_tpl", "company_consultation_button_tpl", "company_consultation_button" );
115 $t->set_block( "company_item_tpl", "company_buy_button_tpl", "company_buy_button" );
116 $t->set_block( "company_item_tpl", "company_folder_button_tpl", "company_folder_button" );
117 $t->set_block( "company_item_tpl", "company_edit_button_tpl", "company_edit_button" );
118 $t->set_block( "company_item_tpl", "company_delete_button_tpl", "company_delete_button" );
119 $t->set_block( "company_item_tpl", "company_stats_item_tpl", "company_stats_item" );
120 $t->set_block( "type_page", "company_new_button_tpl", "company_new_button" );
121
122 $t->set_var( "image_item", "" );
123 $t->set_var( "command_type", "company" );
124
125 $args = false;
126
127 if ( empty( $OrderBy ) )
128 {
129 $OrderBy = "Name";
130 }
131
132 if ( !empty( $LimitBy ) || !empty( $LimitStart ) )
133 {
134 $type_array = $type->getByParentID( $TypeID, $OrderBy, $LimitBy, $LimitStart );
135
136 if ( empty( $LimitStart ) )
137 {
138 $LimitStart = $LimitBy;
139 }
140 else
141 {
142 $LimitStart += $LimitStart;
143 }
144 }
145 else
146 {
147 $type_array = $type->getByParentID( $TypeID, $OrderBy );
148 }
149
150 if ( !empty( $OrderBy ) )
151 {
152 if ( !empty( $args ) )
153 {
154 $args = $args . "&";
155 }
156 $args = $args . "OrderBy=$OrderBy";
157 }
158
159 if ( !empty( $LimitStart ) )
160 {
161 if ( !empty( $args ) )
162 {
163 $args = $args . "&";
164 }
165 $args = $args . "LimitStart=$LimitStart";
166 }
167
168 if ( !empty( $LimitBy ) )
169 {
170 if ( !empty( $args ) )
171 {
172 $args = $args . "&";
173 }
174 $args = $args . "LimitBy=$LimitBy";
175 }
176
177 $type_count = count( $type_array );
178
179 $t->set_var( "page_args", $args );
180
181 $pathArray = $type->path( $TypeID );
182
183 $t->set_var( "path_item", "" );
184 foreach ( $pathArray as $path )
185 {
186 $t->set_var( "parent_id", $path[0] );
187 $t->set_var( "parent_name", $path[1] );
188
189 $t->parse( "path_item", "path_item_tpl", true );
190 }
191 $t->parse( "path", "path_tpl" );
192
193 $id = $type->id();
194 $name = $type->name();
195 $desc = $type->description();
196
197 $t->set_var( "current_id", is_numeric( $id ) ? $id : 0 );
198 $t->set_var( "current_name", $name );
199 $t->set_var( "current_description", $desc );
200
201 $ImageID = $type->imageID();
202
203 if ( is_numeric( $ImageID ) && $ImageID != 0 )
204 {
205 $imageWidth = $ini->variable( "eZContactMain", "CategoryImageWidth" );
206 $imageHeight = $ini->variable( "eZContactMain", "CategoryImageHeight" );
207
208 $image = new eZImage( $ImageID );
209
210 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
211
212 $imageURL = "/" . $variation->imagePath();
213 $imageWidth = $variation->width();
214 $imageHeight = $variation->height();
215 $imageCaption = $image->caption();
216
217 $t->set_var( "image_width", $imageWidth );
218 $t->set_var( "image_height", $imageHeight );
219 $t->set_var( "image_url", $imageURL );
220 $t->set_var( "image_caption", $imageCaption );
221 $t->parse( "image_item", "image_item_tpl" );
222 }
223
224 $t->parse( "current_type", "current_type_tpl" );
225 if ( $TypeID != 0 && $Action == "view" )
226 {
227 $t->parse( "not_root", "not_root_tpl" );
228 }
229 else
230 {
231 $t->set_var( "not_root", "" );
232 }
233 if ( $Action == "view" )
234 {
235 $t->parse( "view", "view_tpl" );
236 $t->set_var( "list", "" );
237 }
238 if ( $Action == "list" )
239 {
240 $t->set_var( "view", "" );
241 $t->parse( "list", "list_tpl" );
242 }
243
244 $t->set_var( "type_edit_button", "" );
245 $t->set_var( "type_delete_button", "" );
246 if ( eZPermission::checkPermission( $user, "eZContact", "CategoryModify" ) )
247 $t->parse( "type_edit_button", "type_edit_button_tpl" );
248 if ( eZPermission::checkPermission( $user, "eZContact", "CategoryDelete" ) )
249 $t->parse( "type_delete_button", "type_delete_button_tpl" );
250 if ( $type_count != 0 )
251 {
252 for ( $i = 0; $i < $type_count; $i++ )
253 {
254 if ( ( $i % 2 ) == 0 )
255 {
256 $t->set_var( "theme-type_class", "bglight" );
257 }
258 else
259 {
260 $t->set_var( "theme-type_class", "bgdark" );
261 }
262
263 $id = $type_array[$i]->id();
264 $name = $type_array[$i]->name();
265 $desc = $type_array[$i]->description();
266
267 $t->set_var( "type_id", $id );
268
269 if ( empty( $name ) )
270 {
271 $t->set_var( "type_name", "&nbsp;" );
272 }
273 else
274 {
275 $t->set_var( "type_name", $name );
276 }
277 if ( empty( $desc ) )
278 {
279 $t->set_var( "type_description", "&nbsp;" );
280 }
281 else
282 {
283 $t->set_var( "type_description", $desc );
284 }
285 $t->parse( "type_item", "type_item_tpl", true );
286 $typesDone = true;
287 }
288 }
289 $t->set_var( "type_new_button", "" );
290 if ( eZPermission::checkPermission( $user, "eZContact", "CategoryAdd" ) )
291 $t->parse( "type_new_button", "type_new_button_tpl" );
292
293 if ( !is_numeric( $Offset ) )
294 $Offset = 0;
295 if ( !is_numeric( $MaxCompanyList ) )
296 $MaxCompanyList = 10;
297
298 // List all the companies.
299 $companyList = $company->getByCategory( $TypeID, $Offset, $MaxCompanyList, $CompanyOrder );
300 $total_companies = $company->countByCategory( $TypeID );
301
302 $t->set_var( "company_consultation_button", "" );
303 $t->set_var( "company_buy_button", "" );
304 $t->set_var( "company_edit_button", "" );
305 $t->set_var( "company_delete_button", "" );
306 $t->set_var( "company_view_button", "" );
307 $t->set_var( "no_company_view_button", "" );
308
309 $t->parse( "company_folder_button", "company_folder_button_tpl" );
310 if ( eZPermission::checkPermission( $user, "eZContact", "Buy" ) )
311 $t->parse( "company_buy_button", "company_buy_button_tpl" );
312 if ( eZPermission::checkPermission( $user, "eZContact", "Consultation" ) )
313 $t->parse( "company_consultation_button", "company_consultation_button_tpl" );
314 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyModify" ) )
315 $t->parse( "company_edit_button", "company_edit_button_tpl" );
316 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyDelete" ) )
317 $t->parse( "company_delete_button", "company_delete_button_tpl" );
318 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyView" ) )
319 {
320 $t->parse( "company_view_button", "company_view_button_tpl" );
321 }
322 else
323 {
324 $t->parse( "no_company_view_button", "no_company_view_button_tpl" );
325 }
326
327 if ( count( $companyList ) == 0 )
328 {
329
330 $t->set_var( "company_item", "" );
331 $t->set_var( "companies_table", "" );
332 $t->parse( "no_companies", "no_companies_tpl" );
333 }
334 else
335 {
336 $can_view_stats = eZPermission::checkPermission( $user, "eZContact", "CompanyStats" ) && $ShowStats;
337 $t->set_var( "company_stats_header", "" );
338 if ( $can_view_stats )
339 $t->parse( "company_stats_header", "company_stats_header_tpl" );
340 $t->set_var( "company_stats_item", "" );
341 for ( $i = 0; $i < count( $companyList ); $i++ )
342 {
343 if ( ( $i % 2 ) == 0 )
344 $t->set_var( "td_class", "bglight" );
345 else
346 $t->set_var( "td_class", "bgdark" );
347
348 $t->set_var( "company_id", $companyList[$i]->id() );
349 $t->set_var( "company_name", $companyList[$i]->name() );
350 if ( $can_view_stats )
351 {
352 $count = $companyList[$i]->totalViewCount();
353 $t->set_var( "company_views", $count );
354 $t->parse( "company_stats_item", "company_stats_item_tpl" );
355 }
356
357 unSet( $logoObj );
358 $logoObj = $companyList[$i]->logoImage();
359
360 if ( is_a( $logoObj, "eZImage" ) )
361 {
362 $variationObj = $logoObj->requestImageVariation( 150, 150 );
363
364 $t->set_var( "company_logo_src", "/" . $variationObj->imagePath() );
365 $image = new eZImage( $variationObj->imageID() );
366 $t->set_var( "image_alt", $image->caption() );
367 $t->set_var( "no_image", "" );
368 $t->parse( "image_view", "image_view_tpl" );
369 }
370 else
371 {
372 $t->set_var( "image_view", "" );
373 $t->parse( "no_image", "no_image_tpl" );
374 }
375
376 $t->set_var( "no_companies", "" );
377 $t->parse( "company_item", "company_item_tpl", true );
378 }
379
380 $t->set_var( "no_companies", "" );
381 $t->parse( "companies_table", "companies_table_tpl" );
382 }
383 $t->set_var( "company_new_button", "" );
384 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyAdd" ) )
385 $t->parse( "company_new_button", "company_new_button_tpl" );
386
387 if ( isset( $typesDone ) && $typesDone == true )
388 {
389 $t->set_var( "no_type_item", "" );
390 $t->parse( "type_list", "type_list_tpl" );
391 }
392 else
393 {
394 $t->set_var( "type_list", "" );
395 $t->parse( "no_type_item", "no_type_item_tpl" );
396 }
397
398 if ( isset( $categoriesDone ) && $categoriesDone == true )
399 {
400 $t->set_var( "no_category_item", "" );
401 $t->parse( "category_list", "category_list_tpl" );
402 }
403 else
404 {
405 $t->set_var( "category_list", "" );
406 $t->parse( "no_category_item", "no_category_item_tpl" );
407 }
408
409 eZList::drawNavigator( $t, $total_companies, $MaxCompanyList, $Offset, "type_page",
410 array( "type_list" => "company_list",
411 "next" => "",
412 "previous" => "",
413 "next_inactive" => "",
414 "previous_inactive" => "",
415 "item" => "",
416 "item_inactive" => "",
417 "item_list" => "",
418 "next_index" => "",
419 "previous_index" => "",
420 "type_item_name" => "",
421 "item_index" => "",
422 "item_name" => "" ) );
423
424 $t->pparse( "output", "type_page" );
425 }
426
427 ?>
$i
$i
Definition: admin/adlist.php:91
eZCompany
Definition: ezcompany.php:54
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$Action
$Action
Definition: companysearch.php:80
$companyList
$companyList
Definition: companytypelist.php:299
$desc
$desc
Definition: companytypelist.php:195
$company
$company
Definition: companytypelist.php:54
$user
$user
Definition: companytypelist.php:56
$pathArray
$pathArray
Definition: companytypelist.php:181
$type
if(empty( $TypeID)) $type
Definition: companytypelist.php:51
$args
$args
Definition: companytypelist.php:125
$total_companies
$total_companies
Definition: companytypelist.php:300
$type_count
if(!empty( $OrderBy)) if(!empty( $LimitStart)) if(!empty( $LimitBy)) $type_count
Definition: companytypelist.php:177
$Language
$Language
Definition: companytypelist.php:34
$ini
$ini
Definition: companytypelist.php:33
$name
$name
Definition: companytypelist.php:194
$ImageID
$ImageID
Definition: companytypelist.php:201
$CompanyOrder
$CompanyOrder
Definition: companytypelist.php:36
$MaxCompanyList
$MaxCompanyList
Definition: companytypelist.php:35
$id
$id
Definition: companytypelist.php:193
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
exit
exit
Definition: folder.php:81
$count
$count
Definition: onlinetypelist.php:108
$OrderBy
$OrderBy
Definition: reciverpopup.php:21
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.