public function offsetSet($attribute, $value)
 {
     if ($attribute === 'value' || $attribute === self::DEFAULT_VALUE) {
         $this->dispatch_value($value, $attribute);
     } else {
         if ($attribute === 'name') {
             foreach ($this->elements as $identifier => $element) {
                 $element[$attribute] = $value . '[' . $identifier . ']';
             }
         }
     }
     parent::offsetSet($attribute, $value);
 }
 public function offsetSet($offset, $value)
 {
     if ($offset == 'name') {
         $is_suffix = $value[strlen($value) - 1] == '_';
         foreach ($this->children as $name => $child) {
             $child['name'] = $is_suffix ? $value . $name : $value . "[{$name}]";
         }
     } else {
         if ($offset == self::DEFAULT_VALUE && is_array($value)) {
             foreach ($value as $name => $default_value) {
                 if (empty($this->children[$name])) {
                     continue;
                 }
                 $this->children[$name][self::DEFAULT_VALUE] = $default_value;
             }
         }
     }
     parent::offsetSet($offset, $value);
 }
 public function offsetSet($offset, $value)
 {
     switch ($offset) {
         case self::DEFAULT_VALUE:
             $options = $value;
             if (is_string($options)) {
                 $options = json_decode($options);
             }
             foreach ($options as $identifier => $v) {
                 if (empty($this->elements[$identifier])) {
                     continue;
                 }
                 $element[$offset] = $v;
             }
             break;
         case 'name':
             foreach ($this->elements as $identifier => $element) {
                 $element[$offset] = $value . '[' . $identifier . ']';
             }
             break;
         case 'value':
             $options = $value;
             if (is_string($options)) {
                 $options = json_decode($options);
             }
             if (!$options) {
                 break;
             }
             foreach ($options as $identifier => $v) {
                 if (empty($this->elements[$identifier])) {
                     continue;
                 }
                 // FIXME-20110518: use handle_value() ?
                 $this->elements[$identifier][$identifier == 'interlace' || $identifier == 'no-upscale' ? 'checked' : 'value'] = $v;
             }
             break;
     }
     parent::offsetSet($offset, $value);
 }
Exemple #4
0
 public function offsetSet($attribute, $value)
 {
     global $core;
     if ($attribute == 'value' && $value && !$value instanceof Photo) {
         $value = $core->models['images.albums/photos'][$value];
         if ($value) {
             foreach ($value->to_array() as $name => $v) {
                 if (empty($this->elements[$name])) {
                     continue;
                 }
                 $this->elements[$name]['value'] = $v;
             }
         }
     }
     parent::offsetSet($attribute, $value);
 }