File modules/cms/macros/macro/CommonMenu.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 // --------------------------------------------------------------------------- 4 // $Id$ 5 // --------------------------------------------------------------------------- 6 // OpenRat Content Management System 7 // Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de 8 // 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU General Public License 11 // as published by the Free Software Foundation; either version 2 12 // of the License, or (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with this program; if not, write to the Free Software 21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 // --------------------------------------------------------------------------- 23 // $Log$ 24 // Revision 1.3 2004-12-19 22:35:23 dankert 25 // Parameter -Angabe 26 // 27 // Revision 1.2 2004/12/19 15:19:29 dankert 28 // Klasse erbt von "Dynamic" 29 // 30 // Revision 1.1 2004/11/10 22:43:35 dankert 31 // Beispiele fuer dynamische Templateelemente 32 // 33 // --------------------------------------------------------------------------- 34 use cms\model\BaseObject; 35 use cms\model\Folder; 36 use cms\model\Page; 37 use util\Macro; 38 39 40 /** 41 * Erstellen eines Menues 42 * @author Jan Dankert 43 */ 44 class CommonMenu extends Macro 45 { 46 /** 47 * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich. 48 * @type String 49 */ 50 var $parameters = Array( 51 'beforeEntry'=>'Chars before an active menu entry', 52 'afterEntry' =>'Chars after an active menu entry' 53 ); 54 55 /** 56 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich. 57 * @type String 58 */ 59 var $description = 'Creates a main menu.'; 60 61 62 /** 63 * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird 64 */ 65 var $beforeEntry = '<li><strong>'; 66 var $afterEntry = '</strong></li>'; 67 68 69 // Erstellen des Hauptmenues 70 function execute() 71 { 72 // Erstellen eines Untermenues 73 74 // Ermitteln der aktuellen Seite 75 $thispage = new Page( $this->getObjectId() ); 76 $thispage->load(); // Seite laden 77 78 // uebergeordneter Ordner dieser Seite 79 $f = new Folder( $thispage->parentid ); 80 81 // Schleife ueber alle Objekte im aktuellen Ordner 82 foreach( $f->getObjectIds() as $id ) 83 { 84 $o = new BaseObject( $id ); 85 $o->load(); 86 87 // Nur Seiten anzeigen 88 if (!$o->isPage && !$o->isLink ) continue; 89 90 $name = $o->getNameForLanguage( $this->pageContext->languageId ); 91 92 // Wenn aktuelle Seite, dann markieren, sonst Link 93 if ( $this->getObjectId() == $id ) 94 { 95 // aktuelle Seite 96 $this->output( '<li><strong>'.$name->name.'</strong></li>' ); 97 } 98 else 99 { 100 // Link erzeugen 101 $this->output( '<li><a href="'.$this->pathToObject($id).'">'.$name->name.'</a></li>' ); 102 } 103 } 104 } 105 }
Download modules/cms/macros/macro/CommonMenu.class.php
History Sun, 5 Dec 2021 20:33:24 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'. 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.