forked from FluidTYPO3/fluidpages
-
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.
Fully compatible with FED templates.
- Loading branch information
Claus Due
committed
Nov 23, 2012
1 parent
e1b3914
commit ee5a174
Showing
13 changed files
with
1,013 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,114 @@ | ||
<?php | ||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2011 Claus Due <[email protected]>, Wildside A/S | ||
* 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! | ||
***************************************************************/ | ||
|
||
/** | ||
* Class that renders a Page template selection field. | ||
* | ||
* @package Fluidpages | ||
* @subpackage Backend | ||
*/ | ||
class Tx_Fluidpages_Backend_PageLayoutSelector { | ||
|
||
/** | ||
* @var Tx_Extbase_Configuration_BackendConfigurationManager | ||
*/ | ||
protected $configurationManager; | ||
|
||
/** | ||
* @var Tx_Fluidpages_Service_ConfigurationService | ||
*/ | ||
protected $configurationService; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $recognizedFormats = array('html', 'xml', 'txt', 'json', 'js', 'css'); | ||
|
||
/** | ||
* @var Tx_Fluidpages_Service_PageService | ||
*/ | ||
protected $pageService; | ||
|
||
/** | ||
* CONSTRUCTOR | ||
*/ | ||
public function __construct() { | ||
$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager'); | ||
$this->configurationManager = $objectManager->get('Tx_Extbase_Configuration_BackendConfigurationManager'); | ||
$this->configurationService = $objectManager->get('Tx_Fluidpages_Service_ConfigurationService'); | ||
$this->pageService = $objectManager->get('Tx_Fluidpages_Service_PageService'); | ||
} | ||
|
||
/** | ||
* Renders a Fluid Page Layout file selector | ||
* | ||
* @param array $parameters | ||
* @param mixed $pObj | ||
* @return string | ||
*/ | ||
public function renderField(&$parameters, &$pObj) { | ||
$name = $parameters['itemFormElName']; | ||
$value = $parameters['itemFormElValue']; | ||
$availableTemplates = $this->pageService->getAvailablePageTemplateFiles(); | ||
if (strpos($name, 'tx_fed_controller_action_sub') === FALSE) { | ||
$onChange = 'onchange="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"'; | ||
} | ||
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fed']['setup']['enableFallbackFluidPageTemplate'] && empty($value) === TRUE) { | ||
$fallbackTemplatePathAndFilename = $this->pageService->getFallbackPageTemplatePathAndFilename(); | ||
if (strpos($fallbackTemplatePathAndFilename, '->')) { | ||
list ($extensionName, $templateFileBase) = explode('->', $fallbackTemplatePathAndFilename); | ||
$fallbackTemplateIdentifier = trim($fallbackTemplatePathAndFilename, '.html'); | ||
unset($templateFileBase); | ||
} else { | ||
$extensionName = NULL; | ||
$fallbackTemplateIdentifier = $fallbackTemplatePathAndFilename; | ||
} | ||
$value = $fallbackTemplateIdentifier; | ||
$emptyLabel = $this->configurationManager->getPageTemplateLabel($extensionName, $fallbackTemplateIdentifier); | ||
} | ||
$selector = '<select name="' . $name . '" class="formField select" ' . $onChange . '>' . LF; | ||
$selector .= '<option value="">' . $emptyLabel . '</option>' . LF; | ||
foreach ($availableTemplates as $extension=>$group) { | ||
if (!t3lib_extMgm::isLoaded($extension)) { | ||
$groupTitle = ucfirst($extension); | ||
} else { | ||
$emConfigFile = t3lib_extMgm::extPath($extension, 'ext_emconf.php'); | ||
require $emConfigFile; | ||
$groupTitle = $EM_CONF['']['title']; | ||
} | ||
$selector .= '<optgroup label="' . $groupTitle . '">' . LF; | ||
foreach ($group as $template) { | ||
$optionValue = $extension . '->' . $template; | ||
$label = $this->pageService->getPageTemplateLabel($extension, $template); | ||
$selected = ($optionValue == $value ? ' selected="formField selected"' : ''); | ||
$option = '<option value="' . $optionValue . '"' . $selected . '>' . $label . '</option>'; | ||
$selector .= $option . LF; | ||
} | ||
$selector .= '</optgroup>' . LF; | ||
} | ||
$selector .= '</select>' . LF; | ||
return $selector; | ||
} | ||
|
||
} |
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,129 @@ | ||
<?php | ||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2011 Claus Due <[email protected]>, Wildside A/S | ||
* | ||
* 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! | ||
***************************************************************/ | ||
|
||
/** | ||
* Page Controller | ||
* | ||
* @package Fluidpages | ||
* @subpackage Controller | ||
* @route off | ||
*/ | ||
class Tx_Fluidpages_Controller_PageController extends Tx_Extbase_MVC_Controller_ActionController { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $defaultViewObjectName = 'Tx_Flux_MVC_View_ExposedTemplateView'; | ||
|
||
/** | ||
* @var Tx_Fluidpages_Service_PageService | ||
*/ | ||
protected $pageService; | ||
|
||
/** | ||
* @var Tx_Fluidpages_Service_ConfigurationService | ||
*/ | ||
protected $configurationService; | ||
|
||
/** | ||
* @var Tx_Flux_Service_FlexForm | ||
*/ | ||
protected $flexFormService; | ||
|
||
/** | ||
* @param Tx_Fluidpages_Service_PageService $pageService | ||
*/ | ||
public function injectPageService(Tx_Fluidpages_Service_PageService $pageService) { | ||
$this->pageService = $pageService; | ||
} | ||
|
||
/** | ||
* @param Tx_Fluidpages_Service_ConfigurationService $configurationService | ||
* @return void | ||
*/ | ||
public function injectConfigurationService(Tx_Fluidpages_Service_ConfigurationService $configurationService) { | ||
$this->configurationService = $configurationService; | ||
} | ||
|
||
/** | ||
* @param Tx_Flux_Service_FlexForm $flexFormService | ||
* @return void | ||
*/ | ||
public function injectFlexFormService(Tx_Flux_Service_FlexForm $flexformService) { | ||
$this->flexFormService = $flexformService; | ||
} | ||
|
||
/** | ||
* @param Tx_Flux_MVC_View_ExposedTemplateView $view | ||
* | ||
* @return void | ||
*/ | ||
public function initializeView(Tx_Flux_MVC_View_ExposedTemplateView $view) { | ||
$configuration = $this->pageService->getPageTemplateConfiguration($GLOBALS['TSFE']->id); | ||
list ($extensionName, $action) = explode('->', $configuration['tx_fed_page_controller_action']); | ||
$paths = $this->configurationService->getPageConfiguration($extensionName); | ||
$flexFormSource = $this->pageService->getPageFlexFormSource($GLOBALS['TSFE']->id); | ||
$flexformData = $this->flexFormService->convertFlexFormContentToArray($flexFormSource); | ||
$view->setLayoutRootPath($paths['layoutRootPath']); | ||
$view->setPartialRootPath($paths['partialRootPath']); | ||
$templatePathAndFilename = $paths['templateRootPath'] . 'Page/' . $action . '.html'; | ||
if (file_exists($templatePathAndFilename) === FALSE && $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fed']['setup']['enableFallbackFluidPageTemplate']) { | ||
$templatePathAndFilename = $this->settings['templates']['fallbackFluidPageTemplate']; | ||
} | ||
$templatePathAndFilename = Tx_Flux_Utility_Path::translatePath($templatePathAndFilename); | ||
if (file_exists($templatePathAndFilename) === TRUE) { | ||
$view->setTemplatePathAndFilename($templatePathAndFilename); | ||
$view->assignMultiple($flexformData); | ||
$view->assign('page', $GLOBALS['TSFE']->page); | ||
$view->assign('user', $GLOBALS['TSFE']->fe_user->user); | ||
$view->assign('cookies', $_COOKIE); | ||
$view->assign('session', $_SESSION); | ||
} else { | ||
$message = 'Template file "' . $templatePathAndFilename . '" does not exist.'; | ||
if (pathinfo($templatePathAndFilename, PATHINFO_BASENAME) === '') { | ||
$message .= ' Additionally, the specified template file basename was empty.'; | ||
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fed']['setup']['enableFallbackFluidPageTemplate']) { | ||
$message .= ' The fallback page template feature is enabled but the fallback template was not found.'; | ||
} else { | ||
$message .= ' A fallback page template was not defined - which means that you probably just need to'; | ||
$message .= ' select a page template for this page or make sure your page inherits its template '; | ||
$message .= ' from the parent page template.'; | ||
} | ||
} | ||
$this->flashMessageContainer->add($message, 'Template file not found'); | ||
} | ||
$this->view = $view; | ||
} | ||
|
||
/** | ||
* @return string | ||
* @route off | ||
*/ | ||
public function renderAction() { | ||
$this->view->setControllerContext($this->controllerContext); | ||
return $this->view->render(); | ||
} | ||
|
||
} |
Oops, something went wrong.