Ejemplo n.º 1
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('nome');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     $password = new Input('password');
     $password->setRequired(true);
     $password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($password);
     $confirmarPassword = new Input('confirmarPassword');
     $confirmarPassword->setRequired(true);
     $confirmarPassword->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum))->addValidator(new Identical(array('token' => 'password', 'messages' => array('notSame' => 'I dati sono errati, riprova.'))));
     $this->add($confirmarPassword);
     $imagen = new FileInput('immagine');
     $imagen->setRequired(false);
     $imagen->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/utenti/utenti_', 'use_upload_extension' => true, 'randomize' => true)));
     $imagen->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
     /*
      $imagen->getValidatorChain()->attach(new MimeType(array(
      'mimeType' => 'image/png,image/x-png,image/gif,image/jpeg,image/pjpeg', 'enableHeaderCheck' => true
      )));
     */
     $this->add($imagen);
 }
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Posterlabs/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('titolo');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     $this->add(array('name' => 'durata', 'required' => true, 'validators' => array(array('name' => 'Int'))));
 }
Ejemplo n.º 3
0
 public function changeLocaleEnglishAction()
 {
     // New Container will get he Language Session if the SessionManager already knows the language session.
     $session = new Container('language');
     //just clear the language session
     $session->getManager()->getStorage()->clear('language');
     $language = 'en_US';
     //set new language
     $request = $this->getRequest();
     $config = $this->serviceLocator->get('config');
     $session->language = $language;
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->setLocale('en_US')->setFallbackLocale('en_US');
     return $this->redirect()->toRoute('home');
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $messaggio = new Input('messaggio');
     $messaggio->setRequired(true);
     $messaggio->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     // $messaggio->getValidatorChain()
     // ->addValidator(new StringLength($this->opcionesStringLenght));
     $this->add($messaggio);
     $this->add(array('name' => 'posterlab', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $this->add(array('name' => 'tipo', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $this->add(array('name' => 'sessione', 'required' => true, 'validators' => array(array('name' => 'Int'))));
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('nome');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght));
     //->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     $password = new Input('password');
     $password->setRequired(true);
     $password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght));
     $this->add($password);
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Contenuti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $titolo = new Input('titolo');
     $titolo->setRequired(true);
     $titolo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $titolo->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($titolo);
     $this->add(array('name' => 'posterlab', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $this->add(array('name' => 'tipo', 'required' => true, 'validators' => array(array('name' => 'Int'))));
     $background = new FileInput('background');
     $background->setRequired(true);
     $background->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/contenuto/contenuto_', 'use_upload_extension' => true, 'randomize' => true)));
     $background->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
     $this->add($background);
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Posterlabs/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('titolo');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     /*
             $password = new Input('password');
             $password->setRequired(true);
             $password->getValidatorChain()
                      ->addValidator(new StringLength($this->opcionesStringLenght))
                      ->addValidator(new Alnum($this->opcionesAlnum));
            
             $this->add($password);
     
     
     
             $confirmarPassword = new Input('confirmarPassword');
             $confirmarPassword->setRequired(true);
             $confirmarPassword->getValidatorChain()
             ->addValidator(new StringLength($this->opcionesStringLenght))
             ->addValidator(new Alnum($this->opcionesAlnum))
             ->addValidator(new Identical(
                 array(
                     'token' => 'password',
                     'messages'=> array(
                     'notSame'=>'I dati sono errati, riprova.',           
                     )
                 )
             ));
             $this->add($confirmarPassword);
     */
     $this->add(array('name' => 'durata', 'required' => true, 'validators' => array(array('name' => 'Int'))));
 }
<?php

$translator = new \Zend\I18n\Translator\Translator();
return ['navigation' => ['default' => [['label' => $translator->translate('Tasks'), 'route' => 'tasks', 'controller' => 'manage', 'action' => 'index', 'resource' => 'UsersTasks.manage.index']]]];
Ejemplo n.º 9
0
 /**
  * Include the good language dict.
  *
  * Get the default language from current user in $_SESSION["glpilanguage"].
  * And load the dict that correspond.
  *
  * @param $forcelang Force to load a specific lang (default '')
  *
  * @return nothing (make an include)
  **/
 static function loadLanguage($forcelang = '')
 {
     global $LANG, $CFG_GLPI, $TRANSLATE;
     $file = "";
     if (!isset($_SESSION["glpilanguage"])) {
         if (isset($CFG_GLPI["language"])) {
             // Default config in GLPI >= 0.72
             $_SESSION["glpilanguage"] = $CFG_GLPI["language"];
         } else {
             if (isset($CFG_GLPI["default_language"])) {
                 // Default config in GLPI < 0.72 : keep it for upgrade process
                 $_SESSION["glpilanguage"] = $CFG_GLPI["default_language"];
             } else {
                 $_SESSION["glpilanguage"] = "en_GB";
             }
         }
     }
     $trytoload = $_SESSION["glpilanguage"];
     // Force to load a specific lang
     if (!empty($forcelang)) {
         $trytoload = $forcelang;
     }
     // If not set try default lang file
     if (empty($trytoload)) {
         $trytoload = $CFG_GLPI["language"];
     }
     if (isset($CFG_GLPI["languages"][$trytoload])) {
         $newfile = "/locales/" . $CFG_GLPI["languages"][$trytoload][1];
     }
     if (empty($newfile) || !is_file(GLPI_ROOT . $newfile)) {
         $newfile = "/locales/en_GB.mo";
     }
     if (isset($CFG_GLPI["languages"][$trytoload][5])) {
         $_SESSION['glpipluralnumber'] = $CFG_GLPI["languages"][$trytoload][5];
     }
     $TRANSLATE = new Zend\I18n\Translator\Translator();
     try {
         $cache = Zend\Cache\StorageFactory::factory(array('adapter' => 'apc'));
         $TRANSLATE->setCache($cache);
     } catch (Zend\Cache\Exception\ExtensionNotLoadedException $e) {
         // ignore when APC not available
         // toolbox::logDebug($e->getMessage());
     }
     $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT . $newfile, 'glpi', $trytoload);
     // Load plugin dicts
     if (isset($_SESSION['glpi_plugins']) && is_array($_SESSION['glpi_plugins'])) {
         if (count($_SESSION['glpi_plugins'])) {
             foreach ($_SESSION['glpi_plugins'] as $plug) {
                 Plugin::loadLang($plug, $forcelang, $trytoload);
             }
         }
     }
     // TRANSLATION_MODE deleted : maybe find another solution ?
     // Debug display lang element with item
     //       if ($_SESSION['glpi_use_mode'] == Session::TRANSLATION_MODE && $CFG_GLPI["debug_lang"]) {
     //          foreach ($LANG as $module => $tab) {
     //             foreach ($tab as $num => $val) {
     //                $LANG[$module][$num] = "".$LANG[$module][$num].
     //                                       "/<span style='font-size:12px; color:red;'>$module/$num</span>";
     //             }
     //          }
     //       }
     $TRANSLATE->setLocale($trytoload);
     return $trytoload;
 }
Ejemplo n.º 10
0
 /**
  * Include the good language dict.
  *
  * Get the default language from current user in $_SESSION["glpilanguage"].
  * And load the dict that correspond.
  *
  * @param $forcelang Force to load a specific lang (default '')
  *
  * @return nothing (make an include)
  **/
 static function loadLanguage($forcelang = '')
 {
     global $LANG, $CFG_GLPI, $TRANSLATE;
     $file = "";
     if (!isset($_SESSION["glpilanguage"])) {
         if (isset($CFG_GLPI["language"])) {
             // Default config in GLPI >= 0.72
             $_SESSION["glpilanguage"] = $CFG_GLPI["language"];
         } else {
             if (isset($CFG_GLPI["default_language"])) {
                 // Default config in GLPI < 0.72 : keep it for upgrade process
                 $_SESSION["glpilanguage"] = $CFG_GLPI["default_language"];
             } else {
                 $_SESSION["glpilanguage"] = "en_GB";
             }
         }
     }
     $trytoload = $_SESSION["glpilanguage"];
     // Force to load a specific lang
     if (!empty($forcelang)) {
         $trytoload = $forcelang;
     }
     // If not set try default lang file
     if (empty($trytoload)) {
         $trytoload = $CFG_GLPI["language"];
     }
     if (isset($CFG_GLPI["languages"][$trytoload])) {
         $newfile = "/locales/" . $CFG_GLPI["languages"][$trytoload][1];
     }
     if (empty($newfile) || !is_file(GLPI_ROOT . $newfile)) {
         $newfile = "/locales/en_GB.mo";
     }
     $TRANSLATE = new Zend\I18n\Translator\Translator();
     try {
         $cache = Zend\Cache\StorageFactory::factory(array('adapter' => 'apc'));
         $TRANSLATE->setCache($cache);
     } catch (Zend\Cache\Exception\ExtensionNotLoadedException $e) {
         // ignore when APC not available
         // toolbox::logDebug($e->getMessage());
     }
     $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT . $newfile, 'glpi', $trytoload);
     // Test APC version, if is enable with special check for cli
     //      if (version_compare(phpversion('apc'), '3.1.6') >= 0
     //          && ini_get('apc.enabled')
     //          && (!isCommandLine() || ini_get('apc.enable_cli'))) { // Try from APC cache
     ////          $key       = "glpi".sha1_file(GLPI_ROOT.$newfile); // Use content to detect changes
     //         $cache = Zend\Cache\StorageFactory::factory(array('adapter' => 'apc',
     //                                                           'plugins' => array('exception_handler'
     //                                                                               => array('throw_exceptions'
     //                                                                                         => false))));
     //         $TRANSLATE->setCache($cache);
     //         $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
     //
     //      } else if (function_exists('xcache_get') && !isCommandLine()) { // Try from XCache
     //         // TODO : use xcache adapter of Zend when available (2.1)
     //         // see http://framework.zend.com/issues/browse/ZF2-543
     //         $key = "glpi".sha1_file(GLPI_ROOT.$newfile); // Use content to detect changes
     //         if (@xcache_isset($key)) {
     //            $TRANSLATE = unserialize(xcache_get($key));
     //         }
     //         if (!$TRANSLATE) {
     //            $TRANSLATE = new Zend\I18n\Translator\Translator;
     //            $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
     //         }
     //         $tmp = xcache_set($key, serialize($TRANSLATE));
     //      } else {
     //         $TRANSLATE = new Zend\I18n\Translator\Translator;
     //         $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
     //      }
     // Load plugin dicts
     if (isset($_SESSION['glpi_plugins']) && is_array($_SESSION['glpi_plugins'])) {
         if (count($_SESSION['glpi_plugins'])) {
             foreach ($_SESSION['glpi_plugins'] as $plug) {
                 Plugin::loadLang($plug, $forcelang, $trytoload);
             }
         }
     }
     // TRANSLATION_MODE deleted : maybe find another solution ?
     // Debug display lang element with item
     //       if ($_SESSION['glpi_use_mode'] == Session::TRANSLATION_MODE && $CFG_GLPI["debug_lang"]) {
     //          foreach ($LANG as $module => $tab) {
     //             foreach ($tab as $num => $val) {
     //                $LANG[$module][$num] = "".$LANG[$module][$num].
     //                                       "/<span style='font-size:12px; color:red;'>$module/$num</span>";
     //             }
     //          }
     //       }
     $TRANSLATE->setLocale($trytoload);
     return $trytoload;
 }
Ejemplo n.º 11
0
<?php

require_once './autoloader.php';
$translator = Zend\I18n\Translator\Translator::factory(array('locale' => 'zh', 'translation_file_patterns' => array('zf' => array('type' => 'PhpArray', 'base_dir' => EVA_LIB_PATH . '/Zend/resources/languages/', 'pattern' => '%s/Zend_Validate.php'))));
\Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
class NewForm extends \Eva\Form\Form
{
    /**
     * Form basic elements
     *
     * @var array
     */
    protected $baseElements = array('username' => array('name' => 'username', 'type' => 'hidden', 'options' => array('label' => 'Username'), 'attributes' => array('value' => '')));
    /**
     * Form basic Validators
     *
     * @var array
     */
    protected $baseFilters = array('username' => array('name' => 'username', 'required' => true, 'filters' => array(), 'validators' => array()));
}
$form = new \NewForm();
$form->setData(array('username' => ''));
$form->isValid();
p($form->getMessages());
Ejemplo n.º 12
0
<?php

// TODO revoir la traduction
$translator = new \Zend\I18n\Translator\Translator();
return array('backend-nav' => array(array('label' => $translator->translate('Accueil'), 'route' => 'backend-index', 'action' => 'index'), array('label' => $translator->translate('Pages'), 'route' => null, 'action' => 'index', 'pages' => array(array('label' => $translator->translate('Home page'), 'route' => 'backend-pages', 'action' => 'index'), array('label' => $translator->translate('A propos'), 'route' => 'backend-pages', 'action' => 'apropos'), array('label' => $translator->translate('Discord Bot'), 'route' => 'backend-pages', 'action' => 'discordbot'), array('label' => $translator->translate("L'Equipe"), 'route' => 'backend-pages', 'action' => 'team'), array('label' => $translator->translate("Articles"), 'route' => 'backend-pages', 'action' => 'articles'))), array('label' => $translator->translate('Personnage'), 'route' => null, 'action' => 'index', 'pages' => array(array('label' => $translator->translate('Factions'), 'route' => 'backend-faction-list', 'action' => 'index'), array('label' => $translator->translate('Races'), 'route' => 'backend-race-list', 'action' => 'index'), array('label' => $translator->translate('Classes'), 'route' => 'backend-classes-list', 'action' => 'index'), array('label' => $translator->translate('Roles'), 'route' => 'backend-role-list', 'action' => 'index'), array('label' => $translator->translate('Spécialisations'), 'route' => 'backend-specialisation-list', 'action' => 'index'), array('label' => $translator->translate('Personnages'), 'route' => 'backend-personnages-list', 'action' => 'index'))), array('label' => $translator->translate('Raid'), 'route' => null, 'action' => 'index', 'pages' => array(array('label' => $translator->translate('Palliers'), 'route' => 'backend-pallier-afficher-list', 'action' => 'index'), array('label' => $translator->translate('Zone'), 'route' => 'backend-zone-list', 'action' => 'index'), array('label' => $translator->translate('Raids'), 'route' => 'backend-raids-list', 'action' => 'index'), array('label' => $translator->translate('Modes de difficulté'), 'route' => 'backend-mode_difficulte-list', 'action' => 'index'), array('label' => $translator->translate('Boss'), 'route' => 'backend-bosses-list', 'action' => 'index'), array('label' => $translator->translate('Items'), 'route' => 'backend-items-list', 'action' => 'index'), array('label' => $translator->translate('Items - pers - raid - boss'), 'route' => 'backend-item-personnage-raid-list', 'action' => 'index'))), array('label' => $translator->translate('Evenements'), 'route' => 'backend-evenements-list', 'action' => 'index'), array('label' => $translator->translate('Guildes'), 'route' => 'backend-guildes-list', 'action' => 'index'), array('label' => $translator->translate('Npc'), 'route' => 'backend-npc-list', 'action' => 'index'), array('label' => $translator->translate('Roster'), 'route' => 'backend-roster-list', 'action' => 'index'), array('label' => $translator->translate('Utilisateurs'), 'route' => 'backend-users-list', 'action' => 'index')));
Ejemplo n.º 13
0
<?php

require_once './autoloader.php';
$translator = Zend\I18n\Translator\Translator::factory(array('locale' => 'jp', 'translation_patterns' => array(array('type' => 'phparray', 'base_dir' => __DIR__ . '/_files', 'pattern' => 'translation-%s.php'))));
echo $translator->translate('Dream');
<?php

$translator = new \Zend\I18n\Translator\Translator();
return ['navigation' => ['default' => [['label' => $translator->translate('Users Admin'), 'route' => 'users-admin', 'controller' => 'manage', 'action' => 'index', 'resource' => 'UsersAdmin.manage.index']]]];
<?php

// TODO revoir la traduction
$translator = new \Zend\I18n\Translator\Translator();
return array('frontend' => array(array('label' => $translator->translate('Accueil'), 'route' => 'home', 'action' => 'index'), array('label' => $translator->translate('Raid'), 'route' => 'raid-list', 'action' => 'index')));
Ejemplo n.º 16
0
 /**
  * 国际化
  *
  */
 public function _initTranslator()
 {
     $lang = new Zend\I18n\Translator\Translator();
     $lang->setLocale('zh_CN');
     $lang->addTranslationFilePattern('phparray', APP_PATH . DS . 'application' . DS . 'language', '%s.php');
     Yaf\Registry::set('lang', $lang);
     unset($lang);
 }