Inheritance: extends Pimcore\Model\AbstractModel
コード例 #1
0
ファイル: Resource.php プロジェクト: Ahmad-Hilali/pimcore
 /**
  * Loads a list of Classificationstore key configs for the specifies parameters, returns an array of config elements
  *
  * @return array
  */
 public function load()
 {
     $sql = "SELECT id FROM " . Object\Classificationstore\KeyConfig\Resource::TABLE_NAME_KEYS . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit();
     $configsData = $this->db->fetchCol($sql, $this->model->getConditionVariables());
     $configData = array();
     foreach ($configsData as $config) {
         $configData[] = Object\Classificationstore\KeyConfig::getById($config);
     }
     $this->model->setList($configData);
     return $configData;
 }
コード例 #2
0
ファイル: DefinitionCache.php プロジェクト: solverat/pimcore
 public static function get($id, $type = "key")
 {
     $key = $type . $id;
     $config = self::$cache[$key];
     if ($config) {
         return $config;
     }
     $config = KeyConfig::getById($id);
     if (!$config) {
         return;
     }
     self::put($config);
     return $config;
 }
コード例 #3
0
 public static function get($id, $type = "key")
 {
     $key = $type . $id;
     $config = self::$cache[$key];
     if ($config) {
         \Logger::debug("#### matched " . $key);
         return $config;
     }
     $config = KeyConfig::getById($id);
     if (!$config->getId()) {
         return;
     }
     self::put($config);
     return $config;
 }
コード例 #4
0
 public function deletePropertyAction()
 {
     $id = $this->getParam("id");
     $config = Classificationstore\KeyConfig::getById($id);
     //        $config->delete();
     $config->setEnabled(false);
     $config->save();
     $this->_helper->json(array("success" => true));
 }
コード例 #5
0
ファイル: Service.php プロジェクト: solverat/pimcore
 /**
  *
  * @param string $filterJson
  * @param ClassDefinition $class
  * @return string
  */
 public static function getFeatureFilters($filterJson, $class)
 {
     $joins = [];
     $conditions = [];
     // create filter condition
     $conditionPartsFilters = [];
     if ($filterJson) {
         $db = \Pimcore\Db::get();
         $filters = \Zend_Json::decode($filterJson);
         foreach ($filters as $filter) {
             $operator = "=";
             $filterField = $filter["property"];
             $filterOperator = $filter["operator"];
             if ($filter["type"] == "string") {
                 $operator = "LIKE";
             } elseif ($filter["type"] == "numeric") {
                 if ($filterOperator == "lt") {
                     $operator = "<";
                 } elseif ($filterOperator == "gt") {
                     $operator = ">";
                 } elseif ($filterOperator == "eq") {
                     $operator = "=";
                 }
             } elseif ($filter["type"] == "date") {
                 if ($filterOperator == "lt") {
                     $operator = "<";
                 } elseif ($filterOperator == "gt") {
                     $operator = ">";
                 } elseif ($filterOperator == "eq") {
                     $operator = "=";
                 }
                 $filter["value"] = strtotime($filter["value"]);
             } elseif ($filter["type"] == "list") {
                 $operator = "=";
             } elseif ($filter["type"] == "boolean") {
                 $operator = "=";
                 $filter["value"] = (int) $filter["value"];
             }
             $keyParts = explode("~", $filterField);
             if (substr($filterField, 0, 1) != "~") {
                 continue;
             }
             $type = $keyParts[1];
             if ($type != "classificationstore") {
                 continue;
             }
             $fieldName = $keyParts[2];
             $groupKeyId = explode("-", $keyParts[3]);
             $groupId = $groupKeyId[0];
             $keyid = $groupKeyId[1];
             $keyConfig = Model\Object\Classificationstore\KeyConfig::getById($keyid);
             $type = $keyConfig->getType();
             $definition = json_decode($keyConfig->getDefinition());
             $field = \Pimcore\Model\Object\Classificationstore\Service::getFieldDefinitionFromJson($definition, $type);
             if ($field instanceof ClassDefinition\Data) {
                 $mappedKey = "cskey_" . $fieldName . "_" . $groupId . "_" . $keyid;
                 $joins[] = ['fieldname' => $fieldName, 'groupId' => $groupId, "keyId" => $keyid];
                 $condition = $field->getFilterConditionExt($filter["value"], $operator, ["name" => $mappedKey]);
                 $conditions[$mappedKey] = $condition;
             }
         }
     }
     $result = ["joins" => $joins, "conditions" => $conditions];
     return $result;
 }
コード例 #6
0
 /**
  * @param mixed $value
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @param IdMapper $idMapper
  * @return mixed|null|Object\Classificationstore
  * @throws \Exception
  */
 public function getFromWebserviceImport($value, $object = null, $params = [], $idMapper = null)
 {
     if ($value) {
         $storeData = new Object\Classificationstore();
         $storeData->setFieldname($this->getName());
         $storeData->setObject($object);
         $activeGroupsLocal = [];
         $activeGroupsRemote = $value->activeGroups;
         if (is_array($activeGroupsRemote)) {
             foreach ($activeGroupsRemote as $data) {
                 $remoteId = $data->id;
                 $localId = $idMapper->getMappedId("csGroup", $remoteId);
                 $activeGroupsLocal[$localId] = $localId;
             }
         }
         $storeData->setActiveGroups($activeGroupsLocal);
         $groupsRemote = $value->groups;
         if (is_array($groupsRemote)) {
             foreach ($groupsRemote as $remoteGroupData) {
                 $remoteGroupId = $remoteGroupData->id;
                 $localGroupId = $idMapper->getMappedId("csGroup", $remoteGroupId);
                 $remoteKeys = $remoteGroupData->keys;
                 $remoteKeys = (array) $remoteKeys;
                 foreach ($remoteKeys as $language => $keyList) {
                     foreach ($keyList as $keyData) {
                         $remoteKeyId = $keyData->id;
                         $localKeyId = $idMapper->getMappedId("csKey", $remoteKeyId);
                         $keyConfig = Object\Classificationstore\KeyConfig::getById($localKeyId);
                         $keyDef = Object\Classificationstore\Service::getFieldDefinitionFromJson(json_decode($keyConfig->getDefinition()), $keyConfig->getType());
                         $value = $keyData->value;
                         $value = $keyDef->getFromWebserviceImport($value, $object, []);
                         $storeData->setLocalizedKeyValue($localGroupId, $localKeyId, $value, $language);
                     }
                 }
             }
         }
         return $storeData;
     }
 }
コード例 #7
0
 protected function mapFieldname($field)
 {
     if (substr($field, 0, 1) == "~") {
         $fieldParts = explode("~", $field);
         $type = $fieldParts[1];
         if ($type == "classificationstore") {
             $fieldname = $fieldParts[2];
             $groupKeyId = explode("-", $fieldParts[3]);
             $groupId = $groupKeyId[0];
             $keyId = $groupKeyId[1];
             $groupConfig = Object\Classificationstore\GroupConfig::getById($groupId);
             $keyConfig = Object\Classificationstore\KeyConfig::getById($keyId);
             $field = $fieldname . "~" . $groupConfig->getName() . "~" . $keyConfig->getName();
         }
     }
     return $field;
 }