Inheritance: extends Pimcore\Model\AbstractModel
コード例 #1
0
ファイル: Dao.php プロジェクト: sfie/pimcore
 /**
  * Loads a list of Classificationstore group configs for the specifies parameters, returns an array of config elements
  *
  * @return array
  */
 public function load()
 {
     $condition = $this->getCondition();
     if ($condition) {
         $condition = $condition . " AND ";
     } else {
         $condition = " where ";
     }
     $condition .= Object\Classificationstore\CollectionGroupRelation\Dao::TABLE_NAME_RELATIONS . ".groupId = " . Object\Classificationstore\GroupConfig\Dao::TABLE_NAME_GROUPS . ".id";
     $sql = "SELECT * FROM " . Object\Classificationstore\CollectionGroupRelation\Dao::TABLE_NAME_RELATIONS . "," . Object\Classificationstore\GroupConfig\Dao::TABLE_NAME_GROUPS . $condition . $this->getOrder() . $this->getOffsetLimit();
     $data = $this->db->fetchAll($sql, $this->model->getConditionVariables());
     $configData = array();
     foreach ($data as $dataItem) {
         $entry = new Object\Classificationstore\CollectionGroupRelation();
         $resource = $entry->getDao();
         $resource->assignVariablesToModel($dataItem);
         $configData[] = $entry;
     }
     $this->model->setList($configData);
     return $configData;
 }
コード例 #2
0
 public function collectionRelationsAction()
 {
     if ($this->getParam("data")) {
         $dataParam = $this->getParam("data");
         $data = \Zend_Json::decode($dataParam);
         $colId = $data["colId"];
         $groupId = $data["groupId"];
         $sorter = $data["sorter"];
         $config = new Classificationstore\CollectionGroupRelation();
         $config->setGroupId($groupId);
         $config->setColId($colId);
         $config->setSorter($sorter);
         $config->save();
         $data["id"] = $config->getColId() . "-" . $config->getGroupId();
         $this->_helper->json(array("success" => true, "data" => $data));
     } else {
         $mapping = array("groupName" => "name", "groupDescription" => "description");
         $start = 0;
         $limit = 15;
         $orderKey = "sorter";
         $order = "ASC";
         if ($this->getParam("dir")) {
             $order = $this->getParam("dir");
         }
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         if ($sortingSettings['orderKey'] && $sortingSettings['order']) {
             $orderKey = $sortingSettings['orderKey'];
             $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 Classificationstore\CollectionGroupRelation\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 .= " AND ";
                 }
                 $count++;
                 $fieldname = $mapping[$f->field];
                 $condition .= $db->getQuoteIdentifierSymbol() . $fieldname . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%");
             }
         }
         $colId = $this->getParam("colId");
         if ($condition) {
             $condition = "( " . $condition . " ) AND";
         }
         $condition .= " colId = " . $list->quote($colId);
         $list->setCondition($condition);
         $listItems = $list->load();
         $rootElement = array();
         $data = array();
         foreach ($listItems as $config) {
             $item = array("colId" => $config->getColId(), "groupId" => $config->getGroupId(), "groupName" => $config->getName(), "groupDescription" => $config->getDescription(), "id" => $config->getColId() . "-" . $config->getGroupId(), "sorter" => $config->getSorter());
             $data[] = $item;
         }
         $rootElement["data"] = $data;
         $rootElement["success"] = true;
         $rootElement["total"] = $list->getTotalCount();
         return $this->_helper->json($rootElement);
     }
 }