Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmediacatalogue/admin/browse.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: browse.php 6279 2001-07-25 12:32:20Z ce $
5 //
6 // Christoffer A. Elo
7 // Created on: <25-Jul-2001 13:11:54 ce>
8 //
9 // This source file is part of Exponential Basic, publishing software.
10 //
11 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
12 //
13 // This program is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
26 //
27
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlog.php" );
31
32 // include_once( "ezuser/classes/ezuser.php" );
33 // include_once( "ezuser/classes/ezpermission.php" );
34 // include_once( "ezuser/classes/ezobjectpermission.php" );
35
36 // include_once( "ezmediacatalogue/classes/ezmedia.php" );
37 // include_once( "ezmediacatalogue/classes/ezmediacategory.php" );
38 // include_once( "classes/ezhttptool.php" );
39
40 $ini =& eZINI::instance( 'site.ini' );
41
42 $Language = $ini->variable( "eZMediaCatalogueMain", "Language" );
43
44 $MediaDir = $ini->variable( "eZMediaCatalogueMain", "ImageDir" );
45
46 $t = new eZTemplate( "kernel/ezmediacatalogue/admin/" . $ini->variable( "eZMediaCatalogueMain", "AdminTemplateDir" ),
47 "kernel/ezmediacatalogue/admin/intl/", $Language, "browse.php" );
48
49 $t->set_file( "media_list_page_tpl", "browse.tpl" );
50
51 $t->setAllStrings();
52
53 $user =& eZUser::currentUser();
54
55
56 $session =& eZSession::globalSession();
57
58 $returnUrl = $session->variable( "MediaListReturnTo" );
59
60 $t->set_var( "action_url", $returnUrl );
61
62 $t->set_block( "media_list_page_tpl", "current_category_tpl", "current_category" );
63
64 // path
65 $t->set_block( "media_list_page_tpl", "path_item_tpl", "path_item" );
66
67 $t->set_block( "media_list_page_tpl", "media_list_tpl", "media_list" );
68
69 $t->set_block( "media_list_tpl", "detail_view_tpl", "detail_view" );
70
71 $t->set_block( "detail_view_tpl", "detail_read_tpl", "detail_read" );
72 $t->set_block( "detail_view_tpl", "detail_write_tpl", "detail_write" );
73
74 $t->set_block( "detail_read_tpl", "single_media_tpl", "single_media" );
75 $t->set_block( "detail_read_tpl", "multi_media_tpl", "multi_media" );
76
77 $t->set_block( "media_list_page_tpl", "category_list_tpl", "category_list" );
78 $t->set_block( "category_list_tpl", "category_tpl", "category" );
79
80 $t->set_block( "category_tpl", "category_read_tpl", "category_read" );
81
82 $t->set_var( "read", "" );
83 $t->set_var( "write_menu", "" );
84
85 $t->set_var( "delete_media_button" , "" );
86 $t->set_var( "delete_categories_button" , "" );
87 $t->set_var( "default_new" , "" );
88 $t->set_var( "default_delete" , "" );
89
90 if ( !is_numeric( $CategoryID ) )
91 $CategoryID = 0;
92
93 $category = new eZMediaCategory( $CategoryID );
94
95 // Check if user have permission to the current category
96
97 $error = true;
98
99 if ( eZObjectPermission::hasPermission( $category->id(), "mediacatalogue_category", "r", $user )
100 || eZMediaCategory::isOwner( $user, $CategoryID ) )
101 {
102 $error = false;
103 }
104
105 if ( $CategoryID == 0 )
106 {
107 $t->set_var( "current_category_description", "" );
108 $error = false;
109 }
110
111 $t->set_var( "current_category", "" );
112
113 if ( $category->id() != 0 )
114 {
115 $t->set_var( "current_category_description", $category->description() );
116 $t->set_var( "category_id", $category->id() );
117 $t->set_var( "category_name", $category->name() );
118
119 $t->parse( "current_category", "current_category_tpl" );
120 }
121
122 // path
123 $pathArray = $category->path();
124
125 $t->set_var( "path_item", "" );
126 foreach ( $pathArray as $path )
127 {
128 $t->set_var( "category_id", $path[0] );
129
130 $t->set_var( "category_name", $path[1] );
131
132 $t->parse( "path_item", "path_item_tpl", true );
133 }
134
135
136 // Print out all the categories
137 $categoryList =& $category->getByParent( $category );
138
139 $i=0;
140 foreach ( $categoryList as $categoryItem )
141 {
142 $t->set_var( "category_name", $categoryItem->name() );
143 $t->set_var( "category_id", $categoryItem->id() );
144 $t->set_var( "category_description", $categoryItem->description() );
145
146 $t->set_var( "category_read", "" );
147 $t->set_var( "category_write", "" );
148 ( $i % 2 ) ? $t->set_var( "td_class", "bgdark" ) : $t->set_var( "td_class", "bglight" );
149
150 // Check if user have read permission
151 if ( eZObjectPermission::hasPermission( $categoryItem->id(), "mediacatalogue_category", "r", $user ) ||
152 eZMediaCategory::isOwner( $user, $categoryItem->id()) )
153 {
154 $t->parse( "category_read", "category_read_tpl" );
155 }
156
157 $t->parse( "category", "category_tpl", true );
158 $i++;
159 }
160
161 if ( count( $categoryList ) > 0 )
162 {
163 $t->parse( "category_list", "category_list_tpl" );
164 }
165 else
166 {
167 $t->set_var( "category_list", "" );
168 }
169
170 // Print out all the media
171 $mediaList =& $category->media();
172
173 $selectMedia = $session->variable( "SelectMedia" );
174 if( !$selectMedia )
175 $selectMedia = "single";
176
177 $t->set_var( "name", $session->variable( "NameInBrowse" ) );
178
179 $i = 0;
180 $counter = 0;
181 foreach ( $mediaList as $media )
182 {
183 $t->set_var( "end_tr", "" );
184 $t->set_var( "begin_tr", "" );
185
186 $t->set_var( "media_id", $media->id() );
187 $t->set_var( "original_media_name", $media->originalFileName() );
188 $t->set_var( "media_name", $media->name() );
189 $t->set_var( "media_caption", $media->name() );
190 $t->set_var( "media_url", $media->name() );
191
192 if ( $selectMedia == "single" )
193 {
194 $t->set_var( "media_id", $media->id() );
195 $t->set_var( "multi_media", "" );
196 $t->parse( "single_media", "single_media_tpl" );
197 }
198 elseif ( $selectMedia == "multi" )
199 {
200 $t->set_var( "media_id", $media->id() );
201 $t->set_var( "single_media", "" );
202 $t->parse( "multi_media", "multi_media_tpl" );
203 }
204
205 $t->set_var( "media_description",$media->description() );
206 $t->set_var( "media_alt", $media->name() );
207 $t->set_var( "media_file_name", $media->originalFileName() );
208
209 $t->set_var( "read", "" );
210 $t->set_var( "write", "" );
211
212 // Check if user have read permission
213 $t->set_var( "detail_read", "" );
214 $can_read = false;
215 $can_write = false;
216 if ( eZObjectPermission::hasPermission( $media->id(), "mediacatalogue_media", "r", $user ) ||
217 eZMedia::isOwner( $user, $media->id() ) )
218 {
219 $t->parse( "detail_read", "detail_read_tpl" );
220 $i++;
221 }
222
223
224 $t->parse( "detail_view", "detail_view_tpl", true );
225
226 $counter++;
227 }
228
229 $t->set_var( "detail_button", "" );
230 $t->set_var( "normal_button", "" );
231
232 if ( count( $mediaList ) > 0 )
233 {
234 $t->parse( "media_list", "media_list_tpl" );
235 }
236 else
237 {
238 $t->set_var( "normal_button", "" );
239 $t->set_var( "detail_button", "" );
240 $t->set_var( "media_list", "" );
241 }
242
243 $t->set_var( "media_dir", $MediaDir );
244
245 $t->set_var( "main_category_id", $CategoryID );
246
247 if ( $error == false )
248 {
249 $t->pparse( "output", "media_list_page_tpl" );
250 }
251 else
252 {
253 eZHTTPTool::header( "Location: /error/403/" );
254 exit();
255 }
256
257 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZMediaCategory
Definition: ezmediacategory.php:55
eZMediaCategory\isOwner
isOwner(&$user, &$mediacategory)
Definition: ezmediacategory.php:444
eZMedia\isOwner
static isOwner(&$user, &$media)
Definition: ezmedia.php:604
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$media
if(isset( $AddMedia)) $media
Definition: ezarticle/admin/medialist.php:76
$category
$category
Definition: ezmediacatalogue/admin/browse.php:93
$selectMedia
$selectMedia
Definition: ezmediacatalogue/admin/browse.php:173
$t
$t
Definition: ezmediacatalogue/admin/browse.php:46
$pathArray
if( $category->id() !=0) $pathArray
Definition: ezmediacatalogue/admin/browse.php:123
$returnUrl
$returnUrl
Definition: ezmediacatalogue/admin/browse.php:58
$user
$user
Definition: ezmediacatalogue/admin/browse.php:53
$i
$i
Definition: ezmediacatalogue/admin/browse.php:139
$Language
$Language
Definition: ezmediacatalogue/admin/browse.php:42
$ini
$ini
Definition: ezmediacatalogue/admin/browse.php:40
$mediaList
$mediaList
Definition: ezmediacatalogue/admin/browse.php:171
$MediaDir
$MediaDir
Definition: ezmediacatalogue/admin/browse.php:44
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: ezmediacatalogue/admin/browse.php:137
$session
$session
Definition: ezmediacatalogue/admin/browse.php:56
$counter
$counter
Definition: ezmediacatalogue/admin/browse.php:180
$error
$error
Definition: ezmediacatalogue/admin/browse.php:97
exit
exit
Definition: folder.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.