/** * @param Object_Abstract $child * @return array */ protected function getTreeNodeConfig($child) { $tmpObject = array("id" => $child->getId(), "text" => $child->getKey(), "type" => $child->getType(), "path" => $child->getFullPath(), "basePath" => $child->getPath(), "elementType" => "object", "locked" => $child->isLocked(), "lockOwner" => $child->getLocked() ? true : false); $tmpObject["isTarget"] = false; $tmpObject["allowDrop"] = false; $tmpObject["allowChildren"] = false; $tmpObject["leaf"] = $child->hasNoChilds(); // $tmpObject["iconCls"] = "pimcore_icon_object"; $tmpObject["isTarget"] = true; $tmpObject["allowDrop"] = true; $tmpObject["allowChildren"] = true; $tmpObject["leaf"] = false; $tmpObject["cls"] = ""; if ($child->getType() == "folder") { // $tmpObject["iconCls"] = "pimcore_icon_folder"; $tmpObject["qtipCfg"] = array("title" => "ID: " . $child->getId()); } else { //assemble object preview URL $previewUrl = $child->getClass()->getPreviewUrl(); if (!empty($previewUrl)) { $vars = get_object_vars($child); $assembled = true; foreach ($vars as $key => $value) { if (!empty($value) && strpos($previewUrl, "%" . $key) !== false) { $previewUrl = str_replace("%" . $key, urlencode($value), $previewUrl); } else { if (strpos($previewUrl, "%" . $key) !== false) { $assembled = false; break; } } if ($assembled) { $tmpObject['previewUrl'] = $previewUrl; } } } $tmpObject["published"] = $child->isPublished(); $tmpObject["className"] = $child->getClass()->getName(); $tmpObject["qtipCfg"] = array("title" => "ID: " . $child->getId(), "text" => 'Type: ' . $child->getClass()->getName()); if (!$child->isPublished()) { $tmpObject["cls"] .= "pimcore_unpublished "; } // if ($child->getClass()->getIcon()) { // unset($tmpObject["iconCls"]); // $tmpObject["icon"] = $child->getClass()->getIcon(); // } } if ($child->getElementAdminStyle()->getElementIcon()) { $tmpObject["icon"] = $child->getO_elementAdminStyle()->getElementIcon(); } if ($child->getElementAdminStyle()->getElementIconClass()) { $tmpObject["iconCls"] = $child->getO_elementAdminStyle()->getElementIconClass(); } if ($child->getElementAdminStyle()->getElementCssClass()) { $tmpObject["cls"] .= $child->getO_elementAdminStyle()->getElementCssClass() . " "; } $tmpObject["expanded"] = $child->hasNoChilds(); $tmpObject["permissions"] = $child->getUserPermissions($this->getUser()); if ($child->isLocked()) { $tmpObject["cls"] .= "pimcore_treenode_locked "; } if ($child->getLocked()) { $tmpObject["cls"] .= "pimcore_treenode_lockOwner "; } return $tmpObject; }
/** * @param Object_Abstract $child * @return array */ protected function getTreeNodeConfig($child) { $tmpObject = array("id" => $child->getId(), "text" => $child->getKey(), "type" => $child->getType(), "path" => $child->getFullPath(), "basePath" => $child->getPath(), "elementType" => "object", "locked" => $child->isLocked(), "lockOwner" => $child->getLocked() ? true : false); $tmpObject["isTarget"] = false; $tmpObject["allowDrop"] = false; $tmpObject["allowChildren"] = false; $tmpObject["leaf"] = $child->hasNoChilds(); // $tmpObject["iconCls"] = "pimcore_icon_object"; $tmpObject["isTarget"] = true; $tmpObject["allowDrop"] = true; $tmpObject["allowChildren"] = true; $tmpObject["leaf"] = false; $tmpObject["cls"] = ""; if ($child->getType() == "folder") { // $tmpObject["iconCls"] = "pimcore_icon_folder"; $tmpObject["qtipCfg"] = array("title" => "ID: " . $child->getId()); } else { $tmpObject["published"] = $child->isPublished(); $tmpObject["className"] = $child->getClass()->getName(); $tmpObject["qtipCfg"] = array("title" => "ID: " . $child->getId(), "text" => 'Type: ' . $child->getClass()->getName()); if (!$child->isPublished()) { $tmpObject["cls"] .= "pimcore_unpublished "; } // if ($child->getClass()->getIcon()) { // unset($tmpObject["iconCls"]); // $tmpObject["icon"] = $child->getClass()->getIcon(); // } } if ($child->getElementAdminStyle()->getElementIcon()) { $tmpObject["icon"] = $child->getO_elementAdminStyle()->getElementIcon(); } if ($child->getElementAdminStyle()->getElementIconClass()) { $tmpObject["iconCls"] = $child->getO_elementAdminStyle()->getElementIconClass(); } if ($child->getElementAdminStyle()->getElementCssClass()) { $tmpObject["cls"] .= $child->getO_elementAdminStyle()->getElementCssClass() . " "; } $tmpObject["expanded"] = $child->hasNoChilds(); $tmpObject["permissions"] = $child->getUserPermissions($this->getUser()); if ($child->isLocked()) { $tmpObject["cls"] .= "pimcore_treenode_locked "; } if ($child->getLocked()) { $tmpObject["cls"] .= "pimcore_treenode_lockOwner "; } return $tmpObject; }
/** * @see Object_Class_Data::getDataFromEditmode * @param string $data * @param null|Object_Abstract $object * @return string */ public function getDataFromEditmode($data, $object = null) { $getter = "get" . ucfirst($this->getName()); $container = $object->{$getter}(); //$this->getObject()->$getter(); if (empty($container)) { $className = $object->getClass()->getName(); //$this->getObject()->getClass()->getName(); $containerClass = "Object_" . ucfirst($className) . "_" . ucfirst($this->getName()); $container = new $containerClass($object, $this->getName()); //$this->getObject(), $this->getName()); } if (is_array($data)) { foreach ($data as $collectionRaw) { $collectionData = array(); $collectionDef = Object_Objectbrick_Definition::getByKey($collectionRaw["type"]); $getter = "get" . ucfirst($collectionRaw["type"]); $brick = $container->{$getter}(); if (empty($brick)) { $brickClass = "Object_Objectbrick_Data_" . ucfirst($collectionRaw["type"]); $brick = new $brickClass($object); //$this->getObject()); } if ($collectionRaw["data"] == "deleted") { $brick->setDoDelete(true); } else { foreach ($collectionDef->getFieldDefinitions() as $fd) { if (array_key_exists($fd->getName(), $collectionRaw["data"])) { $collectionData[$fd->getName()] = $fd->getDataFromEditmode($collectionRaw["data"][$fd->getName()], $object); } } $brick->setValues($collectionData); $brick->setFieldname($this->getName()); } $setter = "set" . ucfirst($collectionRaw["type"]); $container->{$setter}($brick); } } return $container; }
/** * @param Object_Abstract $object * @return string */ protected static function createObjectComparisonString($object, $ignoreCopyDifferences) { if ($object instanceof Object_Abstract) { $o = array(); if ($object instanceof Object_Concrete) { foreach ($object->getClass()->getFieldDefinitions() as $key => $value) { $o[$key] = self::getComparisonDataForField($key, $value, $object); } $o["published"] = $object->isPublished(); } if (!$ignoreCopyDifferences) { $o["id"] = $object->getId(); $o["key"] = $object->getKey(); $o["modification"] = $object->getModificationDate(); $o["creation"] = $object->getCreationDate(); $o["userModified"] = $object->getUserModification(); $o["parentId"] = $object->getParentId(); $o["path"] = $object->getPath; } $o["userOwner"] = $object->getUserOwner(); $properties = $object->getProperties(); $o = array_merge($o, self::createPropertiesComparisonString($properties)); return implode(",", $o); } else { return null; } }
/** * Flattens object data to an array with key=>value where * value is simply a string representation of the value (for objects, hrefs and assets the full path is used) * * @param Object_Abstract $object * @return array */ protected function csvObjectData($object) { $o = array(); foreach ($object->getClass()->getFieldDefinitions() as $key => $value) { //exclude remote owner fields if (!($value instanceof Object_Class_Data_Relations_Abstract and $value->isRemoteOwner())) { $o[$key] = $value->getForCsvExport($object); } } $o["id (system)"] = $object->getId(); $o["key (system)"] = $object->getKey(); $o["fullpath (system)"] = $object->getFullPath(); $o["published (system)"] = $object->isPublished(); return $o; }