File modules/cms/macros/macro/ListMenu.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.1 2005-01-28 23:06:10 dankert 25 // Neues Menue in Listenform (HTML-Listen), aehnlich "BlockMenu" 26 // 27 // Revision 1.2 2004/12/25 21:05:14 dankert 28 // erbt von Klasse Dynamic 29 // 30 // Revision 1.1 2004/10/14 21:16:12 dankert 31 // Erzeugen eines Menues in Bloecken 32 // 33 // --------------------------------------------------------------------------- 34 use cms\model\Folder; 35 use cms\model\BaseObject; 36 use util\Macro; 37 38 39 /** 40 * Erstellen eines Hauptmenues 41 * @author Jan Dankert 42 */ 43 class ListMenu extends Macro 44 { 45 /** 46 * Bitte immer alle Parameter in dieses Array schreiben, dies ist fuer den Web-Developer hilfreich. 47 * @type String 48 */ 49 var $parameters = Array( 50 'arrowChar'=>'String between menu entries, default: "&middot;"' 51 ); 52 53 54 var $arrowChar = ' &middot; '; 55 56 /** 57 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich. 58 * @type String 59 */ 60 var $description = 'Creates a main menu.'; 61 var $version = '$Id$'; 62 var $api; 63 64 // Erstellen des Hauptmenues 65 function execute() 66 { 67 // Erstellen des Hauptmenues 68 69 // Lesen des Root-Ordners 70 $folder = new Folder( $this->getRootObjectId() ); 71 72 // Schleife ueber alle Inhalte des Root-Ordners 73 foreach( $folder->getObjectIds() as $id ) 74 { 75 $o = new BaseObject( $id ); 76 $o->load(); 77 if ( $o->isFolder ) // Nur wenn Ordner 78 { 79 $f = new Folder( $id ); 80 $f->load(); 81 82 // Ermitteln eines Objektes mit dem Dateinamen index 83 // $oid = $f->getObjectIdByFileName('index'); 84 85 if ( count($f->getLinks())+count($f->getPages()) > 0 ) 86 { 87 $this->output( '<h1 class="title">'.$o->getNameForLanguage( $this->pageContext->languageId )->name.'</h1><ul>'); 88 // Untermenue 89 // Schleife ber alle Objekte im aktuellen Ordner 90 foreach( $f->getObjectIds() as $xid ) 91 { 92 $o = new BaseObject( $xid ); 93 $o->load(); 94 95 // Nur Seiten und Verknuepfungen anzeigen 96 if (!$o->isPage && !$o->isLink && !$o->isUrl ) continue; 97 98 // Wenn aktuelle Seite, dann markieren, sonst Link 99 if ( $this->getObjectId() == $xid ) 100 { 101 // aktuelle Seite 102 $this->output( '<li class="menu">'.$o->getNameForLanguage( $this->pageContext->languageId )->name.'</li>' ); 103 } 104 else 105 { 106 $this->output( '<li class="menu"><a class="menu" href="'.$this->pathToObject($xid).'">'.$o->getNameForLanguage( $this->pageContext->languageId )->name.'</a></li>' ); 107 } 108 } 109 110 $this->output( '</ul><br />' ); 111 } 112 } 113 } 114 } 115 }
Download modules/cms/macros/macro/ListMenu.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.