Beispiel #1
0
 /**
  * @param mixed $data
  * @return $this
  */
 public function setDataFromEditmode($data)
 {
     $rewritePath = function ($data) {
         if (!is_array($data)) {
             return array();
         }
         foreach ($data as &$element) {
             if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) {
                 foreach ($element["data"] as &$metaData) {
                     $metaData = new Element\Data\MarkerHotspotItem($metaData);
                     if (in_array($metaData["type"], array("object", "asset", "document"))) {
                         $el = Element\Service::getElementByPath($metaData["type"], $metaData->getValue());
                         $metaData["value"] = $el;
                     }
                 }
             }
         }
         return $data;
     };
     if (is_array($data)) {
         if (array_key_exists("marker", $data) && is_array($data["marker"]) && count($data["marker"]) > 0) {
             $data["marker"] = $rewritePath($data["marker"]);
         }
         if (array_key_exists("hotspots", $data) && is_array($data["hotspots"]) && count($data["hotspots"]) > 0) {
             $data["hotspots"] = $rewritePath($data["hotspots"]);
         }
         $this->id = $data["id"];
         $this->alt = $data["alt"];
         $this->cropPercent = $data["cropPercent"];
         $this->cropWidth = $data["cropWidth"];
         $this->cropHeight = $data["cropHeight"];
         $this->cropTop = $data["cropTop"];
         $this->cropLeft = $data["cropLeft"];
         $this->marker = $data["marker"];
         $this->hotspots = $data["hotspots"];
     }
     return $this;
 }
Beispiel #2
0
 /**
  * @see Model\Object\ClassDefinition\Data::getDataFromEditmode
  * @param Object\Data\Hotspotimage $data
  * @param null|Model\Object\AbstractObject $object
  * @return Asset
  */
 public function getDataFromEditmode($data, $object = null)
 {
     $rewritePath = function ($data) {
         if (!is_array($data)) {
             return array();
         }
         foreach ($data as &$element) {
             if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) {
                 foreach ($element["data"] as &$metaData) {
                     $metaData = new Element\Data\MarkerHotspotItem($metaData);
                     if (in_array($metaData["type"], array("object", "asset", "document"))) {
                         $el = Element\Service::getElementByPath($metaData["type"], $metaData->getValue());
                         $metaData["value"] = $el;
                     }
                 }
             }
         }
         return $data;
     };
     if (array_key_exists("marker", $data) && is_array($data["marker"]) && count($data["marker"]) > 0) {
         $data["marker"] = $rewritePath($data["marker"]);
     }
     if (array_key_exists("hotspots", $data) && is_array($data["hotspots"]) && count($data["hotspots"]) > 0) {
         $data["hotspots"] = $rewritePath($data["hotspots"]);
     }
     return new Object\Data\Hotspotimage($data["image"], $data["hotspots"], $data["marker"], $data["crop"]);
 }