Ejemplo n.º 1
0
 /**
  * Return the post data
  */
 public function getPostData()
 {
     if (isset($_POST[$this->name])) {
         $val = $_POST[$this->name];
         $className = $this->getClass() ? $this->getClass() : 'stdClass';
         $decoded = JSON_decode(stripslashes($val));
         unset($items);
         unset($obj_item);
         $items = array();
         if (is_array($decoded)) {
             foreach ($decoded as $std_object) {
                 $obj_item = new $className();
                 foreach ($std_object as $subkey => $value) {
                     // substitui pq o ttable gera com quebra de linha no multifield
                     $obj_item->{$subkey} = str_replace("\n", '', URLdecode($value));
                     // verifica se é um json
                     if (is_array(json_decode($obj_item->{$subkey}))) {
                         $content = json_decode($obj_item->{$subkey});
                         $return = array();
                         foreach ($content as $position) {
                             $return[$position->{'id'}] = $position->{'text'};
                         }
                         $obj_item->{$subkey} = $return;
                     }
                 }
                 $items[] = $obj_item;
             }
         }
         return $items;
     } else {
         return '';
     }
 }
Ejemplo n.º 2
0
 /**
  * Return the post data
  */
 public function getPostData()
 {
     if (isset($_POST[$this->name])) {
         $val = $_POST[$this->name];
         $className = $this->getClass() ? $this->getClass() : 'stdClass';
         $decoded = JSON_decode(stripslashes($val));
         unset($items);
         unset($obj_item);
         $items = array();
         foreach ($decoded as $std_object) {
             $obj_item = new $className();
             foreach ($std_object as $subkey => $value) {
                 //substitui pq o ttable gera com quebra de linha no multifield
                 //$obj_item->$subkey = URLdecode($value);
                 $obj_item->{$subkey} = str_replace("\n", '', URLdecode($value));
             }
             $items[] = $obj_item;
         }
         return $items;
     } else {
         return '';
     }
 }