public function enrichLayoutDefinition($object) { $this->activeGroupDefinitions = array(); $activeGroupIds = $this->recursiveGetActiveGroupsIds($object); if (!$activeGroupIds) { return; } $filteredGroupIds = array(); foreach ($activeGroupIds as $groupId => $enabled) { if ($enabled) { $filteredGroupIds[] = $groupId; } } $condition = "ID in (" . implode(',', $filteredGroupIds) . ")"; $groupList = new Object\Classificationstore\GroupConfig\Listing(); $groupList->setCondition($condition); $groupList->setOrderKey(array("sorter", "id")); $groupList->setOrder(array("ASC", "ASC")); $groupList = $groupList->load(); /** @var $group Object\Classificationstore\GroupConfig */ foreach ($groupList as $group) { $keyList = array(); $relation = new Object\Classificationstore\KeyGroupRelation\Listing(); $relation->setCondition("groupId = " . $relation->quote($group->getId())); $relation->setOrderKey(array("sorter", "id")); $relation->setOrder(array("ASC", "ASC")); $relation = $relation->load(); foreach ($relation as $key) { $definition = \Pimcore\Model\Object\Classificationstore\Service::getFieldDefinitionFromKeyConfig($key); if (method_exists($definition, "__wakeup")) { $definition->__wakeup(); } $keyList[] = array("name" => $key->getName(), "id" => $key->getKeyId(), "description" => $key->getDescription(), "definition" => $definition); } $this->activeGroupDefinitions[$group->getId()] = array("name" => $group->getName(), "id" => $group->getId(), "description" => $group->getDescription(), "keys" => $keyList); } }
public function addGroupsAction() { $ids = \Zend_Json::decode($this->getParam("groupIds")); $keyCondition = "groupId in (" . implode(",", $ids) . ")"; $keyList = new Classificationstore\KeyGroupRelation\Listing(); $keyList->setCondition($keyCondition); $keyList->setOrderKey(array("sorter", "id")); $keyList->setOrder(array("ASC", "ASC")); $keyList = $keyList->load(); $groupCondition = "id in (" . implode(",", $ids) . ")"; $groupList = new Classificationstore\GroupConfig\Listing(); $groupList->setCondition($groupCondition); $groupList->setOrder("ASC"); $groupList->setOrderKey("id"); $groupList = $groupList->load(); $data = array(); foreach ($groupList as $groupData) { $data[$groupData->getId()] = array("name" => $groupData->getName(), "id" => $groupData->getId(), "description" => $groupData->getDescription(), "keys" => array()); } foreach ($keyList as $keyData) { $groupId = $keyData->getGroupId(); $keyList = $data[$groupId]["keys"]; $type = $keyData->getType(); $definition = json_decode($keyData->getDefinition()); $definition = \Pimcore\Model\Object\Classificationstore\Service::getFieldDefinitionFromJson($definition, $type); if (method_exists($definition, "__wakeup")) { $definition->__wakeup(); } $keyList[] = array("name" => $keyData->getName(), "id" => $keyData->getKeyId(), "description" => $keyData->getDescription(), "definition" => $definition); $data[$groupId]["keys"] = $keyList; } return $this->_helper->json($data); }
public function addGroupsAction() { $db = Resource::get(); $ids = \Zend_Json::decode($this->_getParam("groupIds")); $keyCondition = "groupId in (" . implode(",", $ids) . ")"; $keyList = new Classificationstore\KeyGroupRelation\Listing(); $keyList->setCondition($keyCondition); $keyList = $keyList->load(); $groupCondition = "id in (" . implode(",", $ids) . ")"; $groupList = new Classificationstore\GroupConfig\Listing(); $groupList->setCondition($groupCondition); $groupList->setOrder("ASC"); $groupList->setOrderKey("id"); $groupList = $groupList->load(); $data = array(); foreach ($groupList as $groupData) { $data[$groupData->getId()] = array("name" => $groupData->getName(), "id" => $groupData->getId(), "description" => $groupData->getDescription(), "keys" => array()); } foreach ($keyList as $keyData) { $groupId = $keyData->getGroupId(); $keyList = $data[$groupId]["keys"]; $definition = $keyData->getDefinition(); $keyList[] = array("name" => $keyData->getName(), "id" => $keyData->getKeyId(), "description" => $keyData->getDescription(), "definition" => json_decode($definition)); $data[$groupId]["keys"] = $keyList; } // $data = array_values($data); return $this->_helper->json($data); }