Copyright 2011-2014 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Gunnar Wrobel (wrobel@pardus.de)
Inheritance: extends Horde_Translation
Example #1
0
 /**
  * The main entry point for the application.
  *
  * @param array $parameters A list of named configuration parameters.
  */
 public static function main(array $parameters = array())
 {
     $parser = new Horde_Argv_Parser(array('usage' => '%prog [OPTIONS] [SOURCE://ID]'));
     $parser->addOptions(array(new Horde_Argv_Option('-c', '--config', array('action' => 'store', 'help' => Horde_Push_Translation::t('Path to the configuration file.'))), new Horde_Argv_Option('-S', '--summary', array('action' => 'store', 'help' => Horde_Push_Translation::t('A summary replacing the value provided by the source.'))), new Horde_Argv_Option('-R', '--recipients', array('action' => 'store', 'help' => Horde_Push_Translation::t('A comma delimited list of recipients.'))), new Horde_Argv_Option('-T', '--tags', array('action' => 'store', 'help' => Horde_Push_Translation::t('A comma delimited list of tags.'))), new Horde_Argv_Option('-L', '--links', array('action' => 'store', 'help' => Horde_Push_Translation::t('A comma delimited list of links.'))), new Horde_Argv_Option('-p', '--pretend', array('action' => 'store_true', 'help' => Horde_Push_Translation::t('Do not push the content but display what would be done.')))));
     list($options, $arguments) = $parser->parseArgs();
     global $conf;
     if (isset($options['config'])) {
         if (!file_exists($options['config'])) {
             throw new Horde_Push_Exception(sprintf('The specified config file %s does not exist!', $options['config']));
         }
         include $options['config'];
     } else {
         $conf = array('recipients' => array('mock'));
     }
     if (empty($arguments)) {
         $arguments = explode(' ', trim(file_get_contents('php://stdin')));
     }
     $push_factory = new Horde_Push_Factory_Push();
     $pushes = $push_factory->create($arguments, $options, $conf);
     $fail = false;
     foreach ($pushes as $push) {
         if (isset($options['summary'])) {
             $push->setSummary($options['summary']);
         }
         if (isset($options['tags'])) {
             foreach (explode(',', $options['tags']) as $tag) {
                 $push->addTag($tag);
             }
         }
         if (isset($options['links'])) {
             foreach (explode(',', $options['links']) as $reference) {
                 $push->addReference($reference);
             }
         }
         $recipient_factory = new Horde_Push_Factory_Recipients();
         $recipients = $recipient_factory->create($options, $conf);
         foreach ($recipients as $recipient) {
             $push->addRecipient($recipient);
         }
         $results = $push->push(array('pretend' => !empty($options['pretend'])));
         $cli = Horde_Cli::init();
         foreach ($results as $result) {
             if ($result instanceof Exception) {
                 $cli->message($result->getMessage(), 'cli.error');
                 $fail = true;
             } else {
                 $cli->message((string) $result, 'cli.success');
             }
         }
     }
     if ($fail === true) {
         $status = 1;
     } else {
         $status = 0;
     }
     if (empty($parameters['no_exit'])) {
         exit($status);
     } else {
         return $status;
     }
 }
Example #2
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_Push';
     self::$_directory = '@data_dir@' == '@' . 'data_dir' . '@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Push/locale';
     return parent::ngettext($singular, $plural, $number);
 }