コード例 #1
0
ファイル: DataObject.inc.php プロジェクト: alenoosh/ojs
 function &getLocalizedData($key)
 {
     $localePrecedence = Locale::getLocalePrecedence();
     foreach ($localePrecedence as $locale) {
         $value =& $this->getData($key, $locale);
         if (!empty($value)) {
             return $value;
         }
         unset($value);
     }
     // Fallback: Get the first available piece of data.
     $data =& $this->getData($key, null);
     if (!empty($data)) {
         return $data[array_shift(array_keys($data))];
     }
     // No data available; return null.
     unset($data);
     $data = null;
     return $data;
 }
コード例 #2
0
 /**
  * Get a piece of data for this object, localized to the current
  * locale if possible.
  * @param $key string
  * @return mixed
  */
 function &getLocalizedData($key)
 {
     $localePrecedence = Locale::getLocalePrecedence();
     foreach ($localePrecedence as $locale) {
         $value =& $this->getData($key, $locale);
         if (!empty($value)) {
             return $value;
         }
         unset($value);
     }
     // Fallback: Get the first available piece of data.
     $data =& $this->getData($key, null);
     if (!empty($data)) {
         // WARNING: Collapsing the following into a single line causes PHP 5.0.5 to die.
         $locales = array_keys($data);
         $firstLocale = array_shift($locales);
         return $data[$firstLocale];
     }
     // No data available; return null.
     unset($data);
     $data = null;
     return $data;
 }