expandMetadataForEditmode() public static method

public static expandMetadataForEditmode ( $metadata ) : array
$metadata
return array
コード例 #1
0
ファイル: AssetController.php プロジェクト: solverat/pimcore
 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "asset")) {
         $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset")]);
     }
     Element\Editlock::lock($this->getParam("id"), "asset");
     $asset = Asset::getById(intval($this->getParam("id")));
     $asset = clone $asset;
     if (!$asset instanceof Asset) {
         $this->_helper->json(["success" => false, "message" => "asset doesn't exist"]);
     }
     $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata()));
     $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties()));
     //$asset->getVersions();
     $asset->getScheduledTasks();
     $asset->idPath = Element\Service::getIdPath($asset);
     $asset->userPermissions = $asset->getUserPermissions();
     $asset->setLocked($asset->isLocked());
     $asset->setParent(null);
     if ($asset instanceof Asset\Text) {
         $asset->data = $asset->getData();
     }
     if ($asset instanceof Asset\Image) {
         $imageInfo = [];
         if ($asset->getWidth() && $asset->getHeight()) {
             $imageInfo["dimensions"] = [];
             $imageInfo["dimensions"]["width"] = $asset->getWidth();
             $imageInfo["dimensions"]["height"] = $asset->getHeight();
         }
         if (function_exists("exif_read_data") && is_file($asset->getFileSystemPath())) {
             $supportedTypes = [IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM];
             if (in_array(@exif_imagetype($asset->getFileSystemPath()), $supportedTypes)) {
                 $exif = @exif_read_data($asset->getFileSystemPath());
                 if (is_array($exif)) {
                     $imageInfo["exif"] = [];
                     foreach ($exif as $name => $value) {
                         if (is_string($value) && strlen($value) < 50 || is_numeric($value)) {
                             // this is to ensure that the data can be converted to json (must be utf8)
                             if (mb_check_encoding($value, "UTF-8")) {
                                 $imageInfo["exif"][$name] = $value;
                             }
                         }
                     }
                 }
             }
         }
         $asset->imageInfo = $imageInfo;
     }
     $asset->setStream(null);
     //Hook for modifying return value - e.g. for changing permissions based on object data
     //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
     $returnValueContainer = new Model\Tool\Admin\EventDataContainer(object2array($asset));
     \Pimcore::getEventManager()->trigger("admin.asset.get.preSendData", $this, ["asset" => $asset, "returnValueContainer" => $returnValueContainer]);
     if ($asset->isAllowed("view")) {
         $this->_helper->json($returnValueContainer->getData());
     }
     $this->_helper->json(["success" => false, "message" => "missing_permission"]);
 }
コード例 #2
0
 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "asset")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset")));
     }
     Element\Editlock::lock($this->getParam("id"), "asset");
     $asset = Asset::getById(intval($this->getParam("id")));
     if (!$asset instanceof Asset) {
         $this->_helper->json(array("success" => false, "message" => "asset doesn't exist"));
     }
     $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata()));
     $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties()));
     //$asset->getVersions();
     $asset->getScheduledTasks();
     $asset->idPath = Element\Service::getIdPath($asset);
     $asset->userPermissions = $asset->getUserPermissions();
     $asset->setLocked($asset->isLocked());
     $asset->setParent(null);
     if ($asset instanceof Asset\Text) {
         $asset->data = $asset->getData();
     }
     if ($asset instanceof Asset\Image) {
         $imageInfo = array();
         if ($asset->getWidth() && $asset->getHeight()) {
             $imageInfo["dimensions"] = array();
             $imageInfo["dimensions"]["width"] = $asset->getWidth();
             $imageInfo["dimensions"]["height"] = $asset->getHeight();
         }
         if (function_exists("exif_read_data") && is_file($asset->getFileSystemPath())) {
             $supportedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM);
             if (in_array(exif_imagetype($asset->getFileSystemPath()), $supportedTypes)) {
                 $exif = @exif_read_data($asset->getFileSystemPath());
                 if (is_array($exif)) {
                     $imageInfo["exif"] = array();
                     foreach ($exif as $name => $value) {
                         if (is_string($value) && strlen($value) < 50 || is_numeric($value)) {
                             // this is to ensure that the data can be converted to json (must be utf8)
                             if (mb_check_encoding($value, "UTF-8")) {
                                 $imageInfo["exif"][$name] = $value;
                             }
                         }
                     }
                 }
             }
         }
         $asset->imageInfo = $imageInfo;
     }
     $asset->setStream(null);
     if ($asset->isAllowed("view")) {
         $this->_helper->json($asset);
     }
     $this->_helper->json(array("success" => false, "message" => "missing_permission"));
 }
コード例 #3
0
ファイル: AssetController.php プロジェクト: pimcore/pimcore
 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "asset")) {
         $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset")]);
     }
     Element\Editlock::lock($this->getParam("id"), "asset");
     $asset = Asset::getById(intval($this->getParam("id")));
     $asset = clone $asset;
     if (!$asset instanceof Asset) {
         $this->_helper->json(["success" => false, "message" => "asset doesn't exist"]);
     }
     $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata()));
     $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties()));
     //$asset->getVersions();
     $asset->getScheduledTasks();
     $asset->idPath = Element\Service::getIdPath($asset);
     $asset->userPermissions = $asset->getUserPermissions();
     $asset->setLocked($asset->isLocked());
     $asset->setParent(null);
     if ($asset instanceof Asset\Text) {
         $asset->data = $asset->getData();
     }
     if ($asset instanceof Asset\Image) {
         $imageInfo = [];
         if ($asset->getWidth() && $asset->getHeight()) {
             $imageInfo["dimensions"] = [];
             $imageInfo["dimensions"]["width"] = $asset->getWidth();
             $imageInfo["dimensions"]["height"] = $asset->getHeight();
         }
         $exifData = $asset->getEXIFData();
         if (!empty($exifData)) {
             $imageInfo["exif"] = $exifData;
         }
         $iptcData = $asset->getIPTCData();
         if (!empty($exifData)) {
             $imageInfo["iptc"] = $iptcData;
         }
         $imageInfo["exiftoolAvailable"] = (bool) \Pimcore\Tool\Console::getExecutable("exiftool");
         $asset->imageInfo = $imageInfo;
     }
     $asset->setStream(null);
     //Hook for modifying return value - e.g. for changing permissions based on object data
     //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
     $returnValueContainer = new Model\Tool\Admin\EventDataContainer(object2array($asset));
     \Pimcore::getEventManager()->trigger("admin.asset.get.preSendData", $this, ["asset" => $asset, "returnValueContainer" => $returnValueContainer]);
     if ($asset->isAllowed("view")) {
         $this->_helper->json($returnValueContainer->getData());
     }
     $this->_helper->json(["success" => false, "message" => "missing_permission"]);
 }