Esempio n. 1
0
 /**
  * Checks if string field value is a valid language code.
  *
  * @param string  $fieldName     The name of the property to be checked
  * @param boolean $onlyInstalled Whether to accept only installed languages (default false)
  * @return boolean result of this check
  */
 public function isValidLanguage($fieldName, $onlyInstalled = false)
 {
     $languageMap = ZLanguage::languagemap();
     $result = in_array($this->entity[$fieldName], array_keys($languageMap));
     if (!$result || !$onlyInstalled) {
         return $result;
     }
     $available = ZLanguage::getInstalledLanguages();
     return in_array($this->entity[$fieldName], $available);
 }