public function listAction()
 {
     if ($this->getParam("xaction") == "destroy") {
         $item = Recyclebin\Item::getById(\Pimcore\Admin\Helper\QueryParams::getRecordIdForGridRequest($this->getParam("data")));
         $item->delete();
         $this->_helper->json(array("success" => true, "data" => array()));
     } else {
         $list = new Recyclebin\Item\Listing();
         $list->setLimit($this->getParam("limit"));
         $list->setOffset($this->getParam("start"));
         $list->setOrderKey("date");
         $list->setOrder("DESC");
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         if ($sortingSettings['orderKey']) {
             $list->setOrderKey($sortingSettings['orderKey']);
             $list->setOrder($sortingSettings['order']);
         }
         $conditionFilters = array();
         if ($this->getParam("filterFullText")) {
             $conditionFilters[] = "path LIKE " . $list->quote("%" . $this->getParam("filterFullText") . "%");
         }
         $filters = $this->getParam("filter");
         if ($filters) {
             $filters = \Zend_Json::decode($filters);
             foreach ($filters as $filter) {
                 $operator = "=";
                 $filterField = $filter["field"];
                 $filterOperator = $filter["comparison"];
                 if (\Pimcore\Tool\Admin::isExtJS6()) {
                     $filterField = $filter["property"];
                     $filterOperator = $filter["operator"];
                 }
                 if ($filter["type"] == "string") {
                     $operator = "LIKE";
                 } elseif ($filter["type"] == "numeric") {
                     if ($filterOperator == "lt") {
                         $operator = "<";
                     } elseif ($filterOperator == "gt") {
                         $operator = ">";
                     } elseif ($filterOperator == "eq") {
                         $operator = "=";
                     }
                 } elseif ($filter["type"] == "date") {
                     if ($filterOperator == "lt") {
                         $operator = "<";
                     } elseif ($filterOperator == "gt") {
                         $operator = ">";
                     } elseif ($filterOperator == "eq") {
                         $operator = "=";
                     }
                     $filter["value"] = strtotime($filter["value"]);
                 } elseif ($filter["type"] == "list") {
                     $operator = "=";
                 } elseif ($filter["type"] == "boolean") {
                     $operator = "=";
                     $filter["value"] = (int) $filter["value"];
                 }
                 // system field
                 $value = $filter["value"];
                 if ($operator == "LIKE") {
                     $value = "%" . $value . "%";
                 }
                 $field = "`" . $filterField . "` ";
                 if ($filter["field"] == "fullpath") {
                     $field = "CONCAT(path,filename)";
                 }
                 $conditionFilters[] = $field . $operator . " '" . $value . "' ";
             }
         }
         if (!empty($conditionFilters)) {
             $condition = implode(" AND ", $conditionFilters);
             $list->setCondition($condition);
         }
         $items = $list->load();
         $this->_helper->json(array("data" => $items, "success" => true, "total" => $list->getTotalCount()));
     }
 }
Ejemplo n.º 2
0
 public function listAction()
 {
     if ($this->getParam("xaction") == "destroy") {
         $item = Recyclebin\Item::getById($this->getParam("data"));
         $item->delete();
         $this->_helper->json(array("success" => true, "data" => array()));
     } else {
         $list = new Recyclebin\Item\Listing();
         $list->setLimit($this->getParam("limit"));
         $list->setOffset($this->getParam("start"));
         if ($this->getParam("sort")) {
             $list->setOrderKey($this->getParam("sort"));
             $list->setOrder($this->getParam("dir"));
         }
         $conditionFilters = array();
         if ($this->getParam("filterFullText")) {
             $conditionFilters[] = "path LIKE " . $list->quote("%" . $this->getParam("filterFullText") . "%");
         }
         $filters = $this->getParam("filter");
         if ($filters) {
             $filters = \Zend_Json::decode($filters);
             foreach ($filters as $filter) {
                 $operator = "=";
                 if ($filter["type"] == "string") {
                     $operator = "LIKE";
                 } else {
                     if ($filter["type"] == "numeric") {
                         if ($filter["comparison"] == "lt") {
                             $operator = "<";
                         } else {
                             if ($filter["comparison"] == "gt") {
                                 $operator = ">";
                             } else {
                                 if ($filter["comparison"] == "eq") {
                                     $operator = "=";
                                 }
                             }
                         }
                     } else {
                         if ($filter["type"] == "date") {
                             if ($filter["comparison"] == "lt") {
                                 $operator = "<";
                             } else {
                                 if ($filter["comparison"] == "gt") {
                                     $operator = ">";
                                 } else {
                                     if ($filter["comparison"] == "eq") {
                                         $operator = "=";
                                     }
                                 }
                             }
                             $filter["value"] = strtotime($filter["value"]);
                         } else {
                             if ($filter["type"] == "list") {
                                 $operator = "=";
                             } else {
                                 if ($filter["type"] == "boolean") {
                                     $operator = "=";
                                     $filter["value"] = (int) $filter["value"];
                                 }
                             }
                         }
                     }
                 }
                 // system field
                 $value = $filter["value"];
                 if ($operator == "LIKE") {
                     $value = "%" . $value . "%";
                 }
                 $field = "`" . $filter["field"] . "` ";
                 if ($filter["field"] == "fullpath") {
                     $field = "CONCAT(path,filename)";
                 }
                 $conditionFilters[] = $field . $operator . " '" . $value . "' ";
             }
         }
         if (!empty($conditionFilters)) {
             $condition = implode(" AND ", $conditionFilters);
             $list->setCondition($condition);
         }
         $items = $list->load();
         $this->_helper->json(array("data" => $items, "success" => true, "total" => $list->getTotalCount()));
     }
 }