Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

admin/articlelist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: articlelist.php 9465 2002-04-24 07:38:20Z jhe $
5 //
6 // Created on: <18-Oct-2000 14:41:37 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 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlocale.php" );
30
31 // include_once( "ezarticle/classes/ezarticlecategory.php" );
32 // include_once( "ezarticle/classes/ezarticletool.php" );
33 // include_once( "ezarticle/classes/ezarticle.php" );
34 // include_once( "ezuser/classes/ezobjectpermission.php" );
35 // include_once( "classes/ezcachefile.php" );
36 // include_once( "classes/ezlist.php" );
37
38 $ini =& eZINI::instance( 'site.ini' );
39
40 $Language = $ini->variable( "eZArticleMain", "Language" );
41 $Locale = new eZLocale( $Language );
42 $AdminListLimit = $ini->variable( "eZArticleMain", "AdminListLimit" );
43
44 $session =& eZSession::globalSession();
45
46 if ( isset( $GoTo ) && is_Numeric( $GoToCategoryID ) )
47 {
48 eZHTTPTool::header( "Location: /article/archive/$GoToCategoryID" );
49 exit();
50 }
51
52 if ( isset( $StoreSelection ) )
53 {
54 switch ( $ArticleSelection )
55 {
56 case "Published" :
57 {
58 $session->setVariable( "MixUnpublished", "Published" );
59 }
60 break;
61
62 case "Unpublished" :
63 {
64 $session->setVariable( "MixUnpublished", "Unpublished" );
65 }
66 break;
67
68 case "All" :
69 default :
70 {
71 $session->setVariable( "MixUnpublished", "All" );
72 }
73 }
74 }
75
76 $articleMix =& $session->variable( "MixUnpublished" );
77
78 $ArticleSelection =& $articleMix;
79
80 if ( $articleMix == "" )
81 {
82 $articleMix = "All";
83 }
84
85 if ( isset( $CopyCategories ) )
86 {
87 if ( count( $CategoryArrayID ) != 0 )
88 {
89 foreach ( $CategoryArrayID as $tCategoryID )
90 {
91 // copy category
92 $tmpCategory = new eZArticleCategory( $tCategoryID );
93
94 $newCategory = new eZArticleCategory();
95 $newCategory->setName( "Copy of " . $tmpCategory->name() );
96 $newCategory->setDescription( $tmpCategory->description(false) );
97 $newCategory->setParent( $tmpCategory->parent( false ) );
98 $newCategory->setOwner( eZUser::currentUser() );
99
100 $newCategory->store();
101
102 // write access
103 eZObjectPermission::setPermission( -1, $newCategory->id(), "article_category", 'w' );
104
105 // read access
106 eZObjectPermission::setPermission( -1, $newCategory->id(), "article_category", 'r' );
107
108
109 $tmpCategory->copyTree( $tCategoryID, $newCategory );
110 }
111 eZHTTPTool::header( "Location: /article/archive/" );
112 exit();
113 }
114 }
115
116
117
118
119 if ( isset( $DeleteArticles ) )
120 {
121 if ( count( $ArticleArrayID ) != 0 )
122 {
123 foreach ( $ArticleArrayID as $TArticleID )
124 {
125 if ( eZObjectPermission::hasPermission( $TArticleID, "article_article", 'w' ) ||
126 eZArticle::isAuthor( eZUser::currentUser(), $TArticleID ) )
127 {
128 $article = new eZArticle( $TArticleID );
129
130 // get the category to redirect to
131 $articleID = $article->id();
132
133 $categoryArray =& $article->categories();
134 $categoryIDArray = array();
135 foreach ( $categoryArray as $cat )
136 {
137 $categoryIDArray[] = $cat->id();
138 }
139 $categoryID = $article->categoryDefinition();
140 $categoryID = $categoryID->id();
141
142 // clear the cache files.
143 deleteCache( $TArticleID, $categoryID, $categoryIDArray );
144 $article->delete();
145 }
146 }
147 eZHTTPTool::header( "Location: /article/archive/$CurrentCategoryID" );
148 exit();
149 }
150 }
151
152 if ( isset( $DeleteCategories ) )
153 {
154 if ( count( $CategoryArrayID ) != 0 )
155 {
157 $files =& eZCacheFile::files( "kernel/ezarticle/cache/",
158 array( "menubox", NULL ),
159 "cache", "," );
160 foreach ( $files as $file )
161 {
162 $file->delete();
163 }
164
165 $categories = array();
166 foreach ( $CategoryArrayID as $ID )
167 {
168 $categories[] = $ID;
169 $category = new eZArticleCategory( $ID );
170 $categories[] = $category->parent( false );
171 if ( eZObjectPermission::hasPermission( $ID , "article_category", 'w' ) ||
172 eZArticleCategory::isOwner( eZUser::currentUser(), $ID ) )
173 $category->delete();
174 }
175 $categories = array_unique( $categories );
176 $files =& eZCacheFile::files( "kernel/ezarticle/cache/",
177 array( "articlelist",
178 $categories, NULL ),
179 "cache", "," );
180 foreach ( $files as $file )
181 {
182 $file->delete();
183 }
184 }
185
186 eZHTTPTool::header( "Location: /article/archive/" );
187 exit();
188 }
189
190
191 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
192 "kernel/ezarticle/admin/intl/", $Language, "articlelist.php" );
193
194 $t->setAllStrings();
195
196 $t->set_file( array(
197 "article_list_page_tpl" => "articlelist.tpl"
198 ) );
199
200 // path
201 $t->set_block( "article_list_page_tpl", "path_item_tpl", "path_item" );
202
203 // category selector
204
205 $t->set_block( "article_list_page_tpl", "category_tree_id_tpl", "category_tree_id" );
206
207 // category
208 $t->set_block( "article_list_page_tpl", "category_list_tpl", "category_list" );
209 $t->set_block( "category_list_tpl", "category_item_tpl", "category_item" );
210 $t->set_block( "category_item_tpl", "category_edit_tpl", "category_edit" );
211
212 // article
213 $t->set_block( "article_list_page_tpl", "article_list_tpl", "article_list" );
214 $t->set_block( "article_list_tpl", "article_item_tpl", "article_item" );
215
216 $t->set_block( "article_item_tpl", "article_is_published_tpl", "article_is_published" );
217 $t->set_block( "article_item_tpl", "article_not_published_tpl", "article_not_published" );
218
219 // move up / down
220 $t->set_block( "article_list_tpl", "absolute_placement_header_tpl", "absolute_placement_header" );
221 $t->set_block( "article_item_tpl", "absolute_placement_item_tpl", "absolute_placement_item" );
222 $t->set_block( "article_item_tpl", "article_edit_tpl", "article_edit" );
223
224
225 $t->set_var( "site_style", $SiteDesign );
226
227 $category = new eZArticleCategory( $CategoryID );
228
230 if ( isset( $MoveCategoryUp ) || isset( $MoveCategoryDown ) )
231 {
232 if ( is_numeric( $MoveCategoryUp ) )
233 {
234 $mvcategory = new eZArticleCategory( $MoveCategoryUp );
235 $mvcategory->moveCategoryUp();
236 }
237
238 if ( is_numeric( $MoveCategoryDown ) )
239 {
240 $mvcategory = new eZArticleCategory( $MoveCategoryDown );
241 $mvcategory->moveCategoryDown();
242 }
243
245 $files =& eZCacheFile::files( "kernel/ezarticle/cache/",
246 array( "menubox", NULL ),
247 "cache", "," );
248
249 foreach ( $files as $file )
250 {
251 $file->delete();
252 }
253 $files =& eZCacheFile::files( "kernel/ezarticle/cache/",
254 array( "articlelist", $CategoryID, NULL, NULL ), "cache", "," );
255 foreach ( $files as $file )
256 {
257 $file->delete();
258 }
259
260 }
261 // move articles up / down
262 if ( $category->sortMode() == "absolute_placement" )
263 {
264 if ( is_numeric( $MoveUp ) )
265 {
266 $category->moveUp( $MoveUp );
267 }
268
269 if ( is_numeric( $MoveDown ) )
270 {
271 $category->moveDown( $MoveDown );
272 }
273 }
274
275 $t->set_var( "current_category_id", $category->id() );
276
277 //EP: CategoryDescriptionXML=enabled, description go in XML -------------------
278 if ( $ini->variable( "eZArticleMain", "CategoryDescriptionXML" ) == "enabled" )
279 {
280 if ( $CategoryID )
281 {
282 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
283
284 $article = new eZArticle();
285 $article->setContents( $category->description( false ) );
286
287 $renderer = new eZArticleRenderer( $article );
288
289 $t->set_var( "current_category_description", $renderer->renderIntro() );
290 }
291 else
292 {
293 $t->set_var( "current_category_description", "" );
294 }
295 }
296 else
297 {
298 $t->set_var( "current_category_description", $category->description() );
299 }
300 //EP --------------------------------------------------------------------------
301
302 // path
303 $pathArray = $category->path();
304
305 $t->set_var( "path_item", "" );
306 foreach ( $pathArray as $path )
307 {
308 $t->set_var( "category_id", $path[0] );
309 $t->set_var( "category_name", $path[1] );
310 $t->parse( "path_item", "path_item_tpl", true );
311 }
312
313 $categoryList =& $category->getByParent( $category, true, "placement" );
314
315 // category "tree" selector
316 $tree = new eZArticleCategory();
317 $treeArray =& $tree->getTree();
318
319 foreach ( $treeArray as $catItem )
320 {
321 $t->set_var( "category_id", $catItem[0]->id() );
322 $t->set_var( "category_name", $catItem[0]->name() );
323
324 if ( $catItem[1] > 1 )
325 $t->set_var( "category_level", str_repeat( "&nbsp;&nbsp;", $catItem[1] ) );
326 else
327 $t->set_var( "category_level", "" );
328
329 $t->set_var( "selected", $catItem[0]->id() == $CategoryID ? "selected" : "" );
330
331 $t->parse( "category_tree_id", "category_tree_id_tpl", true );
332 }
333
334
335 // categories
336 $i = 0;
337 $t->set_var( "category_list", "" );
338 foreach ( $categoryList as $categoryItem )
339 {
340 $t->set_var( "category_id", $categoryItem->id() );
341 $t->set_var( "category_name", $categoryItem->name() );
342
343 $parent = $categoryItem->parent();
344
345 if ( ( $i % 2 ) == 0 )
346 {
347 $t->set_var( "td_class", "bglight" );
348 }
349 else
350 {
351 $t->set_var( "td_class", "bgdark" );
352 }
353
354 //EP: CategoryDescriptionXML=enabled, description go in XML -------------------
355 if ( $ini->variable( "eZArticleMain", "CategoryDescriptionXML" ) == "enabled" )
356 {
357 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
358
359 $article = new eZArticle ();
360 $article->setContents ($categoryItem->description(false));
361
362 $renderer = new eZArticleRenderer( $article );
363
364 $t->set_var( "category_description", $renderer->renderIntro() );
365 }
366 else
367 {
368 $t->set_var( "category_description", $categoryItem->description() );
369 }
370 //EP --------------------------------------------------------------------------
371
372 if ( eZObjectPermission::hasPermission( $categoryItem->id(), "article_category", 'w' ) ||
373 eZArticleCategory::isOwner( eZUser::currentUser(), $categoryItem->id() ) )
374 $t->parse( "category_edit", "category_edit_tpl", false );
375 else
376 $t->set_var( "category_edit", "" );
377
378 $t->parse( "category_item", "category_item_tpl", true );
379 $i++;
380 }
381
382 $t->set_var( "archive_id", $CategoryID );
383
384 if ( $i > 0 )
385 $t->parse( "category_list", "category_list_tpl" );
386 else
387 $t->set_var( "category_list", "" );
388
389
390 // set the offset/limit
391 if ( !isset( $Offset ) )
392 $Offset = 0;
393
394 if ( !isset( $Limit ) )
395 $Limit = $AdminListLimit;
396
397 switch ( $articleMix )
398 {
399 case "Published" :
400 {
401 $t->set_var( "published_selected", "selected" );
402 $t->set_var( "un_published_selected", "" );
403 $t->set_var( "all_selected", "" );
404 }
405 break;
406
407 case "Unpublished" :
408 {
409 $t->set_var( "published_selected", "" );
410 $t->set_var( "un_published_selected", "selected" );
411 $t->set_var( "all_selected", "" );
412 }
413 break;
414
415 case "All" :
416 default :
417 {
418 $t->set_var( "published_selected", "" );
419 $t->set_var( "un_published_selected", "" );
420 $t->set_var( "all_selected", "selected" );
421 }
422 }
423
424
425 // articles
426 if ( is_numeric( $CategoryID ) && ( $CategoryID > 0 ) )
427 {
428 switch ( $ArticleSelection )
429 {
430
431 case "Published" :
432 {
433 $articleList =& $category->articles( $category->sortMode(), false, true, $Offset, $Limit );
434 $articleCount = $category->articleCount( false, true );
435 }
436 break;
437
438 case "Unpublished" :
439 {
440 $articleList =& $category->articles( $category->sortMode(), false, false, $Offset, $Limit );
441 $articleCount = $category->articleCount( false, false );
442 }
443 break;
444
445 case "All" :
446 default :
447 {
448 $articleList =& $category->articles( $category->sortMode(), true, true, $Offset, $Limit, $category->id() );
449 $articleCount = $category->articleCount( true, true );
450 }
451 }
452 }
453 else
454 {
455 $articleList = array();
456 $articleCount = 0;
457 }
458
459 $i = 0;
460 $t->set_var( "article_list", "" );
461
462 if ( $category->sortMode() == "absolute_placement" )
463 {
464 $t->parse( "absolute_placement_header", "absolute_placement_header_tpl" );
465 }
466 else
467 {
468 $t->set_var( "absolute_placement_header", "" );
469 }
470
471 $locale = new eZLocale( $Language );
472
473 foreach ( $articleList as $article )
474 {
475 if ( eZObjectPermission::hasPermission( $article->id(), "article_article", 'r' ) ||
476 eZArticle::isAuthor( eZUser::currentUser(), $article->id() ) )
477 {
478 if ( $article->name() == "" )
479 $t->set_var( "article_name", "&nbsp;" );
480 else
481 $t->set_var( "article_name", $article->name() );
482
483 $t->set_var( "article_id", $article->id() );
484
485 if ( $article->isPublished() == true )
486 {
487 $t->parse( "article_is_published", "article_is_published_tpl" );
488 $t->set_var( "article_not_published", "" );
489 }
490 else
491 {
492 $t->set_var( "article_is_published", "" );
493 $t->parse( "article_not_published", "article_not_published_tpl" );
494 }
495
496 if ( ( $i % 2 ) == 0 )
497 {
498 $t->set_var( "td_class", "bglight" );
499 }
500 else
501 {
502 $t->set_var( "td_class", "bgdark" );
503 }
504
505 if ( $category->sortMode() == "absolute_placement" )
506 {
507 $t->parse( "absolute_placement_item", "absolute_placement_item_tpl" );
508 }
509 else
510 {
511 $t->set_var( "absolute_placement_item", "" );
512 }
513
514 $published = $article->published();
515 $t->set_var( "article_published_date", $locale->format( $published ) );
516
517 if( eZObjectPermission::hasPermission( $article->id(), "article_article", 'w') ||
518 eZArticle::isAuthor( eZUser::currentUser(), $article->id() ) )
519 $t->parse( "article_edit", "article_edit_tpl", false );
520 else
521 $t->set_var( "article_edit", "" );
522
523
524 $t->parse( "article_item", "article_item_tpl", true );
525 $i++;
526 }
527 }
528 eZList::drawNavigator( $t, $articleCount, $AdminListLimit, $Offset, "article_list_page_tpl" );
529
530 // $i is from the last foreach loop
531 if ( $i > 0 )
532 $t->parse( "article_list", "article_list_tpl" );
533 else
534 $t->set_var( "article_list", "" );
535
536
537 $t->pparse( "output", "article_list_page_tpl" );
538
542 function deleteCache( $ArticleID, $CategoryID, $CategoryArray )
543 {
544 eZArticleTool::deleteCache( $ArticleID, $CategoryID, $CategoryArray );
545 }
546
547 ?>
$categoryArray
$categoryArray
Definition: adedit.php:379
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$category
$category
Definition: admin/articlelist.php:227
$t
if( $articleMix=="") if(isset( $CopyCategories)) if(isset( $DeleteArticles)) if(isset( $DeleteCategories)) $t
Definition: admin/articlelist.php:191
$ArticleSelection
$ArticleSelection
Definition: admin/articlelist.php:78
$locale
$locale
Definition: admin/articlelist.php:471
$treeArray
$treeArray
Definition: admin/articlelist.php:317
$articleMix
if(isset( $GoTo) &&is_Numeric( $GoToCategoryID)) if(isset( $StoreSelection)) $articleMix
Definition: admin/articlelist.php:76
$AdminListLimit
$AdminListLimit
Definition: admin/articlelist.php:42
$pathArray
$pathArray
Definition: admin/articlelist.php:303
$tree
$tree
Definition: admin/articlelist.php:316
$Locale
$Locale
Definition: admin/articlelist.php:41
$i
foreach( $treeArray as $catItem) $i
Definition: admin/articlelist.php:336
$Language
$Language
Definition: admin/articlelist.php:40
$ini
$ini
Definition: admin/articlelist.php:38
deleteCache
deleteCache( $ArticleID, $CategoryID, $CategoryArray)
Definition: admin/articlelist.php:542
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: admin/articlelist.php:313
$session
$session
Definition: admin/articlelist.php:44
$articleCount
$articleCount
Definition: admin/articlelist.php:456
$article
$article
Definition: articlelog.php:45
$files
$files
Definition: articlepreview.php:91
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\isOwner
isOwner( $user, $categoryID)
Definition: ezarticlecategory.php:825
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZArticleTool\deleteCache
static deleteCache( $ArticleID, $CategoryID, $CategoryArray)
Definition: ezarticletool.php:52
eZArticle
Definition: ezarticle.php:82
eZArticle\isAuthor
static isAuthor( $user, $articleID)
Definition: ezarticle.php:2672
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
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
$ArticleID
$ArticleID
Definition: export.php:48
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$Limit
$Limit
Definition: ezarticle/admin/categorylist.php:66
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
exit
exit
Definition: folder.php:81
$articleList
$articleList
Definition: pendinglist.php:112
$categoryID
else $categoryID
Definition: productview.php:66
$articleID
if( $Action=="New") $articleID
Definition: user/articleedit.php:269
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.