Наследование: extends AbstractModel
Пример #1
0
 /**
  * Loads a list of static routes for the specified parameters, returns an array of Staticroute elements
  *
  * @return array
  */
 public function load()
 {
     $sql = "SELECT id FROM website_settings" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit();
     $settingsData = $this->db->fetchCol($sql, $this->model->getConditionVariables());
     $settings = [];
     foreach ($settingsData as $settingData) {
         $settings[] = Model\WebsiteSetting::getById($settingData);
     }
     $this->model->setSettings($settings);
     return $settings;
 }
 /**
  * @return mixed
  */
 public static function getAllowedDomain()
 {
     $allowedDomain = WebsiteSetting::getByName("subdomainAdmin")->getData();
     return $allowedDomain;
 }
Пример #3
0
 public function websiteSettingsAction()
 {
     try {
         if ($this->getParam("data")) {
             $this->checkPermission("website_settings");
             $data = \Zend_Json::decode($this->getParam("data"));
             if (is_array($data)) {
                 foreach ($data as &$value) {
                     $value = trim($value);
                 }
             }
             if ($this->getParam("xaction") == "destroy") {
                 if (\Pimcore\Tool\Admin::isExtJS6()) {
                     $id = $data["id"];
                 } else {
                     $id = $data;
                 }
                 $setting = WebsiteSetting::getById($id);
                 $setting->delete();
                 $this->_helper->json(array("success" => true, "data" => array()));
             } else {
                 if ($this->getParam("xaction") == "update") {
                     // save routes
                     $setting = WebsiteSetting::getById($data["id"]);
                     switch ($setting->getType()) {
                         case "document":
                         case "asset":
                         case "object":
                             if (isset($data["data"])) {
                                 $path = $data["data"];
                                 $element = Element\Service::getElementByPath($setting->getType(), $path);
                                 $data["data"] = $element ? $element->getId() : null;
                             }
                             break;
                     }
                     $setting->setValues($data);
                     $setting->save();
                     $data = $this->getWebsiteSettingForEditMode($setting);
                     $this->_helper->json(array("data" => $data, "success" => true));
                 } else {
                     if ($this->getParam("xaction") == "create") {
                         unset($data["id"]);
                         // save route
                         $setting = new WebsiteSetting();
                         $setting->setValues($data);
                         $setting->save();
                         $this->_helper->json(array("data" => $setting, "success" => true));
                     }
                 }
             }
         } else {
             // get list of routes
             $list = new WebsiteSetting\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']);
             } else {
                 $list->setOrderKey("name");
                 $list->setOrder("asc");
             }
             if ($this->getParam("filter")) {
                 $list->setCondition("`name` LIKE " . $list->quote("%" . $this->getParam("filter") . "%"));
             }
             $totalCount = $list->getTotalCount();
             $list = $list->load();
             $settings = array();
             foreach ($list as $item) {
                 $resultItem = $this->getWebsiteSettingForEditMode($item);
                 $settings[] = $resultItem;
             }
             $this->_helper->json(array("data" => $settings, "success" => true, "total" => $totalCount));
         }
     } catch (\Exception $e) {
         throw $e;
         $this->_helper->json(false);
     }
     $this->_helper->json(false);
 }
 public static function isInstalled()
 {
     return WebsiteSetting::getByName(self::WEBSITE_SETTING_NAME) !== null;
 }