Пример #1
0
 /**
  * @param $constants string[] key is the property path (can be translated or alias)
  */
 public function setConstants($constants)
 {
     $class_name = $this->getClassName();
     $properties_alias = Import_Array::getPropertiesAlias($class_name);
     $use_reverse_translation = Locale::current() ? true : false;
     foreach ($constants as $property_path => $value) {
         $property_path = Import_Array::propertyPathOf($class_name, $property_path, $use_reverse_translation, $properties_alias);
         $property_name = ($i = strrpos($property_path, DOT)) === false ? $property_path : substr($property_path, $i + 1);
         $master_path = substr($property_path, 0, $i);
         if (isset($this->classes[$master_path])) {
             $this->classes[$master_path]->constants[$property_name] = new Reflection_Property_Value($this->classes[$master_path]->class_name, $property_name, $value, true);
         }
     }
 }
Пример #2
0
 /**
  * @param $list_settings Data_List_Settings
  * @return string[] key is property path, value is title
  */
 protected function getTitles(Data_List_Settings $list_settings)
 {
     $locale = Locale::current();
     $titles = [];
     foreach ($list_settings->properties_path as $property_path) {
         $titles[$property_path] = str_replace('_', SP, isset($list_settings->properties_title[$property_path]) ? $list_settings->properties_title[$property_path] : (isset($locale) ? Loc::tr($property_path) : $property_path));
         $key = array_search($property_path, $list_settings->properties_path);
         if ($key !== false) {
             $titles[$key] = str_replace('_', SP, $titles[$property_path]);
         }
     }
     return $titles;
 }
Пример #3
0
 /**
  * Returns the properties paths list of the array
  *
  * The property list is the first or the second line of the array, depending on if the first line
  * is a class name or not.
  *
  * The cursor on $array is set to the row containing the properties path.
  *
  * @param $array      $value = string[integer $row_number][integer $column_number]
  * @param $class_name string class name : if set, will use current list settings properties alias
  * @return string[] $property_path = string[integer $column_number]
  */
 public static function getPropertiesFromArray(&$array, $class_name = null)
 {
     $use_reverse_translation = Locale::current() ? true : false;
     $properties_alias = isset($class_name) ? self::getPropertiesAlias($class_name) : null;
     self::addConstantsToArray(self::getConstantsFromArray($array), $array);
     $properties = [];
     foreach (current($array) as $column_number => $property_path) {
         if ($property_path) {
             $properties[$column_number] = self::propertyPathOf($class_name, $property_path, $use_reverse_translation, $properties_alias);
         }
     }
     return $properties;
 }
Пример #4
0
 /**
  * Translation
  *
  * @param $text    string
  * @param $context string
  * @return string
  */
 public static function tr($text, $context = '')
 {
     return Locale::current()->translations->translate($text, $context);
 }