Beispiel #1
0
 /**
  * @param $configuration array
  */
 public function __construct($configuration = [])
 {
     foreach ($configuration as $block_key => $items) {
         if ($block_key == self::TITLE) {
             foreach ($items as $item) {
                 if (substr($item, 0, 1) == SL) {
                     $this->title_link = $item;
                 } elseif (substr($item, 0, 1) == '#') {
                     $this->title_link_target = $item;
                 } else {
                     $this->title = $item;
                 }
             }
         } else {
             $block = new Block();
             if (substr($block_key, 0, 1) == SL) {
                 $block->title_link = $block_key;
             } else {
                 $block->title = $block_key;
             }
             foreach ($items as $item_key => $item) {
                 if ($item_key == self::MODULE) {
                     $block->module = $item;
                 } elseif ($item_key == self::TITLE) {
                     $block->title = $item;
                 } elseif ($item_key == self::LINK) {
                     $block->title_link = $item;
                 } elseif ($item_key == self::TARGET) {
                     $block->title_link_target = $item;
                 } else {
                     $menu_item = new Item();
                     $menu_item->link = $item_key;
                     if (is_array($item)) {
                         foreach ($item as $property_key => $property) {
                             if (is_numeric($property_key)) {
                                 if (substr($property, 0, 1) == SL) {
                                     $menu_item->link = $property;
                                 } elseif (substr($property, 0, 1) == '#') {
                                     $menu_item->link_target = $property;
                                 } else {
                                     $menu_item->caption = $property;
                                 }
                             }
                         }
                     } else {
                         $menu_item->caption = $item;
                     }
                     $block->items[] = $menu_item;
                 }
             }
             if (!isset($block->module)) {
                 $block->module = Names::displayToProperty($block_key);
             }
             $this->blocks[] = $block;
         }
     }
 }
Beispiel #2
0
 /**
  * return @string
  */
 public function getName()
 {
     return Names::displayToProperty($this->title);
 }
Beispiel #3
0
 /**
  * @param $class_name              string
  * @param $property_path           string
  * @param $use_reverse_translation boolean if true, will try reverse translation of property names
  * @param $properties_alias        string[] $property_path = string[string $property_alias]
  * @return string
  */
 public static function propertyPathOf($class_name, $property_path, $use_reverse_translation = false, $properties_alias = null)
 {
     if (isset($properties_alias) && isset($properties_alias[$property_path])) {
         $property_path = $properties_alias[$property_path];
     } elseif ($use_reverse_translation) {
         $property_class_name = $class_name;
         $property_names = [];
         foreach (explode(DOT, $property_path) as $property_name) {
             if ($asterisk = substr($property_name, -1) == '*') {
                 $property_name = substr($property_name, 0, -1);
             }
             $property = null;
             $property_name = Names::displayToProperty($property_name);
             try {
                 $property = new Reflection_Property($property_class_name, $property_name);
             } catch (ReflectionException $e) {
                 $translated_property_name = Names::displayToProperty(Loc::rtr($property_name, $property_class_name));
                 try {
                     $property = new Reflection_Property($property_class_name, $translated_property_name);
                     $property_name = $translated_property_name;
                 } catch (ReflectionException $e) {
                 }
             }
             $property_names[] = $property_name . ($asterisk ? '*' : '');
             if (!isset($property)) {
                 break;
             }
             $property_class_name = $property->getType()->getElementTypeAsString();
         }
         $property_path = join(DOT, $property_names);
     }
     return $property_path;
 }