/** * */ public function __wakeup() { $options = $this->getOptions(); if (\Pimcore::inAdmin() || empty($options)) { $this->configureOptions(); } }
/** * @param string $method * @param array $args * @return mixed */ public function callResourceMethod($method, $args) { $capture = false; if (Pimcore::inAdmin()) { $methodsToCheck = array("query", "update", "delete", "insert"); if (in_array($method, $methodsToCheck)) { $capture = true; Pimcore_Resource::startCapturingDefinitionModifications($method, $args); } } //HACK - do not execute transaction methods when //Zend_Registry::set('explicit_transactions', true) was set earlier in code $transactionMethodsToCheck = array('beginTransaction', 'rollBack', 'commit'); try { $explicitTransactions = Zend_Registry::get('explicit_transactions'); } catch (Exception $e) { $explicitTransactions = false; } if (!$explicitTransactions || !in_array($method, $transactionMethodsToCheck)) { $r = call_user_func_array(array($this->getResource(), $method), $args); } if (Pimcore::inAdmin() && $capture) { Pimcore_Resource::stopCapturingDefinitionModifications(); } return $r; }
/** * @return \Pimcore\Model\Object\Fieldcollection */ public function getTokenSettings() { $preValue = $this->preGetValue("tokenSettings"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->getClass()->getFieldDefinition("tokenSettings")->preGetData($this); return $data; }
/** * @param $data * @return static */ public static function __set_state($data) { $obj = parent::__set_state($data); $options = $obj->getOptions(); if (\Pimcore::inAdmin() || empty($options)) { $obj->configureOptions(); } return $obj; }
/** * Get priceRule - Price Rule * @return CoreShop\Model\PriceRule */ public function getPriceRule() { $preValue = $this->preGetValue("priceRule"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->priceRule; return $data; }
/** * Get name - Name * @return string */ public function getName($language = null) { $data = $this->getLocalizedfields()->getLocalizedValue("name", $language); $preValue = $this->preGetValue("name"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } return $data; }
/** * Get name - Name * @return string */ public function getName() { $preValue = $this->preGetValue("name"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->name; return $data; }
/** * @return \Pimcore\Model\Object\Fieldcollection */ public function getFooterobjectdata() { $preValue = $this->preGetValue("footerobjectdata"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->getClass()->getFieldDefinition("footerobjectdata")->preGetData($this); return $data; }
/** * @return User */ protected function init() { //loads select list options $options = $this->getOptions(); if (\Pimcore::inAdmin() || empty($options)) { $this->configureOptions(); } return $this; }
public function getChilds() { if ($this->childs === null) { $childs = parent::getChilds(); $hardLink = $this->getHardLinkSource(); if ($hardLink->getChildsFromSource() && $hardLink->getSourceDocument() && !Pimcore::inAdmin()) { foreach ($childs as &$c) { $c = Document_Hardlink_Service::wrap($c); $c->setHardLinkSource($hardLink); $c->setPath(preg_replace("@^" . preg_quote($hardLink->getSourceDocument()->getFullpath()) . "@", $hardLink->getFullpath(), $c->getPath())); } } $this->setChilds($childs); } return $this->childs; }
/** * @return \Pimcore\Model\Object\Objectbrick */ public function getOfferedServices() { $data = $this->offeredServices; if (!$data) { if (\Pimcore\Tool::classExists("\\Pimcore\\Model\\Object\\Subscriptions\\OfferedServices")) { $data = new \Pimcore\Model\Object\Subscriptions\OfferedServices($this, "offeredServices"); $this->offeredServices = $data; } else { return null; } } $preValue = $this->preGetValue("offeredServices"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } return $data; }
public function __wakeup() { if (Pimcore::inAdmin()) { $this->configureOptions(); } }
/** * @return string */ public function getPath() { // check for site, if so rewrite the path for output try { if (!\Pimcore::inAdmin() && Site::isSiteRequest()) { $site = Site::getCurrentSite(); if ($site instanceof Site) { if ($site->getRootDocument() instanceof Document\Page && $site->getRootDocument() !== $this) { $rootPath = $site->getRootPath(); $rootPath = preg_quote($rootPath); return preg_replace("@^" . $rootPath . "@", "", $this->path); } } } } catch (\Exception $e) { \Logger::error($e); } return $this->path; }
/** * Get icon - icon * @return string */ public function getIcon() { $preValue = $this->preGetValue("icon"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->icon; return $data; }
/** * Get image_3 - Image * @return \Pimcore\Model\Asset\Image */ public function getImage_3() { $preValue = $this->preGetValue("image_3"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->image_3; return $data; }
/** * @param bool $unpublished * @return array|null */ public function getChilds($unpublished = false) { if ($this->childs === null) { $childs = parent::getChilds(); $sourceChilds = array(); if ($this->getChildsFromSource() && $this->getSourceDocument() && !\Pimcore::inAdmin()) { $sourceChilds = $this->getSourceDocument()->getChilds(); foreach ($sourceChilds as &$c) { $c = Document\Hardlink\Service::wrap($c); $c->setHardLinkSource($this); $c->setPath(preg_replace("@^" . preg_quote($this->getSourceDocument()->getFullpath()) . "@", $this->getFullpath(), $c->getPath())); } } $childs = array_merge($sourceChilds, $childs); $this->setChilds($childs); } return $this->childs; }
/** * */ public function getFullPath() { $path = parent::getFullPath(); // do not use pretty url's when in admin, the current document is wrapped by a hardlink or this document isn't in the current site if (!\Pimcore::inAdmin() && !$this instanceof Hardlink\Wrapper\WrapperInterface && \Pimcore\Tool\Frontend::isDocumentInCurrentSite($this)) { // check for a pretty url $prettyUrl = $this->getPrettyUrl(); if (!empty($prettyUrl) && strlen($prettyUrl) > 1) { return $prettyUrl; } } return $path; }
/** * Get cartItemKey - CartItemKey * @return string */ public function getCartItemKey() { $preValue = $this->preGetValue("cartItemKey"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->cartItemKey; return $data; }
/** * Get paymentReference - Payment Ref. * @return string */ public function getPaymentReference() { $preValue = $this->preGetValue("paymentReference"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->paymentReference; return $data; }
/** * Get faqActive - FAQ Active * @return boolean */ public function getFaqActive() { $preValue = $this->preGetValue("faqActive"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->faqActive; return $data; }
/** * prepare data for index creation and store is in store table * * @param OnlineShop_Framework_ProductInterfaces_IIndexable $object */ public function prepareDataForIndex(OnlineShop_Framework_ProductInterfaces_IIndexable $object) { $subObjectIds = $this->tenantConfig->createSubIdsForObject($object); foreach ($subObjectIds as $subObjectId => $object) { /** * @var OnlineShop_Framework_ProductInterfaces_IIndexable $object */ if ($object->getOSDoIndexProduct() && $this->tenantConfig->inIndex($object)) { $a = Pimcore::inAdmin(); $b = \Pimcore\Model\Object\AbstractObject::doGetInheritedValues(); Pimcore::unsetAdminMode(); \Pimcore\Model\Object\AbstractObject::setGetInheritedValues(true); $hidePublishedMemory = \Pimcore\Model\Object\AbstractObject::doHideUnpublished(); \Pimcore\Model\Object\AbstractObject::setHideUnpublished(false); $categories = $object->getCategories(); $categoryIds = array(); $parentCategoryIds = array(); if ($categories) { foreach ($categories as $c) { $parent = $c; if ($parent != null) { if ($parent->getOSProductsInParentCategoryVisible()) { while ($parent && $parent instanceof OnlineShop_Framework_AbstractCategory) { $parentCategoryIds[$parent->getId()] = $parent->getId(); $parent = $parent->getParent(); } } else { $parentCategoryIds[$parent->getId()] = $parent->getId(); } $categoryIds[$c->getId()] = $c->getId(); } } } ksort($categoryIds); $virtualProductId = $subObjectId; $virtualProductActive = $object->isActive(); if ($object->getOSIndexType() == "variant") { $virtualProductId = $this->tenantConfig->createVirtualParentIdForSubId($object, $subObjectId); } $virtualProduct = \Pimcore\Model\Object\AbstractObject::getById($virtualProductId); if ($virtualProduct && method_exists($virtualProduct, "isActive")) { $virtualProductActive = $virtualProduct->isActive(); } $data = array("o_id" => $subObjectId, "o_classId" => $object->getClassId(), "o_virtualProductId" => $virtualProductId, "o_virtualProductActive" => $virtualProductActive, "o_parentId" => $object->getOSParentId(), "o_type" => $object->getOSIndexType(), "categoryIds" => ',' . implode(",", $categoryIds) . ",", "parentCategoryIds" => ',' . implode(",", $parentCategoryIds) . ",", "priceSystemName" => $object->getPriceSystemName(), "active" => $object->isActive(), "inProductList" => $object->isActive(true)); $relationData = array(); $columnConfig = $this->columnConfig->column; if (!empty($columnConfig->name)) { $columnConfig = array($columnConfig); } else { if (empty($columnConfig)) { $columnConfig = array(); } } foreach ($columnConfig as $column) { try { //$data[$column->name] = null; $value = null; if (!empty($column->getter)) { $getter = $column->getter; $value = $getter::get($object, $column->config, $subObjectId, $this->tenantConfig); } else { if (!empty($column->fieldname)) { $getter = "get" . ucfirst($column->fieldname); } else { $getter = "get" . ucfirst($column->name); } if (method_exists($object, $getter)) { $value = $object->{$getter}($column->locale); } } if (!empty($column->interpreter)) { $interpreter = $column->interpreter; $value = $interpreter::interpret($value, $column->config); $interpreterObject = new $interpreter(); if ($interpreterObject instanceof OnlineShop_Framework_IndexService_RelationInterpreter) { foreach ($value as $v) { $relData = array(); $relData['src'] = $subObjectId; $relData['src_virtualProductId'] = $virtualProductId; $relData['dest'] = $v['dest']; $relData['fieldname'] = $column->name; $relData['type'] = $v['type']; $relationData[] = $relData; } } else { $data[$column->name] = $value; } } else { $data[$column->name] = $value; } if (is_array($data[$column->name])) { $data[$column->name] = OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER . implode($data[$column->name], OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER) . OnlineShop_Framework_IndexService_Tenant_IWorker::MULTISELECT_DELIMITER; } } catch (Exception $e) { Logger::err("Exception in IndexService: " . $e->getMessage(), $e); } } if ($a) { Pimcore::setAdminMode(); } \Pimcore\Model\Object\AbstractObject::setGetInheritedValues($b); \Pimcore\Model\Object\AbstractObject::setHideUnpublished($hidePublishedMemory); $subTenantData = $this->tenantConfig->prepareSubTenantEntries($object, $subObjectId); $jsonData = json_encode(array("data" => $data, "relations" => $relationData ? $relationData : [], "subtenants" => $subTenantData ? $subTenantData : [])); $crc = crc32($jsonData); $insertData = array("id" => $subObjectId, "tenant" => $this->name, "data" => $jsonData, "crc_current" => $crc, "preparation_worker_timestamp" => 0, "preparation_worker_id" => $this->db->quote(null), "in_preparation_queue" => 0); $currentEntry = $this->db->fetchRow("SELECT crc_current, in_preparation_queue FROM " . $this->getStoreTableName() . " WHERE id = ? AND tenant = ?", array($subObjectId, $this->name)); if (!$currentEntry) { $this->db->insert($this->getStoreTableName(), $insertData); } else { if ($currentEntry['crc_current'] != $crc) { $this->db->update($this->getStoreTableName(), $insertData, "id = " . $this->db->quote((string) $subObjectId) . " AND tenant = " . $this->db->quote($this->name)); } else { if ($currentEntry['in_preparation_queue']) { $this->db->query("UPDATE " . $this->getStoreTableName() . " SET in_preparation_queue = 0, preparation_worker_timestamp = 0, preparation_worker_id = null WHERE id = ? AND tenant = ?", array($subObjectId, $this->name)); } } } } else { Logger::info("Don't adding product " . $subObjectId . " to index " . $this->name . "."); $this->doDeleteFromIndex($subObjectId); } } //cleans up all old zombie data $this->doCleanupOldZombieData($object, $subObjectIds); }
public function hasChildren() { $hardLink = $this->getHardLinkSource(); if ($hardLink->getChildrenFromSource() && $hardLink->getSourceDocument() && !\Pimcore::inAdmin()) { return parent::hasChildren(); } return false; }
public function save() { // check if there's a valid user if (!$this->getUser()) { // try to use the logged in user if (\Pimcore::inAdmin()) { if ($user = \Pimcore\Tool\Admin::getCurrentUser()) { $this->setUser($user->getId()); } } } $this->getResource()->save(); }
/** * Get email - Send E-Mail to Customer * @return boolean */ public function getEmail() { $preValue = $this->preGetValue("email"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->email; return $data; }
/** * Get start - start * @return \Pimcore\Date */ public function getStart() { $preValue = $this->preGetValue("start"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->start; return $data; }
/** * Get terms - Terms of Use * @return boolean */ public function getTerms() { $preValue = $this->preGetValue("terms"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->terms; return $data; }
/** * @param string $method * @param array $args * @return mixed */ public function callResourceMethod($method, $args) { $resource = $this->getResource(); if ($this->inTransaction || Db::isWriteQuery($method, $args)) { $resource = $this->getWriteResource(); } $capture = false; if (\Pimcore::inAdmin()) { $methodsToCheck = array("query", "update", "delete", "insert"); if (in_array($method, $methodsToCheck)) { $capture = true; Db::startCapturingDefinitionModifications($resource, $method, $args); } } $r = call_user_func_array(array($resource, $method), $args); if (\Pimcore::inAdmin() && $capture) { Db::stopCapturingDefinitionModifications($resource); } return $r; }
/** * @param string $method * @param array $args * @return mixed */ public function callResourceMethod($method, $args) { $resource = $this->getResource(); /*if($method == "query" && Pimcore_Resource::isDDLQuery($args[0])) { $resource = $this->getDDLResource(); }*/ $capture = false; if (\Pimcore::inAdmin()) { $methodsToCheck = array("query", "update", "delete", "insert"); if (in_array($method, $methodsToCheck)) { $capture = true; Resource::startCapturingDefinitionModifications($resource, $method, $args); } } $r = call_user_func_array(array($resource, $method), $args); if (\Pimcore::inAdmin() && $capture) { Resource::stopCapturingDefinitionModifications($resource); } return $r; }
/** * Get posterImage - Poster Image * @return Object_Data_Hotspotimage */ public function getPosterImage() { $preValue = $this->preGetValue("posterImage"); if ($preValue !== null && !\Pimcore::inAdmin()) { return $preValue; } $data = $this->posterImage; return $data; }
/** * Returns the full path of the document including the filename * * @return string */ public function getFullPath() { $path = $this->getPath() . $this->getFilename(); if (!\Pimcore::inAdmin()) { $results = \Pimcore::getEventManager()->trigger("frontend.path.asset", $this); if ($results->count()) { $path = $results->last(); } } return $path; }