TYPO3 API  SVNRelease
NotFoundView.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
00006 *  All rights reserved
00007 *
00008 *  This class is a backport of the corresponding class of FLOW3.
00009 *  All credits go to the v5 team.
00010 *
00011 *  This script is part of the TYPO3 project. The TYPO3 project is
00012 *  free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  The GNU General Public License can be found at
00018 *  http://www.gnu.org/copyleft/gpl.html.
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 /**
00029  * The not found view - a special case.
00030  *
00031  * @package Extbase
00032  * @subpackage MVC\View
00033  * @version $Id: EmptyView.php 2517 2010-08-04 17:56:45Z bwaidelich $
00034  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00035  */
00036 class Tx_Extbase_MVC_View_NotFoundView extends Tx_Extbase_MVC_View_AbstractView {
00037 
00038     /**
00039      * @var array
00040      */
00041     protected $variablesMarker = array('errorMessage' => 'ERROR_MESSAGE');
00042 
00043     /**
00044      * Renders the not found view
00045      *
00046      * @return string The rendered view
00047      * @throws Tx_Extbase_MVC_Exception if no request has been set
00048      * @api
00049      */
00050     public function render() {
00051         if (!is_object($this->controllerContext->getRequest())) throw new Tx_Extbase_MVC_Exception('Can\'t render view without request object.', 1192450280);
00052 
00053         $template = file_get_contents($this->getTemplatePathAndFilename());
00054 
00055         if ($this->controllerContext->getRequest() instanceof Tx_Extbase_MVC_Web_Request) {
00056             $template = str_replace('###BASEURI###', t3lib_div::getIndpEnv('TYPO3_SITE_URL'), $template);
00057         }
00058 
00059         foreach ($this->variablesMarker as $variableName => $marker) {
00060             $variableValue = isset($this->variables[$variableName]) ? $this->variables[$variableName] : '';
00061             $template = str_replace('###' . $marker . '###', $variableValue, $template);
00062         }
00063 
00064         return $template;
00065     }
00066 
00067     /**
00068      * Retrieves path and filename of the not-found-template
00069      *
00070      * @return string path and filename of the not-found-template
00071      * @author Bastian Waidelich <bastian@typo3.org>
00072      */
00073     protected function getTemplatePathAndFilename() {
00074         return t3lib_extmgm::extPath('extbase') . 'Resources/Private/MVC/NotFoundView_Template.html';
00075     }
00076 
00077     /**
00078      * A magic call method.
00079      *
00080      * Because this not found view is used as a Special Case in situations when no matching
00081      * view is available, it must be able to handle method calls which originally were
00082      * directed to another type of view. This magic method should prevent PHP from issuing
00083      * a fatal error.
00084      *
00085      * @return void
00086      */
00087     public function __call($methodName, array $arguments) {
00088     }
00089 }
00090 ?>