상속: extends Pimcore\Model\Listing\AbstractListing
예제 #1
0
 /** Returns the group/key config as XML.
  * @return mixed
  */
 public static function export()
 {
     $xml = new \SimpleXMLElement('<xml/>');
     $groupConfigList = new Object\KeyValue\GroupConfig\Listing();
     $groupConfigList->load();
     $groupConfigItems = $groupConfigList->getList();
     $groups = $xml->addChild('groups');
     foreach ($groupConfigItems as $item) {
         $group = $groups->addChild('group');
         $group->addChild("id", $item->getId());
         $group->addChild("name", $item->getName());
         $group->addChild("description", $item->getDescription());
     }
     $keyConfigList = new Object\KeyValue\KeyConfig\Listing();
     $keyConfigList->load();
     $keyConfigItems = $keyConfigList->getList();
     $keys = $xml->addChild('keys');
     foreach ($keyConfigItems as $item) {
         $key = $keys->addChild('key');
         $id = $key->addChild('id', $item->getId());
         $name = $key->addChild('name', $item->getName());
         $description = $key->addChild('description', $item->getDescription());
         $type = $key->addChild('type', $item->getType());
         $unit = $key->addChild('unit', $item->getUnit());
         $group = $key->addChild('group', $item->getGroup());
         $possiblevalues = $key->addChild('possiblevalues', $item->getPossibleValues());
     }
     return $xml->asXML();
 }
 /** Returns the group/key config as JSON.
  * @return mixed
  */
 public function keyValueDefinitionAction()
 {
     $this->checkUserPermission("classes");
     try {
         if ($this->isGet()) {
             $condition = urldecode($this->getParam("condition"));
             $definition = array();
             $list = new Object\KeyValue\GroupConfig\Listing();
             if ($condition) {
                 $list->setCondition($condition);
             }
             $list->load();
             $items = $list->getList();
             $groups = array();
             foreach ($items as $item) {
                 $groups[] = $item->getObjectVars();
             }
             $definition["groups"] = $groups;
             $list = new Object\KeyValue\KeyConfig\Listing();
             if ($condition) {
                 $list->setCondition($condition);
             }
             $list->load();
             $items = $list->getList();
             $keys = array();
             foreach ($items as $item) {
                 /** @var  $item Object\KeyValue\KeyConfig */
                 $keys[] = $item->getObjectVars();
             }
             $definition["keys"] = $keys;
             $this->encoder->encode(array("success" => true, "data" => $definition));
         }
     } catch (\Exception $e) {
         $this->encoder->encode(array("success" => false, "msg" => (string) $e));
     }
     $this->encoder->encode(array("success" => false));
 }
예제 #3
0
 public function groupsAction()
 {
     if ($this->getParam("data")) {
         $dataParam = $this->getParam("data");
         $data = \Zend_Json::decode($dataParam);
         $id = $data["id"];
         $config = KeyValue\GroupConfig::getById($id);
         foreach ($data as $key => $value) {
             if ($key != "id") {
                 $setter = "set" . $key;
                 $config->{$setter}($value);
             }
         }
         $config->save();
         $this->_helper->json(["success" => true, "data" => $config]);
     } 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("limit")) {
             $limit = $this->getParam("limit");
         }
         if ($this->getParam("start")) {
             $start = $this->getParam("start");
         }
         if ($this->getParam("overrideSort") == "true") {
             $orderKey = "id";
             $order = "DESC";
         }
         $list = new KeyValue\GroupConfig\Listing();
         $list->setLimit($limit);
         $list->setOffset($start);
         $list->setOrder($order);
         $list->setOrderKey($orderKey);
         if ($this->getParam("filter")) {
             $condition = "";
             $filterString = $this->getParam("filter");
             $filters = json_decode($filterString);
             $db = Db::get();
             $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);
         }
         $list->load();
         $configList = $list->getList();
         $rootElement = [];
         $data = [];
         foreach ($configList as $config) {
             $name = $config->getName();
             if (!$name) {
                 $name = "EMPTY";
             }
             $item = ["id" => $config->getId(), "name" => $name, "description" => $config->getDescription()];
             if ($config->getCreationDate()) {
                 $item["creationDate"] = $config->getCreationDate();
             }
             if ($config->getModificationDate()) {
                 $item["modificationDate"] = $config->getModificationDate();
             }
             $data[] = $item;
         }
         $rootElement["data"] = $data;
         $rootElement["success"] = true;
         $rootElement["total"] = $list->getTotalCount();
         return $this->_helper->json($rootElement);
     }
 }