File modules/cms/macros/macro/LanguageLinksForPage.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) 2012 Tobias Schöne tobias@schoenesnetz.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 24 use cms\generator\PageContext; 25 use cms\generator\Producer; 26 use cms\model\Language; 27 use cms\model\Page; 28 use cms\model\Project; 29 use util\Macro; 30 31 /** 32 * Erstellen einer Liste von Language-Links auf die selbe Seite. 33 * 34 * @author Tobias Schoene 35 */ 36 class LanguageLinksForPage extends Macro 37 { 38 /** 39 * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich. 40 * @type String 41 */ 42 var $description = 'Creates language links to the page.'; 43 44 // Build the navigation links to other languages 45 function execute() 46 { 47 $project = new Project( $this->page->projectid ); 48 // Schleife ueber alle Inhalte des Root-Ordners 49 echo '<ul>'; 50 foreach( $project->getLanguages() as $lid=>$lname) 51 { 52 53 $language = new Language( $lid ); 54 $language->load(); 55 56 $targetPage = new Page( $this->page->objectid ); 57 $targetPage->publisher = $this->page->publisher; 58 $targetPage->load(); 59 60 $myPageContext = clone $this->pageContext; 61 $myPageContext->languageId = $lid; 62 63 $linkScheme = $myPageContext->getLinkScheme(); 64 65 $link = $linkScheme->linkToObject( $this->getPage(), $targetPage ); 66 echo '<li><a hreflang="'.$language->isoCode.'" href="'.$link.'">'.strtolower($language->isoCode).'</a></li>'; 67 68 } 69 echo '</ul>'; 70 } 71 } 72 ?>
Download modules/cms/macros/macro/LanguageLinksForPage.class.php
History Sun, 5 Dec 2021 20:33:24 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'. Wed, 23 Sep 2020 01:04:05 +0200 Jan Dankert Cleanup of deprecated methods and deprecated class attributes. 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.