本文整理汇总了PHP中Zend_View_Abstract::addScriptPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Abstract::addScriptPath方法的具体用法?PHP Zend_View_Abstract::addScriptPath怎么用?PHP Zend_View_Abstract::addScriptPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_View_Abstract
的用法示例。
在下文中一共展示了Zend_View_Abstract::addScriptPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Set initial settings and call init()
*
* @param array $settings
*/
function __construct($settings = array())
{
$this->settings = $settings;
$layout = Zend_Layout::getMvcInstance();
$this->view = $layout->getView();
// Add module paths to view scripts
$this->view->addBasePath(ZfApplication::$_base_path . "/app/Flex/views", "Flex_View");
$this->view->addScriptPath($layout->getLayoutPath() . "default/templates/Flex/");
$this->view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/Flex/");
$this->init();
}
示例2: render
/**
* Render a hook's content
*
* @param string $name template to use
* @param string $module module to fetch template from
* @param string $controller controller to fetch template from, defaults to 'hooks'
*
* @return string Rendered content
*
*/
public function render($name, $module, $controller = "hooks")
{
$layout = Zend_Layout::getMvcInstance();
// Reset view script paths
$this->view->setScriptPath(null);
// Build new ones for hooks
$this->view->addBasePath(ZfApplication::$_base_path . "/app/{$module}/views", $module . "_View");
//$this->view->addScriptPath(ZfApplication::$_base_path."/app/$module/Views/");
$this->view->addScriptPath($layout->getLayoutPath() . "default/templates/{$module}");
$this->view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/{$module}");
return $this->view->render($controller . "/" . $name);
}
示例3: _setupView
/**
* Setup the view
*
* @param Zend_View_Abstract $view
* @param Zend_Config $config
*/
protected function _setupView(Zend_View_Abstract $view, Zend_Config $viewConfig)
{
// Add base, filter, helper and script paths
$keys = array('base', 'filter', 'helper', 'script');
foreach ($keys as $key) {
foreach ($viewConfig->get('path')->get($key) as $objKey => $obj) {
// Handle script paths
if ($key == 'script') {
$view->addScriptPath(trim($obj));
continue;
}
// Handle base, filter and helper paths
if ($obj instanceof Zend_Config || is_array($obj)) {
$path = $obj->get('path');
$prefix = $obj->get('prefix');
} else {
// Allow setting namespaces using keys
if (empty($obj)) {
$obj = $objKey;
}
$path = str_replace('_', '/', $obj);
$prefix = $obj;
}
$method = 'add' . ucfirst($key) . 'Path';
call_user_func_array(array($view, $method), array(trim($path), $prefix));
}
}
// Filters
$filters = $viewConfig->get('filter') instanceof Zend_Config ? $viewConfig->get('filter')->toArray() : array($viewConfig->get('filter'));
foreach ($filters as $filter) {
$view->addFilter($filter);
}
// Helpers
$helpers = $viewConfig->get('helper') instanceof Zend_Config ? $viewConfig->get('helper')->toArray() : array();
foreach ($helpers as $helper => $args) {
$helperName = $this->_underscoreToCamelCase($helper);
call_user_func_array(array($view, $helperName), $args);
}
// Set encoding
if ($encoding = $viewConfig->get('encoding')) {
$view->setEncoding($encoding);
}
// Set escape
if ($escape = $viewConfig->get('escape')) {
$view->setEscape($escape);
}
// Streams
if ($view instanceof Zym_View_Abstract) {
$this->_setupViewStreams($view, $viewConfig->get('stream'));
}
}
示例4: addScriptPath
/**
* Add a script path to the view.
*
* @internal Overrides Zend_View_Abstract to ensure that duplicate paths
* are not added to the stack. Fixes a bug where include'ing the same
* script twice causes fatal errors.
* @param string $path Local filesystem path.
*/
public function addScriptPath($path)
{
// For some unknown reason, Zend_View adds a trailing slash to paths.
// Need to add that for the purposes of comparison.
$path = rtrim($path, '/') . '/';
if (!in_array($path, $this->getScriptPaths())) {
return parent::addScriptPath($path);
}
}
示例5: addScriptPath
public function addScriptPath($path)
{
$this->_pathSet = false;
return parent::addScriptPath($path);
}
示例6: resetViewScripts
/**
* Reset the view's script paths and set new ones for use in the block
*
* @param Zend_View_Abstract $view
*/
private function resetViewScripts(Zend_View_Abstract $view)
{
$layout = Zend_Layout::getMvcInstance();
// Reset view script paths
$view->setScriptPath(null);
$module = ucfirst($this->module);
// Build new ones for blocks
$view->addBasePath(ZfApplication::$_base_path . "/app/{$module}/views", $module . "_View");
$view->addScriptPath(ZfApplication::$_base_path . "/app/{$module}/views/scripts/blocks");
$view->addScriptPath($layout->getLayoutPath() . "default/templates/blocks");
$view->addScriptPath($layout->getLayoutPath() . "default/templates/{$module}/blocks");
$view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/blocks");
$view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/{$module}/blocks");
}