openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

DoiMenu.class.php (3897B)


      1 <?php
      2 // ---------------------------------------------------------------------------
      3 // $Id$
      4 // ---------------------------------------------------------------------------
      5 // OpenRat Content Management System
      6 // Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
      7 //
      8 // This program is free software; you can redistribute it and/or
      9 // modify it under the terms of the GNU General Public License
     10 // as published by the Free Software Foundation; either version 2
     11 // of the License, or (at your option) any later version.
     12 //
     13 // This program is distributed in the hope that it will be useful,
     14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 // GNU General Public License for more details.
     17 //
     18 // You should have received a copy of the GNU General Public License
     19 // along with this program; if not, write to the Free Software
     20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     21 // ---------------------------------------------------------------------------
     22 // $Log$
     23 // Revision 1.1  2005-01-04 20:31:52  dankert
     24 // Neues Menue
     25 //
     26 // Revision 1.1  2005/01/04 20:00:12  dankert
     27 // Darstellung eines DHTML-Menues
     28 //
     29 // Revision 1.2  2004/12/28 22:57:56  dankert
     30 // Korrektur Vererbung, "api" ausgebaut
     31 //
     32 // Revision 1.1  2004/10/14 21:15:29  dankert
     33 // Erzeugen und Anzeigen einer Sitemap
     34 //
     35 // ---------------------------------------------------------------------------
     36 use cms\model\File;
     37 use cms\model\Folder;
     38 use cms\model\Page;
     39 
     40 
     41 /**
     42  * Erstellen eines DHTML-Menues (DoiMenu)
     43  *
     44  * Diese Klasse erzeugt Javascript-Code fuer das DoiMenu
     45  *
     46  * @see http://doimenu.sf.net for details
     47  * @author Jan Dankert
     48  */
     49 class DoiMenu extends Macro
     50 {
     51 	/**
     52 	 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
     53 	 * @type String
     54 	 */
     55 	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';
     56 
     57 
     58 	/**
     59 	 * Parameter mit Objekt-Id
     60 	 * Die Datei mit dieser Id enthaelt Parameter fuer das Menu
     61 	 */
     62 	var $parameterFileId = 0;
     63 	
     64 	/**
     65 	 * Ausrichtung des Menues.
     66 	 * available value : 'horizontal','vertical'.
     67 	 */
     68 	var $direction = 'horizontal';
     69 
     70 	
     71 	/**
     72 	 * Erstellen des DHTML-Menues
     73 	 */
     74 	function execute()
     75 	{
     76 		// Erstellen eines Untermenues
     77 		
     78 		// Ermitteln der aktuellen Seite
     79 		$thispage = new Page( $this->getObjectId() );
     80 		$thispage->load(); // Seite laden
     81 		
     82 		$this->outputLn('<script name="javascript" type="text/javascript">');
     83 
     84 		$this->outputLn("  var menu = new TMainMenu('menu','".$this->direction."');");
     85 
     86 		$ro = new Folder($this->getRootObjectId());
     87 		$this->showFolder( $ro );
     88 
     89 		if	( intval( $this->parameterFileId ) != 0 )
     90 		{
     91 			$f = new File( intval($this->parameterFileId) );
     92 			$this->outputLn( $f->loadValue() );
     93 		}
     94 		
     95 		$this->outputLn( '  menu.Build()' );
     96 		$this->outputLn( '</script');
     97 	}
     98 	
     99 	
    100 	function showFolder( $fo )
    101 	{
    102 		if	( $fo->objectid == intval($this->getRootObjectId()) )
    103 			$parentMenu = 'menu';
    104 		else
    105 			$parentMenu = 'menu'.$fo->objectid;
    106 
    107 		foreach( $fo->getObjects() as $o )
    108 		{
    109 			$menu = 'menu'.$o->objectid;
    110 
    111 			if	( $o->isFolder )
    112 			{	$nf = new Folder($o->objectid);
    113 				$pl = $nf->getFirstPageOrLink();
    114 				if	( is_object($pl) )
    115 				{
    116 					$this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($pl->objectid)."','".$o->desc."');");
    117 					$this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
    118 					$this->showFolder( $nf );
    119 				}
    120 			}
    121 
    122 			if	( $o->isPage || $o->isPage )
    123 			{
    124 				$this->outputLn(" var $menu = new TPopMenu('".$o->name."','','a','".$this->pathToObject($o->objectid)."','".$o->desc."');");
    125 				$this->outputLn(" $parentMenu.Add(menu".$o->objectid.");");
    126 			}
    127 		}
    128 	}
    129 
    130 }
    131 
    132 ?>