Translation2
[ class tree: Translation2 ] [ index: Translation2 ] [ all elements ]

Source for file Decorator.php

Documentation is available at Decorator.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * Contains the Translation2_Admin_Decorator class
  6.  *
  7.  * PHP versions 4 and 5
  8.  *
  9.  * LICENSE: Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in the
  15.  *    documentation and/or other materials provided with the distribution.
  16.  * 3. The name of the author may not be used to endorse or promote products
  17.  *    derived from this software without specific prior written permission.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  20.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22.  * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
  23.  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  *
  30.  * @category  Internationalization
  31.  * @package   Translation2
  32.  * @author    Lorenzo Alberton <l.alberton@quipo.it>
  33.  * @copyright 2004-2007 Lorenzo Alberton
  34.  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
  35.  * @version   CVS: $Id: Decorator.php,v 1.12 2007/11/10 00:02:50 quipo Exp $
  36.  * @link      http://pear.php.net/package/Translation2
  37.  */
  38.  
  39. /**
  40.  * Load Translation2_Decorator class
  41.  */
  42. require_once 'Translation2/Decorator.php';
  43.  
  44. /**
  45.  * Decorates a Translation2_Admin class.
  46.  *
  47.  * Create a subclass of this class for your own "decoration".
  48.  *
  49.  * @category  Internationalization
  50.  * @package   Translation2
  51.  * @author    Lorenzo Alberton <l.alberton@quipo.it>
  52.  * @copyright 2004-2007 Lorenzo Alberton
  53.  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
  54.  * @link      http://pear.php.net/package/Translation2
  55.  * @abstract
  56.  * @todo      Don't allow stacking on top of regular Decorators,
  57.  *             since that will break things.
  58.  */
  59. {
  60.     // {{{ addLang()
  61.  
  62.     /**
  63.      * Prepare the storage container for a new lang.
  64.      * If the langsAvail table doesn't exist yet, it is created.
  65.      *
  66.      * @param array $langData array('lang_id'    => 'en',
  67.      *                               'table_name' => 'i18n',
  68.      *                               'name'       => 'english',
  69.      *                               'meta'       => 'some meta info',
  70.      *                               'error_text' => 'not available');
  71.      * @param array $options  array('charset'   => 'utf8',
  72.      *                               'collation' => 'utf8_general_ci');
  73.      *
  74.      * @return mixed true on success, PEAR_Error on failure
  75.      * @see Translation2_Admin::addLang()
  76.      */
  77.     function addLang($langData$options = array())
  78.     {
  79.         return $this->translation2->addLang($langData$options);
  80.     }
  81.     
  82.     // }}}
  83.     // {{{ removeLang()
  84.  
  85.     /**
  86.      * Remove the lang from the langsAvail table and drop the strings table.
  87.      * If the strings table holds other langs and $force==false, then
  88.      * only the lang column is dropped. If $force==true the whole
  89.      * table is dropped without any check
  90.      *
  91.      * @param string  $langID language ID
  92.      * @param boolean $force  remove the language info without further checks
  93.      *
  94.      * @return mixed true on success, PEAR_Error on failure
  95.      * @see Translation2_Admin::removeLang()
  96.      */
  97.     function removeLang($langID = null$force = false)
  98.     {
  99.         return $this->translation2->removeLang($langID$force);
  100.     }
  101.  
  102.     // }}}
  103.     // {{{ updateLang()
  104.  
  105.     /**
  106.      * Update the lang info in the langsAvail table
  107.      *
  108.      * @param array $langData array containing language info
  109.      *
  110.      * @return mixed true on success, PEAR_Error on failure
  111.      * @see Translation2_Admin::updateLang()
  112.      */
  113.     function updateLang($langData)
  114.     {
  115.         return $this->translation2->updateLang($langData);
  116.     }
  117.  
  118.     // }}}
  119.     // {{{ add()
  120.  
  121.     /**
  122.      * Add a new translation
  123.      *
  124.      * @param string $stringID    string ID
  125.      * @param string $pageID      page/group ID
  126.      * @param array  $stringArray Associative array with string translations.
  127.      *                Sample format:  array('en' => 'sample', 'it' => 'esempio')
  128.      *
  129.      * @return mixed true on success, PEAR_Error on failure
  130.      * @see Translation2_Admin::add()
  131.      */
  132.     function add($stringID$pageID$stringArray)
  133.     {
  134.         return $this->translation2->add($stringID$pageID$stringArray);
  135.     }
  136.  
  137.     // }}}
  138.     // {{{ update()
  139.  
  140.     /**
  141.      * Update an existing translation
  142.      *
  143.      * @param string $stringID    string ID
  144.      * @param string $pageID      page/group ID
  145.      * @param array  $stringArray Associative array with string translations.
  146.      *                Sample format:  array('en' => 'sample', 'it' => 'esempio')
  147.      *
  148.      * @return mixed true on success, PEAR_Error on failure
  149.      * @see Translation2_Admin::update()
  150.      */
  151.     function update($stringID$pageID$stringArray)
  152.     {
  153.         return $this->translation2->update($stringID$pageID$stringArray);
  154.     }
  155.  
  156.     // }}}
  157.     // {{{ remove()
  158.  
  159.     /**
  160.      * Remove a translated string
  161.      *
  162.      * @param string $stringID string ID
  163.      * @param string $pageID   page/group ID
  164.      *
  165.      * @return mixed true on success, PEAR_Error on failure
  166.      * @see Translation2_Admin::remove()
  167.      */
  168.     function remove($stringID$pageID = null)
  169.     {
  170.         return $this->translation2->remove($stringID$pageID);
  171.     }
  172.  
  173.     // }}}
  174.     // {{{ removePage
  175.  
  176.     /**
  177.      * Remove all the strings in the given page/group
  178.      *
  179.      * @param string $pageID page/group ID
  180.      *
  181.      * @return mixed true on success, PEAR_Error on failure
  182.      * @see Translation2_Admin::removePage()
  183.      */
  184.     function removePage($pageID = null)
  185.     {
  186.         return $this->translation2->removePager($pageID);
  187.     }
  188.  
  189.     // }}}
  190.     // {{{ getPageNames()
  191.  
  192.     /**
  193.      * Get a list of all the pageIDs in any table.
  194.      *
  195.      * @return array 
  196.      * @see Translation2_Admin::getPageNames()
  197.      */
  198.     function getPageNames()
  199.     {
  200.         return $this->translation2->getPageNames();
  201.     }
  202.  
  203.     // }}}
  204.     // {{{ cleanCache()
  205.  
  206.     /**
  207.      * If you use the CacheLiteFunction decorator, you may want to invalidate
  208.      * the cache after a change in the data base.
  209.      *
  210.      * @return void 
  211.      * @see Translation2_Admin::cleanCache()
  212.      */
  213.     function cleanCache()
  214.     {
  215.         return $this->translation2->cleanCache();
  216.     }
  217.  
  218.     // }}}
  219. }
  220. ?>

Documentation generated on Tue, 06 May 2008 06:00:23 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.