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->setProperties(Element_Service::minimizePropertiesForEditmode($asset->getProperties())); $asset->getVersions(); $asset->getScheduledTasks(); $asset->idPath = Pimcore_Tool::getIdPathForElement($asset); $asset->userPermissions = $asset->getUserPermissions(); $asset->setLocked($asset->isLocked()); if ($asset instanceof Asset_Text) { $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)) { $imageInfo["exif"][$name] = $value; } } } } } $asset->imageInfo = $imageInfo; } if ($asset->isAllowed("view")) { $this->_helper->json($asset); } $this->_helper->json(array("success" => false, "message" => "missing_permission")); }
public function getFolderAction() { // check for lock if (Element_Editlock::isLocked($this->_getParam("id"), "object")) { $this->_helper->json(array("editlock" => Element_Editlock::getByElement($this->_getParam("id"), "object"))); } Element_Editlock::lock($this->_getParam("id"), "object"); $object = Object_Abstract::getById(intval($this->_getParam("id"))); if ($object->isAllowed("view")) { $objectData = array(); $objectData["general"] = array(); $objectData["idPath"] = Pimcore_Tool::getIdPathForElement($object); $allowedKeys = array("o_published", "o_key", "o_id", "o_type"); foreach (get_object_vars($object) as $key => $value) { if (strstr($key, "o_") && in_array($key, $allowedKeys)) { $objectData["general"][$key] = $value; } } $objectData["general"]["o_locked"] = $object->isLocked(); $objectData["properties"] = Element_Service::minimizePropertiesForEditmode($object->getProperties()); $objectData["userPermissions"] = $object->getUserPermissions(); $objectData["classes"] = $object->getResource()->getClasses(); $this->_helper->json($objectData); } else { Logger::debug("prevented getting folder id [ " . $object->getId() . " ] because of missing permissions"); $this->_helper->json(array("success" => false, "message" => "missing_permission")); } }
protected function minimizeProperties($document) { $properties = Element_Service::minimizePropertiesForEditmode($document->getProperties()); $document->setProperties($properties); }