📄 layout.php
字号:
return $this->_layoutPath; } /** * Set content key * * Key in namespace container denoting default content * * @param string $contentKey * @return Zend_Layout */ public function setContentKey($contentKey) { $this->_contentKey = (string) $contentKey; return $this; } /** * Retrieve content key * * @return string */ public function getContentKey() { return $this->_contentKey; } /** * Set MVC enabled flag * * @param bool $mvcEnabled * @return Zend_Layout */ protected function _setMvcEnabled($mvcEnabled) { $this->_mvcEnabled = ($mvcEnabled) ? true : false; return $this; } /** * Retrieve MVC enabled flag * * @return bool */ public function getMvcEnabled() { return $this->_mvcEnabled; } /** * Set MVC Successful Action Only flag * * @param bool $successfulActionOnly * @return Zend_Layout */ public function setMvcSuccessfulActionOnly($successfulActionOnly) { $this->_mvcSuccessfulActionOnly = ($successfulActionOnly) ? true : false; return $this; } /** * Get MVC Successful Action Only Flag * * @return bool */ public function getMvcSuccessfulActionOnly() { return $this->_mvcSuccessfulActionOnly; } /** * Set view object * * @param Zend_View_Interface $view * @return Zend_Layout */ public function setView(Zend_View_Interface $view) { $this->_view = $view; return $this; } /** * Retrieve helper class * * @return string */ public function getHelperClass() { return $this->_helperClass; } /** * Set helper class * * @param string $helperClass * @return Zend_Layout */ public function setHelperClass($helperClass) { $this->_helperClass = (string) $helperClass; return $this; } /** * Retrieve plugin class * * @return string */ public function getPluginClass() { return $this->_pluginClass; } /** * Set plugin class * * @param string $pluginClass * @return Zend_Layout */ public function setPluginClass($pluginClass) { $this->_pluginClass = (string) $pluginClass; return $this; } /** * Get current view object * * If no view object currently set, retrieves it from the ViewRenderer. * * @todo Set inflector from view renderer at same time * @return Zend_View_Interface */ public function getView() { if (null === $this->_view) { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); if (null === $viewRenderer->view) { $viewRenderer->initView(); } $this->setView($viewRenderer->view); } return $this->_view; } /** * Set layout view script suffix * * @param string $viewSuffix * @return Zend_Layout */ public function setViewSuffix($viewSuffix) { $this->_viewSuffix = (string) $viewSuffix; return $this; } /** * Retrieve layout view script suffix * * @return string */ public function getViewSuffix() { return $this->_viewSuffix; } /** * Retrieve inflector target * * @return string */ public function getInflectorTarget() { return $this->_inflectorTarget; } /** * Set inflector target * * @param string $inflectorTarget * @return Zend_Layout */ public function setInflectorTarget($inflectorTarget) { $this->_inflectorTarget = (string) $inflectorTarget; return $this; } /** * Set inflector to use when resolving layout names * * @param Zend_Filter_Inflector $inflector * @return Zend_Layout */ public function setInflector(Zend_Filter_Inflector $inflector) { $this->_inflector = $inflector; return $this; } /** * Retrieve inflector * * @return Zend_Filter_Inflector */ public function getInflector() { if (null === $this->_inflector) { require_once 'Zend/Filter/Inflector.php'; $inflector = new Zend_Filter_Inflector(); $inflector->setTargetReference($this->_inflectorTarget) ->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'))) ->setStaticRuleReference('suffix', $this->_viewSuffix); $this->setInflector($inflector); } return $this->_inflector; } /** * Enable inflector * * @return Zend_Layout */ public function enableInflector() { $this->_inflectorEnabled = true; return $this; } /** * Disable inflector * * @return Zend_Layout */ public function disableInflector() { $this->_inflectorEnabled = false; return $this; } /** * Return status of inflector enabled flag * * @return bool */ public function inflectorEnabled() { return $this->_inflectorEnabled; } /** * Set layout variable * * @param string $key * @param mixed $value * @return void */ public function __set($key, $value) { $this->_container[$key] = $value; } /** * Get layout variable * * @param string $key * @return mixed */ public function __get($key) { if (isset($this->_container[$key])) { return $this->_container[$key]; } return null; } /** * Is a layout variable set? * * @param string $key * @return bool */ public function __isset($key) { return (isset($this->_container[$key])); } /** * Unset a layout variable? * * @param string $key * @return void */ public function __unset($key) { if (isset($this->_container[$key])) { unset($this->_container[$key]); } } /** * Assign one or more layout variables * * @param mixed $spec Assoc array or string key; if assoc array, sets each * key as a layout variable * @param mixed $value Value if $spec is a key * @return Zend_Layout * @throws Zend_Layout_Exception if non-array/string value passed to $spec */ public function assign($spec, $value = null) { if (is_array($spec)) { $orig = $this->_container->getArrayCopy(); $merged = array_merge($orig, $spec); $this->_container->exchangeArray($merged); return $this; } if (is_string($spec)) { $this->_container[$spec] = $value; return $this; } require_once 'Zend/Layout/Exception.php'; throw new Zend_Layout_Exception('Invalid values passed to assign()'); } /** * Render layout * * Sets internal script path as last path on script path stack, assigns * layout variables to view, determines layout name using inflector, and * renders layout view script. * * $name will be passed to the inflector as the key 'script'. * * @param mixed $name * @return mixed */ public function render($name = null) { if (null === $name) { $name = $this->getLayout(); } if ($this->inflectorEnabled() && (null !== ($inflector = $this->getInflector()))) { $name = $this->_inflector->filter(array('script' => $name)); } $view = $this->getView(); if (null !== ($path = $this->getLayoutPath())) { $view->addScriptPath($path); } return $view->render($name); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -