/**
* @param $element
* @return array
*/
protected function getTreeNodeConfig($element)
{
$childDocument = $element;
$tmpDocument = array("id" => $childDocument->getId(), "text" => $childDocument->getKey(), "type" => $childDocument->getType(), "path" => $childDocument->getFullPath(), "basePath" => $childDocument->getPath(), "locked" => $childDocument->isLocked(), "lockOwner" => $childDocument->getLocked() ? true : false, "published" => $childDocument->isPublished(), "elementType" => "document", "leaf" => true, "permissions" => array("view" => $childDocument->isAllowed("view"), "remove" => $childDocument->isAllowed("delete"), "settings" => $childDocument->isAllowed("settings"), "rename" => $childDocument->isAllowed("rename"), "publish" => $childDocument->isAllowed("publish"), "unpublish" => $childDocument->isAllowed("unpublish")));
// add icon
$tmpDocument["iconCls"] = "pimcore_icon_" . $childDocument->getType();
if (\Pimcore\Tool\Admin::isExtJS5()) {
$tmpDocument["expandable"] = $childDocument->hasChilds();
}
// set type specific settings
if ($childDocument->getType() == "page") {
$tmpDocument["leaf"] = false;
$tmpDocument["expanded"] = $childDocument->hasNoChilds();
$tmpDocument["permissions"]["create"] = $childDocument->isAllowed("create");
$tmpDocument["iconCls"] = "pimcore_icon_page";
// test for a site
try {
$site = Site::getByRootId($childDocument->getId());
$tmpDocument["iconCls"] = "pimcore_icon_site";
unset($site->rootDocument);
$tmpDocument["site"] = $site;
} catch (\Exception $e) {
}
} else {
if ($childDocument->getType() == "folder" || $childDocument->getType() == "link" || $childDocument->getType() == "hardlink") {
$tmpDocument["leaf"] = false;
$tmpDocument["expanded"] = $childDocument->hasNoChilds();
if ($childDocument->hasNoChilds() && $childDocument->getType() == "folder") {
$tmpDocument["iconCls"] = "pimcore_icon_folder";
}
$tmpDocument["permissions"]["create"] = $childDocument->isAllowed("create");
} else {
if (method_exists($childDocument, "getTreeNodeConfig")) {
$tmp = $childDocument->getTreeNodeConfig();
$tmpDocument = array_merge($tmpDocument, $tmp);
}
}
}
$tmpDocument["qtipCfg"] = array("title" => "ID: " . $childDocument->getId(), "text" => "Type: " . $childDocument->getType());
// PREVIEWS temporary disabled, need's to be optimized some time
if ($childDocument instanceof Document\Page && Config::getSystemConfig()->documents->generatepreview) {
$thumbnailFile = PIMCORE_TEMPORARY_DIRECTORY . "/document-page-previews/document-page-screenshot-" . $childDocument->getId() . ".jpg";
// only if the thumbnail exists and isn't out of time
if (file_exists($thumbnailFile) && filemtime($thumbnailFile) > $childDocument->getModificationDate() - 20) {
$thumbnailPath = str_replace(PIMCORE_DOCUMENT_ROOT, "", $thumbnailFile);
$tmpDocument["thumbnail"] = $thumbnailPath;
}
}
$tmpDocument["cls"] = "";
if (!$childDocument->isPublished()) {
$tmpDocument["cls"] .= "pimcore_unpublished ";
}
if ($childDocument->isLocked()) {
$tmpDocument["cls"] .= "pimcore_treenode_locked ";
}
if ($childDocument->getLocked()) {
$tmpDocument["cls"] .= "pimcore_treenode_lockOwner ";
}
return $tmpDocument;
}