forked from FluidTYPO3/vhs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Danilo Bürger
committed
Dec 11, 2013
1 parent
8ca70f4
commit cdab38f
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2013 Danilo Bürger <danilo.buerger@hmspl.de>, Heimspiel GmbH | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
/** | ||
* ViewHelper to get the rootline of a page | ||
* | ||
* @author Danilo Bürger <danilo.buerger@hmspl.de>, Heimspiel GmbH | ||
* @package Vhs | ||
* @subpackage ViewHelpers\Page | ||
*/ | ||
class Tx_Vhs_ViewHelpers_Page_RootlineViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper { | ||
|
||
/** | ||
* @var Tx_Vhs_Service_PageSelectService | ||
*/ | ||
protected $pageSelect; | ||
|
||
/** | ||
* @param Tx_Vhs_Service_PageSelectService $pageSelectService | ||
* @return void | ||
*/ | ||
public function injectPageSelectService(Tx_Vhs_Service_PageSelectService $pageSelectService) { | ||
$this->pageSelect = $pageSelectService; | ||
} | ||
|
||
/** | ||
* Initialize arguments. | ||
* | ||
* @return void | ||
* @api | ||
*/ | ||
public function initializeArguments() { | ||
parent::initializeArguments(); | ||
$this->registerArgument('pageUid', 'integer', 'Optional page uid to use.', FALSE, 0); | ||
$this->registerArgument('as', 'string', 'If specified, a template variable with this name containing the requested data will be inserted instead of returning it.', FALSE, NULL); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function render() { | ||
$pageUid = $this->arguments['pageUid']; | ||
if (0 === $pageUid) { | ||
$pageUid = $GLOBALS['TSFE']->id; | ||
} | ||
|
||
$rootLineData = $this->pageSelect->getRootLine($pageUid); | ||
|
||
$as = $this->arguments['as']; | ||
if (TRUE === empty($as)) { | ||
return $rootLineData; | ||
} | ||
|
||
$variables = array($as => $rootLineData); | ||
$output = Tx_Vhs_Utility_ViewHelperUtility::renderChildrenWithVariables($this, $this->templateVariableContainer, $variables); | ||
return $output; | ||
} | ||
|
||
} |