Exemplo n.º 1
0
 /**
  * Sets parent based on default value
  */
 function set_parent($parent = null)
 {
     $p = $this->get_parent();
     if (empty($parent) && empty($p)) {
         $parent = 'text';
         $d = $this->get_default();
         if (is_bool($d)) {
             $parent = 'checkbox';
         }
         $parent = 'option_' . $parent;
     } elseif (!empty($p) && !is_object($p)) {
         $parent =& $p;
     }
     parent::set_parent($parent);
 }
Exemplo n.º 2
0
 /**
  * Sets an element for the field type
  * @param string $name Name of element
  * @param SLB_Field_Type $type Reference of field type to use for element
  * @param array $properties Properties for element (passed as keyed associative array)
  * @param string $id_prop Name of property to set $name to (e.g. ID, etc.)
  */
 function set_element($name, $type, $properties = array(), $id_prop = 'id')
 {
     $name = trim(strval($name));
     if (empty($name)) {
         return false;
     }
     //Create new field for element
     $el = new SLB_Field($name, $type);
     //Set container to current field instance
     $el->set_container($this);
     //Add properties to element
     $el->set_properties($properties);
     //Save element to current instance
     $this->elements[$name] =& $el;
 }
Exemplo n.º 3
0
 /**
  * Default placeholder processing
  * To be executed when current placeholder has not been handled by another handler
  * @param string $output Value to be used in place of placeholder
  * @param SLB_Field $item Field containing placeholder
  * @param array $placeholder Current placeholder
  * @see SLB_Field::parse_layout for structure of $placeholder array
  * @param string $layout Layout to build
  * @param array $data Extended data for item
  * @return string Value to use in place of current placeholder
  */
 function process_placeholder_default($output, $item, $placeholder, $layout, $data)
 {
     //Validate parameters before processing
     if (empty($output) && $item instanceof SLB_Field_Type && is_array($placeholder)) {
         //Build path to replacement data
         $output = $item->get_member_value($placeholder);
         //Check if value is group (properties, etc.)
         //All groups must have additional attributes (beyond reserved attributes) that define how items in group are used
         if (is_array($output) && !empty($placeholder['attributes']) && is_array($placeholder['attributes']) && ($ph = $item->get_placeholder_defaults()) && ($attribs = array_diff(array_keys($placeholder['attributes']), array_values($ph->reserved)))) {
             /* Targeted property is an array, but the placeholder contains additional options on how property is to be used */
             //Find items matching criteria in $output
             //Check for group criteria
             if ('properties' == $placeholder['tag'] && ($prop_group = $item->get_group($placeholder['attributes']['group'])) && !empty($prop_group)) {
                 /* Process group */
                 $group_out = array();
                 //Iterate through properties in group and build string
                 foreach (array_keys($prop_group) as $prop_key) {
                     $prop_val = $item->get_property($prop_key);
                     if (!is_null($prop_val)) {
                         $group_out[] = $prop_key . '="' . $prop_val . '"';
                     }
                 }
                 $output = implode(' ', $group_out);
             }
         } elseif (is_object($output) && $output instanceof $item->base_class) {
             /* Targeted property is actually a nested item */
             //Set caller to current item
             $output->set_caller($item);
             //Build layout for nested element
             $output = $output->build_layout($layout);
         }
     }
     return $output;
 }