/** * Loads a list of static routes for the specicifies parameters, returns an array of Staticroute elements * * @return array */ public function load() { $routesData = $this->db->fetchCol("SELECT id FROM staticroutes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables()); $routes = array(); foreach ($routesData as $routeData) { $routes[] = Model\Staticroute::getById($routeData); } $this->model->setRoutes($routes); return $routes; }
/** * Loads a list of static routes for the specicifies parameters, returns an array of Staticroute elements * * @return array */ public function load() { $routesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder()); $routes = []; foreach ($routesData as $routeData) { $routes[] = Model\Staticroute::getById($routeData["id"]); } $this->model->setRoutes($routes); return $routes; }
public function staticroutesAction() { if ($this->getParam("data")) { $this->checkPermission("routes"); $data = \Zend_Json::decode($this->getParam("data")); if (is_array($data)) { foreach ($data as &$value) { if (is_string($value)) { $value = trim($value); } } } if ($this->getParam("xaction") == "destroy") { $data = \Zend_Json::decode($this->getParam("data")); if (\Pimcore\Tool\Admin::isExtJS6()) { $id = $data["id"]; } else { $id = $data; } $route = Staticroute::getById($id); $route->delete(); $this->_helper->json(array("success" => true, "data" => array())); } else { if ($this->getParam("xaction") == "update") { // save routes $route = Staticroute::getById($data["id"]); $route->setValues($data); $route->save(); $this->_helper->json(array("data" => $route, "success" => true)); } else { if ($this->getParam("xaction") == "create") { unset($data["id"]); // save route $route = new Staticroute(); $route->setValues($data); $route->save(); $this->_helper->json(array("data" => $route, "success" => true)); } } } } else { // get list of routes $list = new Staticroute\Listing(); $list->setLimit($this->getParam("limit")); $list->setOffset($this->getParam("start")); $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams()); if ($sortingSettings['orderKey']) { $list->setOrderKey($sortingSettings['orderKey']); $list->setOrder($sortingSettings['order']); } if ($this->getParam("filter")) { $list->setCondition("`name` LIKE " . $list->quote("%" . $this->getParam("filter") . "%") . " OR `pattern` LIKE " . $list->quote("%" . $this->getParam("filter") . "%") . " OR `reverse` LIKE " . $list->quote("%" . $this->getParam("filter") . "%") . " OR `controller` LIKE " . $list->quote("%" . $this->getParam("filter") . "%") . " OR `action` LIKE " . $list->quote("%" . $this->getParam("filter") . "%")); } $list->load(); $routes = array(); foreach ($list->getRoutes() as $route) { $routes[] = $route; } $this->_helper->json(array("data" => $routes, "success" => true, "total" => $list->getTotalCount())); } $this->_helper->json(false); }
public function staticroutesAction() { if ($this->getParam("data")) { $this->checkPermission("routes"); $data = \Zend_Json::decode($this->getParam("data")); if (is_array($data)) { foreach ($data as &$value) { if (is_string($value)) { $value = trim($value); } } } if ($this->getParam("xaction") == "destroy") { $data = \Zend_Json::decode($this->getParam("data")); if (\Pimcore\Tool\Admin::isExtJS6()) { $id = $data["id"]; } else { $id = $data; } $route = Staticroute::getById($id); $route->delete(); $this->_helper->json(["success" => true, "data" => []]); } elseif ($this->getParam("xaction") == "update") { // save routes $route = Staticroute::getById($data["id"]); $route->setValues($data); $route->save(); $this->_helper->json(["data" => $route, "success" => true]); } elseif ($this->getParam("xaction") == "create") { unset($data["id"]); // save route $route = new Staticroute(); $route->setValues($data); $route->save(); $this->_helper->json(["data" => $route, "success" => true]); } } else { // get list of routes $list = new Staticroute\Listing(); if ($this->getParam("filter")) { $filter = $this->getParam("filter"); $list->setFilter(function ($row) use($filter) { foreach ($row as $value) { if (strpos($value, $filter) !== false) { return true; } } return false; }); } $list->load(); $routes = []; foreach ($list->getRoutes() as $route) { $routes[] = $route; } $this->_helper->json(["data" => $routes, "success" => true, "total" => $list->getTotalCount()]); } $this->_helper->json(false); }