Author: Jan Schneider (jan@horde.org)
Inheritance: extends Horde_Translation_Autodetect
Esempio n. 1
0
    /**
     * TODO
     */
    public static function getJavaScript($formname, $elementname)
    {
        $prompt = addslashes(Horde_Prefs_Translation::t("Please type the new category name:"));
        $error = addslashes(Horde_Prefs_Translation::t("You must type a new category name."));
        return <<<JAVASCRIPT

<script type="text/javascript">
<!--
function checkCategory()
{
    if (document.{$formname}['{$elementname}'].value == '*new*') {
        var category = window.prompt('{$prompt}', '');
        if (category != null && category != '') {
            document.{$formname}.new_category.value = category;
        } else {
            window.alert('{$error}');
            return false;
        }
    } else if (document.{$formname}['{$elementname}'].value.indexOf('*new*') != -1) {
        document.{$formname}.new_category.value = document.{$formname}['{$elementname}'].value.substr(5, document.{$formname}['{$elementname}'].value.length);
    }

    return true;
}
//-->
</script>
JAVASCRIPT;
    }
Esempio n. 2
0
 /**
  * Constructor.
  *
  * @param string $user   The username.
  * @param array $params  Configuration parameters.
  * <pre>
  * 'kolab'  - (Horde_Kolab_Storage) [REQUIRED] The storage backend.
  * 'folder' - (string) The default name of the preferences folder.
  *            DEFAULT: _('Preferences')
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct($user, array $params = array())
 {
     if (!isset($params['kolab'])) {
         throw new InvalidArgumentException('Missing "kolab" parameter.');
     }
     $this->_kolab = $params['kolab'];
     unset($params['kolab']);
     if (isset($params['logger'])) {
         $this->_logger = $params['logger'];
     }
     if (isset($params['folder'])) {
         $this->_folder = $params['folder'];
     } else {
         $this->_folder = Horde_Prefs_Translation::t("Preferences");
     }
     parent::__construct($user, $params);
 }
Esempio n. 3
0
 /**
  * Verifies and sanitizes all identity properties.
  *
  * @param integer $identity  The identity to verify.
  *
  * @throws Horde_Prefs_Exception
  */
 public function verify($identity = null)
 {
     if (is_null($identity)) {
         $identity = $this->_default;
     }
     if (!$this->getValue('id', $identity)) {
         $this->setValue('id', Horde_Prefs_Translation::t("Unnamed"), $identity);
     }
     // To verify e-mail, first parse input, than re-parse in verify mode.
     $ob = new Horde_Mail_Rfc822_Address($this->getValue($this->_prefnames['from_addr'], $identity));
     try {
         $rfc822 = new Horde_Mail_Rfc822();
         $rfc822->parseAddressList($ob, array('validate' => true));
     } catch (Horde_Mail_Exception $e) {
         throw new Horde_Prefs_Exception(sprintf(Horde_Prefs_Translation::t("\"%s\" is not a valid email address."), strval($ob)));
     }
     $this->setValue('from_addr', strval($ob), $identity);
 }
Esempio n. 4
0
 /**
  * Returns the plural translation of a message.
  *
  * @param string $singular  The singular version to translate.
  * @param string $plural    The plural version to translate.
  * @param integer $number   The number that determines singular vs. plural.
  *
  * @return string  The string translation, or the original string if no
  *                 translation exists.
  */
 public static function ngettext($singular, $plural, $number)
 {
     self::$_domain = 'Horde_Prefs';
     self::$_directory = '@data_dir@' == '@' . 'data_dir' . '@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Prefs/locale';
     return parent::ngettext($singular, $plural, $number);
 }