Inheritance: extends Pimcore\Model\Listing\AbstractListing, implements Zend_Paginator_Adapter_Interface, implements Zend_Paginator_AdapterAggregate, implements Iterator
Ejemplo n.º 1
0
 /**
  * @static
  * @param array $types
  * @return void
  */
 public static function objects($types = null, $classes = null)
 {
     if (empty($types)) {
         $types = array("object", "folder", "variant");
     }
     $classesCondition = "";
     if (!empty($classes)) {
         $classesCondition .= " AND o_className IN ('" . implode("','", $classes) . "')";
     }
     $list = new Object\Listing();
     $list->setCondition("o_type IN ('" . implode("','", $types) . "')" . $classesCondition);
     self::loadToCache($list);
 }
 /**
  * @param \Zend_DB_Select $select
  *
  * @return $this
  */
 protected function addConditions(\Zend_DB_Select $select)
 {
     $condition = $this->model->getCondition();
     if ($condition) {
         $select->where($condition);
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @return Listing
  */
 protected function getListing()
 {
     if (empty($this->list)) {
         $objectList = "\\Pimcore\\Model\\Object\\" . ucfirst($this->class) . "\\Listing";
         $this->list = new $objectList();
         $conditions = ["(newsletterActive = 1 AND newsletterConfirmed = 1)"];
         if ($this->condition) {
             $conditions[] = "(" . $this->condition . ")";
         }
         if ($this->personas) {
             $class = ClassDefinition::getByName($this->class);
             if ($class && $class->getFieldDefinition("persona")) {
                 $personas = [];
                 if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Persona) {
                     foreach ($this->personas as $value) {
                         if (!empty($value)) {
                             $personas[] = $this->list->quote($value);
                         }
                     }
                     $conditions[] = "persona IN (" . implode(",", $personas) . ")";
                 } elseif ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Personamultiselect) {
                     $personasCondition = [];
                     foreach ($this->personas as $value) {
                         $personasCondition[] = "persona LIKE " . $this->list->quote("%," . $value . ",%");
                     }
                     $conditions[] = "(" . implode(" OR ", $personasCondition) . ")";
                 }
             }
         }
         $this->list->setCondition(implode(" AND ", $conditions));
         $this->list->setOrderKey("email");
         $this->list->setOrder("ASC");
         $this->elementsTotal = $this->list->getTotalCount();
     }
     return $this->list;
 }
Ejemplo n.º 4
0
 public function copyInfoAction()
 {
     $transactionId = time();
     $pasteJobs = array();
     Tool\Session::useSession(function ($session) use($transactionId) {
         $session->{$transactionId} = array("idMapping" => array());
     }, "pimcore_copy");
     if ($this->getParam("type") == "recursive" || $this->getParam("type") == "recursive-update-references") {
         $object = Object::getById($this->getParam("sourceId"));
         // first of all the new parent
         $pasteJobs[] = array(array("url" => "/admin/object/copy", "params" => array("sourceId" => $this->getParam("sourceId"), "targetId" => $this->getParam("targetId"), "type" => "child", "transactionId" => $transactionId, "saveParentId" => true)));
         if ($object->hasChilds(array(Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_VARIANT))) {
             // get amount of childs
             $list = new Object\Listing();
             $list->setCondition("o_path LIKE '" . $object->getFullPath() . "/%'");
             $list->setOrderKey("LENGTH(o_path)", false);
             $list->setOrder("ASC");
             $list->setObjectTypes(array(Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_VARIANT));
             $childIds = $list->loadIdList();
             if (count($childIds) > 0) {
                 foreach ($childIds as $id) {
                     $pasteJobs[] = array(array("url" => "/admin/object/copy", "params" => array("sourceId" => $id, "targetParentId" => $this->getParam("targetId"), "sourceParentId" => $this->getParam("sourceId"), "type" => "child", "transactionId" => $transactionId)));
                 }
             }
         }
         // add id-rewrite steps
         if ($this->getParam("type") == "recursive-update-references") {
             for ($i = 0; $i < count($childIds) + 1; $i++) {
                 $pasteJobs[] = array(array("url" => "/admin/object/copy-rewrite-ids", "params" => array("transactionId" => $transactionId, "_dc" => uniqid())));
             }
         }
     } elseif ($this->getParam("type") == "child" || $this->getParam("type") == "replace") {
         // the object itself is the last one
         $pasteJobs[] = array(array("url" => "/admin/object/copy", "params" => array("sourceId" => $this->getParam("sourceId"), "targetId" => $this->getParam("targetId"), "type" => $this->getParam("type"), "transactionId" => $transactionId)));
     }
     $this->_helper->json(array("pastejobs" => $pasteJobs));
 }
Ejemplo n.º 5
0
 public static function getUniqueKey($item, $nr = 0)
 {
     $list = new Listing();
     $list->setUnpublished(true);
     $key = \Pimcore\File::getValidFilename($item->getKey());
     if (!$key) {
         throw new \Exception("No item key set.");
     }
     if ($nr) {
         $key = $key . '_' . $nr;
     }
     $parent = $item->getParent();
     if (!$parent) {
         throw new \Exception("You have to set a parent Object to determine a unique Key");
     }
     if (!$item->getId()) {
         $list->setCondition('o_parentId = ? AND `o_key` = ? ', array($parent->getId(), $key));
     } else {
         $list->setCondition('o_parentId = ? AND `o_key` = ? AND o_id != ? ', array($parent->getId(), $key, $item->getId()));
     }
     $check = $list->loadIdList();
     if (!empty($check)) {
         $nr++;
         $key = self::getUniqueKey($item, $nr);
     }
     return $key;
 }
Ejemplo n.º 6
0
 /**
  * Get a list of the sibling documents
  *
  * @param array $objectTypes
  * @param bool $unpublished
  * @return array
  */
 public function getSiblings($objectTypes = array(self::OBJECT_TYPE_OBJECT, self::OBJECT_TYPE_FOLDER), $unpublished = false)
 {
     if ($this->o_siblings === null || $this->lastGetSiblingObjectTypes != $objectTypes) {
         $list = new Listing();
         $list->setUnpublished($unpublished);
         // string conversion because parentId could be 0
         $list->addConditionParam("o_parentId = ?", (string) $this->getParentId());
         $list->addConditionParam("o_id != ?", $this->getId());
         $list->setOrderKey("o_key");
         $list->setObjectTypes($objectTypes);
         $list->setOrder("asc");
         $this->o_siblings = $list->load();
     }
     return $this->o_siblings;
 }
Ejemplo n.º 7
0
 /**
  * @return void
  */
 public function delete()
 {
     // delete all objects using this class
     $list = new Listing();
     $list->setCondition("o_classId = ?", $this->getId());
     $list->load();
     foreach ($list->getObjects() as $o) {
         $o->delete();
     }
     $this->deletePhpClasses();
     // empty object cache
     try {
         Cache::clearTag("class_" . $this->getId());
     } catch (\Exception $e) {
     }
     // empty output cache
     try {
         Cache::clearTag("output");
     } catch (\Exception $e) {
     }
     $customLayouts = new ClassDefinition\CustomLayout\Listing();
     $customLayouts->setCondition("classId = " . $this->getId());
     $customLayouts = $customLayouts->load();
     foreach ($customLayouts as $customLayout) {
         $customLayout->delete();
     }
     $this->getDao()->delete();
 }