Admin_AssetController::getTreeNodeConfig PHP Метод

getTreeNodeConfig() защищенный Метод

protected getTreeNodeConfig ( $element ) : array
$element
Результат array
    protected function getTreeNodeConfig($element)
    {
        $asset = $element;
        $tmpAsset = ["id" => $asset->getId(), "text" => $asset->getFilename(), "type" => $asset->getType(), "path" => $asset->getRealFullPath(), "basePath" => $asset->getRealPath(), "locked" => $asset->isLocked(), "lockOwner" => $asset->getLocked() ? true : false, "elementType" => "asset", "permissions" => ["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["loaded"] = $asset->hasNoChilds();
            $tmpAsset["iconCls"] = "pimcore_icon_folder";
            $tmpAsset["permissions"]["create"] = $asset->isAllowed("create");
            $folderThumbs = [];
            $children = new Asset\Listing();
            $children->setCondition("path LIKE ?", [$asset->getRealFullPath() . "/%"]);
            $children->setLimit(35);
            foreach ($children as $child) {
                if ($child->isAllowed("view")) {
                    if ($thumbnailUrl = $this->getThumbnailUrl($child)) {
                        $folderThumbs[] = $thumbnailUrl;
                    }
                }
            }
            if (!empty($folderThumbs)) {
                $tmpAsset["thumbnails"] = $folderThumbs;
            }
        } else {
            $tmpAsset["leaf"] = true;
            $tmpAsset["expandable"] = false;
            $tmpAsset["expanded"] = false;
            $tmpAsset["iconCls"] = "pimcore_icon_asset_default";
            $fileExt = File::getFileExtension($asset->getFilename());
            if ($fileExt) {
                $tmpAsset["iconCls"] .= " pimcore_icon_" . File::getFileExtension($asset->getFilename());
            }
        }
        $tmpAsset["qtipCfg"] = ["title" => "ID: " . $asset->getId()];
        if ($asset->getType() == "image") {
            try {
                $tmpAsset["thumbnail"] = $this->getThumbnailUrl($asset);
                // this is for backward-compatibility, to calculate the dimensions if they are not there
                if (!$asset->getCustomSetting("imageDimensionsCalculated")) {
                    $asset->save();
                }
                // we need the dimensions for the wysiwyg editors, so that they can resize the image immediately
                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.");
            }
        } elseif ($asset->getType() == "video") {
            try {
                if (\Pimcore\Video::isAvailable()) {
                    $tmpAsset["thumbnail"] = $this->getThumbnailUrl($asset);
                }
            } catch (\Exception $e) {
                Logger::debug("Cannot get dimensions of video, seems to be broken.");
            }
        } elseif ($asset->getType() == "document") {
            try {
                // add the PDF check here, otherwise the preview layer in admin is shown without content
                if (\Pimcore\Document::isAvailable() && \Pimcore\Document::isFileTypeSupported($asset->getFilename())) {
                    $tmpAsset["thumbnail"] = $this->getThumbnailUrl($asset);
                }
            } 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;
    }