openrat-cms

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

ClassicMenu.class.php (3324B)


      1 <?php
      2 // OpenRat Content Management System
      3 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
      4 //
      5 // This program is free software; you can redistribute it and/or
      6 // modify it under the terms of the GNU General Public License
      7 // as published by the Free Software Foundation; either version 2
      8 // of the License, or (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU General Public License
     16 // along with this program; if not, write to the Free Software
     17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     18 use cms\model\Folder;
     19 use cms\model\Page;
     20 
     21 
     22 /**
     23  * Erstellen eines Menues
     24  * @author Jan Dankert
     25  */
     26 class ClassicMenu extends Macro
     27 {
     28 	/**
     29 	 * Beschreibung dieser Klasse
     30 	 * @type String
     31 	 */
     32 	var $description = 'This is a dynamic Menue which contains all pages. Folders are opened when useful. Nice standard menu :-)';
     33 
     34 
     35 	/**
     36 	 * Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird 
     37 	 */
     38 	var $css_class  = 'macro-classicmenu';
     39 	var $onlySameTemplate = true;
     40 	
     41 
     42 	// Erstellen des Hauptmenues
     43 	public function execute()
     44 	{
     45 		$rootId = $this->getRootObjectId();
     46 		// Erstellen eines Untermenues
     47 
     48 		$f = new Folder( $this->page->parentid );
     49 		$this->parentFolders = $f->parentObjectFileNames(false,true);
     50 		
     51 		$this->showFolder( $rootId );
     52 	}
     53 
     54 	private function showFolder( $oid )
     55 	{
     56 		$this->outputLn('<ul class="'.$this->css_class.'">');
     57 		$f = new Folder( $oid );
     58 
     59 		// Schleife ueber alle Objekte im aktuellen Ordner
     60 		foreach( $f->getObjects() as $o )
     61 		{
     62 			$o->languageid = $this->page->languageid;
     63 			$o->load();
     64 			
     65 			// Ordner anzeigen
     66 			if ($o->isFolder )
     67 			{
     68 				$nf = new Folder($o->objectid);
     69 				$fp = $nf->getFirstPageOrLink();
     70 				
     71 				if	( is_object($fp) )
     72 				{
     73 	
     74 					// Wenn aktuelle Seite, dann markieren, sonst Link
     75 					if ( $this->page->objectid == $fp->objectid )
     76 						// aktuelle Seite
     77 						$this->outputLn( '<li class="active">'.$o->name.'' );
     78 					else
     79 						// Link erzeugen
     80 						$this->outputLn( '<li><a href="'.$this->pathToObject($fp->objectid).'">'.$o->name.'</a>' );
     81 
     82 					if	( in_array($o->objectid,array_keys($this->parentFolders)) )
     83 					{
     84 						$this->showFolder($o->objectid);
     85 					}
     86 
     87 					$this->outputLn( '</li>' );
     88 				}
     89 			}
     90 
     91 			if ($o->isPage)
     92 			{
     93 				$page = new Page($o->objectid);
     94 				$page->load();
     95 				if	( $page->templateid != $this->page->templateid && $this->onlySameTemplate )
     96 					continue;
     97 			}
     98 			
     99 			// Seiten und Verknuepfungen anzeigen
    100 			if ($o->isPage ||  $o->isLink )
    101 			{
    102 				// Wenn aktuelle Seite, dann markieren, sonst Link
    103 				if ( $this->getObjectId() == $o->objectid)
    104 					// aktuelle Seite
    105 					$this->output( '<li class="active">'.$o->name.'</li>' );
    106 				elseif	( $o->isLink )
    107 					// Link mit HTML-Sonderzeichenumwandlung erzeugen
    108 					$this->output( '<li><a href="'.htmlspecialchars($this->pathToObject($o->objectid)).'">'.$o->name.'</a></li>' );
    109 				else
    110 					// Link erzeugen
    111 					$this->output( '<li><a href="'.$this->pathToObject($o->objectid).'">'.$o->name.'</a></li>' );
    112 			}
    113 		}
    114 		$this->output('</ul>');
    115 	}
    116 
    117 }