Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

companysearch.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: companysearch.php 9805 2003-04-10 14:48:45Z br $
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 Searches for companies.
29 */
30 // include_once( "classes/INIFile.php" );
31 // include_once( "classes/eztemplate.php" );
32 // include_once( "ezcontact/classes/ezcompany.php" );
33 // include_once( "ezcontact/classes/ezcompanytype.php" );
34 // include_once( "ezuser/classes/ezpermission.php" );
35
36 $ini =& eZINI::globalINI();
37 $Language = $ini->variable( "eZContactMain", "Language" );
38 $errorIni = new eZINI( "kernel/ezcontact/user/intl/" . $Language . "/companysearch.php.ini", false );
39
40 $t = new eZTemplate( "kernel/ezcontact/user/" . $ini->variable( "eZContactMain", "TemplateDir" ),
41 "kernel/ezcontact/user/intl/", $Language, "companysearch.php" );
42
43 $t->set_file( "search", "companysearch.tpl" );
44
45 $t->set_block( "search", "current_type_tpl", "current_type" );
46 $t->set_block( "search", "list_tpl", "list" );
47 $t->set_block( "search", "not_root_tpl", "not_root" );
48
49 $t->set_block( "search", "category_list_tpl", "category_list" );
50
51 $t->set_block( "search", "no_type_item_tpl", "no_type_item" );
52 $t->set_block( "search", "no_category_item_tpl", "no_category_item" );
53 $t->set_block( "search", "company_item_tpl", "company_item" );
54 $t->set_block( "company_item_tpl", "image_view_tpl", "image_view" );
55 $t->set_block( "search", "no_companies_tpl", "no_companies" );
56 $t->set_block( "search", "companies_table_tpl", "companies_table" );
57 $t->set_block( "companies_table_tpl", "company_stats_header_tpl", "company_stats_header" );
58
59 $t->set_block( "company_item_tpl", "no_image_tpl", "no_image" );
60 $t->set_block( "company_item_tpl", "company_view_button_tpl", "company_view_button" );
61 $t->set_block( "company_item_tpl", "no_company_view_button_tpl", "no_company_view_button" );
62 $t->set_block( "company_item_tpl", "company_consultation_button_tpl", "company_consultation_button" );
63 $t->set_block( "company_item_tpl", "company_edit_button_tpl", "company_edit_button" );
64 $t->set_block( "company_item_tpl", "company_delete_button_tpl", "company_delete_button" );
65 $t->set_block( "company_item_tpl", "company_stats_item_tpl", "company_stats_item" );
66 $t->set_block( "search", "company_new_button_tpl", "company_new_button" );
67
68 $t->set_var( "search_box", "" );
69 $t->set_var( "search_results", "" );
70 $t->set_var( "results", "" );
71 $t->set_var( "result_item", "" );
72 $t->set_var( "category_option", "" );
73 $t->set_var( "result_category", "" );
74 $t->set_var( "companies_table", "" );
75 $t->set_var( "command_type", "company" );
76
77 $t->set_var( "search_text", htmlspecialchars( $SearchText ) );
78 $t->set_var( "current_id", isset( $SearchCategory ) ? $SearchCategory : false );
79
80 $Action = "new";
81 $results = "false";
82
83 if ( isset( $SearchObject ) && $SearchObject == "company" )
84 {
85 $Action = "search";
86 }
87
88 if ( !empty( $SearchText ) )
89 {
90 $Action = "search";
91 }
92
93 $company = new eZCompany();
94 $result = false;
95 $companyArray = array();
96 if ( $Action == "search" )
97 {
98 $companyArray = $company->search( $SearchText );
99
100 $count = count( $companyArray );
101 if ( $count > 0 )
102 {
103 $results = true;
104 }
105 }
106
107 if ( $results == true )
108 {
109 $count = count( $companyArray );
110 $t->set_var( "results", $count );
111 $i = 0;
112
113 $can_view_stats = eZPermission::checkPermission( $user, "eZContact", "CompanyStats" ) && isset( $ShowStats ) && $ShowStats;
114 $t->set_var( "company_stats_header", "" );
115 if ( $can_view_stats )
116 $t->parse( "company_stats_header", "company_stats_header_tpl" );
117 $t->set_var( "company_stats_item", "" );
118
119
120 $t->set_var( "company_consultation_button", "" );
121 $t->set_var( "company_edit_button", "" );
122 $t->set_var( "company_delete_button", "" );
123 $t->set_var( "company_view_button", "" );
124 $t->set_var( "no_company_view_button", "" );
125 if ( eZPermission::checkPermission( $user, "eZContact", "Consultation" ) )
126 $t->parse( "company_consultation_button", "company_consultation_button_tpl" );
127 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyModify" ) )
128 $t->parse( "company_edit_button", "company_edit_button_tpl" );
129 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyDelete" ) )
130 $t->parse( "company_delete_button", "company_delete_button_tpl" );
131 if ( eZPermission::checkPermission( $user, "eZContact", "CompanyView" ) )
132 {
133 $t->parse( "company_view_button", "company_view_button_tpl" );
134 }
135 else
136 {
137 $t->parse( "no_company_view_button", "no_company_view_button_tpl" );
138 }
139
140 if ( !isset( $companyList ) || isset( $companyList ) && count( $companyList ) == 0 )
141 {
142 $t->set_var( "company_item", "" );
143 $t->set_var( "companies_table", "" );
144 $t->parse( "no_companies", "no_companies_tpl" );
145 }
146 else
147 {
148 $can_view_stats = eZPermission::checkPermission( $user, "eZContact", "CompanyStats" ) && $ShowStats;
149 $t->set_var( "company_stats_header", "" );
150 if ( $can_view_stats )
151 $t->parse( "company_stats_header", "company_stats_header_tpl" );
152 $t->set_var( "company_stats_item", "" );
153 $t->set_var( "no_companies", "" );
154 $t->parse( "companies_table", "companies_table_tpl" );
155 }
156
157 foreach ( $companyArray as $company )
158 {
159 if ( $can_view_stats )
160 {
161 $count = $companyList[$i]->totalViewCount();
162 $t->set_var( "company_views", $count );
163 $t->parse( "company_stats_item", "company_stats_item_tpl" );
164 }
165
166 unSet( $logoObj );
167 $logoObj = $companyArray[$i]->logoImage();
168
169 if ( is_a( $logoObj, "eZImage" ) )
170 {
171 $variationObj = $logoObj->requestImageVariation( 150, 150 );
172
173 $t->set_var( "company_logo_src", "/" . $variationObj->imagePath() );
174 $image = new eZImage( $variationObj->imageID() );
175 $t->set_var( "image_alt", $image->caption() );
176 $t->set_var( "no_image", "" );
177 $t->parse( "image_view", "image_view_tpl" );
178 }
179 else
180 {
181 $t->set_var( "image_view", "" );
182 $t->parse( "no_image", "no_image_tpl" );
183 }
184
185 $t->set_var( "no_companies", "" );
186
187 if ( ( $i % 2 ) == 0 )
188 $t->set_var( "td_class", "bglight" );
189 else
190 $t->set_var( "td_class", "bgdark" );
191 $i++;
192 $t->set_var( "company_name", $company->name() );
193 $t->set_var( "company_id", $company->id() );
194 $t->set_var( "item_description", $company->comment() );
195 $t->set_var( "item_view_path", "/contact/company/view" );
196 $t->set_var( "item_delete_path", "/contact/company/delete" );
197 $t->set_var( "item_edit_path", "/contact/company/edit" );
198
199 $t->set_var( "result_category", "" );
200 $t->parse( "company_item", "company_item_tpl", true );
201
202 }
203
204 if ( $count > 0 )
205 {
206 $t->parse( "companies_table", "companies_table_tpl" );
207 }
208 }
209 $t->parse( "list", "list_tpl" );
210 $t->setAllStrings();
211
212 $t->pparse( "output", "search");
213
214 ?>
$i
$i
Definition: admin/adlist.php:91
eZCompany
Definition: ezcompany.php:54
eZINI
Reads and writes .ini style configuration files.
eZImage
Definition: ezimage.php:95
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
$companyArray
$companyArray
Definition: companysearch.php:95
$result
$result
Definition: companysearch.php:94
$results
$results
Definition: companysearch.php:81
$t
$t
Definition: companysearch.php:40
$errorIni
$errorIni
Definition: companysearch.php:38
$Language
$Language
Definition: companysearch.php:37
$ini
$ini
Definition: companysearch.php:36
$Action
$Action
Definition: companysearch.php:80
$company
if(isset( $SearchObject) && $SearchObject=="company") if(!empty( $SearchText)) $company
Definition: companysearch.php:93
$companyList
$companyList
Definition: companytypelist.php:299
globalINI
static & globalINI( $type="SiteIni", $file="settings/site.ini")
Definition: eZPBINIFile.php:482
$SearchText
$SearchText
Definition: ezaddress/admin/typelist.php:143
$count
$count
Definition: onlinetypelist.php:108
$user
$user
Definition: user/adlist.php:39
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.