import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
156
libs/Zend/Application/Resource/Db.php
Normal file
156
libs/Zend/Application/Resource/Db.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Db.php 15337 2009-05-05 17:33:06Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for creating database adapter
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* Adapter to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_adapter = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Db_Adapter_Interface
|
||||
*/
|
||||
protected $_db;
|
||||
|
||||
/**
|
||||
* Parameters to use
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_params = array();
|
||||
|
||||
/**
|
||||
* Wether to register the created adapter as default table adapter
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_isDefaultTableAdapter = true;
|
||||
|
||||
/**
|
||||
* Set the adapter
|
||||
*
|
||||
* @param $adapter string
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setAdapter($adapter)
|
||||
{
|
||||
$this->_adapter = $adapter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter type to use
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->_adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the adapter params
|
||||
*
|
||||
* @param $adapter string
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setParams(array $params)
|
||||
{
|
||||
$this->_params = $params;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to use this as default table adapter
|
||||
*
|
||||
* @param boolean $defaultTableAdapter
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setIsDefaultTableAdapter($isDefaultTableAdapter)
|
||||
{
|
||||
$this->_isDefaultTableAdapter = $isDefaultTableAdapter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this adapter the default table adapter?
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isDefaultTableAdapter()
|
||||
{
|
||||
return $this->_isDefaultTableAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve initialized DB connection
|
||||
*
|
||||
* @return null|Zend_Db_Adapter_Interface
|
||||
*/
|
||||
public function getDbAdapter()
|
||||
{
|
||||
if ((null === $this->_db)
|
||||
&& (null !== ($adapter = $this->getAdapter()))
|
||||
) {
|
||||
$this->_db = Zend_Db::factory($adapter, $this->getParams());
|
||||
}
|
||||
return $this->_db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Db_Adapter_Abstract|null
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (null !== ($db = $this->getDbAdapter())) {
|
||||
if ($this->isDefaultTableAdapter()) {
|
||||
Zend_Db_Table::setDefaultAdapter($db);
|
||||
}
|
||||
return $db;
|
||||
}
|
||||
}
|
||||
}
|
35
libs/Zend/Application/Resource/Exception.php
Normal file
35
libs/Zend/Application/Resource/Exception.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 14229 2009-03-05 20:00:10Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Application
|
||||
*
|
||||
* @uses Zend_Application_Exception
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Exception extends Zend_Application_Exception
|
||||
{
|
||||
}
|
132
libs/Zend/Application/Resource/Frontcontroller.php
Normal file
132
libs/Zend/Application/Resource/Frontcontroller.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Frontcontroller.php 15356 2009-05-06 12:50:18Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Front Controller resource
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Controller_Front
|
||||
*/
|
||||
protected $_front;
|
||||
|
||||
/**
|
||||
* Initialize Front Controller
|
||||
*
|
||||
* @return Zend_Controller_Front
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$front = $this->getFrontController();
|
||||
|
||||
foreach ($this->getOptions() as $key => $value) {
|
||||
switch (strtolower($key)) {
|
||||
case 'controllerdirectory':
|
||||
if (is_string($value)) {
|
||||
$front->setControllerDirectory($value);
|
||||
} elseif (is_array($value)) {
|
||||
foreach ($value as $module => $directory) {
|
||||
$front->addControllerDirectory($directory, $module);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'modulecontrollerdirectoryname':
|
||||
$front->setModuleControllerDirectoryName($value);
|
||||
break;
|
||||
|
||||
case 'moduledirectory':
|
||||
$front->addModuleDirectory($value);
|
||||
break;
|
||||
|
||||
case 'defaultcontrollername':
|
||||
$front->setDefaultControllerName($value);
|
||||
break;
|
||||
|
||||
case 'defaultaction':
|
||||
$front->setDefaultAction($value);
|
||||
break;
|
||||
|
||||
case 'defaultmodule':
|
||||
$front->setDefaultModule($value);
|
||||
break;
|
||||
|
||||
case 'baseurl':
|
||||
$front->setBaseUrl($value);
|
||||
break;
|
||||
|
||||
case 'params':
|
||||
$front->setParams($value);
|
||||
break;
|
||||
|
||||
case 'plugins':
|
||||
foreach ((array) $value as $pluginClass) {
|
||||
$plugin = new $pluginClass();
|
||||
$front->registerPlugin($plugin);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'throwexceptions':
|
||||
$front->throwExceptions((bool) $value);
|
||||
break;
|
||||
|
||||
case 'actionhelperpaths':
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $helperPrefix => $helperPath) {
|
||||
Zend_Controller_Action_HelperBroker::addPath($helperPath, $helperPrefix);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$front->setParam($key, $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== ($bootstrap = $this->getBootstrap())) {
|
||||
$this->getBootstrap()->frontController = $front;
|
||||
}
|
||||
|
||||
return $front;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve front controller instance
|
||||
*
|
||||
* @return Zend_Controller_Front
|
||||
*/
|
||||
public function getFrontController()
|
||||
{
|
||||
if (null === $this->_front) {
|
||||
$this->_front = Zend_Controller_Front::getInstance();
|
||||
}
|
||||
return $this->_front;
|
||||
}
|
||||
}
|
64
libs/Zend/Application/Resource/Layout.php
Normal file
64
libs/Zend/Application/Resource/Layout.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for settings layout options
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Layout
|
||||
extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Layout
|
||||
*/
|
||||
protected $_layout;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Layout
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->getBootstrap()->bootstrap('FrontController');
|
||||
return $this->getLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve layout object
|
||||
*
|
||||
* @return Zend_Layout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
if (null === $this->_layout) {
|
||||
$this->_layout = Zend_Layout::startMvc($this->getOptions());
|
||||
}
|
||||
return $this->_layout;
|
||||
}
|
||||
}
|
77
libs/Zend/Application/Resource/Locale.php
Normal file
77
libs/Zend/Application/Resource/Locale.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for initializing the locale
|
||||
*
|
||||
* @uses Zend_Application_Resource_Base
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Locale
|
||||
extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
const DEFAULT_REGISTRY_KEY = 'Zend_Locale';
|
||||
|
||||
/**
|
||||
* @var Zend_Locale
|
||||
*/
|
||||
protected $_locale;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Locale
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return $this->getLocale();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve locale object
|
||||
*
|
||||
* @return Zend_Locale
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
if (null === $this->_locale) {
|
||||
$options = $this->getOptions();
|
||||
if (!isset($options['default'])) {
|
||||
$this->_locale = new Zend_Locale();
|
||||
} else {
|
||||
Zend_Locale::setDefault($options['default']);
|
||||
$this->_locale = new Zend_Locale($options['default']);
|
||||
}
|
||||
|
||||
$key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
|
||||
? $options['registry_key']
|
||||
: self::DEFAULT_REGISTRY_KEY;
|
||||
Zend_Registry::set($key, $this->_locale);
|
||||
}
|
||||
return $this->_locale;
|
||||
}
|
||||
}
|
115
libs/Zend/Application/Resource/Modules.php
Normal file
115
libs/Zend/Application/Resource/Modules.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Modules.php 16156 2009-06-19 04:09:36Z norm2782 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module bootstrapping resource
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Modules extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var ArrayObject
|
||||
*/
|
||||
protected $_bootstraps;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
$this->_bootstraps = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize modules
|
||||
*
|
||||
* @return array
|
||||
* @throws Zend_Application_Resource_Exception When bootstrap class was not found
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$bootstrap = $this->getBootstrap();
|
||||
$bootstrap->bootstrap('FrontController');
|
||||
$front = $bootstrap->getResource('FrontController');
|
||||
|
||||
$modules = $front->getControllerDirectory();
|
||||
$default = $front->getDefaultModule();
|
||||
foreach (array_keys($modules) as $module) {
|
||||
if ($module === $default) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap';
|
||||
if (!class_exists($bootstrapClass, false)) {
|
||||
$bootstrapPath = $front->getModuleDirectory($module) . '/Bootstrap.php';
|
||||
if (file_exists($bootstrapPath)) {
|
||||
include_once $bootstrapPath;
|
||||
if (!class_exists($bootstrapClass, false)) {
|
||||
throw new Zend_Application_Resource_Exception('Bootstrap file found for module "' . $module . '" but bootstrap class "' . $bootstrapClass . '" not found');
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$moduleBootstrap = new $bootstrapClass($bootstrap);
|
||||
$moduleBootstrap->bootstrap();
|
||||
$this->_bootstraps[$module] = $moduleBootstrap;
|
||||
}
|
||||
|
||||
return $this->_bootstraps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bootstraps that have been run
|
||||
*
|
||||
* @return ArrayObject
|
||||
*/
|
||||
public function getExecutedBootstraps()
|
||||
{
|
||||
return $this->_bootstraps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a module name to the module class prefix
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function _formatModuleName($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(array('-', '.'), ' ', $name);
|
||||
$name = ucwords($name);
|
||||
$name = str_replace(' ', '', $name);
|
||||
return $name;
|
||||
}
|
||||
}
|
112
libs/Zend/Application/Resource/Navigation.php
Normal file
112
libs/Zend/Application/Resource/Navigation.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for setting navigation structure
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @author Dolf Schimmel
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Navigation
|
||||
extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
const DEFAULT_REGISTRY_KEY = 'Zend_Navigation';
|
||||
|
||||
/**
|
||||
* @var Zend_Navigation
|
||||
*/
|
||||
protected $_container;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Navigation
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->_container) {
|
||||
$options = $this->getOptions();
|
||||
$pages = isset($options['pages']) ? $options['pages'] : array();
|
||||
$this->_container = new Zend_Navigation($pages);
|
||||
}
|
||||
|
||||
$this->store();
|
||||
return $this->_container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores navigation container in registry or Navigation view helper
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
if (isset($options['storage']['registry']) &&
|
||||
$options['storage']['registry'] == true) {
|
||||
$this->_storeRegistry();
|
||||
} else {
|
||||
$this->_storeHelper();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores navigation container in the registry
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _storeRegistry()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$key = !is_numeric($options['storage']['registry']['key'])
|
||||
? $options['storage']['registry']['key']
|
||||
: self::DEFAULT_REGISTRY_KEY;
|
||||
Zend_Registry::set($key,$this->getContainer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores navigation container in the Navigation helper
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _storeHelper()
|
||||
{
|
||||
$this->getBootstrap()->bootstrap('view');
|
||||
$view = $this->getBootstrap()->getPluginResource('view')->getView();
|
||||
$view->getHelper('navigation')->navigation($this->getContainer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns navigation container
|
||||
*
|
||||
* @return Zend_Navigation
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->_container;
|
||||
}
|
||||
}
|
80
libs/Zend/Application/Resource/Resource.php
Normal file
80
libs/Zend/Application/Resource/Resource.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Resource.php 14881 2009-04-13 16:48:43Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for bootstrap resources
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Application_Resource_Resource
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Must take an optional single argument, $options.
|
||||
*
|
||||
* @param mixed $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = null);
|
||||
|
||||
/**
|
||||
* Set the bootstrap to which the resource is attached
|
||||
*
|
||||
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
|
||||
* @return Zend_Application_Resource_Resource
|
||||
*/
|
||||
public function setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap);
|
||||
|
||||
/**
|
||||
* Retrieve the bootstrap to which the resource is attached
|
||||
*
|
||||
* @return Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function getBootstrap();
|
||||
|
||||
/**
|
||||
* Set resource options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Application_Resource_Resource
|
||||
*/
|
||||
public function setOptions(array $options);
|
||||
|
||||
/**
|
||||
* Retrieve resource options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions();
|
||||
|
||||
/**
|
||||
* Strategy pattern: initialize resource
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function init();
|
||||
}
|
159
libs/Zend/Application/Resource/ResourceAbstract.php
Normal file
159
libs/Zend/Application/Resource/ResourceAbstract.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ResourceAbstract.php 15556 2009-05-12 14:45:23Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Application_Resource_Resource
|
||||
*/
|
||||
require_once 'Zend/Application/Resource/Resource.php';
|
||||
|
||||
/**
|
||||
* Abstract class for bootstrap resources
|
||||
*
|
||||
* @uses Zend_Application_Resource_Resource
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Application_Resource_Resource
|
||||
{
|
||||
/**
|
||||
* Parent bootstrap
|
||||
*
|
||||
* @var Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
protected $_bootstrap;
|
||||
|
||||
/**
|
||||
* Options for the resource
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_options = array();
|
||||
|
||||
/**
|
||||
* Option keys to skip when calling setOptions()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_skipOptions = array(
|
||||
'options',
|
||||
'config',
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a instance with options
|
||||
*
|
||||
* @param mixed $options
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
} else if ($options instanceof Zend_Config) {
|
||||
$this->setOptions($options->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options from array
|
||||
*
|
||||
* @param array $options Configuration for resource
|
||||
* @return Zend_Application_Resource_ResourceAbstract
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
if (in_array(strtolower($key), $this->_skipOptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = 'set' . strtolower($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
if ('bootstrap' == $key) {
|
||||
unset($options[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_options = $this->mergeOptions($this->_options, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve resource options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge options recursively
|
||||
*
|
||||
* @param array $array1
|
||||
* @param mixed $array2
|
||||
* @return array
|
||||
*/
|
||||
public function mergeOptions(array $array1, $array2 = null)
|
||||
{
|
||||
if (is_array($array2)) {
|
||||
foreach ($array2 as $key => $val) {
|
||||
if (is_array($array2[$key])) {
|
||||
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
|
||||
? $this->mergeOptions($array1[$key], $array2[$key])
|
||||
: $array2[$key];
|
||||
} else {
|
||||
$array1[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $array1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bootstrap to which the resource is attached
|
||||
*
|
||||
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
|
||||
* @return Zend_Application_Resource_Resource
|
||||
*/
|
||||
public function setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)
|
||||
{
|
||||
$this->_bootstrap = $bootstrap;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the bootstrap to which the resource is attached
|
||||
*
|
||||
* @return null|Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function getBootstrap()
|
||||
{
|
||||
return $this->_bootstrap;
|
||||
}
|
||||
}
|
74
libs/Zend/Application/Resource/Router.php
Normal file
74
libs/Zend/Application/Resource/Router.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for initializing the locale
|
||||
*
|
||||
* @uses Zend_Application_Resource_Base
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @author Dolf Schimmel
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Router
|
||||
extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Controller_Router_Rewrite
|
||||
*/
|
||||
protected $_router;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Controller_Router_Rewrite
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return $this->getRouter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve router object
|
||||
*
|
||||
* @return Zend_Controller_Router_Rewrite
|
||||
*/
|
||||
public function getRouter()
|
||||
{
|
||||
if (null === $this->_router) {
|
||||
$bootstrap = $this->getBootstrap();
|
||||
$bootstrap->bootstrap('FrontController');
|
||||
$front = $bootstrap->getContainer()->frontcontroller;
|
||||
|
||||
$options = $this->getOptions();
|
||||
if(!isset($options['routes'])) {
|
||||
$options['routes'] = array();
|
||||
}
|
||||
|
||||
$this->_router = $front->getRouter();
|
||||
$this->_router->addConfig(new Zend_Config($options['routes']));
|
||||
}
|
||||
return $this->_router;
|
||||
}
|
||||
}
|
93
libs/Zend/Application/Resource/Session.php
Normal file
93
libs/Zend/Application/Resource/Session.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Session.php 14957 2009-04-17 12:20:40Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for setting session options
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Session extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* Save handler to use
|
||||
*
|
||||
* @var Zend_Session_SaveHandler_Interface
|
||||
*/
|
||||
protected $_saveHandler = null;
|
||||
|
||||
/**
|
||||
* Set session save handler
|
||||
*
|
||||
* @param array|string|Zend_Session_SaveHandler_Interface $saveHandler
|
||||
* @return Zend_Application_Resource_Session
|
||||
* @throws Zend_Application_Resource_Exception When $saveHandler is no valid save handler
|
||||
*/
|
||||
public function setSaveHandler($saveHandler)
|
||||
{
|
||||
if (is_array($saveHandler)) {
|
||||
if (!array_key_exists('class', $saveHandler)) {
|
||||
throw new Zend_Application_Resource_Exception('Session save handler class not provided in options');
|
||||
}
|
||||
if (array_key_exists('options', $saveHandler)) {
|
||||
$options = $saveHandler['options'];
|
||||
}
|
||||
$saveHandler = $saveHandler['class'];
|
||||
$saveHandler = new $saveHandler($options);
|
||||
} elseif (is_string($saveHandler)) {
|
||||
$saveHandler = new $saveHandler();
|
||||
}
|
||||
|
||||
if (!$saveHandler instanceof Zend_Session_SaveHandler_Interface) {
|
||||
throw new Zend_Application_Resource_Exception('Invalid session save handler');
|
||||
}
|
||||
|
||||
$this->_saveHandler = $saveHandler;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$options = array_change_key_case($this->getOptions(), CASE_LOWER);
|
||||
if (isset($options['savehandler'])) {
|
||||
unset($options['savehandler']);
|
||||
}
|
||||
|
||||
if (count($options) > 0) {
|
||||
Zend_Session::setOptions($options);
|
||||
}
|
||||
|
||||
if ($this->_saveHandler !== null) {
|
||||
Zend_Session::setSaveHandler($this->_saveHandler);
|
||||
}
|
||||
}
|
||||
}
|
83
libs/Zend/Application/Resource/Translate.php
Normal file
83
libs/Zend/Application/Resource/Translate.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Translate.php 14974 2009-04-18 00:02:32Z norm2782 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for setting translation options
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Translate extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
const DEFAULT_REGISTRY_KEY = 'Zend_Translate';
|
||||
|
||||
/**
|
||||
* @var Zend_Translate
|
||||
*/
|
||||
protected $_translate;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Translate
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return $this->getTranslate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve translate object
|
||||
*
|
||||
* @return Zend_Translate
|
||||
*/
|
||||
public function getTranslate()
|
||||
{
|
||||
if (null === $this->_translate) {
|
||||
$options = $this->getOptions();
|
||||
|
||||
if (!isset($options['data'])) {
|
||||
throw new Zend_Application_Resource_Exception('No translation source data provided.');
|
||||
}
|
||||
|
||||
$adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
|
||||
$locale = isset($options['locale']) ? $options['locale'] : null;
|
||||
$translateOptions = isset($options['options']) ? $options['options'] : array();
|
||||
|
||||
$this->_translate = new Zend_Translate(
|
||||
$adapter, $options['data'], $locale, $translateOptions
|
||||
);
|
||||
|
||||
$key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
|
||||
? $options['registry_key']
|
||||
: self::DEFAULT_REGISTRY_KEY;
|
||||
|
||||
Zend_Registry::set($key, $this->_translate);
|
||||
}
|
||||
|
||||
return $this->_translate;
|
||||
}
|
||||
}
|
67
libs/Zend/Application/Resource/View.php
Normal file
67
libs/Zend/Application/Resource/View.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: View.php 15333 2009-05-05 13:43:53Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resource for settings view options
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_View_Interface
|
||||
*/
|
||||
protected $_view;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_View
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$view = $this->getView();
|
||||
|
||||
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
|
||||
$viewRenderer->setView($view);
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve view object
|
||||
*
|
||||
* @return Zend_View
|
||||
*/
|
||||
public function getView()
|
||||
{
|
||||
if (null === $this->_view) {
|
||||
$this->_view = new Zend_View($this->getOptions());
|
||||
}
|
||||
return $this->_view;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user