public function propertiesAction() { if ($this->getParam("data")) { $dataParam = $this->getParam("data"); $data = \Zend_Json::decode($dataParam); $id = $data["id"]; $config = KeyValue\KeyConfig::getById($id); foreach ($data as $key => $value) { if ($key != "id") { $setter = "set" . $key; if (method_exists($config, $setter)) { $config->{$setter}($value); } } } $config->save(); $item = $this->getConfigItem($config); $this->_helper->json(["success" => true, "data" => $item]); } else { $start = 0; $limit = 15; $orderKey = "name"; $order = "ASC"; $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams()); if ($sortingSettings['orderKey']) { $orderKey = $sortingSettings['orderKey']; } if ($sortingSettings['order']) { $order = $sortingSettings['order']; } if ($this->getParam("overrideSort") == "true") { $orderKey = "id"; $order = "DESC"; } if ($this->getParam("limit")) { $limit = $this->getParam("limit"); } if ($this->getParam("start")) { $start = $this->getParam("start"); } $list = new KeyValue\KeyConfig\Listing(); if ($limit > 0) { $list->setLimit($limit); } $list->setOffset($start); $list->setOrder($order); $list->setOrderKey($orderKey); if ($this->getParam("filter")) { $db = Db::get(); $condition = ""; $filterString = $this->getParam("filter"); $filters = json_decode($filterString); $count = 0; foreach ($filters as $f) { if ($count > 0) { $condition .= " OR "; } $count++; if (\Pimcore\Tool\Admin::isExtJS6()) { $condition .= $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%"); } else { $condition .= $db->getQuoteIdentifierSymbol() . $f->field . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%"); } } $list->setCondition($condition); } if ($this->getParam("groupIds") || $this->getParam("keyIds")) { $db = Db::get(); if ($this->getParam("groupIds")) { $ids = \Zend_Json::decode($this->getParam("groupIds")); $col = "group"; } else { $ids = \Zend_Json::decode($this->getParam("keyIds")); $col = "id"; } $condition = $db->getQuoteIdentifierSymbol() . $col . $db->getQuoteIdentifierSymbol() . " IN ("; $count = 0; foreach ($ids as $theId) { if ($count > 0) { $condition .= ","; } $condition .= $theId; $count++; } $condition .= ")"; $list->setCondition($condition); } $list->load(); $configList = $list->getList(); $rootElement = []; $data = []; foreach ($configList as $config) { $item = $this->getConfigItem($config); $data[] = $item; } $rootElement["data"] = $data; $rootElement["success"] = true; $rootElement["total"] = $list->getTotalCount(); return $this->_helper->json($rootElement); } }