Ejemplo n.º 1
0
 public function testOptions()
 {
     $element = $this->getElement();
     $languages = Application_Form_Element_Language::getLanguageList();
     $this->assertEquals(count($languages), count($element->getMultiOptions()));
     foreach ($element->getMultiOptions() as $type => $label) {
         $this->assertTrue(array_key_exists($type, $languages));
     }
 }
Ejemplo n.º 2
0
 /**
  * Setup language list.
  *
  * @return void
  */
 public static function initLanguageList()
 {
     $translate = Zend_Registry::get(Application_Translate::REGISTRY_KEY);
     $languages = array();
     foreach (Opus_Language::getAllActiveTable() as $languageRow) {
         $langId = $languageRow['part2_t'];
         $languages[$langId] = $translate->translate($langId);
     }
     self::$_languageList = $languages;
     Zend_Registry::set('Available_Languages', $languages);
 }
Ejemplo n.º 3
0
 /**
  * Formats value that is instance of Opus_Model_Abstract.
  * @param Opus_Model_Abstract $field
  * @param string Name of model for field (default = null)
  * @return string Formatted output
  */
 public function formatModel($field, $model = null)
 {
     if ($field instanceof Opus_Date) {
         return $this->formatDate($field);
     } else {
         $modelClass = $field->getValueModelClass();
         $this->getLogger()->debug('Formatting field ' . $field->getName());
         if (!empty($modelClass)) {
             switch ($modelClass) {
                 case 'Opus_Date':
                     return $this->formatDate($field->getValue());
                 case 'Opus_DnbInstitute':
                     $value = $field->getValue();
                     if (isset($value[0])) {
                         return $value[0]->getName();
                     } else {
                         // Should never happen (DNB Institute without name),
                         // but in case it does:
                         return 'ERROR: DNB institute without name.';
                     }
                 default:
                     // Should never happen, but in case it does:
                     $this->getLogger()->err(__CLASS__ . ' Trying to format unknown model ' . $modelClass);
                     return 'ERROR: Unknown model class (see log).';
             }
         } else {
             if ($field->isSelection()) {
                 Application_Form_Element_Language::getLanguageList();
                 // initializes language list translations
                 $value = $field->getValue();
                 $key = $this->_translation->getKeyForValue($model, $field->getName(), $value);
                 return $this->view->translate($key);
             } else {
                 if ($field->isCheckbox()) {
                     if ($field->getValue()) {
                         $key = 'Field_Value_True';
                     } else {
                         $key = 'Field_Value_False';
                     }
                     return $this->view->translate($key);
                 } else {
                     return $field->getValue();
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * return the available languages from registry, database or chache
  * @return <Array> languages
  */
 private function getLanguages()
 {
     return Application_Form_Element_Language::getLanguageList();
 }
 /**
  * Stellt die Übersetzungen auf English um.
  */
 public function useEnglish()
 {
     $session = new Zend_Session_Namespace();
     $session->language = 'en';
     Zend_Registry::get('Zend_Translate')->setLocale('en');
     Application_Form_Element_Language::initLanguageList();
 }