/** * @param $multiline boolean keep this value empty, it is not used because the @multiline * annotation is automatically used * @param $values string[] keep this value empty, it is not used because the @values annotation * is automatically used * @return Element */ protected function buildString($multiline = false, $values = null) { $values_captions = []; $values = $this->property->getListAnnotation('values')->values(); foreach ($values as $value) { $values_captions[$value] = Names::propertyToDisplay($value); } if ($values_captions && !in_array($this->value, $values_captions)) { $values_captions[$this->value] = $this->value; } $element = parent::buildString($this->property->getAnnotation('multiline')->value, $values_captions); if ($this->property->getAnnotation('mandatory')->value) { $element->setAttribute('required', true); } if ($this->property->getAnnotation('password')->value) { $element->setAttribute('type', 'password'); $element->setAttribute('value', strlen($this->value) ? Password::UNCHANGED : ''); } return $element; }
/** * 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; }
/** * @param $object object * @return string HTML combo-box with filters */ protected function getCombo($object) { $class_name = get_class($object); $edit = new Html_Builder_Type('replace_with', new Type($class_name), Builder::create($class_name)); return $edit->buildObject(null, $this->getFilters($object)); }