Example #1
0
 /**
  * Returns a children by the filename
  *
  * @param string $asset
  * @return array
  */
 function getChild($name)
 {
     $nameParts = explode("/", $name);
     $name = Pimcore_File::getValidFilename($nameParts[count($nameParts) - 1]);
     //$name = implode("/",$nameParts);
     if (is_string($name)) {
         $parentPath = $this->asset->getFullPath();
         if ($parentPath == "/") {
             $parentPath = "";
         }
         if (!($asset = Asset::getByPath($parentPath . "/" . $name))) {
             throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
         }
     } else {
         if ($name instanceof Asset) {
             $asset = $name;
         }
     }
     if ($asset instanceof Asset) {
         if ($asset->getType() == "folder") {
             return new Asset_WebDAV_Folder($asset);
         } else {
             return new Asset_WebDAV_File($asset);
         }
     }
     throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
 }
Example #2
0
 /**
  * @param Document|Asset|Object_Abstract $element
  * @return array
  */
 public static function getDependencyForFrontend($element)
 {
     if ($element instanceof Document) {
         return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "document", "subtype" => $element->getType());
     } else {
         if ($element instanceof Asset) {
             return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "asset", "subtype" => $element->getType());
         } else {
             if ($element instanceof Object_Abstract) {
                 return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "object", "subtype" => $element->geto_Type());
             }
         }
     }
 }
 /**
  * @param Asset $asset
  * @return array|string
  */
 protected function getTreeNodeConfig($asset)
 {
     $tmpAsset = array("id" => $asset->getId(), "text" => $asset->getFilename(), "type" => $asset->getType(), "path" => $asset->getFullPath(), "basePath" => $asset->getPath(), "locked" => $asset->isLocked(), "lockOwner" => $asset->getLocked() ? true : false, "elementType" => "asset", "permissions" => array("remove" => $asset->isAllowed("delete"), "settings" => $asset->isAllowed("settings"), "rename" => $asset->isAllowed("rename"), "publish" => $asset->isAllowed("publish"), "view" => $asset->isAllowed("view")));
     // set type specific settings
     if ($asset->getType() == "folder") {
         $tmpAsset["leaf"] = false;
         $tmpAsset["expanded"] = $asset->hasNoChilds();
         $tmpAsset["iconCls"] = "pimcore_icon_folder";
         $tmpAsset["permissions"]["create"] = $asset->isAllowed("create");
     } else {
         $tmpAsset["leaf"] = true;
         $tmpAsset["iconCls"] = "pimcore_icon_" . Pimcore_File::getFileExtension($asset->getFilename());
     }
     $tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId());
     if ($asset->getType() == "image") {
         try {
             $tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId(), "text" => '<img src="/admin/asset/get-image-thumbnail/id/' . $asset->getId() . '/width/130/aspectratio/true" width="130" />', "width" => 140);
             // this is for backward-compatibilty, to calculate the dimensions if they are not there
             if (!$asset->getCustomSetting("imageDimensionsCalculated")) {
                 $asset->save();
             }
             if ($asset->getCustomSetting("imageWidth") && $asset->getCustomSetting("imageHeight")) {
                 $tmpAsset["imageWidth"] = $asset->getCustomSetting("imageWidth");
                 $tmpAsset["imageHeight"] = $asset->getCustomSetting("imageHeight");
             }
         } catch (Exception $e) {
             Logger::debug("Cannot get dimensions of image, seems to be broken.");
         }
     } else {
         if ($asset->getType() == "video") {
             try {
                 if (Pimcore_Video::isAvailable()) {
                     $tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId(), "text" => '<img src="/admin/asset/get-video-thumbnail/id/' . $asset->getId() . '/width/130/aspectratio/true" width="130" />', "width" => 140);
                 }
             } catch (Exception $e) {
                 Logger::debug("Cannot get dimensions of video, seems to be broken.");
             }
         }
     }
     $tmpAsset["cls"] = "";
     if ($asset->isLocked()) {
         $tmpAsset["cls"] .= "pimcore_treenode_locked ";
     }
     if ($asset->getLocked()) {
         $tmpAsset["cls"] .= "pimcore_treenode_lockOwner ";
     }
     return $tmpAsset;
 }
Example #4
0
 /**
  * @see Object_Class_Data::getDataForEditmode
  * @param Asset|Document|Object_Abstract $data
  * @param null|Object_Abstract $object
  * @return array
  */
 public function getDataForEditmode($data, $object = null)
 {
     if ($data) {
         $r = array("id" => $data->getId(), "path" => $data->getFullPath());
         if ($data instanceof Document) {
             $r["subtype"] = $data->getType();
             $r["type"] = "document";
         } else {
             if ($data instanceof Asset) {
                 $r["subtype"] = $data->getType();
                 $r["type"] = "asset";
             } else {
                 if ($data instanceof Object_Abstract) {
                     $r["subtype"] = $data->getO_Type();
                     $r["type"] = "object";
                 }
             }
         }
         return $r;
     }
     return;
 }