diff --git a/thirdparty/Zend/Loader.php b/thirdparty/Zend/Loader.php
new file mode 100644
index 000000000..9bc083aa6
--- /dev/null
+++ b/thirdparty/Zend/Loader.php
@@ -0,0 +1,329 @@
+ $dir) {
+ if ($dir == '.') {
+ $dirs[$key] = $dirPath;
+ } else {
+ $dir = rtrim($dir, '\\/');
+ $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
+ }
+ }
+ $file = basename($file);
+ self::loadFile($file, $dirs, true);
+ } else {
+ self::loadFile($file, null, true);
+ }
+
+ if (!class_exists($class, false) && !interface_exists($class, false)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file");
+ }
+ }
+
+ /**
+ * Loads a PHP file. This is a wrapper for PHP's include() function.
+ *
+ * $filename must be the complete filename, including any
+ * extension such as ".php". Note that a security check is performed that
+ * does not permit extended characters in the filename. This method is
+ * intended for loading Zend Framework files.
+ *
+ * If $dirs is a string or an array, it will search the directories
+ * in the order supplied, and attempt to load the first matching file.
+ *
+ * If the file was not found in the $dirs, or if no $dirs were specified,
+ * it will attempt to load it from PHP's include_path.
+ *
+ * If $once is TRUE, it will use include_once() instead of include().
+ *
+ * @param string $filename
+ * @param string|array $dirs - OPTIONAL either a path or array of paths
+ * to search.
+ * @param boolean $once
+ * @return boolean
+ * @throws Zend_Exception
+ */
+ public static function loadFile($filename, $dirs = null, $once = false)
+ {
+ self::_securityCheck($filename);
+
+ /**
+ * Search in provided directories, as well as include_path
+ */
+ $incPath = false;
+ if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
+ if (is_array($dirs)) {
+ $dirs = implode(PATH_SEPARATOR, $dirs);
+ }
+ $incPath = get_include_path();
+ set_include_path($dirs . PATH_SEPARATOR . $incPath);
+ }
+
+ /**
+ * Try finding for the plain filename in the include_path.
+ */
+ if ($once) {
+ include_once $filename;
+ } else {
+ include $filename;
+ }
+
+ /**
+ * If searching in directories, reset include_path
+ */
+ if ($incPath) {
+ set_include_path($incPath);
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns TRUE if the $filename is readable, or FALSE otherwise.
+ * This function uses the PHP include_path, where PHP's is_readable()
+ * does not.
+ *
+ * Note from ZF-2900:
+ * If you use custom error handler, please check whether return value
+ * from error_reporting() is zero or not.
+ * At mark of fopen() can not suppress warning if the handler is used.
+ *
+ * @param string $filename
+ * @return boolean
+ */
+ public static function isReadable($filename)
+ {
+ if (is_readable($filename)) {
+ // Return early if the filename is readable without needing the
+ // include_path
+ return true;
+ }
+
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
+ && preg_match('/^[a-z]:/i', $filename)
+ ) {
+ // If on windows, and path provided is clearly an absolute path,
+ // return false immediately
+ return false;
+ }
+
+ foreach (self::explodeIncludePath() as $path) {
+ if ($path == '.') {
+ if (is_readable($filename)) {
+ return true;
+ }
+ continue;
+ }
+ $file = $path . '/' . $filename;
+ if (is_readable($file)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Explode an include path into an array
+ *
+ * If no path provided, uses current include_path. Works around issues that
+ * occur when the path includes stream schemas.
+ *
+ * @param string|null $path
+ * @return array
+ */
+ public static function explodeIncludePath($path = null)
+ {
+ if (null === $path) {
+ $path = get_include_path();
+ }
+
+ if (PATH_SEPARATOR == ':') {
+ // On *nix systems, include_paths which include paths with a stream
+ // schema cannot be safely explode'd, so we have to be a bit more
+ // intelligent in the approach.
+ $paths = preg_split('#:(?!//)#', $path);
+ } else {
+ $paths = explode(PATH_SEPARATOR, $path);
+ }
+ return $paths;
+ }
+
+ /**
+ * spl_autoload() suitable implementation for supporting class autoloading.
+ *
+ * Attach to spl_autoload() using the following:
+ *
+ * spl_autoload_register(array('Zend_Loader', 'autoload'));
+ *
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class
+ * @return string|false Class name on success; false on failure
+ */
+ public static function autoload($class)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ try {
+ @self::loadClass($class);
+ return $class;
+ } catch (Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Register {@link autoload()} with spl_autoload()
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class (optional)
+ * @param boolean $enabled (optional)
+ * @return void
+ * @throws Zend_Exception if spl_autoload() is not found
+ * or if the specified class does not have an autoload() method.
+ */
+ public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ require_once 'Zend/Loader/Autoloader.php';
+ $autoloader = Zend_Loader_Autoloader::getInstance();
+ $autoloader->setFallbackAutoloader(true);
+
+ if ('Zend_Loader' != $class) {
+ self::loadClass($class);
+ $methods = get_class_methods($class);
+ if (!in_array('autoload', (array) $methods)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
+ }
+
+ $callback = array($class, 'autoload');
+
+ if ($enabled) {
+ $autoloader->pushAutoloader($callback);
+ } else {
+ $autoloader->removeAutoloader($callback);
+ }
+ }
+ }
+
+ /**
+ * Ensure that filename does not contain exploits
+ *
+ * @param string $filename
+ * @return void
+ * @throws Zend_Exception
+ */
+ protected static function _securityCheck($filename)
+ {
+ /**
+ * Security check
+ */
+ if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Security check: Illegal character in filename');
+ }
+ }
+
+ /**
+ * Attempt to include() the file.
+ *
+ * include() is not prefixed with the @ operator because if
+ * the file is loaded and contains a parse error, execution
+ * will halt silently and this is difficult to debug.
+ *
+ * Always set display_errors = Off on production servers!
+ *
+ * @param string $filespec
+ * @param boolean $once
+ * @return boolean
+ * @deprecated Since 1.5.0; use loadFile() instead
+ */
+ protected static function _includeFile($filespec, $once = false)
+ {
+ if ($once) {
+ return include_once $filespec;
+ } else {
+ return include $filespec ;
+ }
+ }
+}
diff --git a/thirdparty/Zend/Loader/Autoloader.php b/thirdparty/Zend/Loader/Autoloader.php
new file mode 100644
index 000000000..360987787
--- /dev/null
+++ b/thirdparty/Zend/Loader/Autoloader.php
@@ -0,0 +1,589 @@
+ true,
+ 'ZendX_' => true,
+ );
+
+ /**
+ * @var array Namespace-specific autoloaders
+ */
+ protected $_namespaceAutoloaders = array();
+
+ /**
+ * @var bool Whether or not to suppress file not found warnings
+ */
+ protected $_suppressNotFoundWarnings = false;
+
+ /**
+ * @var null|string
+ */
+ protected $_zfPath;
+
+ /**
+ * Retrieve singleton instance
+ *
+ * @return Zend_Loader_Autoloader
+ */
+ public static function getInstance()
+ {
+ if (null === self::$_instance) {
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * Reset the singleton instance
+ *
+ * @return void
+ */
+ public static function resetInstance()
+ {
+ self::$_instance = null;
+ }
+
+ /**
+ * Autoload a class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public static function autoload($class)
+ {
+ $self = self::getInstance();
+
+ foreach ($self->getClassAutoloaders($class) as $autoloader) {
+ if ($autoloader instanceof Zend_Loader_Autoloader_Interface) {
+ if ($autoloader->autoload($class)) {
+ return true;
+ }
+ } elseif (is_array($autoloader)) {
+ if (call_user_func($autoloader, $class)) {
+ return true;
+ }
+ } elseif (is_string($autoloader) || is_callable($autoloader)) {
+ if ($autoloader($class)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Set the default autoloader implementation
+ *
+ * @param string|array $callback PHP callback
+ * @return void
+ */
+ public function setDefaultAutoloader($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new Zend_Loader_Exception('Invalid callback specified for default autoloader');
+ }
+
+ $this->_defaultAutoloader = $callback;
+ return $this;
+ }
+
+ /**
+ * Retrieve the default autoloader callback
+ *
+ * @return string|array PHP Callback
+ */
+ public function getDefaultAutoloader()
+ {
+ return $this->_defaultAutoloader;
+ }
+
+ /**
+ * Set several autoloader callbacks at once
+ *
+ * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders
+ * @return Zend_Loader_Autoloader
+ */
+ public function setAutoloaders(array $autoloaders)
+ {
+ $this->_autoloaders = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Get attached autoloader implementations
+ *
+ * @return array
+ */
+ public function getAutoloaders()
+ {
+ return $this->_autoloaders;
+ }
+
+ /**
+ * Return all autoloaders for a given namespace
+ *
+ * @param string $namespace
+ * @return array
+ */
+ public function getNamespaceAutoloaders($namespace)
+ {
+ $namespace = (string) $namespace;
+ if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
+ return array();
+ }
+ return $this->_namespaceAutoloaders[$namespace];
+ }
+
+ /**
+ * Register a namespace to autoload
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function registerNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (!isset($this->_namespaces[$ns])) {
+ $this->_namespaces[$ns] = true;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Unload a registered autoload namespace
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function unregisterNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (isset($this->_namespaces[$ns])) {
+ unset($this->_namespaces[$ns]);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get a list of registered autoload namespaces
+ *
+ * @return array
+ */
+ public function getRegisteredNamespaces()
+ {
+ return array_keys($this->_namespaces);
+ }
+
+ public function setZfPath($spec, $version = 'latest')
+ {
+ $path = $spec;
+ if (is_array($spec)) {
+ if (!isset($spec['path'])) {
+ throw new Zend_Loader_Exception('No path specified for ZF');
+ }
+ $path = $spec['path'];
+ if (isset($spec['version'])) {
+ $version = $spec['version'];
+ }
+ }
+
+ $this->_zfPath = $this->_getVersionPath($path, $version);
+ set_include_path(implode(PATH_SEPARATOR, array(
+ $this->_zfPath,
+ get_include_path(),
+ )));
+ return $this;
+ }
+
+ public function getZfPath()
+ {
+ return $this->_zfPath;
+ }
+
+ /**
+ * Get or set the value of the "suppress not found warnings" flag
+ *
+ * @param null|bool $flag
+ * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
+ */
+ public function suppressNotFoundWarnings($flag = null)
+ {
+ if (null === $flag) {
+ return $this->_suppressNotFoundWarnings;
+ }
+ $this->_suppressNotFoundWarnings = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Indicate whether or not this autoloader should be a fallback autoloader
+ *
+ * @param bool $flag
+ * @return Zend_Loader_Autoloader
+ */
+ public function setFallbackAutoloader($flag)
+ {
+ $this->_fallbackAutoloader = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Is this instance acting as a fallback autoloader?
+ *
+ * @return bool
+ */
+ public function isFallbackAutoloader()
+ {
+ return $this->_fallbackAutoloader;
+ }
+
+ /**
+ * Get autoloaders to use when matching class
+ *
+ * Determines if the class matches a registered namespace, and, if so,
+ * returns only the autoloaders for that namespace. Otherwise, it returns
+ * all non-namespaced autoloaders.
+ *
+ * @param string $class
+ * @return array Array of autoloaders to use
+ */
+ public function getClassAutoloaders($class)
+ {
+ $namespace = false;
+ $autoloaders = array();
+
+ // Add concrete namespaced autoloaders
+ foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
+ if ('' == $ns) {
+ continue;
+ }
+ if (0 === strpos($class, $ns)) {
+ if ((false === $namespace) || (strlen($ns) > strlen($namespace))) {
+ $namespace = $ns;
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ }
+ }
+ }
+
+ // Add internal namespaced autoloader
+ foreach ($this->getRegisteredNamespaces() as $ns) {
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders[] = $this->_internalAutoloader;
+ break;
+ }
+ }
+
+ // Add non-namespaced autoloaders
+ $autoloadersNonNamespace = $this->getNamespaceAutoloaders('');
+ if (count($autoloadersNonNamespace)) {
+ foreach ($autoloadersNonNamespace as $ns) {
+ $autoloaders[] = $ns;
+ }
+ unset($autoloadersNonNamespace);
+ }
+
+ // Add fallback autoloader
+ if (!$namespace && $this->isFallbackAutoloader()) {
+ $autoloaders[] = $this->_internalAutoloader;
+ }
+
+ return $autoloaders;
+ }
+
+ /**
+ * Add an autoloader to the beginning of the stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function unshiftAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_unshift($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_unshift($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append an autoloader to the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function pushAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_push($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_push($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Remove an autoloader from the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader
+ * @return Zend_Loader_Autoloader
+ */
+ public function removeAutoloader($callback, $namespace = null)
+ {
+ if (null === $namespace) {
+ $autoloaders = $this->getAutoloaders();
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->setAutoloaders($autoloaders);
+ }
+
+ foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) {
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ } else {
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Constructor
+ *
+ * Registers instance with spl_autoload stack
+ *
+ * @return void
+ */
+ protected function __construct()
+ {
+ spl_autoload_register(array(__CLASS__, 'autoload'));
+ $this->_internalAutoloader = array($this, '_autoload');
+ }
+
+ /**
+ * Internal autoloader implementation
+ *
+ * @param string $class
+ * @return bool
+ */
+ protected function _autoload($class)
+ {
+ $callback = $this->getDefaultAutoloader();
+ try {
+ if ($this->suppressNotFoundWarnings()) {
+ @call_user_func($callback, $class);
+ } else {
+ call_user_func($callback, $class);
+ }
+ return $class;
+ } catch (Zend_Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Set autoloaders for a specific namespace
+ *
+ * @param array $autoloaders
+ * @param string $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '')
+ {
+ $namespace = (string) $namespace;
+ $this->_namespaceAutoloaders[$namespace] = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Retrieve the filesystem path for the requested ZF version
+ *
+ * @param string $path
+ * @param string $version
+ * @return void
+ */
+ protected function _getVersionPath($path, $version)
+ {
+ $type = $this->_getVersionType($version);
+
+ if ($type == 'latest') {
+ $version = 'latest';
+ }
+
+ $availableVersions = $this->_getAvailableVersions($path, $version);
+ if (empty($availableVersions)) {
+ throw new Zend_Loader_Exception('No valid ZF installations discovered');
+ }
+
+ $matchedVersion = array_pop($availableVersions);
+ return $matchedVersion;
+ }
+
+ /**
+ * Retrieve the ZF version type
+ *
+ * @param string $version
+ * @return string "latest", "major", "minor", or "specific"
+ * @throws Zend_Loader_Exception if version string contains too many dots
+ */
+ protected function _getVersionType($version)
+ {
+ if (strtolower($version) == 'latest') {
+ return 'latest';
+ }
+
+ $parts = explode('.', $version);
+ $count = count($parts);
+ if (1 == $count) {
+ return 'major';
+ }
+ if (2 == $count) {
+ return 'minor';
+ }
+ if (3 < $count) {
+ throw new Zend_Loader_Exception('Invalid version string provided');
+ }
+ return 'specific';
+ }
+
+ /**
+ * Get available versions for the version type requested
+ *
+ * @param string $path
+ * @param string $version
+ * @return array
+ */
+ protected function _getAvailableVersions($path, $version)
+ {
+ if (!is_dir($path)) {
+ throw new Zend_Loader_Exception('Invalid ZF path provided');
+ }
+
+ $path = rtrim($path, '/');
+ $path = rtrim($path, '\\');
+ $versionLen = strlen($version);
+ $versions = array();
+ $dirs = glob("$path/*", GLOB_ONLYDIR);
+ foreach ((array) $dirs as $dir) {
+ $dirName = substr($dir, strlen($path) + 1);
+ if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) {
+ continue;
+ }
+
+ $matchedVersion = $matches[1];
+
+ if (('latest' == $version)
+ || ((strlen($matchedVersion) >= $versionLen)
+ && (0 === strpos($matchedVersion, $version)))
+ ) {
+ $versions[$matchedVersion] = $dir . '/library';
+ }
+ }
+
+ uksort($versions, 'version_compare');
+ return $versions;
+ }
+}
diff --git a/thirdparty/Zend/Loader/Autoloader/Interface.php b/thirdparty/Zend/Loader/Autoloader/Interface.php
new file mode 100644
index 000000000..822983270
--- /dev/null
+++ b/thirdparty/Zend/Loader/Autoloader/Interface.php
@@ -0,0 +1,43 @@
+toArray();
+ }
+ if (!is_array($options)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Options must be passed to resource loader constructor');
+ }
+
+ $this->setOptions($options);
+
+ $namespace = $this->getNamespace();
+ if ((null === $namespace)
+ || (null === $this->getBasePath())
+ ) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Resource loader requires both a namespace and a base path for initialization');
+ }
+
+ if (!empty($namespace)) {
+ $namespace .= '_';
+ }
+ require_once 'Zend/Loader/Autoloader.php';
+ Zend_Loader_Autoloader::getInstance()->unshiftAutoloader($this, $namespace);
+ }
+
+ /**
+ * Overloading: methods
+ *
+ * Allow retrieving concrete resource object instances using 'get()'
+ * syntax. Example:
+ *
+ * $loader = new Zend_Loader_Autoloader_Resource(array(
+ * 'namespace' => 'Stuff_',
+ * 'basePath' => '/path/to/some/stuff',
+ * ))
+ * $loader->addResourceType('Model', 'models', 'Model');
+ *
+ * $foo = $loader->getModel('Foo'); // get instance of Stuff_Model_Foo class
+ *
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ * @throws Zend_Loader_Exception if method not beginning with 'get' or not matching a valid resource type is called
+ */
+ public function __call($method, $args)
+ {
+ if ('get' == substr($method, 0, 3)) {
+ $type = strtolower(substr($method, 3));
+ if (!$this->hasResourceType($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Invalid resource type $type; cannot load resource");
+ }
+ if (empty($args)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Cannot load resources; no resource specified");
+ }
+ $resource = array_shift($args);
+ return $this->load($resource, $type);
+ }
+
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Method '$method' is not supported");
+ }
+
+ /**
+ * Helper method to calculate the correct class path
+ *
+ * @param string $class
+ * @return False if not matched other wise the correct path
+ */
+ public function getClassPath($class)
+ {
+ $segments = explode('_', $class);
+ $namespaceTopLevel = $this->getNamespace();
+ $namespace = '';
+
+ if (!empty($namespaceTopLevel)) {
+ $namespace = array();
+ $topLevelSegments = count(explode('_', $namespaceTopLevel));
+ for ($i = 0; $i < $topLevelSegments; $i++) {
+ $namespace[] = array_shift($segments);
+ }
+ $namespace = implode('_', $namespace);
+ if ($namespace != $namespaceTopLevel) {
+ // wrong prefix? we're done
+ return false;
+ }
+ }
+
+ if (count($segments) < 2) {
+ // assumes all resources have a component and class name, minimum
+ return false;
+ }
+
+ $final = array_pop($segments);
+ $component = $namespace;
+ $lastMatch = false;
+ do {
+ $segment = array_shift($segments);
+ $component .= empty($component) ? $segment : '_' . $segment;
+ if (isset($this->_components[$component])) {
+ $lastMatch = $component;
+ }
+ } while (count($segments));
+
+ if (!$lastMatch) {
+ return false;
+ }
+
+ $final = substr($class, strlen($lastMatch) + 1);
+ $path = $this->_components[$lastMatch];
+ $classPath = $path . '/' . str_replace('_', '/', $final) . '.php';
+
+ if (Zend_Loader::isReadable($classPath)) {
+ return $classPath;
+ }
+
+ return false;
+ }
+
+ /**
+ * Attempt to autoload a class
+ *
+ * @param string $class
+ * @return mixed False if not matched, otherwise result if include operation
+ */
+ public function autoload($class)
+ {
+ $classPath = $this->getClassPath($class);
+ if (false !== $classPath) {
+ return include $classPath;
+ }
+ return false;
+ }
+
+ /**
+ * Set class state from options
+ *
+ * @param array $options
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setOptions(array $options)
+ {
+ // Set namespace first, see ZF-10836
+ if (isset($options['namespace'])) {
+ $this->setNamespace($options['namespace']);
+ unset($options['namespace']);
+ }
+
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Set namespace that this autoloader handles
+ *
+ * @param string $namespace
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setNamespace($namespace)
+ {
+ $this->_namespace = rtrim((string) $namespace, '_');
+ return $this;
+ }
+
+ /**
+ * Get namespace this autoloader handles
+ *
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->_namespace;
+ }
+
+ /**
+ * Set base path for this set of resources
+ *
+ * @param string $path
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setBasePath($path)
+ {
+ $this->_basePath = (string) $path;
+ return $this;
+ }
+
+ /**
+ * Get base path to this set of resources
+ *
+ * @return string
+ */
+ public function getBasePath()
+ {
+ return $this->_basePath;
+ }
+
+ /**
+ * Add resource type
+ *
+ * @param string $type identifier for the resource type being loaded
+ * @param string $path path relative to resource base path containing the resource types
+ * @param null|string $namespace sub-component namespace to append to base namespace that qualifies this resource type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function addResourceType($type, $path, $namespace = null)
+ {
+ $type = strtolower($type);
+ if (!isset($this->_resourceTypes[$type])) {
+ if (null === $namespace) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace');
+ }
+ $namespaceTopLevel = $this->getNamespace();
+ $namespace = ucfirst(trim($namespace, '_'));
+ $this->_resourceTypes[$type] = array(
+ 'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace,
+ );
+ }
+ if (!is_string($path)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Invalid path specification provided; must be string');
+ }
+ $this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/');
+
+ $component = $this->_resourceTypes[$type]['namespace'];
+ $this->_components[$component] = $this->_resourceTypes[$type]['path'];
+ return $this;
+ }
+
+ /**
+ * Add multiple resources at once
+ *
+ * $types should be an associative array of resource type => specification
+ * pairs. Each specification should be an associative array containing
+ * minimally the 'path' key (specifying the path relative to the resource
+ * base path) and optionally the 'namespace' key (indicating the subcomponent
+ * namespace to append to the resource namespace).
+ *
+ * As an example:
+ *
+ * $loader->addResourceTypes(array(
+ * 'model' => array(
+ * 'path' => 'models',
+ * 'namespace' => 'Model',
+ * ),
+ * 'form' => array(
+ * 'path' => 'forms',
+ * 'namespace' => 'Form',
+ * ),
+ * ));
+ *
+ *
+ * @param array $types
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function addResourceTypes(array $types)
+ {
+ foreach ($types as $type => $spec) {
+ if (!is_array($spec)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays');
+ }
+ if (!isset($spec['path'])) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element');
+ }
+ $paths = $spec['path'];
+ $namespace = null;
+ if (isset($spec['namespace'])) {
+ $namespace = $spec['namespace'];
+ }
+ $this->addResourceType($type, $paths, $namespace);
+ }
+ return $this;
+ }
+
+ /**
+ * Overwrite existing and set multiple resource types at once
+ *
+ * @see Zend_Loader_Autoloader_Resource::addResourceTypes()
+ * @param array $types
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setResourceTypes(array $types)
+ {
+ $this->clearResourceTypes();
+ return $this->addResourceTypes($types);
+ }
+
+ /**
+ * Retrieve resource type mappings
+ *
+ * @return array
+ */
+ public function getResourceTypes()
+ {
+ return $this->_resourceTypes;
+ }
+
+ /**
+ * Is the requested resource type defined?
+ *
+ * @param string $type
+ * @return bool
+ */
+ public function hasResourceType($type)
+ {
+ return isset($this->_resourceTypes[$type]);
+ }
+
+ /**
+ * Remove the requested resource type
+ *
+ * @param string $type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function removeResourceType($type)
+ {
+ if ($this->hasResourceType($type)) {
+ $namespace = $this->_resourceTypes[$type]['namespace'];
+ unset($this->_components[$namespace]);
+ unset($this->_resourceTypes[$type]);
+ }
+ return $this;
+ }
+
+ /**
+ * Clear all resource types
+ *
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function clearResourceTypes()
+ {
+ $this->_resourceTypes = array();
+ $this->_components = array();
+ return $this;
+ }
+
+ /**
+ * Set default resource type to use when calling load()
+ *
+ * @param string $type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setDefaultResourceType($type)
+ {
+ if ($this->hasResourceType($type)) {
+ $this->_defaultResourceType = $type;
+ }
+ return $this;
+ }
+
+ /**
+ * Get default resource type to use when calling load()
+ *
+ * @return string|null
+ */
+ public function getDefaultResourceType()
+ {
+ return $this->_defaultResourceType;
+ }
+
+ /**
+ * Object registry and factory
+ *
+ * Loads the requested resource of type $type (or uses the default resource
+ * type if none provided). If the resource has been loaded previously,
+ * returns the previous instance; otherwise, instantiates it.
+ *
+ * @param string $resource
+ * @param string $type
+ * @return object
+ * @throws Zend_Loader_Exception if resource type not specified or invalid
+ */
+ public function load($resource, $type = null)
+ {
+ if (null === $type) {
+ $type = $this->getDefaultResourceType();
+ if (empty($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('No resource type specified');
+ }
+ }
+ if (!$this->hasResourceType($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Invalid resource type specified');
+ }
+ $namespace = $this->_resourceTypes[$type]['namespace'];
+ $class = $namespace . '_' . ucfirst($resource);
+ if (!isset($this->_resources[$class])) {
+ $this->_resources[$class] = new $class;
+ }
+ return $this->_resources[$class];
+ }
+}
diff --git a/thirdparty/Zend/Loader/Exception.php b/thirdparty/Zend/Loader/Exception.php
new file mode 100644
index 000000000..ee2ba686c
--- /dev/null
+++ b/thirdparty/Zend/Loader/Exception.php
@@ -0,0 +1,35 @@
+_useStaticRegistry = $staticRegistryName;
+ if(!isset(self::$_staticPrefixToPaths[$staticRegistryName])) {
+ self::$_staticPrefixToPaths[$staticRegistryName] = array();
+ }
+ if(!isset(self::$_staticLoadedPlugins[$staticRegistryName])) {
+ self::$_staticLoadedPlugins[$staticRegistryName] = array();
+ }
+ }
+
+ foreach ($prefixToPaths as $prefix => $path) {
+ $this->addPrefixPath($prefix, $path);
+ }
+ }
+
+ /**
+ * Format prefix for internal use
+ *
+ * @param string $prefix
+ * @return string
+ */
+ protected function _formatPrefix($prefix)
+ {
+ if($prefix == "") {
+ return $prefix;
+ }
+
+ $last = strlen($prefix) - 1;
+ if ($prefix{$last} == '\\') {
+ return $prefix;
+ }
+
+ return rtrim($prefix, '_') . '_';
+ }
+
+ /**
+ * Add prefixed paths to the registry of paths
+ *
+ * @param string $prefix
+ * @param string $path
+ * @return Zend_Loader_PluginLoader
+ */
+ public function addPrefixPath($prefix, $path)
+ {
+ if (!is_string($prefix) || !is_string($path)) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.');
+ }
+
+ $prefix = $this->_formatPrefix($prefix);
+ $path = rtrim($path, '/\\') . '/';
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix][] = $path;
+ } else {
+ if (!isset($this->_prefixToPaths[$prefix])) {
+ $this->_prefixToPaths[$prefix] = array();
+ }
+ if (!in_array($path, $this->_prefixToPaths[$prefix])) {
+ $this->_prefixToPaths[$prefix][] = $path;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get path stack
+ *
+ * @param string $prefix
+ * @return false|array False if prefix does not exist, array otherwise
+ */
+ public function getPaths($prefix = null)
+ {
+ if ((null !== $prefix) && is_string($prefix)) {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) {
+ return self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix];
+ }
+
+ return false;
+ }
+
+ if (isset($this->_prefixToPaths[$prefix])) {
+ return $this->_prefixToPaths[$prefix];
+ }
+
+ return false;
+ }
+
+ if ($this->_useStaticRegistry) {
+ return self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ }
+
+ return $this->_prefixToPaths;
+ }
+
+ /**
+ * Clear path stack
+ *
+ * @param string $prefix
+ * @return bool False only if $prefix does not exist
+ */
+ public function clearPaths($prefix = null)
+ {
+ if ((null !== $prefix) && is_string($prefix)) {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) {
+ unset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]);
+ return true;
+ }
+
+ return false;
+ }
+
+ if (isset($this->_prefixToPaths[$prefix])) {
+ unset($this->_prefixToPaths[$prefix]);
+ return true;
+ }
+
+ return false;
+ }
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticPrefixToPaths[$this->_useStaticRegistry] = array();
+ } else {
+ $this->_prefixToPaths = array();
+ }
+
+ return true;
+ }
+
+ /**
+ * Remove a prefix (or prefixed-path) from the registry
+ *
+ * @param string $prefix
+ * @param string $path OPTIONAL
+ * @return Zend_Loader_PluginLoader
+ */
+ public function removePrefixPath($prefix, $path = null)
+ {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ $registry =& self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ } else {
+ $registry =& $this->_prefixToPaths;
+ }
+
+ if (!isset($registry[$prefix])) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' was not found in the PluginLoader.');
+ }
+
+ if ($path != null) {
+ $pos = array_search($path, $registry[$prefix]);
+ if (false === $pos) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.');
+ }
+ unset($registry[$prefix][$pos]);
+ } else {
+ unset($registry[$prefix]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Normalize plugin name
+ *
+ * @param string $name
+ * @return string
+ */
+ protected function _formatName($name)
+ {
+ return ucfirst((string) $name);
+ }
+
+ /**
+ * Whether or not a Plugin by a specific name is loaded
+ *
+ * @param string $name
+ * @return Zend_Loader_PluginLoader
+ */
+ public function isLoaded($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry) {
+ return isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]);
+ }
+
+ return isset($this->_loadedPlugins[$name]);
+ }
+
+ /**
+ * Return full class name for a named plugin
+ *
+ * @param string $name
+ * @return string|false False if class not found, class name otherwise
+ */
+ public function getClassName($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry
+ && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name])
+ ) {
+ return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name];
+ } elseif (isset($this->_loadedPlugins[$name])) {
+ return $this->_loadedPlugins[$name];
+ }
+
+ return false;
+ }
+
+ /**
+ * Get path to plugin class
+ *
+ * @param mixed $name
+ * @return string|false False if not found
+ */
+ public function getClassPath($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry
+ && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name])
+ ) {
+ return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name];
+ } elseif (!empty($this->_loadedPluginPaths[$name])) {
+ return $this->_loadedPluginPaths[$name];
+ }
+
+ if ($this->isLoaded($name)) {
+ $class = $this->getClassName($name);
+ $r = new ReflectionClass($class);
+ $path = $r->getFileName();
+ if ($this->_useStaticRegistry) {
+ self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = $path;
+ } else {
+ $this->_loadedPluginPaths[$name] = $path;
+ }
+ return $path;
+ }
+
+ return false;
+ }
+
+ /**
+ * Load a plugin via the name provided
+ *
+ * @param string $name
+ * @param bool $throwExceptions Whether or not to throw exceptions if the
+ * class is not resolved
+ * @return string|false Class name of loaded class; false if $throwExceptions
+ * if false and no class found
+ * @throws Zend_Loader_Exception if class not found
+ */
+ public function load($name, $throwExceptions = true)
+ {
+ $name = $this->_formatName($name);
+ if ($this->isLoaded($name)) {
+ return $this->getClassName($name);
+ }
+
+ if ($this->_useStaticRegistry) {
+ $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ } else {
+ $registry = $this->_prefixToPaths;
+ }
+
+ $registry = array_reverse($registry, true);
+ $found = false;
+ $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
+ $incFile = self::getIncludeFileCache();
+ foreach ($registry as $prefix => $paths) {
+ $className = $prefix . $name;
+
+ if (class_exists($className, false)) {
+ $found = true;
+ break;
+ }
+
+ $paths = array_reverse($paths, true);
+
+ foreach ($paths as $path) {
+ $loadFile = $path . $classFile;
+ if (Zend_Loader::isReadable($loadFile)) {
+ include_once $loadFile;
+ if (class_exists($className, false)) {
+ if (null !== $incFile) {
+ self::_appendIncFile($loadFile);
+ }
+ $found = true;
+ break 2;
+ }
+ }
+ }
+ }
+
+ if (!$found) {
+ if (!$throwExceptions) {
+ return false;
+ }
+
+ $message = "Plugin by name '$name' was not found in the registry; used paths:";
+ foreach ($registry as $prefix => $paths) {
+ $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths);
+ }
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception($message);
+ }
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className;
+ } else {
+ $this->_loadedPlugins[$name] = $className;
+ }
+ return $className;
+ }
+
+ /**
+ * Set path to class file cache
+ *
+ * Specify a path to a file that will add include_once statements for each
+ * plugin class loaded. This is an opt-in feature for performance purposes.
+ *
+ * @param string $file
+ * @return void
+ * @throws Zend_Loader_PluginLoader_Exception if file is not writeable or path does not exist
+ */
+ public static function setIncludeFileCache($file)
+ {
+ if (null === $file) {
+ self::$_includeFileCache = null;
+ return;
+ }
+
+ if (!file_exists($file) && !file_exists(dirname($file))) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')');
+ }
+ if (file_exists($file) && !is_writable($file)) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')');
+ }
+ if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')');
+ }
+
+ self::$_includeFileCache = $file;
+ }
+
+ /**
+ * Retrieve class file cache path
+ *
+ * @return string|null
+ */
+ public static function getIncludeFileCache()
+ {
+ return self::$_includeFileCache;
+ }
+
+ /**
+ * Append an include_once statement to the class file cache
+ *
+ * @param string $incFile
+ * @return void
+ */
+ protected static function _appendIncFile($incFile)
+ {
+ if (!file_exists(self::$_includeFileCache)) {
+ $file = '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 $options Options to use
+ * @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) {
+ require_once 'Zend/Translate/Exception.php';
+ 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);
+ }
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Unknown method '" . $method . "' called!");
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter.php b/thirdparty/Zend/Translate/Adapter.php
new file mode 100644
index 000000000..f8a78f750
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter.php
@@ -0,0 +1,995 @@
+ when true, clears already loaded translations when adding new files
+ * 'content' => content to translate or file or directory with content
+ * 'disableNotices' => when true, omits notices from being displayed
+ * 'ignore' => a prefix for files and directories which are not being added
+ * 'locale' => the actual set locale to use
+ * 'log' => a instance of Zend_Log where logs are written to
+ * 'logMessage' => message to be logged
+ * 'logPriority' => priority which is used to write the log message
+ * 'logUntranslated' => when true, untranslated messages are not logged
+ * 'reload' => reloads the cache by reading the content again
+ * 'scan' => searches for translation files using the LOCALE constants
+ * 'tag' => tag to use for the cache
+ *
+ * @var array
+ */
+ protected $_options = array(
+ 'clear' => false,
+ 'content' => null,
+ 'disableNotices' => false,
+ 'ignore' => '.',
+ 'locale' => 'auto',
+ 'log' => null,
+ 'logMessage' => "Untranslated message within '%locale%': %message%",
+ 'logPriority' => 5,
+ 'logUntranslated' => false,
+ 'reload' => false,
+ 'route' => null,
+ 'scan' => null,
+ 'tag' => 'Zend_Translate'
+ );
+
+ /**
+ * Translation table
+ * @var array
+ */
+ protected $_translate = array();
+
+ /**
+ * Generates the adapter
+ *
+ * @param array|Zend_Config $options Translation options for this adapter
+ * @throws Zend_Translate_Exception
+ * @return void
+ */
+ public function __construct($options = array())
+ {
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ } else if (func_num_args() > 1) {
+ $args = func_get_args();
+ $options = array();
+ $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('content' => $options);
+ }
+
+ if (array_key_exists('cache', $options)) {
+ self::setCache($options['cache']);
+ unset($options['cache']);
+ }
+
+ if (isset(self::$_cache)) {
+ $id = 'Zend_Translate_' . $this->toString() . '_Options';
+ $result = self::$_cache->load($id);
+ if ($result) {
+ $this->_options = $result;
+ }
+ }
+
+ if (empty($options['locale']) || ($options['locale'] === "auto")) {
+ $this->_automatic = true;
+ } else {
+ $this->_automatic = false;
+ }
+
+ $locale = null;
+ if (!empty($options['locale'])) {
+ $locale = $options['locale'];
+ unset($options['locale']);
+ }
+
+ $this->setOptions($options);
+ $options['locale'] = $locale;
+
+ if (!empty($options['content'])) {
+ $this->addTranslation($options);
+ }
+
+ if ($this->getLocale() !== (string) $options['locale']) {
+ $this->setLocale($options['locale']);
+ }
+ }
+
+ /**
+ * Add translations
+ *
+ * This may be a new language or additional content for an existing language
+ * If the key 'clear' is true, then translations for the specified
+ * language will be replaced and added otherwise
+ *
+ * @param array|Zend_Config $options Options and translations to be added
+ * @throws Zend_Translate_Exception
+ * @return Zend_Translate_Adapter Provides fluent interface
+ */
+ public function addTranslation($options = array())
+ {
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ } else if (func_num_args() > 1) {
+ $args = func_get_args();
+ $options = array();
+ $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('content' => $options);
+ }
+
+ if (!isset($options['content']) || empty($options['content'])) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Required option 'content' is missing");
+ }
+
+ $originate = null;
+ if (!empty($options['locale'])) {
+ $originate = (string) $options['locale'];
+ }
+
+ if ((array_key_exists('log', $options)) && !($options['log'] instanceof Zend_Log)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log');
+ }
+
+ try {
+ if (!($options['content'] instanceof Zend_Translate) && !($options['content'] instanceof Zend_Translate_Adapter)) {
+ if (empty($options['locale'])) {
+ $options['locale'] = null;
+ }
+
+ $options['locale'] = Zend_Locale::findLocale($options['locale']);
+ }
+ } catch (Zend_Locale_Exception $e) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e);
+ }
+
+ $options = $options + $this->_options;
+ if (is_string($options['content']) and is_dir($options['content'])) {
+ $options['content'] = realpath($options['content']);
+ $prev = '';
+ $iterator = new RecursiveIteratorIterator(
+ new RecursiveRegexIterator(
+ new RecursiveDirectoryIterator($options['content'], RecursiveDirectoryIterator::KEY_AS_PATHNAME),
+ '/^(?!.*(\.svn|\.cvs)).*$/', RecursiveRegexIterator::MATCH
+ ),
+ RecursiveIteratorIterator::SELF_FIRST
+ );
+
+ foreach ($iterator as $directory => $info) {
+ $file = $info->getFilename();
+ if (is_array($options['ignore'])) {
+ foreach ($options['ignore'] as $key => $ignore) {
+ if (strpos($key, 'regex') !== false) {
+ if (preg_match($ignore, $directory)) {
+ // ignore files matching the given regex from option 'ignore' and all files below
+ continue 2;
+ }
+ } else if (strpos($directory, DIRECTORY_SEPARATOR . $ignore) !== false) {
+ // ignore files matching first characters from option 'ignore' and all files below
+ continue 2;
+ }
+ }
+ } else {
+ if (strpos($directory, DIRECTORY_SEPARATOR . $options['ignore']) !== false) {
+ // ignore files matching first characters from option 'ignore' and all files below
+ continue;
+ }
+ }
+
+ if ($info->isDir()) {
+ // pathname as locale
+ if (($options['scan'] === self::LOCALE_DIRECTORY) and (Zend_Locale::isLocale($file, true, false))) {
+ $options['locale'] = $file;
+ $prev = (string) $options['locale'];
+ }
+ } else if ($info->isFile()) {
+ // filename as locale
+ if ($options['scan'] === self::LOCALE_FILENAME) {
+ $filename = explode('.', $file);
+ array_pop($filename);
+ $filename = implode('.', $filename);
+ if (Zend_Locale::isLocale((string) $filename, true, false)) {
+ $options['locale'] = (string) $filename;
+ } else {
+ $parts = explode('.', $file);
+ $parts2 = array();
+ foreach($parts as $token) {
+ $parts2 += explode('_', $token);
+ }
+ $parts = array_merge($parts, $parts2);
+ $parts2 = array();
+ foreach($parts as $token) {
+ $parts2 += explode('-', $token);
+ }
+ $parts = array_merge($parts, $parts2);
+ $parts = array_unique($parts);
+ $prev = '';
+ foreach($parts as $token) {
+ if (Zend_Locale::isLocale($token, true, false)) {
+ if (strlen($prev) <= strlen($token)) {
+ $options['locale'] = $token;
+ $prev = $token;
+ }
+ }
+ }
+ }
+ }
+
+ try {
+ $options['content'] = $info->getPathname();
+ $this->_addTranslationData($options);
+ } catch (Zend_Translate_Exception $e) {
+ // ignore failed sources while scanning
+ }
+ }
+ }
+
+ unset($iterator);
+ } else {
+ $this->_addTranslationData($options);
+ }
+
+ if ((isset($this->_translate[$originate]) === true) and (count($this->_translate[$originate]) > 0)) {
+ $this->setLocale($originate);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Sets new adapter options
+ *
+ * @param array $options Adapter options
+ * @throws Zend_Translate_Exception
+ * @return Zend_Translate_Adapter Provides fluent interface
+ */
+ public function setOptions(array $options = array())
+ {
+ $change = false;
+ $locale = null;
+ foreach ($options as $key => $option) {
+ if ($key == 'locale') {
+ $locale = $option;
+ } else if ((isset($this->_options[$key]) and ($this->_options[$key] != $option)) or
+ !isset($this->_options[$key])) {
+ if (($key == 'log') && !($option instanceof Zend_Log)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log');
+ }
+
+ if ($key == 'cache') {
+ self::setCache($option);
+ continue;
+ }
+
+ $this->_options[$key] = $option;
+ $change = true;
+ }
+ }
+
+ if ($locale !== null) {
+ $this->setLocale($locale);
+ }
+
+ if (isset(self::$_cache) and ($change == true)) {
+ $id = 'Zend_Translate_' . $this->toString() . '_Options';
+ if (self::$_cacheTags) {
+ self::$_cache->save($this->_options, $id, array($this->_options['tag']));
+ } else {
+ self::$_cache->save($this->_options, $id);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the adapters name and it's options
+ *
+ * @param string|null $optionKey String returns this option
+ * null returns all options
+ * @return integer|string|array|null
+ */
+ public function getOptions($optionKey = null)
+ {
+ if ($optionKey === null) {
+ return $this->_options;
+ }
+
+ if (isset($this->_options[$optionKey]) === true) {
+ return $this->_options[$optionKey];
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets locale
+ *
+ * @return Zend_Locale|string|null
+ */
+ public function getLocale()
+ {
+ return $this->_options['locale'];
+ }
+
+ /**
+ * Sets locale
+ *
+ * @param string|Zend_Locale $locale Locale to set
+ * @throws Zend_Translate_Exception
+ * @return Zend_Translate_Adapter Provides fluent interface
+ */
+ public function setLocale($locale)
+ {
+ if (($locale === "auto") or ($locale === null)) {
+ $this->_automatic = true;
+ } else {
+ $this->_automatic = false;
+ }
+
+ try {
+ $locale = Zend_Locale::findLocale($locale);
+ } catch (Zend_Locale_Exception $e) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist", 0, $e);
+ }
+
+ if (!isset($this->_translate[$locale])) {
+ $temp = explode('_', $locale);
+ if (!isset($this->_translate[$temp[0]]) and !isset($this->_translate[$locale])) {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->log("The language '{$locale}' has to be added before it can be used.", $this->_options['logPriority']);
+ } else {
+ trigger_error("The language '{$locale}' has to be added before it can be used.", E_USER_NOTICE);
+ }
+ }
+ }
+
+ $locale = $temp[0];
+ }
+
+ if (empty($this->_translate[$locale])) {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->log("No translation for the language '{$locale}' available.", $this->_options['logPriority']);
+ } else {
+ trigger_error("No translation for the language '{$locale}' available.", E_USER_NOTICE);
+ }
+ }
+ }
+
+ if ($this->_options['locale'] != $locale) {
+ $this->_options['locale'] = $locale;
+
+ if (isset(self::$_cache)) {
+ $id = 'Zend_Translate_' . $this->toString() . '_Options';
+ if (self::$_cacheTags) {
+ self::$_cache->save($this->_options, $id, array($this->_options['tag']));
+ } else {
+ self::$_cache->save($this->_options, $id);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the available languages from this adapter
+ *
+ * @return array|null
+ */
+ public function getList()
+ {
+ $list = array_keys($this->_translate);
+ $result = null;
+ foreach($list as $value) {
+ if (!empty($this->_translate[$value])) {
+ $result[$value] = $value;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Returns the message id for a given translation
+ * If no locale is given, the actual language will be used
+ *
+ * @param string $message Message to get the key for
+ * @param string|Zend_Locale $locale (optional) Language to return the message ids from
+ * @return string|array|false
+ */
+ public function getMessageId($message, $locale = null)
+ {
+ if (empty($locale) or !$this->isAvailable($locale)) {
+ $locale = $this->_options['locale'];
+ }
+
+ return array_search($message, $this->_translate[(string) $locale]);
+ }
+
+ /**
+ * Returns all available message ids from this adapter
+ * If no locale is given, the actual language will be used
+ *
+ * @param string|Zend_Locale $locale (optional) Language to return the message ids from
+ * @return array
+ */
+ public function getMessageIds($locale = null)
+ {
+ if (empty($locale) or !$this->isAvailable($locale)) {
+ $locale = $this->_options['locale'];
+ }
+
+ return array_keys($this->_translate[(string) $locale]);
+ }
+
+ /**
+ * Returns all available translations from this adapter
+ * If no locale is given, the actual language will be used
+ * If 'all' is given the complete translation dictionary will be returned
+ *
+ * @param string|Zend_Locale $locale (optional) Language to return the messages from
+ * @return array
+ */
+ public function getMessages($locale = null)
+ {
+ if ($locale === 'all') {
+ return $this->_translate;
+ }
+
+ if ((empty($locale) === true) or ($this->isAvailable($locale) === false)) {
+ $locale = $this->_options['locale'];
+ }
+
+ return $this->_translate[(string) $locale];
+ }
+
+ /**
+ * Is the wished language available ?
+ *
+ * @see Zend_Locale
+ * @param string|Zend_Locale $locale Language to search for, identical with locale identifier,
+ * @see Zend_Locale for more information
+ * @return boolean
+ */
+ public function isAvailable($locale)
+ {
+ $return = isset($this->_translate[(string) $locale]);
+ return $return;
+ }
+
+ /**
+ * Load translation data
+ *
+ * @param mixed $data
+ * @param string|Zend_Locale $locale
+ * @param array $options (optional)
+ * @return array
+ */
+ abstract protected function _loadTranslationData($data, $locale, array $options = array());
+
+ /**
+ * Internal function for adding translation data
+ *
+ * This may be a new language or additional data for an existing language
+ * If the options 'clear' is true, then the translation data for the specified
+ * language is replaced and added otherwise
+ *
+ * @see Zend_Locale
+ * @param array|Zend_Config $content Translation data to add
+ * @throws Zend_Translate_Exception
+ * @return Zend_Translate_Adapter Provides fluent interface
+ */
+ private function _addTranslationData($options = array())
+ {
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ } else if (func_num_args() > 1) {
+ $args = func_get_args();
+ $options['content'] = array_shift($args);
+
+ if (!empty($args)) {
+ $options['locale'] = array_shift($args);
+ }
+
+ if (!empty($args)) {
+ $options += array_shift($args);
+ }
+ }
+
+ if (($options['content'] instanceof Zend_Translate) || ($options['content'] instanceof Zend_Translate_Adapter)) {
+ $options['usetranslateadapter'] = true;
+ if (!empty($options['locale']) && ($options['locale'] !== 'auto')) {
+ $options['content'] = $options['content']->getMessages($options['locale']);
+ } else {
+ $content = $options['content'];
+ $locales = $content->getList();
+ foreach ($locales as $locale) {
+ $options['locale'] = $locale;
+ $options['content'] = $content->getMessages($locale);
+ $this->_addTranslationData($options);
+ }
+
+ return $this;
+ }
+ }
+
+ try {
+ $options['locale'] = Zend_Locale::findLocale($options['locale']);
+ } catch (Zend_Locale_Exception $e) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e);
+ }
+
+ if ($options['clear'] || !isset($this->_translate[$options['locale']])) {
+ $this->_translate[$options['locale']] = array();
+ }
+
+ $read = true;
+ if (isset(self::$_cache)) {
+ $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString();
+ $temp = self::$_cache->load($id);
+ if ($temp) {
+ $read = false;
+ }
+ }
+
+ if ($options['reload']) {
+ $read = true;
+ }
+
+ if ($read) {
+ if (!empty($options['usetranslateadapter'])) {
+ $temp = array($options['locale'] => $options['content']);
+ } else {
+ $temp = $this->_loadTranslationData($options['content'], $options['locale'], $options);
+ }
+ }
+
+ if (empty($temp)) {
+ $temp = array();
+ }
+
+ $keys = array_keys($temp);
+ foreach($keys as $key) {
+ if (!isset($this->_translate[$key])) {
+ $this->_translate[$key] = array();
+ }
+
+ if (array_key_exists($key, $temp) && is_array($temp[$key])) {
+ $this->_translate[$key] = $temp[$key] + $this->_translate[$key];
+ }
+ }
+
+ if ($this->_automatic === true) {
+ $find = new Zend_Locale($options['locale']);
+ $browser = $find->getEnvironment() + $find->getBrowser();
+ arsort($browser);
+ foreach($browser as $language => $quality) {
+ if (isset($this->_translate[$language])) {
+ $this->_options['locale'] = $language;
+ break;
+ }
+ }
+ }
+
+ if (($read) and (isset(self::$_cache))) {
+ $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString();
+ if (self::$_cacheTags) {
+ self::$_cache->save($temp, $id, array($this->_options['tag']));
+ } else {
+ self::$_cache->save($temp, $id);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Translates the given string
+ * returns the translation
+ *
+ * @see Zend_Locale
+ * @param string|array $messageId Translation string, or Array for plural translations
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with
+ * locale identifier, @see Zend_Locale for more information
+ * @return string
+ */
+ public function translate($messageId, $locale = null)
+ {
+ if ($locale === null) {
+ $locale = $this->_options['locale'];
+ }
+
+ $plural = null;
+ if (is_array($messageId)) {
+ if (count($messageId) > 2) {
+ $number = array_pop($messageId);
+ if (!is_numeric($number)) {
+ $plocale = $number;
+ $number = array_pop($messageId);
+ } else {
+ $plocale = 'en';
+ }
+
+ $plural = $messageId;
+ $messageId = $messageId[0];
+ } else {
+ $messageId = $messageId[0];
+ }
+ }
+
+ if (!Zend_Locale::isLocale($locale, true, false)) {
+ if (!Zend_Locale::isLocale($locale, false, false)) {
+ // language does not exist, return original string
+ $this->_log($messageId, $locale);
+ // use rerouting when enabled
+ if (!empty($this->_options['route'])) {
+ if (array_key_exists($locale, $this->_options['route']) &&
+ !array_key_exists($locale, $this->_routed)) {
+ $this->_routed[$locale] = true;
+ return $this->translate($messageId, $this->_options['route'][$locale]);
+ }
+ }
+
+ $this->_routed = array();
+ if ($plural === null) {
+ return $messageId;
+ }
+
+ $rule = Zend_Translate_Plural::getPlural($number, $plocale);
+ if (!isset($plural[$rule])) {
+ $rule = 0;
+ }
+
+ return $plural[$rule];
+ }
+
+ $locale = new Zend_Locale($locale);
+ }
+
+ $locale = (string) $locale;
+ if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) {
+ // return original translation
+ if ($plural === null) {
+ $this->_routed = array();
+ return $this->_translate[$locale][$messageId];
+ }
+
+ $rule = Zend_Translate_Plural::getPlural($number, $locale);
+ if (isset($this->_translate[$locale][$plural[0]][$rule])) {
+ $this->_routed = array();
+ return $this->_translate[$locale][$plural[0]][$rule];
+ }
+ } else if (strlen($locale) != 2) {
+ // faster than creating a new locale and separate the leading part
+ $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
+
+ if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) {
+ // return regionless translation (en_US -> en)
+ if ($plural === null) {
+ $this->_routed = array();
+ return $this->_translate[$locale][$messageId];
+ }
+
+ $rule = Zend_Translate_Plural::getPlural($number, $locale);
+ if (isset($this->_translate[$locale][$plural[0]][$rule])) {
+ $this->_routed = array();
+ return $this->_translate[$locale][$plural[0]][$rule];
+ }
+ }
+ }
+
+ $this->_log($messageId, $locale);
+ // use rerouting when enabled
+ if (!empty($this->_options['route'])) {
+ if (array_key_exists($locale, $this->_options['route']) &&
+ !array_key_exists($locale, $this->_routed)) {
+ $this->_routed[$locale] = true;
+ return $this->translate($messageId, $this->_options['route'][$locale]);
+ }
+ }
+
+ $this->_routed = array();
+ if ($plural === null) {
+ return $messageId;
+ }
+
+ $rule = Zend_Translate_Plural::getPlural($number, $plocale);
+ if (!isset($plural[$rule])) {
+ $rule = 0;
+ }
+
+ return $plural[$rule];
+ }
+
+ /**
+ * Translates the given string using plural notations
+ * Returns the translated string
+ *
+ * @see Zend_Locale
+ * @param string $singular Singular translation string
+ * @param string $plural Plural translation string
+ * @param integer $number Number for detecting the correct plural
+ * @param string|Zend_Locale $locale (Optional) Locale/Language to use, identical with
+ * locale identifier, @see Zend_Locale for more information
+ * @return string
+ */
+ public function plural($singular, $plural, $number, $locale = null)
+ {
+ return $this->translate(array($singular, $plural, $number), $locale);
+ }
+
+ /**
+ * Logs a message when the log option is set
+ *
+ * @param string $message Message to log
+ * @param String $locale Locale to log
+ */
+ protected function _log($message, $locale) {
+ if ($this->_options['logUntranslated']) {
+ $message = str_replace('%message%', $message, $this->_options['logMessage']);
+ $message = str_replace('%locale%', $locale, $message);
+ if ($this->_options['log']) {
+ $this->_options['log']->log($message, $this->_options['logPriority']);
+ } else {
+ trigger_error($message, E_USER_NOTICE);
+ }
+ }
+ }
+
+ /**
+ * Translates the given string
+ * returns the translation
+ *
+ * @param string $messageId Translation string
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale
+ * identifier, @see Zend_Locale for more information
+ * @return string
+ */
+ public function _($messageId, $locale = null)
+ {
+ return $this->translate($messageId, $locale);
+ }
+
+ /**
+ * Checks if a string is translated within the source or not
+ * returns boolean
+ *
+ * @param string $messageId Translation string
+ * @param boolean $original (optional) Allow translation only for original language
+ * when true, a translation for 'en_US' would give false when it can
+ * be translated with 'en' only
+ * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale identifier,
+ * see Zend_Locale for more information
+ * @return boolean
+ */
+ public function isTranslated($messageId, $original = false, $locale = null)
+ {
+ if (($original !== false) and ($original !== true)) {
+ $locale = $original;
+ $original = false;
+ }
+
+ if ($locale === null) {
+ $locale = $this->_options['locale'];
+ }
+
+ if (!Zend_Locale::isLocale($locale, true, false)) {
+ if (!Zend_Locale::isLocale($locale, false, false)) {
+ // language does not exist, return original string
+ return false;
+ }
+
+ $locale = new Zend_Locale($locale);
+ }
+
+ $locale = (string) $locale;
+ if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) {
+ // return original translation
+ return true;
+ } else if ((strlen($locale) != 2) and ($original === false)) {
+ // faster than creating a new locale and separate the leading part
+ $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
+
+ if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) {
+ // return regionless translation (en_US -> en)
+ return true;
+ }
+ }
+
+ // No translation found, return original
+ return false;
+ }
+
+ /**
+ * Returns the set cache
+ *
+ * @return Zend_Cache_Core The set cache
+ */
+ public static function getCache()
+ {
+ return self::$_cache;
+ }
+
+ /**
+ * Sets a cache for all Zend_Translate_Adapters
+ *
+ * @param Zend_Cache_Core $cache Cache to store to
+ */
+ public static function setCache(Zend_Cache_Core $cache)
+ {
+ self::$_cache = $cache;
+ self::_getTagSupportForCache();
+ }
+
+ /**
+ * Returns true when a cache is set
+ *
+ * @return boolean
+ */
+ public static function hasCache()
+ {
+ if (self::$_cache !== null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Removes any set cache
+ *
+ * @return void
+ */
+ public static function removeCache()
+ {
+ self::$_cache = null;
+ }
+
+ /**
+ * 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)
+ {
+ require_once 'Zend/Cache.php';
+ if (self::$_cacheTags) {
+ if ($tag == null) {
+ $tag = 'Zend_Translate';
+ }
+
+ self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag));
+ } else {
+ self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
+ }
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ abstract public function toString();
+
+ /**
+ * Internal method to check if the given cache supports tags
+ *
+ * @param Zend_Cache $cache
+ */
+ private static function _getTagSupportForCache()
+ {
+ $backend = self::$_cache->getBackend();
+ if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) {
+ $cacheOptions = $backend->getCapabilities();
+ self::$_cacheTags = $cacheOptions['tags'];
+ } else {
+ self::$_cacheTags = false;
+ }
+
+ return self::$_cacheTags;
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/all-wcprops b/thirdparty/Zend/Translate/Adapter/.svn/all-wcprops
new file mode 100644
index 000000000..8384dc189
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/all-wcprops
@@ -0,0 +1,59 @@
+K 25
+svn:wc:ra_dav:version-url
+V 89
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter
+END
+Csv.php
+K 25
+svn:wc:ra_dav:version-url
+V 97
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Csv.php
+END
+Tbx.php
+K 25
+svn:wc:ra_dav:version-url
+V 97
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Tbx.php
+END
+Array.php
+K 25
+svn:wc:ra_dav:version-url
+V 99
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Array.php
+END
+Ini.php
+K 25
+svn:wc:ra_dav:version-url
+V 97
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Ini.php
+END
+XmlTm.php
+K 25
+svn:wc:ra_dav:version-url
+V 99
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/XmlTm.php
+END
+Gettext.php
+K 25
+svn:wc:ra_dav:version-url
+V 101
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Gettext.php
+END
+Qt.php
+K 25
+svn:wc:ra_dav:version-url
+V 96
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Qt.php
+END
+Tmx.php
+K 25
+svn:wc:ra_dav:version-url
+V 97
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Tmx.php
+END
+Xliff.php
+K 25
+svn:wc:ra_dav:version-url
+V 99
+/svn/framework/!svn/ver/24017/standard/tags/release-1.11.6/library/Zend/Translate/Adapter/Xliff.php
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/entries b/thirdparty/Zend/Translate/Adapter/.svn/entries
new file mode 100644
index 000000000..948d8bd1b
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+24565
+http://framework.zend.com/svn/framework/standard/tags/release-1.11.6/library/Zend/Translate/Adapter
+http://framework.zend.com/svn/framework
+
+
+
+2011-05-03T11:20:34.395271Z
+23961
+yoshida@zend.co.jp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+44c647ce-9c0f-0410-b52a-842ac1e357ba
+
+Csv.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+e6e10d574d4194de3bd5ebe44d679b1d
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3751
+
+Tbx.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+5164497ddd9ce01375c2e364307982b3
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5687
+
+Array.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+bcf5c47068340838c80661537b9bdcb3
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2406
+
+Ini.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+e3f24638b51ee16d66c7013a03e0522c
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2319
+
+XmlTm.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+62e7173fa4f5f2522cdbec31b7090996
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4606
+
+Gettext.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+eacc1aeb1b1b6819ecd272015da17c52
+2011-05-03T11:20:34.395271Z
+23961
+yoshida@zend.co.jp
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5797
+
+Qt.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+55621ed579b49d64805cf65fc89d0215
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5178
+
+Tmx.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+59205b8016e01fca89f7e5aeed2da993
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8452
+
+Xliff.php
+file
+
+
+
+
+2011-11-25T13:43:09.000000Z
+0eaebb1f6b88657d0bc98190079e8466
+2011-03-01T17:25:24.990528Z
+23775
+ralph
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8488
+
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Array.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Array.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Array.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Csv.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Csv.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Csv.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Gettext.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Gettext.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Gettext.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Ini.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Ini.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Ini.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Qt.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Qt.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Qt.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tbx.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tbx.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tbx.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tmx.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tmx.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Tmx.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Xliff.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Xliff.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/Xliff.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/prop-base/XmlTm.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/XmlTm.php.svn-base
new file mode 100644
index 000000000..92c8ad747
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/prop-base/XmlTm.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Array.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Array.php.svn-base
new file mode 100644
index 000000000..c6b680613
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Array.php.svn-base
@@ -0,0 +1,81 @@
+_data = array();
+ if (!is_array($data)) {
+ if (file_exists($data)) {
+ ob_start();
+ $data = include($data);
+ ob_end_clean();
+ }
+ }
+ if (!is_array($data)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Error including array or file '".$data."'");
+ }
+
+ if (!isset($this->_data[$locale])) {
+ $this->_data[$locale] = array();
+ }
+
+ $this->_data[$locale] = $data + $this->_data[$locale];
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Array";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Csv.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Csv.php.svn-base
new file mode 100644
index 000000000..a05e196a5
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Csv.php.svn-base
@@ -0,0 +1,121 @@
+_options['delimiter'] = ";";
+ $this->_options['length'] = 0;
+ $this->_options['enclosure'] = '"';
+
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ } else if (func_num_args() > 1) {
+ $args = func_get_args();
+ $options = array();
+ $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('content' => $options);
+ }
+
+ parent::__construct($options);
+ }
+
+ /**
+ * Load translation data
+ *
+ * @param string|array $filename Filename and full path to the translation source
+ * @param string $locale Locale/Language to add data for, identical with locale identifier,
+ * see Zend_Locale for more information
+ * @param array $option OPTIONAL Options to use
+ * @return array
+ */
+ protected function _loadTranslationData($filename, $locale, array $options = array())
+ {
+ $this->_data = array();
+ $options = $options + $this->_options;
+ $this->_file = @fopen($filename, 'rb');
+ if (!$this->_file) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
+ }
+
+ while(($data = fgetcsv($this->_file, $options['length'], $options['delimiter'], $options['enclosure'])) !== false) {
+ if (substr($data[0], 0, 1) === '#') {
+ continue;
+ }
+
+ if (!isset($data[1])) {
+ continue;
+ }
+
+ if (count($data) == 2) {
+ $this->_data[$locale][$data[0]] = $data[1];
+ } else {
+ $singular = array_shift($data);
+ $this->_data[$locale][$singular] = $data;
+ }
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Csv";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Gettext.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Gettext.php.svn-base
new file mode 100644
index 000000000..70045aac1
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Gettext.php.svn-base
@@ -0,0 +1,169 @@
+_bigEndian === false) {
+ return unpack('V' . $bytes, fread($this->_file, 4 * $bytes));
+ } else {
+ return unpack('N' . $bytes, fread($this->_file, 4 * $bytes));
+ }
+ }
+
+ /**
+ * Load translation data (MO file reader)
+ *
+ * @param string $filename MO file to add, full path must be given for access
+ * @param string $locale New Locale/Language to set, identical with locale identifier,
+ * see Zend_Locale for more information
+ * @param array $option OPTIONAL Options to use
+ * @throws Zend_Translation_Exception
+ * @return array
+ */
+ protected function _loadTranslationData($filename, $locale, array $options = array())
+ {
+ $this->_data = array();
+ $this->_bigEndian = false;
+ $this->_file = @fopen($filename, 'rb');
+ if (!$this->_file) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
+ }
+ if (@filesize($filename) < 10) {
+ @fclose($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
+ }
+
+ // get Endian
+ $input = $this->_readMOData(1);
+ if (strtolower(substr(dechex($input[1]), -8)) == "950412de") {
+ $this->_bigEndian = false;
+ } else if (strtolower(substr(dechex($input[1]), -8)) == "de120495") {
+ $this->_bigEndian = true;
+ } else {
+ @fclose($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
+ }
+ // read revision - not supported for now
+ $input = $this->_readMOData(1);
+
+ // number of bytes
+ $input = $this->_readMOData(1);
+ $total = $input[1];
+
+ // number of original strings
+ $input = $this->_readMOData(1);
+ $OOffset = $input[1];
+
+ // number of translation strings
+ $input = $this->_readMOData(1);
+ $TOffset = $input[1];
+
+ // fill the original table
+ fseek($this->_file, $OOffset);
+ $origtemp = $this->_readMOData(2 * $total);
+ fseek($this->_file, $TOffset);
+ $transtemp = $this->_readMOData(2 * $total);
+
+ for($count = 0; $count < $total; ++$count) {
+ if ($origtemp[$count * 2 + 1] != 0) {
+ fseek($this->_file, $origtemp[$count * 2 + 2]);
+ $original = @fread($this->_file, $origtemp[$count * 2 + 1]);
+ $original = explode("\0", $original);
+ } else {
+ $original[0] = '';
+ }
+
+ if ($transtemp[$count * 2 + 1] != 0) {
+ fseek($this->_file, $transtemp[$count * 2 + 2]);
+ $translate = fread($this->_file, $transtemp[$count * 2 + 1]);
+ $translate = explode("\0", $translate);
+ if ((count($original) > 1) && (count($translate) > 1)) {
+ $this->_data[$locale][$original[0]] = $translate;
+ array_shift($original);
+ foreach ($original as $orig) {
+ $this->_data[$locale][$orig] = '';
+ }
+ } else {
+ $this->_data[$locale][$original[0]] = $translate[0];
+ }
+ }
+ }
+
+ @fclose($this->_file);
+
+ $this->_data[$locale][''] = trim($this->_data[$locale]['']);
+ if (empty($this->_data[$locale][''])) {
+ $this->_adapterInfo[$filename] = 'No adapter information available';
+ } else {
+ $this->_adapterInfo[$filename] = $this->_data[$locale][''];
+ }
+
+ unset($this->_data[$locale]['']);
+ return $this->_data;
+ }
+
+ /**
+ * Returns the adapter informations
+ *
+ * @return array Each loaded adapter information as array value
+ */
+ public function getAdapterInfo()
+ {
+ return $this->_adapterInfo;
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Gettext";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Ini.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Ini.php.svn-base
new file mode 100644
index 000000000..e0c8b8f1a
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Ini.php.svn-base
@@ -0,0 +1,74 @@
+_data = array();
+ if (!file_exists($data)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Ini file '".$data."' not found");
+ }
+
+ $inidata = parse_ini_file($data, false);
+ if (!isset($this->_data[$locale])) {
+ $this->_data[$locale] = array();
+ }
+
+ $this->_data[$locale] = array_merge($this->_data[$locale], $inidata);
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Ini";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Qt.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Qt.php.svn-base
new file mode 100644
index 000000000..bf15dad2e
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Qt.php.svn-base
@@ -0,0 +1,160 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $this->_target = $locale;
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ switch(strtolower($name)) {
+ case 'message':
+ $this->_source = null;
+ $this->_stag = false;
+ $this->_ttag = false;
+ $this->_scontent = null;
+ $this->_tcontent = null;
+ break;
+ case 'source':
+ $this->_stag = true;
+ break;
+ case 'translation':
+ $this->_ttag = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ switch (strtolower($name)) {
+ case 'source':
+ $this->_stag = false;
+ break;
+
+ case 'translation':
+ if (!empty($this->_scontent) and !empty($this->_tcontent) or
+ (isset($this->_data[$this->_target][$this->_scontent]) === false)) {
+ $this->_data[$this->_target][$this->_scontent] = $this->_tcontent;
+ }
+ $this->_ttag = false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if ($this->_stag === true) {
+ $this->_scontent .= $data;
+ }
+
+ if ($this->_ttag === true) {
+ $this->_tcontent .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Qt";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tbx.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tbx.php.svn-base
new file mode 100644
index 000000000..905a3d6a6
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tbx.php.svn-base
@@ -0,0 +1,165 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ if ($this->_term !== null) {
+ $this->_content .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_content .= " $key=\"$value\"";
+ }
+ $this->_content .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'termentry':
+ $this->_termentry = null;
+ break;
+ case 'langset':
+ if (isset($attrib['xml:lang']) === true) {
+ $this->_langset = $attrib['xml:lang'];
+ if (isset($this->_data[$this->_langset]) === false) {
+ $this->_data[$this->_langset] = array();
+ }
+ }
+ break;
+ case 'term':
+ $this->_term = true;
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ if (($this->_term !== null) and ($name != "term")) {
+ $this->_content .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'langset':
+ $this->_langset = null;
+ break;
+ case 'term':
+ $this->_term = null;
+ if (empty($this->_termentry)) {
+ $this->_termentry = $this->_content;
+ }
+ if (!empty($this->_content) or (isset($this->_data[$this->_langset][$this->_termentry]) === false)) {
+ $this->_data[$this->_langset][$this->_termentry] = $this->_content;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if ($this->_term !== null) {
+ $this->_content .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Tbx";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tmx.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tmx.php.svn-base
new file mode 100644
index 000000000..bc106e40b
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Tmx.php.svn-base
@@ -0,0 +1,233 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ if (isset($options['useId'])) {
+ $this->_useId = (boolean) $options['useId'];
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * Internal method, called by xml element handler at start
+ *
+ * @param resource $file File handler
+ * @param string $name Elements name
+ * @param array $attrib Attributes for this element
+ */
+ protected function _startElement($file, $name, $attrib)
+ {
+ if ($this->_seg !== null) {
+ $this->_content .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_content .= " $key=\"$value\"";
+ }
+ $this->_content .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'header':
+ if (empty($this->_useId) && isset($attrib['srclang'])) {
+ if (Zend_Locale::isLocale($attrib['srclang'])) {
+ $this->_srclang = Zend_Locale::findLocale($attrib['srclang']);
+ } else {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->notice("The language '{$attrib['srclang']}' can not be set because it does not exist.");
+ } else {
+ trigger_error("The language '{$attrib['srclang']}' can not be set because it does not exist.", E_USER_NOTICE);
+ }
+ }
+
+ $this->_srclang = $attrib['srclang'];
+ }
+ }
+ break;
+ case 'tu':
+ if (isset($attrib['tuid'])) {
+ $this->_tu = $attrib['tuid'];
+ }
+ break;
+ case 'tuv':
+ if (isset($attrib['xml:lang'])) {
+ if (Zend_Locale::isLocale($attrib['xml:lang'])) {
+ $this->_tuv = Zend_Locale::findLocale($attrib['xml:lang']);
+ } else {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->notice("The language '{$attrib['xml:lang']}' can not be set because it does not exist.");
+ } else {
+ trigger_error("The language '{$attrib['xml:lang']}' can not be set because it does not exist.", E_USER_NOTICE);
+ }
+ }
+
+ $this->_tuv = $attrib['xml:lang'];
+ }
+
+ if (!isset($this->_data[$this->_tuv])) {
+ $this->_data[$this->_tuv] = array();
+ }
+ }
+ break;
+ case 'seg':
+ $this->_seg = true;
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * Internal method, called by xml element handler at end
+ *
+ * @param resource $file File handler
+ * @param string $name Elements name
+ */
+ protected function _endElement($file, $name)
+ {
+ if (($this->_seg !== null) and ($name !== 'seg')) {
+ $this->_content .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'tu':
+ $this->_tu = null;
+ break;
+ case 'tuv':
+ $this->_tuv = null;
+ break;
+ case 'seg':
+ $this->_seg = null;
+ if (!empty($this->_srclang) && ($this->_srclang == $this->_tuv)) {
+ $this->_tu = $this->_content;
+ }
+
+ if (!empty($this->_content) or (!isset($this->_data[$this->_tuv][$this->_tu]))) {
+ $this->_data[$this->_tuv][$this->_tu] = $this->_content;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * Internal method, called by xml element handler for content
+ *
+ * @param resource $file File handler
+ * @param string $data Elements content
+ */
+ protected function _contentElement($file, $data)
+ {
+ if (($this->_seg !== null) and ($this->_tu !== null) and ($this->_tuv !== null)) {
+ $this->_content .= $data;
+ }
+ }
+
+
+ /**
+ * Internal method, detects the encoding of the xml file
+ *
+ * @param string $name Filename
+ * @return string Encoding
+ */
+ protected function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Tmx";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/Xliff.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Xliff.php.svn-base
new file mode 100644
index 000000000..9a6a2ee32
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/Xliff.php.svn-base
@@ -0,0 +1,229 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ if (empty($options['useId'])) {
+ $this->_useId = false;
+ } else {
+ $this->_useId = true;
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_target = $locale;
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ if ($this->_stag === true) {
+ $this->_scontent .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_scontent .= " $key=\"$value\"";
+ }
+ $this->_scontent .= ">";
+ } else if ($this->_ttag === true) {
+ $this->_tcontent .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_tcontent .= " $key=\"$value\"";
+ }
+ $this->_tcontent .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'file':
+ $this->_source = $attrib['source-language'];
+ if (isset($attrib['target-language'])) {
+ $this->_target = $attrib['target-language'];
+ }
+
+ if (!isset($this->_data[$this->_source])) {
+ $this->_data[$this->_source] = array();
+ }
+
+ if (!isset($this->_data[$this->_target])) {
+ $this->_data[$this->_target] = array();
+ }
+
+ break;
+ case 'trans-unit':
+ $this->_transunit = true;
+ $this->_langId = $attrib['id'];
+ break;
+ case 'source':
+ if ($this->_transunit === true) {
+ $this->_scontent = null;
+ $this->_stag = true;
+ $this->_ttag = false;
+ }
+ break;
+ case 'target':
+ if ($this->_transunit === true) {
+ $this->_tcontent = null;
+ $this->_ttag = true;
+ $this->_stag = false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ if (($this->_stag === true) and ($name !== 'source')) {
+ $this->_scontent .= "".$name.">";
+ } else if (($this->_ttag === true) and ($name !== 'target')) {
+ $this->_tcontent .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'trans-unit':
+ $this->_transunit = null;
+ $this->_langId = null;
+ $this->_scontent = null;
+ $this->_tcontent = null;
+ break;
+ case 'source':
+ if ($this->_useId) {
+ if (!empty($this->_scontent) && !empty($this->_langId) &&
+ !isset($this->_data[$this->_source][$this->_langId])) {
+ $this->_data[$this->_source][$this->_langId] = $this->_scontent;
+ }
+ } else {
+ if (!empty($this->_scontent) &&
+ !isset($this->_data[$this->_source][$this->_scontent])) {
+ $this->_data[$this->_source][$this->_scontent] = $this->_scontent;
+ }
+ }
+ $this->_stag = false;
+ break;
+ case 'target':
+ if ($this->_useId) {
+ if (!empty($this->_tcontent) && !empty($this->_langId) &&
+ !isset($this->_data[$this->_target][$this->_langId])) {
+ $this->_data[$this->_target][$this->_langId] = $this->_tcontent;
+ }
+ } else {
+ if (!empty($this->_tcontent) && !empty($this->_scontent) &&
+ !isset($this->_data[$this->_target][$this->_scontent])) {
+ $this->_data[$this->_target][$this->_scontent] = $this->_tcontent;
+ }
+ }
+ $this->_ttag = false;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if (($this->_transunit !== null) and ($this->_source !== null) and ($this->_stag === true)) {
+ $this->_scontent .= $data;
+ }
+
+ if (($this->_transunit !== null) and ($this->_target !== null) and ($this->_ttag === true)) {
+ $this->_tcontent .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Xliff";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/.svn/text-base/XmlTm.php.svn-base b/thirdparty/Zend/Translate/Adapter/.svn/text-base/XmlTm.php.svn-base
new file mode 100644
index 000000000..4dfe075a9
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/.svn/text-base/XmlTm.php.svn-base
@@ -0,0 +1,139 @@
+_data = array();
+ $this->_lang = $locale;
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ switch(strtolower($name)) {
+ case 'tm:tu':
+ $this->_tag = $attrib['id'];
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ switch (strtolower($name)) {
+ case 'tm:tu':
+ if (!empty($this->_tag) and !empty($this->_content) or
+ (isset($this->_data[$this->_lang][$this->_tag]) === false)) {
+ $this->_data[$this->_lang][$this->_tag] = $this->_content;
+ }
+ $this->_tag = null;
+ $this->_content = null;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if (($this->_tag !== null)) {
+ $this->_content .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "XmlTm";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Array.php b/thirdparty/Zend/Translate/Adapter/Array.php
new file mode 100644
index 000000000..cbecbb934
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Array.php
@@ -0,0 +1,81 @@
+_data = array();
+ if (!is_array($data)) {
+ if (file_exists($data)) {
+ ob_start();
+ $data = include($data);
+ ob_end_clean();
+ }
+ }
+ if (!is_array($data)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Error including array or file '".$data."'");
+ }
+
+ if (!isset($this->_data[$locale])) {
+ $this->_data[$locale] = array();
+ }
+
+ $this->_data[$locale] = $data + $this->_data[$locale];
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Array";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Csv.php b/thirdparty/Zend/Translate/Adapter/Csv.php
new file mode 100644
index 000000000..f24437dd9
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Csv.php
@@ -0,0 +1,121 @@
+_options['delimiter'] = ";";
+ $this->_options['length'] = 0;
+ $this->_options['enclosure'] = '"';
+
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ } else if (func_num_args() > 1) {
+ $args = func_get_args();
+ $options = array();
+ $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('content' => $options);
+ }
+
+ parent::__construct($options);
+ }
+
+ /**
+ * Load translation data
+ *
+ * @param string|array $filename Filename and full path to the translation source
+ * @param string $locale Locale/Language to add data for, identical with locale identifier,
+ * see Zend_Locale for more information
+ * @param array $option OPTIONAL Options to use
+ * @return array
+ */
+ protected function _loadTranslationData($filename, $locale, array $options = array())
+ {
+ $this->_data = array();
+ $options = $options + $this->_options;
+ $this->_file = @fopen($filename, 'rb');
+ if (!$this->_file) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
+ }
+
+ while(($data = fgetcsv($this->_file, $options['length'], $options['delimiter'], $options['enclosure'])) !== false) {
+ if (substr($data[0], 0, 1) === '#') {
+ continue;
+ }
+
+ if (!isset($data[1])) {
+ continue;
+ }
+
+ if (count($data) == 2) {
+ $this->_data[$locale][$data[0]] = $data[1];
+ } else {
+ $singular = array_shift($data);
+ $this->_data[$locale][$singular] = $data;
+ }
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Csv";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Gettext.php b/thirdparty/Zend/Translate/Adapter/Gettext.php
new file mode 100644
index 000000000..de06c107a
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Gettext.php
@@ -0,0 +1,169 @@
+_bigEndian === false) {
+ return unpack('V' . $bytes, fread($this->_file, 4 * $bytes));
+ } else {
+ return unpack('N' . $bytes, fread($this->_file, 4 * $bytes));
+ }
+ }
+
+ /**
+ * Load translation data (MO file reader)
+ *
+ * @param string $filename MO file to add, full path must be given for access
+ * @param string $locale New Locale/Language to set, identical with locale identifier,
+ * see Zend_Locale for more information
+ * @param array $option OPTIONAL Options to use
+ * @throws Zend_Translation_Exception
+ * @return array
+ */
+ protected function _loadTranslationData($filename, $locale, array $options = array())
+ {
+ $this->_data = array();
+ $this->_bigEndian = false;
+ $this->_file = @fopen($filename, 'rb');
+ if (!$this->_file) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
+ }
+ if (@filesize($filename) < 10) {
+ @fclose($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
+ }
+
+ // get Endian
+ $input = $this->_readMOData(1);
+ if (strtolower(substr(dechex($input[1]), -8)) == "950412de") {
+ $this->_bigEndian = false;
+ } else if (strtolower(substr(dechex($input[1]), -8)) == "de120495") {
+ $this->_bigEndian = true;
+ } else {
+ @fclose($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
+ }
+ // read revision - not supported for now
+ $input = $this->_readMOData(1);
+
+ // number of bytes
+ $input = $this->_readMOData(1);
+ $total = $input[1];
+
+ // number of original strings
+ $input = $this->_readMOData(1);
+ $OOffset = $input[1];
+
+ // number of translation strings
+ $input = $this->_readMOData(1);
+ $TOffset = $input[1];
+
+ // fill the original table
+ fseek($this->_file, $OOffset);
+ $origtemp = $this->_readMOData(2 * $total);
+ fseek($this->_file, $TOffset);
+ $transtemp = $this->_readMOData(2 * $total);
+
+ for($count = 0; $count < $total; ++$count) {
+ if ($origtemp[$count * 2 + 1] != 0) {
+ fseek($this->_file, $origtemp[$count * 2 + 2]);
+ $original = @fread($this->_file, $origtemp[$count * 2 + 1]);
+ $original = explode("\0", $original);
+ } else {
+ $original[0] = '';
+ }
+
+ if ($transtemp[$count * 2 + 1] != 0) {
+ fseek($this->_file, $transtemp[$count * 2 + 2]);
+ $translate = fread($this->_file, $transtemp[$count * 2 + 1]);
+ $translate = explode("\0", $translate);
+ if ((count($original) > 1) && (count($translate) > 1)) {
+ $this->_data[$locale][$original[0]] = $translate;
+ array_shift($original);
+ foreach ($original as $orig) {
+ $this->_data[$locale][$orig] = '';
+ }
+ } else {
+ $this->_data[$locale][$original[0]] = $translate[0];
+ }
+ }
+ }
+
+ @fclose($this->_file);
+
+ $this->_data[$locale][''] = trim($this->_data[$locale]['']);
+ if (empty($this->_data[$locale][''])) {
+ $this->_adapterInfo[$filename] = 'No adapter information available';
+ } else {
+ $this->_adapterInfo[$filename] = $this->_data[$locale][''];
+ }
+
+ unset($this->_data[$locale]['']);
+ return $this->_data;
+ }
+
+ /**
+ * Returns the adapter informations
+ *
+ * @return array Each loaded adapter information as array value
+ */
+ public function getAdapterInfo()
+ {
+ return $this->_adapterInfo;
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Gettext";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Ini.php b/thirdparty/Zend/Translate/Adapter/Ini.php
new file mode 100644
index 000000000..4dfdb6492
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Ini.php
@@ -0,0 +1,74 @@
+_data = array();
+ if (!file_exists($data)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception("Ini file '".$data."' not found");
+ }
+
+ $inidata = parse_ini_file($data, false);
+ if (!isset($this->_data[$locale])) {
+ $this->_data[$locale] = array();
+ }
+
+ $this->_data[$locale] = array_merge($this->_data[$locale], $inidata);
+ return $this->_data;
+ }
+
+ /**
+ * returns the adapters name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Ini";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Qt.php b/thirdparty/Zend/Translate/Adapter/Qt.php
new file mode 100644
index 000000000..27ff71217
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Qt.php
@@ -0,0 +1,160 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $this->_target = $locale;
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ switch(strtolower($name)) {
+ case 'message':
+ $this->_source = null;
+ $this->_stag = false;
+ $this->_ttag = false;
+ $this->_scontent = null;
+ $this->_tcontent = null;
+ break;
+ case 'source':
+ $this->_stag = true;
+ break;
+ case 'translation':
+ $this->_ttag = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ switch (strtolower($name)) {
+ case 'source':
+ $this->_stag = false;
+ break;
+
+ case 'translation':
+ if (!empty($this->_scontent) and !empty($this->_tcontent) or
+ (isset($this->_data[$this->_target][$this->_scontent]) === false)) {
+ $this->_data[$this->_target][$this->_scontent] = $this->_tcontent;
+ }
+ $this->_ttag = false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if ($this->_stag === true) {
+ $this->_scontent .= $data;
+ }
+
+ if ($this->_ttag === true) {
+ $this->_tcontent .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Qt";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Tbx.php b/thirdparty/Zend/Translate/Adapter/Tbx.php
new file mode 100644
index 000000000..1436c5eb0
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Tbx.php
@@ -0,0 +1,165 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ if ($this->_term !== null) {
+ $this->_content .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_content .= " $key=\"$value\"";
+ }
+ $this->_content .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'termentry':
+ $this->_termentry = null;
+ break;
+ case 'langset':
+ if (isset($attrib['xml:lang']) === true) {
+ $this->_langset = $attrib['xml:lang'];
+ if (isset($this->_data[$this->_langset]) === false) {
+ $this->_data[$this->_langset] = array();
+ }
+ }
+ break;
+ case 'term':
+ $this->_term = true;
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ if (($this->_term !== null) and ($name != "term")) {
+ $this->_content .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'langset':
+ $this->_langset = null;
+ break;
+ case 'term':
+ $this->_term = null;
+ if (empty($this->_termentry)) {
+ $this->_termentry = $this->_content;
+ }
+ if (!empty($this->_content) or (isset($this->_data[$this->_langset][$this->_termentry]) === false)) {
+ $this->_data[$this->_langset][$this->_termentry] = $this->_content;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if ($this->_term !== null) {
+ $this->_content .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Tbx";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Tmx.php b/thirdparty/Zend/Translate/Adapter/Tmx.php
new file mode 100644
index 000000000..31c8f1bf4
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Tmx.php
@@ -0,0 +1,233 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ if (isset($options['useId'])) {
+ $this->_useId = (boolean) $options['useId'];
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * Internal method, called by xml element handler at start
+ *
+ * @param resource $file File handler
+ * @param string $name Elements name
+ * @param array $attrib Attributes for this element
+ */
+ protected function _startElement($file, $name, $attrib)
+ {
+ if ($this->_seg !== null) {
+ $this->_content .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_content .= " $key=\"$value\"";
+ }
+ $this->_content .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'header':
+ if (empty($this->_useId) && isset($attrib['srclang'])) {
+ if (Zend_Locale::isLocale($attrib['srclang'])) {
+ $this->_srclang = Zend_Locale::findLocale($attrib['srclang']);
+ } else {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->notice("The language '{$attrib['srclang']}' can not be set because it does not exist.");
+ } else {
+ trigger_error("The language '{$attrib['srclang']}' can not be set because it does not exist.", E_USER_NOTICE);
+ }
+ }
+
+ $this->_srclang = $attrib['srclang'];
+ }
+ }
+ break;
+ case 'tu':
+ if (isset($attrib['tuid'])) {
+ $this->_tu = $attrib['tuid'];
+ }
+ break;
+ case 'tuv':
+ if (isset($attrib['xml:lang'])) {
+ if (Zend_Locale::isLocale($attrib['xml:lang'])) {
+ $this->_tuv = Zend_Locale::findLocale($attrib['xml:lang']);
+ } else {
+ if (!$this->_options['disableNotices']) {
+ if ($this->_options['log']) {
+ $this->_options['log']->notice("The language '{$attrib['xml:lang']}' can not be set because it does not exist.");
+ } else {
+ trigger_error("The language '{$attrib['xml:lang']}' can not be set because it does not exist.", E_USER_NOTICE);
+ }
+ }
+
+ $this->_tuv = $attrib['xml:lang'];
+ }
+
+ if (!isset($this->_data[$this->_tuv])) {
+ $this->_data[$this->_tuv] = array();
+ }
+ }
+ break;
+ case 'seg':
+ $this->_seg = true;
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * Internal method, called by xml element handler at end
+ *
+ * @param resource $file File handler
+ * @param string $name Elements name
+ */
+ protected function _endElement($file, $name)
+ {
+ if (($this->_seg !== null) and ($name !== 'seg')) {
+ $this->_content .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'tu':
+ $this->_tu = null;
+ break;
+ case 'tuv':
+ $this->_tuv = null;
+ break;
+ case 'seg':
+ $this->_seg = null;
+ if (!empty($this->_srclang) && ($this->_srclang == $this->_tuv)) {
+ $this->_tu = $this->_content;
+ }
+
+ if (!empty($this->_content) or (!isset($this->_data[$this->_tuv][$this->_tu]))) {
+ $this->_data[$this->_tuv][$this->_tu] = $this->_content;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * Internal method, called by xml element handler for content
+ *
+ * @param resource $file File handler
+ * @param string $data Elements content
+ */
+ protected function _contentElement($file, $data)
+ {
+ if (($this->_seg !== null) and ($this->_tu !== null) and ($this->_tuv !== null)) {
+ $this->_content .= $data;
+ }
+ }
+
+
+ /**
+ * Internal method, detects the encoding of the xml file
+ *
+ * @param string $name Filename
+ * @return string Encoding
+ */
+ protected function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Tmx";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/Xliff.php b/thirdparty/Zend/Translate/Adapter/Xliff.php
new file mode 100644
index 000000000..2fc12ff96
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/Xliff.php
@@ -0,0 +1,229 @@
+_data = array();
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ if (empty($options['useId'])) {
+ $this->_useId = false;
+ } else {
+ $this->_useId = true;
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_target = $locale;
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ if ($this->_stag === true) {
+ $this->_scontent .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_scontent .= " $key=\"$value\"";
+ }
+ $this->_scontent .= ">";
+ } else if ($this->_ttag === true) {
+ $this->_tcontent .= "<".$name;
+ foreach($attrib as $key => $value) {
+ $this->_tcontent .= " $key=\"$value\"";
+ }
+ $this->_tcontent .= ">";
+ } else {
+ switch(strtolower($name)) {
+ case 'file':
+ $this->_source = $attrib['source-language'];
+ if (isset($attrib['target-language'])) {
+ $this->_target = $attrib['target-language'];
+ }
+
+ if (!isset($this->_data[$this->_source])) {
+ $this->_data[$this->_source] = array();
+ }
+
+ if (!isset($this->_data[$this->_target])) {
+ $this->_data[$this->_target] = array();
+ }
+
+ break;
+ case 'trans-unit':
+ $this->_transunit = true;
+ $this->_langId = $attrib['id'];
+ break;
+ case 'source':
+ if ($this->_transunit === true) {
+ $this->_scontent = null;
+ $this->_stag = true;
+ $this->_ttag = false;
+ }
+ break;
+ case 'target':
+ if ($this->_transunit === true) {
+ $this->_tcontent = null;
+ $this->_ttag = true;
+ $this->_stag = false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ if (($this->_stag === true) and ($name !== 'source')) {
+ $this->_scontent .= "".$name.">";
+ } else if (($this->_ttag === true) and ($name !== 'target')) {
+ $this->_tcontent .= "".$name.">";
+ } else {
+ switch (strtolower($name)) {
+ case 'trans-unit':
+ $this->_transunit = null;
+ $this->_langId = null;
+ $this->_scontent = null;
+ $this->_tcontent = null;
+ break;
+ case 'source':
+ if ($this->_useId) {
+ if (!empty($this->_scontent) && !empty($this->_langId) &&
+ !isset($this->_data[$this->_source][$this->_langId])) {
+ $this->_data[$this->_source][$this->_langId] = $this->_scontent;
+ }
+ } else {
+ if (!empty($this->_scontent) &&
+ !isset($this->_data[$this->_source][$this->_scontent])) {
+ $this->_data[$this->_source][$this->_scontent] = $this->_scontent;
+ }
+ }
+ $this->_stag = false;
+ break;
+ case 'target':
+ if ($this->_useId) {
+ if (!empty($this->_tcontent) && !empty($this->_langId) &&
+ !isset($this->_data[$this->_target][$this->_langId])) {
+ $this->_data[$this->_target][$this->_langId] = $this->_tcontent;
+ }
+ } else {
+ if (!empty($this->_tcontent) && !empty($this->_scontent) &&
+ !isset($this->_data[$this->_target][$this->_scontent])) {
+ $this->_data[$this->_target][$this->_scontent] = $this->_tcontent;
+ }
+ }
+ $this->_ttag = false;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if (($this->_transunit !== null) and ($this->_source !== null) and ($this->_stag === true)) {
+ $this->_scontent .= $data;
+ }
+
+ if (($this->_transunit !== null) and ($this->_target !== null) and ($this->_ttag === true)) {
+ $this->_tcontent .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "Xliff";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Adapter/XmlTm.php b/thirdparty/Zend/Translate/Adapter/XmlTm.php
new file mode 100644
index 000000000..a0e5f8839
--- /dev/null
+++ b/thirdparty/Zend/Translate/Adapter/XmlTm.php
@@ -0,0 +1,139 @@
+_data = array();
+ $this->_lang = $locale;
+ if (!is_readable($filename)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
+ }
+
+ $encoding = $this->_findEncoding($filename);
+ $this->_file = xml_parser_create($encoding);
+ xml_set_object($this->_file, $this);
+ xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($this->_file, "_startElement", "_endElement");
+ xml_set_character_data_handler($this->_file, "_contentElement");
+
+ if (!xml_parse($this->_file, file_get_contents($filename))) {
+ $ex = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($this->_file)),
+ xml_get_current_line_number($this->_file));
+ xml_parser_free($this->_file);
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception($ex);
+ }
+
+ return $this->_data;
+ }
+
+ private function _startElement($file, $name, $attrib)
+ {
+ switch(strtolower($name)) {
+ case 'tm:tu':
+ $this->_tag = $attrib['id'];
+ $this->_content = null;
+ break;
+ default:
+ break;
+ }
+ }
+
+ private function _endElement($file, $name)
+ {
+ switch (strtolower($name)) {
+ case 'tm:tu':
+ if (!empty($this->_tag) and !empty($this->_content) or
+ (isset($this->_data[$this->_lang][$this->_tag]) === false)) {
+ $this->_data[$this->_lang][$this->_tag] = $this->_content;
+ }
+ $this->_tag = null;
+ $this->_content = null;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private function _contentElement($file, $data)
+ {
+ if (($this->_tag !== null)) {
+ $this->_content .= $data;
+ }
+ }
+
+ private function _findEncoding($filename)
+ {
+ $file = file_get_contents($filename, null, null, 0, 100);
+ if (strpos($file, "encoding") !== false) {
+ $encoding = substr($file, strpos($file, "encoding") + 9);
+ $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
+ return $encoding;
+ }
+ return 'UTF-8';
+ }
+
+ /**
+ * Returns the adapter name
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return "XmlTm";
+ }
+}
diff --git a/thirdparty/Zend/Translate/Exception.php b/thirdparty/Zend/Translate/Exception.php
new file mode 100644
index 000000000..66f910900
--- /dev/null
+++ b/thirdparty/Zend/Translate/Exception.php
@@ -0,0 +1,37 @@
+ 3) {
+ $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
+ }
+
+ if (isset(self::$_plural[$locale])) {
+ $return = call_user_func(self::$_plural[$locale], $number);
+
+ if (!is_int($return) || ($return < 0)) {
+ $return = 0;
+ }
+
+ return $return;
+ }
+
+ switch($locale) {
+ case 'bo':
+ case 'dz':
+ case 'id':
+ case 'ja':
+ case 'jv':
+ case 'ka':
+ case 'km':
+ case 'kn':
+ case 'ko':
+ case 'ms':
+ case 'th':
+ case 'tr':
+ case 'vi':
+ case 'zh':
+ return 0;
+ break;
+
+ case 'af':
+ case 'az':
+ case 'bn':
+ case 'bg':
+ case 'ca':
+ case 'da':
+ case 'de':
+ case 'el':
+ case 'en':
+ case 'eo':
+ case 'es':
+ case 'et':
+ case 'eu':
+ case 'fa':
+ case 'fi':
+ case 'fo':
+ case 'fur':
+ case 'fy':
+ case 'gl':
+ case 'gu':
+ case 'ha':
+ case 'he':
+ case 'hu':
+ case 'is':
+ case 'it':
+ case 'ku':
+ case 'lb':
+ case 'ml':
+ case 'mn':
+ case 'mr':
+ case 'nah':
+ case 'nb':
+ case 'ne':
+ case 'nl':
+ case 'nn':
+ case 'no':
+ case 'om':
+ case 'or':
+ case 'pa':
+ case 'pap':
+ case 'ps':
+ case 'pt':
+ case 'so':
+ case 'sq':
+ case 'sv':
+ case 'sw':
+ case 'ta':
+ case 'te':
+ case 'tk':
+ case 'ur':
+ case 'zu':
+ return ($number == 1) ? 0 : 1;
+
+ case 'am':
+ case 'bh':
+ case 'fil':
+ case 'fr':
+ case 'gun':
+ case 'hi':
+ case 'ln':
+ case 'mg':
+ case 'nso':
+ case 'xbr':
+ case 'ti':
+ case 'wa':
+ return (($number == 0) || ($number == 1)) ? 0 : 1;
+
+ case 'be':
+ case 'bs':
+ case 'hr':
+ case 'ru':
+ case 'sr':
+ case 'uk':
+ return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
+
+ case 'cs':
+ case 'sk':
+ return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
+
+ case 'ga':
+ return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
+
+ case 'lt':
+ return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
+
+ case 'sl':
+ return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
+
+ case 'mk':
+ return ($number % 10 == 1) ? 0 : 1;
+
+ case 'mt':
+ return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
+
+ case 'lv':
+ return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
+
+ case 'pl':
+ return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
+
+ case 'cy':
+ return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
+
+ case 'ro':
+ return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
+
+ case 'ar':
+ return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number >= 3) && ($number <= 10)) ? 3 : ((($number >= 11) && ($number <= 99)) ? 4 : 5))));
+
+ default:
+ return 0;
+ }
+ }
+
+ /**
+ * Set's a new plural rule
+ *
+ * @param string $rule Callback which acts as rule
+ * @param string $locale Locale which is used for this callback
+ * @return null
+ */
+ public static function setPlural($rule, $locale)
+ {
+ if ($locale == "pt_BR") {
+ // temporary set a locale for brasilian
+ $locale = "xbr";
+ }
+
+ if (strlen($locale) > 3) {
+ $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
+ }
+
+ if (!is_callable($rule)) {
+ require_once 'Zend/Translate/Exception.php';
+ throw new Zend_Translate_Exception('The given rule can not be called');
+ }
+
+ self::$_plural[$locale] = $rule;
+ }
+}