cache = $cacheObject; } /** * Sets configuration data * * This backend accepts two settings which can be set through this * function. FIXME : fix docs * * Example: * * setOptions( * array( 'location' => 'usr/share/translations', * 'format' => 'translation-[LOCALE].xml' ) * ); * ?> * * * @param array $configurationData */ public function setOptions( $configurationData ) { foreach ( $configurationData as $name => $value ) { switch ( $name ) { default: throw new ezcBaseConfigException( $name, ezcBaseConfigException::UNKNOWN_CONFIG_SETTING ); } } } /** * Returns a array containing a translation map. * * This method returns an array containing the translation map for the * specified $locale and $context. It uses the $tsLocationPath and * $tsFilenameFormat properties to locate the file, unless caching is * enabled. If a cache object is available it will be used to retrieve the * information from the cache. * * @param $locale string The locale to retrieve translations for * @param $context string The translation context to retrieve translations for * @returns array[ezcTranslationData] * @throws ezcTranslationException when a context is not available */ public function getContext( $locale, $context ) { $cachedContext = $this->cache->restore( "$locale/$context" ); if ( $cachedContext === false ) { throw new ezcTranslationException( "The context <{$context}> does not exist.", ezcTranslationException::CONTEXT_NOT_AVAILABLE ); } foreach ( $cachedContext as $key => $cachedElement ) { if ( $cachedElement->status == ezcTranslationData::OBSOLETE ) { unset( $cachedContext[$key] ); } } return $cachedContext; } /** * Initializes the writer * * Before starting to writer contexts to the writer, you should call * this method to initialize it. * * @param string $locale The locale to write to. */ public function initWriter( $locale ) { $this->writeLocale = $locale; } /** * Deinitializes the writer * * This method should be called after the last context was written to * cleanup resources. * * @throws TranslationException when the writer is not initialized with * initWriter(). */ public function deinitWriter() { if ( is_null( $this->writeLocale ) ) { throw new ezcTranslationException( 'The writer is not initialized with the initWriter() method.', ezcTranslationException::WRITER_NOT_INITIALIZED ); } $this->writeLocale = null; } /** * Stores a context * * This method stores the context that it received to the backend specified * storage place. * * @param string $context The context's name * @param array $data The context's translation map * @throws TranslationException when the writer is not initialized with * initWriter(). */ public function storeContext( $context, array $data ) { if ( is_null( $this->writeLocale ) ) { throw new ezcTranslationException( 'The writer is not initialized with the initWriter() method.', ezcTranslationException::WRITER_NOT_INITIALIZED ); } foreach ( $data as $key => $cachedElement ) { if ( $cachedElement->status == ezcTranslationData::OBSOLETE ) { unset( $data[$key] ); } } $cachedContext = $this->cache->store( "{$this->writeLocale}/$context" , $data ); } } ?>