File modules/cms/macros/macro/DoiMenu.class.php

Last commit: Sat Mar 19 01:28:00 2022 +0100	dankert	Fixed this old class (maybe we should throw it away).
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-04 20:31:52 dankert 25 // Neues Menue 26 // 27 // Revision 1.1 2005/01/04 20:00:12 dankert 28 // Darstellung eines DHTML-Menues 29 // 30 // Revision 1.2 2004/12/28 22:57:56 dankert 31 // Korrektur Vererbung, "api" ausgebaut 32 // 33 // Revision 1.1 2004/10/14 21:15:29 dankert 34 // Erzeugen und Anzeigen einer Sitemap 35 // 36 // --------------------------------------------------------------------------- 37 use cms\model\BaseObject; 38 use cms\model\File; 39 use cms\model\Folder; 40 use cms\model\Page; 41 use util\Macro; 42 43 44 /** 45 * Erstellen eines DHTML-Menues (DoiMenu) 46 * 47 * Diese Klasse erzeugt Javascript-Code fuer das DoiMenu 48 * 49 * @see http://doimenu.sf.net for details 50 * @author Jan Dankert 51 */ 52 class DoiMenu extends Macro 53 { 54 /** 55 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich. 56 * @type String 57 */ 58 var $description = 'You *have to* include doiMenuDOM.js in the page!<br/>Put the code below in head section:<br/><tt>&lt;script type="text/javascript" src="{{your-elementname}}.js"&gt;&lt;/script&gt;</tt><br/>The file is distributed with OpenRat'; 59 60 61 /** 62 * Parameter mit Objekt-Id 63 * Die Datei mit dieser Id enthaelt Parameter fuer das Menu 64 */ 65 var $parameterFileId = 0; 66 67 /** 68 * Ausrichtung des Menues. 69 * available value : 'horizontal','vertical'. 70 */ 71 var $direction = 'horizontal'; 72 73 74 /** 75 * Erstellen des DHTML-Menues 76 */ 77 function execute() 78 { 79 // Erstellen eines Untermenues 80 81 // Ermitteln der aktuellen Seite 82 $thispage = new Page( $this->getObjectId() ); 83 $thispage->load(); // Seite laden 84 85 $this->outputLn('<script name="javascript" type="text/javascript">'); 86 87 $this->outputLn(" var menu = new TMainMenu('menu','".$this->direction."');"); 88 89 $ro = new Folder($this->getRootObjectId()); 90 $this->showFolder( $ro ); 91 92 if ( intval( $this->parameterFileId ) != 0 ) 93 { 94 $f = new File( intval($this->parameterFileId) ); 95 $this->outputLn( $f->loadValue() ); 96 } 97 98 $this->outputLn( ' menu.Build()' ); 99 $this->outputLn( '</script'); 100 } 101 102 103 function showFolder( $fo ) 104 { 105 if ( $fo->objectid == intval($this->getRootObjectId()) ) 106 $parentMenu = 'menu'; 107 else 108 $parentMenu = 'menu'.$fo->objectid; 109 110 /** @var BaseObject $o */ 111 foreach($fo->getObjects() as $o ) 112 { 113 $menu = 'menu'.$o->objectid; 114 115 if ( $o->isFolder ) 116 { $nf = new Folder($o->objectid); 117 $pl = $nf->getFirstPageOrLink(); 118 if ( is_object($pl) ) 119 { 120 $this->outputLn(" var $menu = new TPopMenu('".$o->filename."','','a','".$this->pathToObject($pl->objectid)."','".$o->filename."');"); 121 $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");"); 122 $this->showFolder( $nf ); 123 } 124 } 125 126 if ( $o->isPage || $o->isPage ) 127 { 128 $this->outputLn(" var $menu = new TPopMenu('".$o->filename."','','a','".$this->pathToObject($o->objectid)."','".$o->filename."');"); 129 $this->outputLn(" $parentMenu.Add(menu".$o->objectid.");"); 130 } 131 } 132 } 133 134 } 135 136 ?>
Download modules/cms/macros/macro/DoiMenu.class.php
History Sat, 19 Mar 2022 01:28:00 +0100 dankert Fixed this old class (maybe we should throw it away). 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.