From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Translate.php | 220 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 library/vendor/Zend/Translate.php (limited to 'library/vendor/Zend/Translate.php') diff --git a/library/vendor/Zend/Translate.php b/library/vendor/Zend/Translate.php new file mode 100644 index 0000000..de9f530 --- /dev/null +++ b/library/vendor/Zend/Translate.php @@ -0,0 +1,220 @@ +toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options = array(); + $options['adapter'] = array_shift($args); + if (!empty($args)) { + $options['content'] = array_shift($args); + } + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $opt = array_shift($args); + $options = array_merge($opt, $options); + } + } else if (!is_array($options)) { + $options = array('adapter' => $options); + } + + $this->setAdapter($options); + } + + /** + * Sets a new adapter + * + * @param array|Zend_Config|Zend_Translate_Adapter $options Options to use + * @param string|array [$content] Path to content, or content itself + * @param string|Zend_Locale [$locale] + * @throws Zend_Translate_Exception + */ + public function setAdapter($options = array()) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options = array(); + $options['adapter'] = array_shift($args); + if (!empty($args)) { + $options['content'] = array_shift($args); + } + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $opt = array_shift($args); + $options = array_merge($opt, $options); + } + } else if (!is_array($options)) { + $options = array('adapter' => $options); + } + + if (Zend_Loader::isReadable('Zend/Translate/Adapter/' . ucfirst($options['adapter']). '.php')) { + $options['adapter'] = 'Zend_Translate_Adapter_' . ucfirst($options['adapter']); + } + + if (!class_exists($options['adapter'])) { + Zend_Loader::loadClass($options['adapter']); + } + + if (array_key_exists('cache', $options)) { + Zend_Translate_Adapter::setCache($options['cache']); + } + + $adapter = $options['adapter']; + unset($options['adapter']); + $this->_adapter = new $adapter($options); + if (!$this->_adapter instanceof Zend_Translate_Adapter) { + throw new Zend_Translate_Exception("Adapter " . $adapter . " does not extend Zend_Translate_Adapter"); + } + } + + /** + * Returns the adapters name and it's options + * + * @return Zend_Translate_Adapter + */ + public function getAdapter() + { + return $this->_adapter; + } + + /** + * Returns the set cache + * + * @return Zend_Cache_Core The set cache + */ + public static function getCache() + { + return Zend_Translate_Adapter::getCache(); + } + + /** + * Sets a cache for all instances of Zend_Translate + * + * @param Zend_Cache_Core $cache Cache to store to + * @return void + */ + public static function setCache(Zend_Cache_Core $cache) + { + Zend_Translate_Adapter::setCache($cache); + } + + /** + * Returns true when a cache is set + * + * @return boolean + */ + public static function hasCache() + { + return Zend_Translate_Adapter::hasCache(); + } + + /** + * Removes any set cache + * + * @return void + */ + public static function removeCache() + { + Zend_Translate_Adapter::removeCache(); + } + + /** + * Clears all set cache data + * + * @param string $tag Tag to clear when the default tag name is not used + * @return void + */ + public static function clearCache($tag = null) + { + Zend_Translate_Adapter::clearCache($tag); + } + + /** + * Calls all methods from the adapter + */ + public function __call($method, array $options) + { + if (method_exists($this->_adapter, $method)) { + return call_user_func_array(array($this->_adapter, $method), $options); + } + throw new Zend_Translate_Exception("Unknown method '" . $method . "' called!"); + } +} -- cgit v1.2.3