예제 #1
0
 /**
  * Loads a list of static routes for the specicifies parameters, returns an array of Staticroute elements
  *
  * @return array
  */
 public function load()
 {
     $glossarysData = $this->db->fetchCol("SELECT id FROM glossary" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $glossary = array();
     foreach ($glossarysData as $glossaryData) {
         $glossary[] = Glossary::getById($glossaryData);
     }
     $this->model->setGlossary($glossary);
     return $glossary;
 }
예제 #2
0
 public function glossaryAction()
 {
     if ($this->_getParam("data")) {
         if ($this->getUser()->isAllowed("glossary")) {
             Pimcore_Model_Cache::clearTag("glossary");
             if ($this->_getParam("xaction") == "destroy") {
                 $id = Zend_Json::decode($this->_getParam("data"));
                 $glossary = Glossary::getById($id);
                 $glossary->delete();
                 $this->_helper->json(array("success" => true, "data" => array()));
             } else {
                 if ($this->_getParam("xaction") == "update") {
                     $data = Zend_Json::decode($this->_getParam("data"));
                     // save glossary
                     $glossary = Glossary::getById($data["id"]);
                     if ($data["link"]) {
                         if ($doc = Document::getByPath($data["link"])) {
                             $tmpLink = $data["link"];
                             $data["link"] = $doc->getId();
                         }
                     }
                     $glossary->setValues($data);
                     $glossary->save();
                     if ($link = $glossary->getLink()) {
                         if (intval($link) > 0) {
                             if ($doc = Document::getById(intval($link))) {
                                 $glossary->setLink($doc->getFullPath());
                             }
                         }
                     }
                     $this->_helper->json(array("data" => $glossary, "success" => true));
                 } else {
                     if ($this->_getParam("xaction") == "create") {
                         $data = Zend_Json::decode($this->_getParam("data"));
                         unset($data["id"]);
                         // save glossary
                         $glossary = new Glossary();
                         if ($data["link"]) {
                             if ($doc = Document::getByPath($data["link"])) {
                                 $tmpLink = $data["link"];
                                 $data["link"] = $doc->getId();
                             }
                         }
                         $glossary->setValues($data);
                         $glossary->save();
                         if ($link = $glossary->getLink()) {
                             if (intval($link) > 0) {
                                 if ($doc = Document::getById(intval($link))) {
                                     $glossary->setLink($doc->getFullPath());
                                 }
                             }
                         }
                         $this->_helper->json(array("data" => $glossary, "success" => true));
                     }
                 }
             }
         } else {
             Logger::err("user [" . $this->getUser()->getId() . "] attempted to modify static routes, but has no permission to do so.");
         }
     } else {
         // get list of routes
         $list = new Glossary_List();
         $list->setLimit($this->_getParam("limit"));
         $list->setOffset($this->_getParam("start"));
         if ($this->_getParam("sort")) {
             $list->setOrderKey($this->_getParam("sort"));
             $list->setOrder($this->_getParam("dir"));
         }
         if ($this->_getParam("filter")) {
             $list->setCondition("`text` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%"));
         }
         $list->load();
         $glossaries = array();
         foreach ($list->getGlossary() as $glossary) {
             if ($link = $glossary->getLink()) {
                 if (intval($link) > 0) {
                     if ($doc = Document::getById(intval($link))) {
                         $glossary->setLink($doc->getFullPath());
                     }
                 }
             }
             $glossaries[] = $glossary;
         }
         $this->_helper->json(array("data" => $glossaries, "success" => true, "total" => $list->getTotalCount()));
     }
     $this->_helper->json(false);
 }