Exemplo n.º 1
0
 function setupData($data)
 {
     maxUtils::addTime("Button: Setup data");
     foreach ($this->blocks as $block) {
         if (array_key_exists($block, $data)) {
             $this->data[$block] = maybe_unserialize($data[$block]);
             // allow to feed unserialized stuff not from dbase
             if (!is_array($this->data[$block])) {
                 $this->data[$block] = json_decode($data[$block], true);
             }
         } else {
             // else block does not exist in this dataset - ignoring.
             //exit("Fatal: Something wrong with provider on $block ");
         }
     }
     $this->id = $data["id"];
     $this->document_id = maxButtons::getDocumentID(array("button_id" => $this->id));
     $this->cache = isset($data["cache"]) ? trim($data["cache"]) : '';
     // not set at button packs / non-dbase buttons!
     $this->data["id"] = $this->id;
     // needed for certain blocks, to be button aware.
     $this->data["document_id"] = $this->document_id;
     // bound to JS and others.
     $this->name = $data["name"];
     $this->status = $data["status"];
     $this->description = $this->data["basic"]["description"];
     do_action('mb-data-load', $this->data);
     return true;
 }