예제 #1
0
 /**
  * Copy from \Zend_Translate_Adapter
  *
  * Translates the given string
  * returns the translation
  *
  * @param  string             $text   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 _($text, $locale = null)
 {
     if (!$this->translateAdapter) {
         $this->initTranslateable();
     }
     return $this->translateAdapter->_($text, $locale);
 }
 /**
  * proxy for easy access to translations
  *
  * @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
  */
 private function _($messageId, $locale = null)
 {
     if ($this->translate) {
         return $this->translate->_($messageId, $locale);
     }
     return $messageId;
 }
 public function afterRegistry()
 {
     parent::afterRegistry();
     $this->setIfExists('gof_form_id', 'label', $this->translate->_('FormID'));
     $this->setIfExists('gof_form_version', 'label', $this->translate->_('Version'));
     $this->setIfExists('gof_form_title', 'label', $this->translate->_('Name'));
     $this->setIfExists('gof_form_active', 'label', $this->translate->_('Active'), 'elementClass', 'checkbox');
 }
예제 #4
0
 public function testDiffReadableBeforeAndAfterLocalised()
 {
     $this->translate->setLocale('nl');
     $this->object = new \MUtil_Date('2010-05-13 12:00:00');
     $testDate = new \MUtil_Date('2010-05-13 12:00:10');
     $this->assertEquals('10 seconden geleden', $this->object->diffReadable($testDate, $this->translate));
     $testDate = new \MUtil_Date('2010-05-13 11:59:50');
     $this->assertEquals('over 10 seconden', $this->object->diffReadable($testDate, $this->translate));
     $testDate = new \MUtil_Date('2010-05-13 12:00:00');
     $this->assertEquals('over 0 seconden', $this->object->diffReadable($testDate, $this->translate));
 }
예제 #5
0
 private function _addElementPerson()
 {
     $translate = Zend_Registry::get("Zend_Translate");
     $url = new Zend_View_Helper_Url();
     $urlSearch = $url->url(array('module' => 'persons', 'controller' => 'person', 'action' => 'search-form'), null, true);
     $urlNew = $url->url(array('module' => 'persons', 'controller' => 'person', 'action' => 'create'), null, true);
     $append = '';
     if ($this->_action == self::ACTION_ADD) {
         $append .= '<a id="btnPersonSearch" href="' . $urlSearch . '" ' . ' rel="colorbox-search" search-return-id="id" search-return-value="person_name">' . '<i class="icon-search" rel="tooltip" data-original-title="' . $this->translate->_("Search person") . '"></i>' . '</a>';
     }
     $this->addElement('text', 'person_name', array('label' => 'Person', 'value' => $this->_model ? $this->_model->getPerson()->getName() : '', 'dimension' => 6, 'disabled' => true, 'placeholder' => $translate->_('Use the links aside to search a person or create a new one'), 'append' => $append . ' | ' . '<a class="hide" id="btnPersonDetails" href="#" rel="colorbox-details">' . $this->translate->_("Details") . '</a>' . ' | ' . '<a class="hide" id="btnPersonCreate" href="' . $urlNew . '" rel="colorbox">' . '<i class="icon-plus-sign" rel="tooltip" data-original-title="' . $this->translate->_("Add new") . ' ' . $this->translate->_("person") . '"></i>' . '</a>'));
 }
예제 #6
0
 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate
  * @return Zend_View_Helper_HeadTitle
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } elseif ($translate instanceof Zend_Translate) {
         $this->_translator = $translate->getAdapter();
     } else {
         require_once 'Zend/View/Exception.php';
         throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
     }
     return $this;
 }
예제 #7
0
 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate
  * @return Zend_View_Helper_HeadTitle
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } elseif ($translate instanceof Zend_Translate) {
         $this->_translator = $translate->getAdapter();
     } else {
         $e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
예제 #8
0
 /**
  * Set translator
  *
  * @param  Zend_Translate|Zend_Translate_Adapter|null $translator
  * @return Zend_View_Helper_FormElement
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator) {
         $this->_translator = null;
     } elseif ($translator instanceof Zend_Translate_Adapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof Zend_Translate) {
         $this->_translator = $translator->getAdapter();
     } else {
         $e = new Zend_View_Exception('Invalid translator specified');
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
예제 #9
0
 /**
  * Generates the adapter
  *
  * @param  string              $data     Translation data
  * @param  string|Zend_Locale  $locale   OPTIONAL Locale/Language to set, identical with locale identifier,
  *                                       see Zend_Locale for more information
  * @param  array               $options  Options for this adapter
  */
 public function __construct($data, $locale = null, array $options = array())
 {
     $this->_options['delimiter'] = ";";
     $this->_options['length'] = 0;
     $this->_options['enclosure'] = '"';
     parent::__construct($data, $locale, $options);
 }
예제 #10
0
 /**
  * Generates the adapter
  *
  * @param  array               $db    The DB connection
  * @param  string|Zend_Locale  $locale   OPTIONAL Locale/Language to set, identical with locale identifier,
  *                                       see Zend_Locale for more information
  * @param  array               $options  OPTIONAL Options to set
  */
 public function __construct($db, $locale = null, array $options = array())
 {
     // If $db is null: nothing to do.
     if ($db == null) {
         return;
     }
     // Keep the db reference for possible use
     $this->db = $db;
     // Check whether the view system is PHPLIB. In yes we
     // add all the translations as entities in the view object
     // Get the utilitary objects from the registry
     $registry = Zend_registry::getInstance();
     $zmax_context = $registry->get("zmax_context");
     $config = $zmax_context->config;
     // By default we take the zmax context view, unless it is explicitly given
     if (isset($options['view'])) {
         $this->phplib_view = $options['view'];
     } else {
         if ($config->view->zmax_view_system == "phplib") {
             $this->phplib_view = $zmax_context->view;
         }
     }
     // Now call the parent constructor
     // Adding this option is necessary starting with Zend 1.6, to prevent
     // an ugly message
     $options['disableNotices'] = 'true';
     parent::__construct($db, $locale, $options);
 }
예제 #11
0
 /**
  * Retrieve translate object
  *
  * @throws Zend_Application_Resource_Exception if registry key was used
  *          already but is no instance of Zend_Translate
  * @return Zend_Translate
  */
 public function getTranslate()
 {
     if (null === $this->_translate) {
         $this->buildLog();
         // retrieve cache if requested
         if (isset($this->_options['cacheEnabled']) && $this->_options['cacheEnabled']) {
             // check for cachemanager in bootstrap
             if (!$this->getBootstrap()->hasPluginResource('cachemanager')) {
                 throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
             }
             // bootstrap the cachemanager and retrieve it
             /** @var $cacheManager Zend_Cache_Manager */
             $cacheManager = $this->getBootstrap()->bootstrap('cachemanager')->getResource('cachemanager');
             // check for the given key
             if (!$cacheManager->hasCache($this->getCacheKey())) {
                 throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
             }
             // set cache for translator
             Zend_Translate_Adapter::setCache($cacheManager->getCache($this->getCacheKey()));
         }
         // fetch translate object into local variable
         $this->_translate = parent::getTranslate();
     }
     return $this->_translate;
 }
예제 #12
0
파일: Csv.php 프로젝트: Nerutiz/trades
 /**
  * Generates the adapter
  *
  * @param  array|Zend_Config $options Translation content
  */
 public function __construct($options = array())
 {
     $this->_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);
 }
예제 #13
0
 public function __construct($locale)
 {
     if (!$locale instanceof Zend_Locale) {
         $locale = new Zend_Locale($locale);
     }
     $locale = (string) $locale;
     parent::__construct(array("locale" => $locale, "content" => array("__pimcore_dummy" => "only_a_dummy")));
 }
예제 #14
0
 /**
  * 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
  * @param  string $section
  * @return string
  */
 public function translate($messageId, $locale = null, $section = 'global')
 {
     $this->_logSection = $section;
     $translated = parent::translate($messageId, $locale);
     if ($translated == '') {
         return $messageId;
     }
     return $translated;
 }
예제 #15
0
 protected function tearDown()
 {
     // restore static variables
     if (isset($this->cache)) {
         Zend_Translate_Adapter::setCache($this->cache);
         unset($this->cache);
     } else {
         Zend_Translate_Adapter::removeCache();
     }
     // unset the registry
     Zend_Registry::_unsetInstance();
 }
예제 #16
0
 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setOrder(99999);
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
예제 #17
0
 /**
  * Plural translation with context
  *
  * @param string $messageId
  * @param string $pluralId
  * @param int $n
  * @param string $ctxt
  * @return string
  */
 public function _nx($messageId, $pluralId, $n, $ctxt)
 {
     if (null === $this->translate) {
         return $messageId;
     }
     $msgId = $ctxt . chr(4) . $messageId;
     $plrId = $ctxt . chr(4) . $pluralId;
     $txt = $this->translate->translate(array($msgId, $plrId, $n));
     if ($txt == $msgId && !is_null($this->fallback)) {
         $txt = $this->fallback->translate(array($msgId, $plrId, $n));
     }
     return sprintf($txt, $n);
 }
 /**
  * Get a model to store the config
  *
  * @param boolean $valueMask MAsk the password or if false decrypt it
  * @return \Gems_Model_JoinModel
  */
 protected function getConfigModel($valueMask = true)
 {
     if (!$this->_configModel) {
         $model = new \MUtil_Model_TableModel('gems__radius_config', 'config');
         // $model = new \Gems_Model_JoinModel('config', 'gems__radius_config', 'grcfg');
         $model->setIfExists('grcfg_ip', 'label', $this->translate->_('IP address'), 'required', true);
         $model->setIfExists('grcfg_port', 'label', $this->translate->_('Port'), 'required', true);
         $model->setIfExists('grcfg_secret', 'label', $this->translate->_('Shared secret'), 'description', $this->translate->_('Enter only when changing'), 'elementClass', 'password', 'required', false, 'repeatLabel', $this->translate->_('Repeat password'));
         $type = new \Gems_Model_Type_EncryptedField($this->project, $valueMask);
         $type->apply($model, 'grcfg_secret', 'grcfg_encryption');
         $this->_configModel = $model;
     }
     return $this->_configModel;
 }
예제 #19
0
 private function _addElementHomeType()
 {
     $this->addElement('radio', 'home_type_choice', array('label' => 'Home type', 'value' => $this->_model ? $this->_model->getHome_type() : NULL, 'dimension' => 2, 'rel' => 'choice-for-another-element', 'data-target' => '#home_type'));
     $el = $this->getElement('home_type_choice');
     $ops = Persons_Model_Home::toArrayType();
     foreach ($ops as $key => $value) {
         $ops[$key] = $this->translate->_($value);
     }
     sort($ops);
     foreach ($ops as $op) {
         $el->addMultiOption($op, $op);
     }
     $el->addMultiOption('', 'another');
     $this->addElement('text', 'home_type', array('label' => 'Home type', 'value' => $this->_model ? $this->_model->getHome_type() : '', 'dimension' => 6, 'required' => true, 'validators' => array(array('StringLength', false, array(0, isset($options['maxlength']) ? $options['maxlength'] : 50))), 'maxlength' => 50, 'readonly' => true));
 }
예제 #20
0
 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $btnSubmit = $this->createElement('submit', 'submit');
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setAttrib('class', 'btn btn-info');
     $this->addElement($btnSubmit);
 }
 /**
  * setMessage() - method set message and type
  *
  * @param string $type
  * @param string $message
  * @param mixed $value
  * @param int $len
  * @return \Extlib\Controller\Action\Helper\FlashMessage
  */
 public function setMessage($type, $message, $value = null, $len = 25)
 {
     if (!in_array(strtolower($type), self::$_allowedTypes)) {
         throw new \Zend_Controller_Action_Exception('Incorrect type of message!');
     }
     if (!\Zend_Validate::is($len, 'Int')) {
         throw new \Zend_Controller_Action_Exception("Param 'len' must be a int value!");
     }
     if (null !== $this->_translator) {
         $message = $this->_translator->translate($message);
     }
     if (null !== $value) {
         if (strlen($value) > $len) {
             $value = mb_substr($value, 0, $len, 'UTF-8') . '..';
         }
         $message = str_replace(self::VALUE_PATTERN, $value, $message);
     }
     self::$_session->setExpirationHops(1, null, true);
     self::$_session->{$this->_namespace} = array(strtolower($type) => $message);
     self::$_messageAdded = true;
     return $this;
 }
예제 #22
0
파일: Input.php 프로젝트: cljk/kimai
 /**
  * Set translation object
  *
  * @param  Zend_Translate|Zend_Translate_Adapter|null $translator
  * @return Zend_Filter_Input
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator || $translator instanceof Zend_Translate_Adapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof Zend_Translate) {
         $this->_translator = $translator->getAdapter();
     } else {
         require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception('Invalid translator specified');
     }
     return $this;
 }
예제 #23
0
 /**
  * Removes any set cache
  *
  * @return void
  */
 public static function removeCache()
 {
     self::$_cache = null;
 }
예제 #24
0
 /**
  * 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);
 }
예제 #25
0
 /**
  * Set default translation object for all validate objects
  *
  * @param  Zend_Translate|Zend_Translate_Adapter|null $translator
  * @return void
  */
 public static function setDefaultTranslator($translator = null)
 {
     if (null === $translator || $translator instanceof Zend_Translate_Adapter) {
         self::$_defaultTranslator = $translator;
     } elseif ($translator instanceof Zend_Translate) {
         self::$_defaultTranslator = $translator->getAdapter();
     } else {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception('Invalid translator specified');
     }
 }
예제 #26
0
 /**
  * Generates the adapter
  *
  * @param  array               $data     Translation data
  * @param  string|Zend_Locale  $locale   OPTIONAL Locale/Language to set, identical with locale identifier,
  *                                       see Zend_Locale for more information
  * @param  array               $options  OPTIONAL Options to set
  */
 public function __construct($data, $locale = null, array $options = array())
 {
     parent::__construct($data, $locale, $options);
 }
예제 #27
0
 /**
  * Generates the  adapter
  *
  * @param  array               $options  Options for this adapter
  * @param  string|Zend_Locale  $locale   OPTIONAL Locale/Language to set, identical with locale identifier,
  *                                       see Zend_Locale for more information
  */
 public function __construct($options, $locale = null)
 {
     parent::__construct($options, $locale);
 }
예제 #28
0
 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate Instance of Zend_Translate
  * @throws Zend_View_Exception When no or a false instance was set
  * @return Zend_View_Helper_Translate
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } else {
         if ($translate instanceof Zend_Translate) {
             $this->_translator = $translate->getAdapter();
         } else {
             require_once 'Zend/View/Exception.php';
             $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
             $e->setView($this->view);
             throw $e;
         }
     }
     return $this;
 }
예제 #29
0
 /**
  * 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;
 }
예제 #30
0
 /**
  * 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;
 }