Наследование: extends Pimcore\Model\AbstractModel
Пример #1
0
 /**
  * Loads a list of predefined properties for the specicifies parameters, returns an array of Property\Predefined elements
  *
  * @return array
  */
 public function load()
 {
     $properties = array();
     $propertiesData = $this->db->fetchCol("SELECT id FROM properties_predefined" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($propertiesData as $propertyData) {
         $properties[] = Property\Predefined::getById($propertyData);
     }
     $this->model->setProperties($properties);
     return $properties;
 }
Пример #2
0
 /**
  * Loads a list of predefined properties for the specicifies parameters, returns an array of Property\Predefined elements
  *
  * @return array
  */
 public function load()
 {
     $properties = array();
     $propertiesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder());
     foreach ($propertiesData as $propertyData) {
         $properties[] = Property\Predefined::getById($propertyData["id"]);
     }
     $this->model->setProperties($properties);
     return $properties;
 }
 public function installProperties()
 {
     $defProperty = Property\Predefined::getByKey('assigned_language');
     if (!$defProperty instanceof Property\Predefined) {
         $languages = \Pimcore\Tool::getValidLanguages();
         $data = 'all,';
         foreach ($languages as $language) {
             $data .= $language . ',';
         }
         $data = rtrim($data, ',');
         $property = new Property\Predefined();
         $property->setType('select');
         $property->setName('Assigned Language');
         $property->setKey('assigned_language');
         $property->setDescription('set a specific language which lucene search should respect while crawling.');
         $property->setCtype('asset');
         $property->setData('all');
         $property->setConfig($data);
         $property->setInheritable(FALSE);
         $property->save();
     }
 }
Пример #4
0
 public function propertiesAction()
 {
     if ($this->getParam("data")) {
         $this->checkPermission("predefined_properties");
         if ($this->getParam("xaction") == "destroy") {
             $data = \Zend_Json::decode($this->getParam("data"));
             if (\Pimcore\Tool\Admin::isExtJS6()) {
                 $id = $data["id"];
             } else {
                 $id = $data;
             }
             $property = Property\Predefined::getById($id);
             $property->delete();
             $this->_helper->json(array("success" => true, "data" => array()));
         } else {
             if ($this->getParam("xaction") == "update") {
                 $data = \Zend_Json::decode($this->getParam("data"));
                 // save type
                 $property = Property\Predefined::getById($data["id"]);
                 $property->setValues($data);
                 $property->save();
                 $this->_helper->json(array("data" => $property, "success" => true));
             } else {
                 if ($this->getParam("xaction") == "create") {
                     $data = \Zend_Json::decode($this->getParam("data"));
                     unset($data["id"]);
                     // save type
                     $property = Property\Predefined::create();
                     $property->setValues($data);
                     $property->save();
                     $this->_helper->json(array("data" => $property, "success" => true));
                 }
             }
         }
     } else {
         // get list of types
         $list = new Property\Predefined\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');
         }
         if ($this->getParam("filter")) {
             $list->setCondition("`name` LIKE " . $list->quote("%" . $this->getParam("filter") . "%") . " OR `description` LIKE " . $list->quote("%" . $this->getParam("filter") . "%"));
         }
         $list->load();
         $properties = array();
         if (is_array($list->getProperties())) {
             foreach ($list->getProperties() as $property) {
                 $properties[] = $property;
             }
         }
         $this->_helper->json(array("data" => $properties, "success" => true, "total" => $list->getTotalCount()));
     }
 }
Пример #5
0
 public function propertiesAction()
 {
     if ($this->getParam("data")) {
         $this->checkPermission("predefined_properties");
         if ($this->getParam("xaction") == "destroy") {
             $data = \Zend_Json::decode($this->getParam("data"));
             if (\Pimcore\Tool\Admin::isExtJS6()) {
                 $id = $data["id"];
             } else {
                 $id = $data;
             }
             $property = Property\Predefined::getById($id);
             $property->delete();
             $this->_helper->json(["success" => true, "data" => []]);
         } elseif ($this->getParam("xaction") == "update") {
             $data = \Zend_Json::decode($this->getParam("data"));
             // save type
             $property = Property\Predefined::getById($data["id"]);
             $property->setValues($data);
             $property->save();
             $this->_helper->json(["data" => $property, "success" => true]);
         } elseif ($this->getParam("xaction") == "create") {
             $data = \Zend_Json::decode($this->getParam("data"));
             unset($data["id"]);
             // save type
             $property = Property\Predefined::create();
             $property->setValues($data);
             $property->save();
             $this->_helper->json(["data" => $property, "success" => true]);
         }
     } else {
         // get list of types
         $list = new Property\Predefined\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();
         $properties = [];
         if (is_array($list->getProperties())) {
             foreach ($list->getProperties() as $property) {
                 $properties[] = $property;
             }
         }
         $this->_helper->json(["data" => $properties, "success" => true, "total" => $list->getTotalCount()]);
     }
 }
Пример #6
0
 /**
  * @static
  * @param  $props
  * @return array
  */
 public static function minimizePropertiesForEditmode($props)
 {
     $properties = array();
     foreach ($props as $key => $p) {
         //$p = object2array($p);
         $allowedProperties = array("key", "o_key", "filename", "path", "o_path", "id", "o_id", "o_type", "type");
         if ($p->getData() instanceof Document || $p->getData() instanceof Asset || $p->getData() instanceof Object\AbstractObject) {
             $pa = array();
             $vars = get_object_vars($p->getData());
             foreach ($vars as $k => $value) {
                 if (in_array($k, $allowedProperties)) {
                     $pa[$k] = $p->getData()->{$k};
                 }
             }
             // clone it because of caching
             $tmp = clone $p;
             $tmp->setData($pa);
             $properties[$key] = object2array($tmp);
         } else {
             $properties[$key] = object2array($p);
         }
         // add config from predefined properties
         if ($p->getName() && $p->getType()) {
             $predefined = Model\Property\Predefined::getByKey($p->getName());
             if ($predefined && $predefined->getType() == $p->getType()) {
                 $properties[$key]["config"] = $predefined->getConfig();
             }
         }
     }
     return $properties;
 }
Пример #7
0
 public static function setup()
 {
     // Reset first page
     $document = Document\Page::getById(1);
     $document->setModule("Multilingual");
     $document->setController("default");
     $document->setAction('language-detection');
     $document->save();
     // Add predefined property
     $property = Property\Predefined::create();
     $property->setValues(array('key' => 'doNotSyncProperties', 'name' => 'Multilingual: Do not sync properties', 'description' => 'Do not sync properties across documents in other languages', 'data' => 1, 'type' => 'bool', 'ctype' => 'document', 'inheritable' => false));
     $property->save();
 }