/** * Retrieve or create registry instnace * * @return void */ public static function getRegistry() { if (IfwPsn_Vendor_Zend_Registry::isRegistered(self::REGISTRY_KEY)) { $registry = IfwPsn_Vendor_Zend_Registry::get(self::REGISTRY_KEY); } else { $registry = new self(); IfwPsn_Vendor_Zend_Registry::set(self::REGISTRY_KEY, $registry); } return $registry; }
/** * Constructor * * Map constants to doctype strings, and set default doctype * * @return void */ public function __construct() { if (!IfwPsn_Vendor_Zend_Registry::isRegistered($this->_regKey)) { $this->_registry = new ArrayObject(array('doctypes' => array(self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', self::XHTML1_FRAMESET => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', self::XHTML1_RDFA => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">', self::XHTML1_RDFA11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">', self::XHTML_BASIC1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">', self::XHTML5 => '<!DOCTYPE html>', self::HTML4_STRICT => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', self::HTML4_LOOSE => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', self::HTML4_FRAMESET => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', self::HTML5 => '<!DOCTYPE html>'))); IfwPsn_Vendor_Zend_Registry::set($this->_regKey, $this->_registry); $this->setDoctype($this->_defaultDoctype); } else { $this->_registry = IfwPsn_Vendor_Zend_Registry::get($this->_regKey); } }
/** * Retrieve locale object * * @return IfwPsn_Vendor_Zend_Locale */ public function getLocale() { if (null === $this->_locale) { $options = $this->getOptions(); if (!isset($options['default'])) { $this->_locale = new IfwPsn_Vendor_Zend_Locale(); } elseif (!isset($options['force']) || (bool) $options['force'] == false) { // Don't force any locale, just go for auto detection IfwPsn_Vendor_Zend_Locale::setDefault($options['default']); $this->_locale = new IfwPsn_Vendor_Zend_Locale(); } else { $this->_locale = new IfwPsn_Vendor_Zend_Locale($options['default']); } $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY; IfwPsn_Vendor_Zend_Registry::set($key, $this->_locale); } return $this->_locale; }
/** * Stores navigation container in the registry * * @return void */ protected function _storeRegistry() { $options = $this->getOptions(); if (isset($options['storage']['registry']['key']) && !is_numeric($options['storage']['registry']['key'])) { $key = $options['storage']['registry']['key']; } else { $key = self::DEFAULT_REGISTRY_KEY; } IfwPsn_Vendor_Zend_Registry::set($key, $this->getContainer()); }
/** * Retrieve translate object * * @return IfwPsn_Vendor_Zend_Translate * @throws IfwPsn_Vendor_Zend_Application_Resource_Exception if registry key was used * already but is no instance of IfwPsn_Vendor_Zend_Translate */ public function getTranslate() { if (null === $this->_translate) { $options = $this->getOptions(); if (!isset($options['content']) && !isset($options['data'])) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Application/Resource/Exception.php'; throw new IfwPsn_Vendor_Zend_Application_Resource_Exception('No translation source data provided.'); } else { if (array_key_exists('content', $options) && array_key_exists('data', $options)) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Application/Resource/Exception.php'; throw new IfwPsn_Vendor_Zend_Application_Resource_Exception('Conflict on translation source data: choose only one key between content and data.'); } } if (empty($options['adapter'])) { $options['adapter'] = IfwPsn_Vendor_Zend_Translate::AN_ARRAY; } if (!empty($options['data'])) { $options['content'] = $options['data']; unset($options['data']); } if (isset($options['log'])) { if (is_array($options['log'])) { $log = IfwPsn_Vendor_Zend_Log::factory($options['log']); } if ($log instanceof IfwPsn_Vendor_Zend_Log) { $options['log'] = $log; } } if (isset($options['options'])) { foreach ($options['options'] as $key => $value) { $options[$key] = $value; } } if (!empty($options['cache']) && is_string($options['cache'])) { $bootstrap = $this->getBootstrap(); if ($bootstrap instanceof IfwPsn_Vendor_Zend_Application_Bootstrap_ResourceBootstrapper && $bootstrap->hasPluginResource('CacheManager')) { $cacheManager = $bootstrap->bootstrap('CacheManager')->getResource('CacheManager'); if (null !== $cacheManager && $cacheManager->hasCache($options['cache'])) { $options['cache'] = $cacheManager->getCache($options['cache']); } } } $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY; unset($options['registry_key']); if (IfwPsn_Vendor_Zend_Registry::isRegistered($key)) { $translate = IfwPsn_Vendor_Zend_Registry::get($key); if (!$translate instanceof IfwPsn_Vendor_Zend_Translate) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Application/Resource/Exception.php'; throw new IfwPsn_Vendor_Zend_Application_Resource_Exception($key . ' already registered in registry but is ' . 'no instance of IfwPsn_Vendor_Zend_Translate'); } $translate->addTranslation($options); $this->_translate = $translate; } else { $this->_translate = new IfwPsn_Vendor_Zend_Translate($options); IfwPsn_Vendor_Zend_Registry::set($key, $this->_translate); } } return $this->_translate; }