openrat-cms

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

LanguageLinksForPage.class.php (2370B)


      1 <?php
      2 // ---------------------------------------------------------------------------
      3 // $Id$
      4 // ---------------------------------------------------------------------------
      5 // OpenRat Content Management System
      6 // Copyright (C) 2012 Tobias Schöne tobias@schoenesnetz.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 
     23 use cms\model\Language;
     24 use cms\model\Page;
     25 use cms\model\Project;
     26 
     27 /**
     28  * Erstellen einer Liste von Language-Links auf die selbe Seite.
     29  *
     30  * @author Tobias Schoene
     31  */
     32 class LanguageLinksForPage extends Macro
     33 {
     34 	/**
     35 	 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
     36 	 * @type String
     37 	 */
     38 	var $description = 'Creates language links to the page.';
     39 
     40 	// Build the navigation links to other languages
     41 	function execute()
     42 	{
     43 		// current language
     44 		$languageId = $this->page->languageid;
     45 
     46 		$project = new Project( $this->page->projectid );
     47 		// Schleife ueber alle Inhalte des Root-Ordners
     48 		echo '<ul>';
     49 		foreach( $project->getLanguages() as $lid=>$lname)
     50 		{
     51 			
     52 			$language = new Language( $lid );
     53             $language->load();
     54 
     55             $targetPage = new Page( $this->page->objectid );
     56             $targetPage->publisher  = $this->page->publisher;
     57             $targetPage->languageid = $lid;
     58             $targetPage->modelid    = $this->page->modelid;
     59             $targetPage->load();
     60 
     61             $link = $this->page->publisher->linkToObject( $this->page, $targetPage );
     62 			echo '<li><a hreflang="'.$language->isoCode.'" href="'.$link.'">'.strtolower($language->isoCode).'</a></li>';
     63 			
     64 		}
     65 		$this->page->languageid = $languageId;
     66 		echo '</ul>';
     67 	}
     68 }
     69 ?>