Example #1
0
 /**
  * @param $class_name         string
  * @param $search             string
  * @param $exclude_properties string[]
  * @param $prefix             string
  * @param $depth              integer
  * @return Reflection_Property[]
  */
 protected function searchProperties($class_name, $search, $exclude_properties = [], $prefix = '', $depth = 0)
 {
     $class = new Reflection_Class($class_name);
     $all_properties = $this->getProperties($class);
     $first_properties = [];
     $properties = [];
     $more_properties = [];
     foreach ($all_properties as $property) {
         if (!isset($exclude_properties[$property->name])) {
             $property_path = $prefix . $property->name;
             if ($property->name == $search || $property_path == $search) {
                 $first_properties[$property_path] = $property;
                 $matches = true;
             } else {
                 preg_match('|^' . $search . '|', strtolower(strSimplify(Loc::tr($property->name), SP)), $matches);
                 preg_match('|^' . $search . '|', strtolower(strSimplify(Loc::tr($prefix . $property_path), DOT . SP)), $matches2);
                 if ($matches || $matches2) {
                     $properties[$property_path] = $property;
                     $matches = true;
                 } else {
                     preg_match('|' . $search . '|', strtolower(strSimplify(Loc::tr($property_path), DOT . SP)), $matches);
                     if ($matches) {
                         $more_properties[$property_path] = $property;
                     }
                 }
             }
             if ($depth < $this->max_depth && !$matches) {
                 $type = $property->getType();
                 if ($type->isClass()) {
                     $property_class = $type->getElementTypeAsString();
                     $is_component = isA($property_class, Component::class);
                     $exclude_sub_properties = $is_component ? call_user_func([$property_class, 'getCompositeProperties'], $class_name) : [];
                     $parent_classes[] = $class_name;
                     $sub_properties = $this->searchProperties($type->getElementTypeAsString(), $search, $exclude_sub_properties, $property->name . DOT, $depth + 1);
                     foreach ($sub_properties as $sub_property) {
                         if (!isset($exclude_properties[$sub_property->name])) {
                             $more_properties[] = new Reflection_Property($class_name, $property->name . DOT . $sub_property->path);
                         }
                     }
                 }
             }
         }
     }
     $properties = array_merge($first_properties, $properties, $more_properties);
     return $properties;
 }
Example #2
0
 /**
  * @return Head
  */
 protected function buildHead()
 {
     $head = new Head();
     $row = new Row();
     foreach ($this->properties as $property) {
         if (!$property->getType()->isMultiple() || $property->getType()->getElementTypeAsString() != $property->getFinalClass()->name) {
             $cell = new Header_Cell(Loc::tr(Names::propertyToDisplay($property->getAnnotation('alias')->value), $this->class_name));
             $row->addCell($cell);
         }
     }
     $head->addRow($row);
     return $head;
 }
Example #3
0
 /**
  * Translate content of html options in Html_Option objects
  *
  * @param $result string
  */
 public function translateOptionContent(&$result)
 {
     if (trim($result)) {
         $result = Loc::tr($result);
     }
 }
Example #4
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;
 }
Example #5
0
 /**
  * @return Head
  */
 protected function buildHead()
 {
     $head = new Head();
     $row = new Row();
     foreach ($this->properties as $property) {
         $cell = new Header_Cell(Loc::tr(Names::propertyToDisplay($property->getAnnotation('alias')->value), $this->class_name));
         $row->addCell($cell);
     }
     $head->addRow($row);
     return $head;
 }
Example #6
0
 /**
  * @param $csv_file string
  * @param $errors   string[]
  * @return array
  */
 public static function readCsvFile($csv_file, &$errors = [])
 {
     $lines = [];
     $row = 0;
     $f = fopen($csv_file, 'r');
     if ($f) {
         while ($buf = fgetcsv($f)) {
             $row++;
             if (($column = array_search('#REF!', $buf)) !== false) {
                 $column++;
                 $errors[] = str_replace(['$1', '$2'], [$row, $column], Loc::tr('unsolved reference at row $1 and column $2'));
             }
             $lines[] = $buf;
         }
     }
     fclose($f);
     return $lines;
 }