File modules/cms/macros/macro/Album.class.php
Last commit: Sun Dec 5 20:33:24 2021 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'.
1 <?php 2 namespace cms\macros\macro; 3 // OpenRat Content Management System 4 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 use cms\model\BaseObject; 20 use cms\model\File; 21 use cms\model\Folder; 22 use cms\model\Image; 23 use util\Macro; 24 25 26 /** 27 * Erzeugt eine Bilder-Liste. 28 * 29 * Die Ordner-Id kann als Parameter "folderid" übergeben werden. 30 * Falls nicht, wird der aktuelle Ordner, in dem sich die Seite 31 * befindet, benutzt. 32 * 33 * Es wird eine Definitionsliste mit der CSS-Klasse "album" erzeugt, damit 34 * bequem eine Auszeichnung per CSS erfolgen kann. 35 * 36 * Beispiel: 37 * <dl class="album"> 38 * <dt><img src="bild.jpg" width=".." .. /></dt> 39 * <dd>Beschreibung</dd> 40 * </dl> 41 * 42 * @author Jan Dankert 43 */ 44 class Album extends Macro 45 { 46 47 /** 48 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich. 49 * @type String 50 */ 51 public $description = 'Creates an album.'; 52 53 public $folderid = 0; 54 55 public $withImages = true; 56 public $withFiles = false; 57 58 /** 59 */ 60 public function execute() 61 { 62 if ( intval($this->folderid)!=0 ) 63 $folderid = $this->folderid; 64 else 65 $folderid = $this->page->parentid; 66 67 $f = new Folder($folderid); 68 $files = $f->getObjectIdsByType(BaseObject::TYPEID_IMAGE); 69 70 $this->output('<dl class="album">'); 71 72 foreach( $files as $fileid ) 73 { 74 $file = new Image($fileid); 75 $file->load(); 76 77 $file->getImageSize(); 78 $img = '<img src="'.$this->pathToObject($fileid).'" alt="'.$file->getNameForLanguage( $this->pageContext->languageId )->name.'" width="'.$file->width.'" height="'.$file->height.'" />'; 79 $this->output('<dt>'.$img.'</dt><dd>'.$file->getNameForLanguage( $this->pageContext->languageId )->description.'</dd>'); 80 81 } 82 83 $this->output('</dl>'); 84 } 85 86 } 87 88 ?>
Downloadmodules/cms/macros/macro/Album.class.php
History Sun, 5 Dec 2021 20:33:24 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'. Thu, 4 Mar 2021 03:39:25 +0100 Jan Dankert New: Separate edit action for images and texts. Sun, 23 Feb 2020 04:49:34 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 2. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.