当前位置: 首页>>代码示例>>PHP>>正文


PHP Service::getFilterCondition方法代码示例

本文整理汇总了PHP中Pimcore\Model\Object\Service::getFilterCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getFilterCondition方法的具体用法?PHP Service::getFilterCondition怎么用?PHP Service::getFilterCondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Model\Object\Service的用法示例。


在下文中一共展示了Service::getFilterCondition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gridProxyAction


//.........这里部分代码省略.........
                                         $currentLocale = (string) \Zend_Registry::get("Zend_Locale");
                                         if (!in_array($currentLocale, $languagePermissions)) {
                                             continue;
                                         }
                                     }
                                 }
                             }
                         }
                         $objectData[$key] = $value;
                     }
                 }
                 $object->setValues($objectData);
                 $object->save();
                 $this->_helper->json(array("data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true));
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         }
     } else {
         // get list of objects
         $folder = Object::getById($this->getParam("folderId"));
         $class = Object\ClassDefinition::getById($this->getParam("classId"));
         $className = $class->getName();
         $colMappings = array("filename" => "o_key", "fullpath" => array("o_path", "o_key"), "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate");
         $start = 0;
         $limit = 20;
         $orderKey = "o_id";
         $order = "ASC";
         $fields = array();
         $bricks = array();
         if ($this->getParam("fields")) {
             $fields = $this->getParam("fields");
             foreach ($fields as $f) {
                 $parts = explode("~", $f);
                 $sub = substr($f, 0, 1);
                 if (substr($f, 0, 1) == "~") {
                     //                        $type = $parts[1];
                     //                        $field = $parts[2];
                     //                        $keyid = $parts[3];
                     // key value, ignore for now
                 } elseif (count($parts) > 1) {
                     $bricks[$parts[0]] = $parts[0];
                 }
             }
         }
         if ($this->getParam("limit")) {
             $limit = $this->getParam("limit");
         }
         if ($this->getParam("start")) {
             $start = $this->getParam("start");
         }
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         if ($sortingSettings['order']) {
             $order = $sortingSettings['order'];
         }
         if (strlen($sortingSettings['orderKey']) > 0) {
             $orderKey = $sortingSettings['orderKey'];
             if (!(substr($orderKey, 0, 1) == "~")) {
                 if (array_key_exists($orderKey, $colMappings)) {
                     $orderKey = $colMappings[$orderKey];
                 }
             }
         }
         $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
         $conditionFilters = array();
         if ($this->getParam("only_direct_children") == "true") {
             $conditionFilters[] = "o_parentId = " . $folder->getId();
         } else {
             $conditionFilters[] = "(o_path = '" . $folder->getFullPath() . "' OR o_path LIKE '" . str_replace("//", "/", $folder->getFullPath() . "/") . "%')";
         }
         // create filter condition
         if ($this->getParam("filter")) {
             $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
         }
         if ($this->getParam("condition")) {
             $conditionFilters[] = "(" . $this->getParam("condition") . ")";
         }
         $list = new $listClass();
         if (!empty($bricks)) {
             foreach ($bricks as $b) {
                 $list->addObjectbrick($b);
             }
         }
         $list->setCondition(implode(" AND ", $conditionFilters));
         $list->setLimit($limit);
         $list->setOffset($start);
         $list->setOrder($order);
         $list->setOrderKey($orderKey);
         if ($class->getShowVariants()) {
             $list->setObjectTypes([Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT]);
         }
         $list->load();
         $objects = array();
         foreach ($list->getObjects() as $object) {
             $o = Object\Service::gridObjectData($object, $fields);
             $objects[] = $o;
         }
         $this->_helper->json(array("data" => $objects, "success" => true, "total" => $list->getTotalCount()));
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:101,代码来源:ObjectController.php

示例2: getBatchJobsAction

 public function getBatchJobsAction()
 {
     if ($this->getParam("language")) {
         $this->setLanguage($this->getParam("language"), true);
     }
     $folder = Object::getById($this->getParam("folderId"));
     $class = Object\ClassDefinition::getById($this->getParam("classId"));
     $conditionFilters = array("o_path = ? OR o_path LIKE '" . str_replace("//", "/", $folder->getFullPath() . "/") . "%'");
     if ($this->getParam("filter")) {
         $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
     }
     if ($this->getParam("condition")) {
         $conditionFilters[] = " (" . $this->getParam("condition") . ")";
     }
     $className = $class->getName();
     $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
     $list = new $listClass();
     $list->setCondition(implode(" AND ", $conditionFilters), array($folder->getFullPath()));
     $list->setOrder("ASC");
     $list->setOrderKey("o_id");
     if ($this->getParam("objecttype")) {
         $list->setObjectTypes(array($this->getParam("objecttype")));
     }
     $jobs = $list->loadIdList();
     $this->_helper->json(array("success" => true, "jobs" => $jobs));
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:26,代码来源:ObjectHelperController.php

示例3: findAction


//.........这里部分代码省略.........
         $conditionParts[] = "(" . implode(" AND ", $forbiddenConditions) . ")";
     }
     if (!empty($query)) {
         $queryCondition = "( MATCH (`data`,`properties`) AGAINST (" . $db->quote($query) . " IN BOOLEAN MODE) )";
         // the following should be done with an exact-search now "ID", because the Element-ID is now in the fulltext index
         // if the query is numeric the user might want to search by id
         //if(is_numeric($query)) {
         //$queryCondition = "(" . $queryCondition . " OR id = " . $db->quote($query) ." )";
         //}
         $conditionParts[] = $queryCondition;
     }
     //For objects - handling of bricks
     $fields = array();
     $bricks = array();
     if ($this->getParam("fields")) {
         $fields = $this->getParam("fields");
         foreach ($fields as $f) {
             $parts = explode("~", $f);
             if (substr($f, 0, 1) == "~") {
                 //                    $type = $parts[1];
                 //                    $field = $parts[2];
                 //                    $keyid = $parts[3];
                 // key value, ignore for now
             } else {
                 if (count($parts) > 1) {
                     $bricks[$parts[0]] = $parts[0];
                 }
             }
         }
     }
     // filtering for objects
     if ($this->getParam("filter") && $this->getParam("class")) {
         $class = Object\ClassDefinition::getByName($this->getParam("class"));
         $conditionFilters = Object\Service::getFilterCondition($this->getParam("filter"), $class);
         $join = "";
         foreach ($bricks as $ob) {
             $join .= " LEFT JOIN object_brick_query_" . $ob . "_" . $class->getId();
             $join .= " `" . $ob . "`";
             $join .= " ON `" . $ob . "`.o_id = `object_" . $class->getId() . "`.o_id";
         }
         $conditionParts[] = "( id IN (SELECT `object_" . $class->getId() . "`.o_id FROM object_" . $class->getId() . $join . " WHERE " . $conditionFilters . ") )";
     }
     if (is_array($types) and !empty($types[0])) {
         foreach ($types as $type) {
             $conditionTypeParts[] = $db->quote($type);
         }
         if (in_array("folder", $subtypes)) {
             $conditionTypeParts[] = $db->quote('folder');
         }
         $conditionParts[] = "( maintype IN (" . implode(",", $conditionTypeParts) . ") )";
     }
     if (is_array($subtypes) and !empty($subtypes[0])) {
         foreach ($subtypes as $subtype) {
             $conditionSubtypeParts[] = $db->quote($subtype);
         }
         $conditionParts[] = "( type IN (" . implode(",", $conditionSubtypeParts) . ") )";
     }
     if (is_array($classnames) and !empty($classnames[0])) {
         if (in_array("folder", $subtypes)) {
             $classnames[] = "folder";
         }
         foreach ($classnames as $classname) {
             $conditionClassnameParts[] = $db->quote($classname);
         }
         $conditionParts[] = "( subtype IN (" . implode(",", $conditionClassnameParts) . ") )";
     }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:67,代码来源:SearchController.php

示例4: getVariantsAction


//.........这里部分代码省略.........
                     $brick = $object->{$fieldGetter}()->{$brickGetter}();
                     if (empty($brick)) {
                         $classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
                         $brickSetter = "set" . ucfirst($brickType);
                         $brick = new $classname($object);
                         $object->{$fieldGetter}()->{$brickSetter}($brick);
                     }
                     $brick->{$valueSetter}($value);
                 } else {
                     $objectData[$key] = $value;
                 }
             }
             $object->setValues($objectData);
             try {
                 $object->save();
                 $this->_helper->json(["data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true]);
             } catch (\Exception $e) {
                 $this->_helper->json(["success" => false, "message" => $e->getMessage()]);
             }
         } else {
             throw new \Exception("Permission denied");
         }
     } else {
         $parentObject = Object\Concrete::getById($this->getParam("objectId"));
         if (empty($parentObject)) {
             throw new \Exception("No Object found with id " . $this->getParam("objectId"));
         }
         if ($parentObject->isAllowed("view")) {
             $class = $parentObject->getClass();
             $className = $parentObject->getClass()->getName();
             $start = 0;
             $limit = 15;
             $orderKey = "o_id";
             $order = "ASC";
             $fields = [];
             $bricks = [];
             if ($this->getParam("fields")) {
                 $fields = $this->getParam("fields");
                 foreach ($fields as $f) {
                     $parts = explode("~", $f);
                     if (count($parts) > 1) {
                         $bricks[$parts[0]] = $parts[0];
                     }
                 }
             }
             if ($this->getParam("limit")) {
                 $limit = $this->getParam("limit");
             }
             if ($this->getParam("start")) {
                 $start = $this->getParam("start");
             }
             $orderKey = "o_id";
             $order = "ASC";
             $colMappings = ["filename" => "o_key", "fullpath" => ["o_path", "o_key"], "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate"];
             $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
             if ($sortingSettings['orderKey'] && $sortingSettings['order']) {
                 $orderKey = $sortingSettings['orderKey'];
                 if (array_key_exists($orderKey, $colMappings)) {
                     $orderKey = $colMappings[$orderKey];
                 }
                 $order = $sortingSettings['order'];
             }
             if ($this->getParam("dir")) {
                 $order = $this->getParam("dir");
             }
             $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
             $conditionFilters = ["o_parentId = " . $parentObject->getId()];
             // create filter condition
             if ($this->getParam("filter")) {
                 $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
             }
             if ($this->getParam("condition")) {
                 $conditionFilters[] = "(" . $this->getParam("condition") . ")";
             }
             $list = new $listClass();
             if (!empty($bricks)) {
                 foreach ($bricks as $b) {
                     $list->addObjectbrick($b);
                 }
             }
             $list->setCondition(implode(" AND ", $conditionFilters));
             $list->setLimit($limit);
             $list->setOffset($start);
             $list->setOrder($order);
             $list->setOrderKey($orderKey);
             $list->setObjectTypes([Object\AbstractObject::OBJECT_TYPE_VARIANT]);
             $list->load();
             $objects = [];
             foreach ($list->getObjects() as $object) {
                 if ($object->isAllowed("view")) {
                     $o = Object\Service::gridObjectData($object, $fields);
                     $objects[] = $o;
                 }
             }
             $this->_helper->json(["data" => $objects, "success" => true, "total" => $list->getTotalCount()]);
         } else {
             throw new \Exception("Permission denied");
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:101,代码来源:VariantsController.php

示例5: gridProxyAction


//.........这里部分代码省略.........
         if ($this->getParam("fields")) {
             $fields = $this->getParam("fields");
             foreach ($fields as $f) {
                 $parts = explode("~", $f);
                 $sub = substr($f, 0, 1);
                 if (substr($f, 0, 1) == "~") {
                     $type = $parts[1];
                     //                        $field = $parts[2];
                     //                        $keyid = $parts[3];
                     // key value, ignore for now
                     if ($type == "classificationstore") {
                     }
                 } elseif (count($parts) > 1) {
                     $bricks[$parts[0]] = $parts[0];
                 }
             }
         }
         if ($this->getParam("limit")) {
             $limit = $this->getParam("limit");
         }
         if ($this->getParam("start")) {
             $start = $this->getParam("start");
         }
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         $doNotQuote = false;
         if ($sortingSettings['order']) {
             $order = $sortingSettings['order'];
         }
         if (strlen($sortingSettings['orderKey']) > 0) {
             $orderKey = $sortingSettings['orderKey'];
             if (!(substr($orderKey, 0, 1) == "~")) {
                 if (array_key_exists($orderKey, $colMappings)) {
                     $orderKey = $colMappings[$orderKey];
                 } elseif ($class->getFieldDefinition($orderKey) instanceof Object\ClassDefinition\Data\QuantityValue) {
                     $orderKey = "concat(" . $orderKey . "__unit, " . $orderKey . "__value)";
                     $doNotQuote = true;
                 } elseif (strpos($orderKey, "~") !== false) {
                     $orderKeyParts = explode("~", $orderKey);
                     if (count($orderKeyParts) == 2) {
                         $orderKey = $orderKeyParts[1];
                     }
                 }
             }
         }
         $listClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\Listing";
         $conditionFilters = [];
         if ($this->getParam("only_direct_children") == "true") {
             $conditionFilters[] = "o_parentId = " . $folder->getId();
         } else {
             $conditionFilters[] = "(o_path = '" . $folder->getRealFullPath() . "' OR o_path LIKE '" . str_replace("//", "/", $folder->getRealFullPath() . "/") . "%')";
         }
         if (!$this->getUser()->isAdmin()) {
             $userIds = $this->getUser()->getRoles();
             $userIds[] = $this->getUser()->getId();
             $conditionFilters[] .= " (\n                                                    (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(o_path,o_key),cpath)=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n                                                    OR\n                                                    (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(o_path,o_key))=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n                                                 )";
         }
         $featureJoins = [];
         $featureFilters = false;
         // create filter condition
         if ($this->getParam("filter")) {
             $conditionFilters[] = Object\Service::getFilterCondition($this->getParam("filter"), $class);
             $featureFilters = Object\Service::getFeatureFilters($this->getParam("filter"), $class);
             if ($featureFilters) {
                 $featureJoins = array_merge($featureJoins, $featureFilters["joins"]);
             }
         }
         if ($this->getParam("condition")) {
             $conditionFilters[] = "(" . $this->getParam("condition") . ")";
         }
         $list = new $listClass();
         if (!empty($bricks)) {
             foreach ($bricks as $b) {
                 $list->addObjectbrick($b);
             }
         }
         $list->setCondition(implode(" AND ", $conditionFilters));
         $list->setLimit($limit);
         $list->setOffset($start);
         if (isset($sortingSettings["isFeature"]) && $sortingSettings["isFeature"]) {
             $orderKey = "cskey_" . $sortingSettings["fieldname"] . "_" . $sortingSettings["groupId"] . "_" . $sortingSettings["keyId"];
             $list->setOrderKey($orderKey);
             $list->setGroupBy("o_id");
             $featureJoins[] = $sortingSettings;
         } else {
             $list->setOrderKey($orderKey, !$doNotQuote);
         }
         $list->setOrder($order);
         if ($class->getShowVariants()) {
             $list->setObjectTypes([Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT]);
         }
         Object\Service::addGridFeatureJoins($list, $featureJoins, $class, $featureFilters, $requestedLanguage);
         $list->load();
         $objects = [];
         foreach ($list->getObjects() as $object) {
             $o = Object\Service::gridObjectData($object, $fields, $requestedLanguage);
             $objects[] = $o;
         }
         $this->_helper->json(["data" => $objects, "success" => true, "total" => $list->getTotalCount()]);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:101,代码来源:ObjectController.php

示例6: findAction


//.........这里部分代码省略.........
     if ($this->getParam("fields")) {
         $fields = $this->getParam("fields");
         foreach ($fields as $f) {
             $parts = explode("~", $f);
             if (substr($f, 0, 1) == "~") {
                 //                    $type = $parts[1];
                 //                    $field = $parts[2];
                 //                    $keyid = $parts[3];
                 // key value, ignore for now
             } elseif (count($parts) > 1) {
                 $bricks[$parts[0]] = $parts[0];
             }
         }
     }
     // filtering for objects
     if ($this->getParam("filter") && $this->getParam("class")) {
         $class = Object\ClassDefinition::getByName($this->getParam("class"));
         // add Localized Fields filtering
         $params = \Zend_Json::decode($this->getParam('filter'));
         $unlocalizedFieldsFilters = [];
         $localizedFieldsFilters = [];
         foreach ($params as $paramConditionObject) {
             //this loop divides filter parameters to localized and unlocalized groups
             $definitionExists = in_array('o_' . $paramConditionObject['property'], Object\Service::getSystemFields()) || $class->getFieldDefinition($paramConditionObject['property']);
             if ($definitionExists) {
                 //TODO: for sure, we can add additional condition like getLocalizedFieldDefinition()->getFieldDefiniton(...
                 $unlocalizedFieldsFilters[] = $paramConditionObject;
             } else {
                 $localizedFieldsFilters[] = $paramConditionObject;
             }
         }
         //get filter condition only when filters array is not empty
         //string statements for divided filters
         $conditionFilters = count($unlocalizedFieldsFilters) ? Object\Service::getFilterCondition(\Zend_Json::encode($unlocalizedFieldsFilters), $class) : null;
         $localizedConditionFilters = count($localizedFieldsFilters) ? Object\Service::getFilterCondition(\Zend_Json::encode($localizedFieldsFilters), $class) : null;
         $join = "";
         foreach ($bricks as $ob) {
             $join .= " LEFT JOIN object_brick_query_" . $ob . "_" . $class->getId();
             $join .= " `" . $ob . "`";
             $join .= " ON `" . $ob . "`.o_id = `object_" . $class->getId() . "`.o_id";
         }
         if (null !== $conditionFilters) {
             //add condition query for non localised fields
             $conditionParts[] = "( id IN (SELECT `object_" . $class->getId() . "`.o_id FROM object_" . $class->getId() . $join . " WHERE " . $conditionFilters . ") )";
         }
         if (null !== $localizedConditionFilters) {
             //add condition query for localised fields
             $conditionParts[] = "( id IN (SELECT `object_localized_data_" . $class->getId() . "`.ooo_id FROM object_localized_data_" . $class->getId() . $join . " WHERE " . $localizedConditionFilters . " GROUP BY ooo_id " . ") )";
         }
     }
     if (is_array($types) and !empty($types[0])) {
         foreach ($types as $type) {
             $conditionTypeParts[] = $db->quote($type);
         }
         if (in_array("folder", $subtypes)) {
             $conditionTypeParts[] = $db->quote('folder');
         }
         $conditionParts[] = "( maintype IN (" . implode(",", $conditionTypeParts) . ") )";
     }
     if (is_array($subtypes) and !empty($subtypes[0])) {
         foreach ($subtypes as $subtype) {
             $conditionSubtypeParts[] = $db->quote($subtype);
         }
         $conditionParts[] = "( type IN (" . implode(",", $conditionSubtypeParts) . ") )";
     }
     if (is_array($classnames) and !empty($classnames[0])) {
开发者ID:pimcore,项目名称:pimcore,代码行数:67,代码来源:SearchController.php


注:本文中的Pimcore\Model\Object\Service::getFilterCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。