_resource->getAttribute('forActionName')) { $this->_forActionName = $forActionName; $this->_filesystemName = $this->_convertActionNameToFilesystemName($forActionName) . '.phtml'; } elseif ($scriptName = $this->_resource->getAttribute('scriptName')) { $this->_scriptName = $scriptName; $this->_filesystemName = $scriptName . '.phtml'; } else { throw new Exception('Either a forActionName or scriptName is required.'); } parent::init(); return $this; } /** * getPersistentAttributes() * * @return unknown */ public function getPersistentAttributes() { $attributes = array(); if ($this->_forActionName) { $attributes['forActionName'] = $this->_forActionName; } if ($this->_scriptName) { $attributes['scriptName'] = $this->_scriptName; } return $attributes; } /** * getContents() * * @return string */ public function getContents() { $contents = ''; $controllerName = $this->_resource->getParentResource()->getAttribute('forControllerName'); $viewsDirectoryResource = $this->_resource ->getParentResource() // view script ->getParentResource() // view controller dir ->getParentResource(); // views dir if ($viewsDirectoryResource->getParentResource()->getName() == 'ModuleDirectory') { $moduleName = $viewsDirectoryResource->getParentResource()->getModuleName(); } else { $moduleName = 'default'; } if ($this->_filesystemName == 'error.phtml') { // should also check that the above directory is forController=error $contents .= << Zend Framework Default Application

An error occurred

message ?>

exception)): ?>

Exception information:

Message: exception->getMessage() ?>

Stack trace:

exception->getTraceAsString() ?>
  

Request Parameters:

escape(var_export(\$this->request->getParams(), true)) ?>
  
EOS; } elseif ($this->_forActionName == 'index' && $controllerName == 'Index' && $moduleName == 'default') { $contents =<< a:link, a:visited { color: #0398CA; } span#zf-name { color: #91BE3F; } div#welcome { color: #FFFFFF; background-image: url(http://framework.zend.com/images/bkg_header.jpg); width: 600px; height: 400px; border: 2px solid #444444; overflow: hidden; text-align: center; } div#more-information { background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif); height: 100%; }

Welcome to the Zend Framework!

This is your project's main page

EOS; } else { $controllerName = $this->_resource->getParentResource()->getAttribute('forControllerName'); $actionName = $this->_forActionName; $contents = <<

View script for controller $controllerName and script/action name $actionName

EOS; } return $contents; } protected function _convertActionNameToFilesystemName($actionName) { $filter = new Zend_Filter(); $filter->addFilter(new Zend_Filter_Word_CamelCaseToDash()) ->addFilter(new Zend_Filter_StringToLower()); return $filter->filter($actionName); } }