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)); } }
/** * 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(); } } } } }
/** * return the available languages from registry, database or chache * @return <Array> languages */ private function getLanguages() { return Application_Form_Element_Language::getLanguageList(); }