Пример #1
0
 /**
  * Parse a variable / function / include and returns its return value
  *
  * @param $property_name string can be an unique var or path.of.vars
  * @param $format_value  boolean
  * @return string var value after reading value / executing specs (can be an object)
  */
 protected function parseSingleValue($property_name, $format_value = true)
 {
     $property = $source_object = reset($this->objects);
     if ($property instanceof Reflection_Property_Value && $property_name == 'value') {
         if (($builder = $property->getAnnotation('widget')->value) && is_a($builder, Property::class, true)) {
             $builder = Builder::create($builder, [$property, $property->value(), $this]);
             /** @var $builder Property */
             $builder->parameters[Feature::F_EDIT] = Feature::F_EDIT;
             $value = $builder->buildHtml();
             if ($builder instanceof Value_Widget) {
                 $value = (new Html_Builder_Property($property, $value))->setTemplate($this)->build();
             }
         } else {
             $value = $property->getType()->isBoolean() ? $property->value() : parent::parseSingleValue($property_name, false);
             if (($preprop = lLastParse($property->pathAsField(), '[', 1, false)) && (!isset($this->cache[self::PARSED_ID]) || !isset($this->cache[self::PARSED_ID][$this->getFormId()]) || !isset($this->cache[self::PARSED_ID][$this->getFormId()][$preprop]))) {
                 $this->cache[self::PARSED_ID][$this->getFormId()][$preprop] = true;
                 if ($property instanceof Reflection_Property_Value) {
                     $parent_object = $property->getObject();
                     $id = isset($parent_object) ? Dao::getObjectIdentifier($parent_object) : null;
                     $html_builder_type = new Html_Builder_Type('id', null, $id, $preprop);
                     $id_value = $html_builder_type->setTemplate($this)->build();
                 } else {
                     $id_value = '';
                 }
             } else {
                 $id_value = '';
             }
             if ($property->getAnnotation('output')->value == 'string') {
                 $property->setAnnotationLocal('var')->value = 'string';
                 $value = isset($value) ? strval($value) : null;
                 $id_value = '';
             }
             $value = $id_value . (new Html_Builder_Property($property, $value))->setTemplate($this)->build();
         }
     } else {
         $value = parent::parseSingleValue($property_name);
     }
     return $value;
 }
Пример #2
0
 /**
  * Returns template's top object
  * (use it inside of loops)
  *
  * @param $template Template
  * @return object
  */
 public function getTop(Template $template)
 {
     return $template->getObject();
 }