Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

classes/admin/linklist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: linklist.php 8145 2001-11-01 12:06:23Z ce $
5 //
6 // Created on: <30-Apr-2001 18:50:47 amos>
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 // To use the general link list you need to initialize some variables before
28 // including this file. The variables are:
29 //
30 // Static variables:
31 // $INIGroup = The group name of the module in the site.ini file, eg. "eZTradeMain"
32 // $DefaultSectionsName = site.ini item name which contains the default sections names, eg. "ProductLinkSections"
33 // $PreferencesSetting = Preferences variable name which contains the type selection, eg. "ProductLinkType"
34 // $ClientModuleName = Name of the module in use, eg. "eZTrade"
35 // $ClientModuleType = Name of the module sub type in use, eg. "Product"
36 // $root = Helper variable for the url list, not used by linklist, eg. "/trade/productedit"
37 // $URLS = Array of urls which are used in navigating the link pages.
38 // Must contain these keys (values are examples only),
39 // the values must always contain the same amount of % items as in the examples, and in the same order.
40 // array( "back" => "$root/edit/%s",
41 // "linklist" => "$root/link/list/%s",
42 // "linkmoveup" => "$root/link/moveup/link/%d/%d/%d",
43 // "linkmovedown" => "$root/link/movedown/link/%d/%d/%d",
44 // "sectionmoveup" => "$root/link/moveup/section/%d/%d",
45 // "sectionmovedown" => "$root/link/movedown/section/%d/%d",
46 // "linkselect" => "$root/link/select/%s/%s/%s/%s/%s/0/%s",
47 // "linkselect_basic" => "$root/link/select/",
48 // "linkselect_std" => "$root/link/select/%s/%s/%s/%s/%s",
49 // "urledit" => "$root/link/select/%s/%s/%s/%s",
50 // "linkedit" => "$root/link/select/%s/%s/%s/0/0/%s" );
51 // $Funcs = Array of functions to call, currently only "delete" is used.
52 // eg. array( "delete" => "deleteCacheHelper" );
53 // Variables which you may set to use a different template and/or intl file.
54 // $ClientRoot = The root of the module, default is "classes/", eg. "kernel/eztrade/admin/"
55 // $ClientIntlDir = The intl dir of the module, default is "classes/admin/intl/", eg. "kernel/eztrade/admin/intl/"
56
57 // include_once( "kernel/classes/INIFile.php" );
58 // include_once( "kernel/classes/eztemplate.php" );
59 // include_once( "kernel/classes/ezlocale.php" );
60 // include_once( "kernel/classes/ezcachefile.php" );
61 // include_once( "kernel/classes/ezhttptool.php" );
62
63
64 $ini =& eZINI::instance( 'site.ini' );
65 $Language = $ini->variable( $INIGroup, "Language" );
66 $Modules = $ini->variable( $INIGroup, "ModuleList" );
67
68 if ( !isset( $ClientRoot ) )
69 {
70 $ClientRoot = "kernel/classes/";
71 }
72 if ( !isset( $ClientIntlDir ) )
73 {
74 $ClientIntlDir = "kernel/classes/admin/intl/";
75 }
76
77 $intl_dirs = array( $ClientIntlDir );
78 $php_files = array( "linklist.php" );
79 foreach( $Modules as $module )
80 {
81 $dir = strtolower( "kernel/" . $module ) . "/user/intl/";
82 $file = strtolower( "kernel/" . $module ) . "/user/urlsupplier.php";
83 if ( file_exists( $file ) )
84 {
85 $intl_dirs[] = $dir;
86 $php_files[] = "urlsupplier.php";
87 }
88 }
89
90 // include_once( "kernel/classes/ezmodulelink.php" );
91 // include_once( "kernel/classes/ezlinksection.php" );
92 // include_once( "kernel/classes/ezlinkitem.php" );
93
94 if ( isset( $ItemInsert ) )
95 {
96 list($ModuleName,$Type) = explode( "/", $ModuleType );
97 $module_lower = strtolower("kernel/$ModuleName" );
98 if ( !isset( $LinkID ) )
99 $LinkID = false;
100 switch( $ModuleName )
101 {
102 case "std":
103 {
104 if ( $Type == "url" )
105 {
106 $link_item = new eZLinkItem( $LinkID, $ClientModuleName );
107 $link_item->setName( $URLName );
108 $link_item->setURL( $URL );
109 $link_item->setSection( $SectionID );
110
111 $link_item->setType( $ModuleName,$Type );
112
113 $link_item->store();
114 $Funcs["delete"]( $ItemID );
115 }
116 else
117 {
118 }
119 break;
120 }
121
122 default:
123 {
124 $file = $module_lower . "/user/urlsupplier.php";
125 if ( file_exists( $file ) )
126 {
127 unset( $Supplier );
128 include( $file );
129 if ( isset( $Supplier ) and get_class( $Supplier ) )
130 {
131 if ( !is_array( $CategorySelect ) )
132 $CategorySelect = array();
133 if ( !is_array( $ItemSelect ) )
134 $ItemSelect = array();
135 foreach( $CategorySelect as $category )
136 {
137 $category_info = $Supplier->item( $Type, $category, true );
138 $link_item = new eZLinkItem( $LinkID, $ClientModuleName );
139 $link_item->setName( $category_info["name"] );
140 $link_item->setURL( $category_info["url"] );
141 $link_item->setSection( $SectionID );
142 $link_item->setType( $ModuleName,$Type );
143 $link_item->store();
144 }
145 foreach( $ItemSelect as $item )
146 {
147 if ( isset( $LinkID ) and $item < 0 )
148 {
149 $item_info = $Supplier->item( $Type, -$item, true );
150 }
151 else
152 $item_info = $Supplier->item( $Type, $item, false );
153 $link_item = new eZLinkItem( $LinkID, $ClientModuleName );
154 $link_item->setName( $item_info["name"] );
155 $link_item->setURL( $item_info["url"] );
156 $link_item->setSection( $SectionID );
157 $link_item->setType( $ModuleName,$Type );
158 $link_item->store();
159 }
160 $Funcs["delete"]( $ItemID );
161 }
162 }
163 break;
164 }
165 }
166 }
167
168 $t = new eZTemplate( $ClientRoot . $ini->variable( $INIGroup, "AdminTemplateDir" ),
169 $intl_dirs, $Language, $php_files );
170
171 $t->set_file( "link_list_tpl", "linklist.tpl" );
172
173 $t->set_block( "link_list_tpl", "value_tpl", "value" );
174
175 $t->set_block( "link_list_tpl", "section_item_tpl", "section_item" );
176 $t->set_block( "section_item_tpl", "link_item_tpl", "link_item" );
177
178 $t->set_block( "link_item_tpl", "link_edit_item_tpl", "link_edit_item" );
179
180 $t->set_var( "value", "" );
181
182 $t->set_var( "client_name", $ClientModuleName );
183 $t->set_var( "client_type", $ClientModuleType );
184
185 // include_once( "kernel/ezsession/classes/ezpreferences.php" );
186 $preferences = new eZPreferences();
187 $LinkType = $preferences->variable( $PreferencesSetting );
188 if ( is_bool( $LinkType ) )
189 $LinkType = $ModuleType;
190
191 $t->set_var( "url_selected", "" );
192 foreach( $Modules as $module )
193 {
194 $module_lower = strtolower( $module );
195 $file = $module_lower . "/user/urlsupplier.php";
196 if ( file_exists( $file ) )
197 {
198 unset( $Supplier );
199 include( $file );
200 if ( isset( $Supplier ) and get_class( $Supplier ) )
201 {
202 $types =& $Supplier->urlTypes();
203 $t->set_var( "type_level", "" );
204 $t->set_var( "selected", $LinkType == $module_lower ? "selected" : "" );
205 $t->set_var( "module_type", $module_lower );
206 $t->set_var( "type_name", $module );
207 $t->parse( "value", "value_tpl", true );
208 $t->set_var( "type_level", "&nbsp;" );
209 reset( $types );
210 while( list($key,$val) = each($types) )
211 {
212 $type = "$module_lower/$key";
213 $t->set_var( "module_type", $type );
214 $t->set_var( "type_name", $val );
215 $t->set_var( "selected", $LinkType == $type ? "selected" : "" );
216 $t->parse( "value", "value_tpl", true );
217 }
218 $t->set_var( "url_selected", $LinkType == "std/url" ? "selected" : "" );
219 }
220 }
221 }
222 $t->set_var( "url", $REQUEST_URI );
223 $t->set_var( "item_id", $ItemID );
224
225 $t->set_var( "section_item", "" );
226 $module_link = new eZModuleLink( $ClientModuleName, $ClientModuleType, $ItemID );
227 $sections =& $module_link->sections();
228 $item = 0;
229 if ( !isset( $SectionID ) or ( $SectionID <= 0 ) )
230 {
231 if ( count( $sections ) > 0 )
232 $SectionID = $sections[0]->id();
233 else
234 $SectionID = 1;
235 }
236 foreach( $sections as $section )
237 {
238 $t->set_var( "link_item", "" );
239 $t->set_var( "section_name", $section->name() );
240 $t->set_var( "section_id", $section->id() );
241 $t->set_var( "section_checked", $section->id() == $SectionID ? "checked" : "" );
242 $links =& $section->links();
243 $i = 0;
244 foreach( $links as $link )
245 {
246 $t->set_var( "link_edit_item", "" );
247 $t->set_var( "td_class", ($i%2) == 0 ? "bglight" : "bgdark" );
248 $t->set_var( "link_name", $link->name() );
249 $t->set_var( "link_url", $link->url() );
250 $t->set_var( "link_id", $link->id() );
251 $m_name = "std";
252 $m_type = "url";
253 if ( $link->type() != 0 )
254 {
255 $type_array = $link->type( true );
256 $m_name = $type_array["Module"];
257 $m_type = $type_array["Type"];
258 }
259 $t->set_var( "link_module_name", $m_name );
260 $t->set_var( "link_module_type", $m_type );
261 if ( $m_name != "std" )
262 {
263 $url_str = $URLS["linkedit"];
264 }
265 else
266 {
267 $url_str = $URLS["urledit"];
268 }
269 $t->set_var( "item_edit_command", sprintf( $url_str, $ItemID , "$m_name/$m_type", $section->id(), $link->id() ) );
270 $t->parse( "link_edit_item", "link_edit_item_tpl" );
271 $t->set_var( "item_up_command", sprintf( $URLS["linkmoveup"], $ItemID, $section->id(), $link->id() ) );
272 $t->set_var( "item_down_command", sprintf( $URLS["linkmovedown"], $ItemID, $section->id(), $link->id() ) );
273 $t->parse( "link_item", "link_item_tpl", true );
274 ++$i;
275 }
276 $t->set_var( "item_up_command", sprintf( $URLS["sectionmoveup"], $ItemID, $section->id() ) );
277 $t->set_var( "item_down_command", sprintf( $URLS["sectionmovedown"], $ItemID, $section->id() ) );
278 $t->parse( "section_item", "section_item_tpl", true );
279 ++$item;
280 }
281
282 $t->set_var( "link_list_url", $URLS["linkselect_basic"] );
283
284 $t->setAllStrings();
285
286 $t->pparse( "output", "link_list_tpl" );
287
288 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$i
$i
Definition: admin/adlist.php:91
$types
$types
Definition: articlepreview.php:108
eZLinkItem
Definition: ezlinkitem.php:38
eZModuleLink
Definition: ezmodulelink.php:65
eZPreferences
Definition: ezpreferences.php:62
eZTemplate
Definition: eztemplate.php:107
$Modules
$Modules
Definition: classes/admin/linklist.php:66
$intl_dirs
if(!isset( $ClientRoot)) if(!isset( $ClientIntlDir)) $intl_dirs
Definition: classes/admin/linklist.php:77
$module_link
$module_link
Definition: classes/admin/linklist.php:226
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$preferences
$preferences
Definition: classes/admin/linklist.php:186
$LinkType
$LinkType
Definition: classes/admin/linklist.php:187
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$item
$item
Definition: classes/admin/linklist.php:228
$php_files
$php_files
Definition: classes/admin/linklist.php:78
$sections
$sections
Definition: classes/admin/linklist.php:227
$type
$type
Definition: classes/admin/linkselect.php:220
$module
$module
Definition: classes/admin/linkselect.php:219
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$Supplier
$Supplier
Definition: ezarticle/user/urlsupplier.php:29
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$SectionID
$SectionID
Definition: ezfilemanager/user/filelist.php:46
$URL
$URL
Definition: ezgroupeventcalendar/user/dayview.php:80
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$link
$link
Definition: ezlink/admin/attributeedit.php:49
$dir
$dir
Definition: ezsitemanager/admin/filelist.php:87
$REQUEST_URI
$REQUEST_URI
Definition: storestats.php:32
$links
$links
Definition: user/linkcategorylist.php:181
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.