コード例 #1
0
 public function init()
 {
     parent::init();
     // enable layout only if its a normal request
     if ($this->getRequest()->isXmlHttpRequest() === false) {
         $this->enableLayout();
         $this->setLayout('back-office');
     }
     // sprache setzen
     $language = $this->getUser() ? $this->getUser()->getLanguage() : 'en';
     Zend_Registry::set("Zend_Locale", new Zend_Locale($language));
     $this->language = $language;
     $this->view->language = $language;
     $this->initTranslation();
     // enable inherited values
     Object_Abstract::setGetInheritedValues(true);
     Object_Localizedfield::setGetFallbackValues(true);
     // init
     $this->orderManager = OnlineShop_Framework_Factory::getInstance()->getOrderManager();
 }
コード例 #2
0
 public function preGetData($object)
 {
     if (!$object->localizedfields instanceof Object_Localizedfield) {
         $lf = new Object_Localizedfield();
         $lf->setObject($object);
         $object->localizedfields = $lf;
     }
     return $object->localizedfields;
 }
コード例 #3
0
 /**
  * @param Object_Concrete|Object_Fieldcollection_Data_Abstract|Object_Localizedfield $object
  * @return null | array
  */
 public function load($object, $params = array())
 {
     $db = Pimcore_Resource::get();
     $data = null;
     if ($object instanceof Object_Concrete) {
         if (!method_exists($this, "getLazyLoading") or !$this->getLazyLoading() or $params["force"]) {
             $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'object'", array($object->getO_id(), $this->getName()));
         } else {
             return null;
         }
     } else {
         if ($object instanceof Object_Fieldcollection_Data_Abstract) {
             $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'fieldcollection' AND ownername = ? AND position = ?", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getIndex()));
         } else {
             if ($object instanceof Object_Localizedfield) {
                 $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'localizedfield' AND ownername = 'localizedfield' AND position = ?", array($object->getObject()->getId(), $this->getName(), $params["language"]));
             } else {
                 if ($object instanceof Object_Objectbrick_Data_Abstract) {
                     $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? AND position = ?", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getType()));
                     // THIS IS KIND A HACK: it's necessary because of this bug PIMCORE-1454 and therefore cannot be removed
                     if (count($relations) < 1) {
                         $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? AND (position IS NULL OR position = '')", array($object->getObject()->getId(), $this->getName(), $object->getFieldname()));
                     }
                     // HACK END
                 }
             }
         }
     }
     // using PHP sorting to order the relations, because "ORDER BY index ASC" in the queries above will cause a
     // filesort in MySQL which is extremly slow especially when there are millions of relations in the database
     usort($relations, function ($a, $b) {
         if ($a["index"] == $b["index"]) {
             return 0;
         }
         return $a["index"] < $b["index"] ? -1 : 1;
     });
     $data = $this->getDataFromResource($relations);
     return $data;
 }
コード例 #4
0
ファイル: Resource.php プロジェクト: nblackman/pimcore
 /**
  * @param $e
  * @return array
  */
 protected function exceptionHandler($e)
 {
     // create view if it doesn't exist already // HACK
     if (preg_match("/Base table or view not found/", $e->getMessage()) && $this->firstException) {
         $this->firstException = false;
         $localizedFields = new Object_Localizedfield();
         $localizedFields->setClass(Object_Class::getById($this->model->getClassId()));
         $localizedFields->createUpdateTable();
         return $this->load();
     }
     throw $e;
 }
コード例 #5
0
ファイル: Abstract.php プロジェクト: ngocanh/pimcore
 /**
  * @param Object_Concrete|Object_Fieldcollection_Data_Abstract|Object_Localizedfield $object
  * @return null | array
  */
 public function load($object, $params = array())
 {
     $db = Pimcore_Resource::get();
     if ($object instanceof Object_Concrete) {
         if (!method_exists($this, "getLazyLoading") or !$this->getLazyLoading() or $params["force"]) {
             $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'object' ORDER BY `index` ASC", array($object->getO_id(), $this->getName()));
             return $this->getDataFromResource($relations);
         } else {
             return null;
         }
     } else {
         if ($object instanceof Object_Fieldcollection_Data_Abstract) {
             $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'fieldcollection' AND ownername = ? AND position = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getIndex()));
             return $this->getDataFromResource($relations);
         } else {
             if ($object instanceof Object_Localizedfield) {
                 $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'localizedfield' AND ownername = 'localizedfield' AND position = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $params["language"]));
                 return $this->getDataFromResource($relations);
             } else {
                 if ($object instanceof Object_Objectbrick_Data_Abstract) {
                     $relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $object->getFieldname()));
                     return $this->getDataFromResource($relations);
                 }
             }
         }
     }
 }