示例#1
0
 /**
  *
  */
 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object\AbstractObject) {
                 $indentElement = Object::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
示例#2
0
 /**
  *
  */
 public function restore($user = null)
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } elseif ($element instanceof Asset) {
         $indentElement = Asset::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setFilename($element->getFilename() . "_restore");
         }
     } elseif ($element instanceof Object\AbstractObject) {
         $indentElement = Object::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     }
     if (\Pimcore\Tool\Admin::getCurrentUser()) {
         $parent = $element->getParent();
         if (!$parent->isAllowed("publish")) {
             throw new \Exception("Not sufficient permissions");
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
示例#3
0
 /**
  * Save object to database
  *
  * @return mixed
  */
 protected function getLayoutData()
 {
     $file = PIMCORE_CUSTOMLAYOUT_DIRECTORY . "/custom_definition_" . $this->model->getId() . ".psf";
     if (is_file($file)) {
         return Serialize::unserialize(file_get_contents($file));
     }
     return;
 }
示例#4
0
 /**
  * @static
  * @param Document $doc
  * @return Document
  */
 public static function upperCastDocument(Document $doc)
 {
     $to_class = "Pimcore\\Model\\Document\\Hardlink\\Wrapper\\" . ucfirst($doc->getType());
     $old_serialized_prefix = "O:" . strlen(get_class($doc));
     $old_serialized_prefix .= ":\"" . get_class($doc) . "\":";
     // unset eventually existing children, because of performance reasons when serializing the document
     $doc->setChilds(null);
     $old_serialized_object = Serialize::serialize($doc);
     $new_serialized_object = 'O:' . strlen($to_class) . ':"' . $to_class . '":';
     $new_serialized_object .= substr($old_serialized_object, strlen($old_serialized_prefix));
     $document = Serialize::unserialize($new_serialized_object);
     return $document;
 }
示例#5
0
文件: Dao.php 项目: pimcore/pimcore
 /**
  * @param null $id
  * @throws \Exception
  */
 public function getById($id = null)
 {
     if ($id != null) {
         $this->model->setId($id);
     }
     $data = $this->db->fetchRow("SELECT * FROM targeting_rules WHERE id = ?", $this->model->getId());
     if ($data["id"]) {
         $data["conditions"] = Serialize::unserialize($data["conditions"]);
         $data["actions"] = isset($data["actions"]) ? Serialize::unserialize($data["actions"]) : [];
         $this->assignVariablesToModel($data);
     } else {
         throw new \Exception("target with id " . $this->model->getId() . " doesn't exist");
     }
 }
示例#6
0
文件: Listing.php 项目: sfie/pimcore
 /**
  * @return array
  */
 public function load()
 {
     $fields = array();
     $objectBricksFolder = PIMCORE_CLASS_DIRECTORY . "/objectbricks";
     if (is_dir($objectBricksFolder)) {
         $files = scandir($objectBricksFolder);
         foreach ($files as $file) {
             $file = $objectBricksFolder . "/" . $file;
             if (is_file($file)) {
                 $fieldData = file_get_contents($file);
                 $fields[] = \Pimcore\Tool\Serialize::unserialize($fieldData);
             }
         }
     }
     return $fields;
 }
示例#7
0
 /**
  * @return array
  */
 public function load()
 {
     $fields = [];
     $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections";
     if (is_dir($fieldCollectionFolder)) {
         $files = scandir($fieldCollectionFolder);
         foreach ($files as $file) {
             $file = $fieldCollectionFolder . "/" . $file;
             if (is_file($file)) {
                 $fieldData = file_get_contents($file);
                 $fields[] = \Pimcore\Tool\Serialize::unserialize($fieldData);
             }
         }
     }
     return $fields;
 }
示例#8
0
 /**
  * Get the data for the object by the given id, or by the id which is set in the object
  *
  * @param integer $id
  * @throws \Exception
  */
 public function getById($id = null)
 {
     try {
         if ($id != null) {
             $this->model->setId($id);
         }
         $data = $this->db->fetchRow("SELECT documents.*, documents_page.*, tree_locks.locked FROM documents\n                LEFT JOIN documents_page ON documents.id = documents_page.id\n                LEFT JOIN tree_locks ON documents.id = tree_locks.id AND tree_locks.type = 'document'\n                    WHERE documents.id = ?", $this->model->getId());
         if ($data["id"] > 0) {
             $data["metaData"] = Serialize::unserialize($data["metaData"]);
             $this->assignVariablesToModel($data);
         } else {
             throw new \Exception("Page with the ID " . $this->model->getId() . " doesn't exists");
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#9
0
 /**
  * Moves a file/directory
  *
  * @param string $sourcePath
  * @param string $destinationPath
  * @return void
  */
 public function move($sourcePath, $destinationPath)
 {
     $nameParts = explode("/", $sourcePath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             $asset = null;
             if ($asset = Asset::getByPath("/" . $destinationPath)) {
                 // If we got here, this means the destination exists, and needs to be overwritten
                 $sourceAsset = Asset::getByPath("/" . $sourcePath);
                 $asset->setData($sourceAsset->getData());
                 $sourceAsset->delete();
             }
             // see: Asset\WebDAV\File::delete() why this is necessary
             $log = Asset\WebDAV\Service::getDeleteLog();
             if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
                 $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
                 if ($asset) {
                     $sourceAsset = Asset::getByPath("/" . $sourcePath);
                     $asset->setData($sourceAsset->getData());
                     $sourceAsset->delete();
                 }
             }
             if (!$asset) {
                 $asset = Asset::getByPath("/" . $sourcePath);
             }
             $asset->setFilename(basename($destinationPath));
         } else {
             $asset = Asset::getByPath("/" . $sourcePath);
             $parent = Asset::getByPath("/" . dirname($destinationPath));
             $asset->setPath($parent->getFullPath() . "/");
             $asset->setParentId($parent->getId());
         }
         $user = \Pimcore\Tool\Admin::getCurrentUser();
         $asset->setUserModification($user->getId());
         $asset->save();
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
示例#10
0
 /**
  * @return array|mixed
  */
 protected function loadFile()
 {
     if (!is_dir($this->getConfigDir())) {
         File::mkdir($this->getConfigDir());
     }
     if (empty($this->dashboards)) {
         if (is_file($this->getConfigFile())) {
             $dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
             if (!empty($dashboards)) {
                 $this->dashboards = $dashboards;
             }
         }
         if (empty($this->dashboards)) {
             // if no configuration exists, return the base config
             $this->dashboards = array("welcome" => array("positions" => array(array(array("id" => 1, "type" => "pimcore.layout.portlets.modificationStatistic", "config" => null), array("id" => 2, "type" => "pimcore.layout.portlets.modifiedAssets", "config" => null)), array(array("id" => 3, "type" => "pimcore.layout.portlets.modifiedObjects", "config" => null), array("id" => 4, "type" => "pimcore.layout.portlets.modifiedDocuments", "config" => null)))));
         }
     }
     return $this->dashboards;
 }
示例#11
0
 /**
  * @return array|mixed
  */
 protected function loadFile()
 {
     if (!is_dir($this->getConfigDir())) {
         File::mkdir($this->getConfigDir());
     }
     if (empty($this->dashboards)) {
         if (is_file($this->getConfigFile())) {
             $dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
             if (!empty($dashboards)) {
                 $this->dashboards = $dashboards;
             }
         }
         if (empty($this->dashboards)) {
             $perspectiveCfg = Config::getRuntimePerspective();
             $dasboardCfg = $perspectiveCfg["dashboards"] ? $perspectiveCfg["dashboards"] : [];
             $this->dashboards = $dasboardCfg["predefined"] ? $dasboardCfg["predefined"] : [];
         }
     }
     return $this->dashboards;
 }
示例#12
0
 /**
  * @see Document\Tag\TagInterface::setDataFromResource
  * @param mixed $data
  * @return void
  */
 public function setDataFromResource($data)
 {
     $data = \Pimcore\Tool\Serialize::unserialize($data);
     $this->id = $data["id"];
     $this->type = $data["type"];
     $this->subtype = $data["subtype"];
     $this->setElement();
     return $this;
 }
 public function gridGetColumnConfigAction()
 {
     if ($this->getParam("id")) {
         $class = Object\ClassDefinition::getById($this->getParam("id"));
     } else {
         if ($this->getParam("name")) {
             $class = Object\ClassDefinition::getByName($this->getParam("name"));
         }
     }
     $gridType = "search";
     if ($this->getParam("gridtype")) {
         $gridType = $this->getParam("gridtype");
     }
     $objectId = $this->getParam("objectId");
     if ($objectId) {
         $fields = Object\Service::getCustomGridFieldDefinitions($class->getId(), $objectId);
     }
     if (!$fields) {
         $fields = $class->getFieldDefinitions();
     }
     $types = array();
     if ($this->getParam("types")) {
         $types = explode(",", $this->getParam("types"));
     }
     // grid config
     $gridConfig = array();
     if ($objectId) {
         $configFiles["configFileClassUser"] = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $this->getParam("objectId") . "_" . $class->getId() . "-user_" . $this->getUser()->getId() . ".psf";
         $configFiles["configFileUser"] = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $this->getParam("objectId") . "-user_" . $this->getUser()->getId() . ".psf";
         foreach ($configFiles as $configFile) {
             if (is_file($configFile)) {
                 $gridConfig = Tool\Serialize::unserialize(file_get_contents($configFile));
                 if (is_array($gridConfig) && array_key_exists("classId", $gridConfig)) {
                     if ($gridConfig["classId"] == $class->getId()) {
                         break;
                     } else {
                         $gridConfig = array();
                     }
                 } else {
                     break;
                 }
             }
         }
     }
     $localizedFields = array();
     $objectbrickFields = array();
     foreach ($fields as $key => $field) {
         if ($field instanceof Object\ClassDefinition\Data\Localizedfields) {
             $localizedFields[] = $field;
         } else {
             if ($field instanceof Object\ClassDefinition\Data\Objectbricks) {
                 $objectbrickFields[] = $field;
             }
         }
     }
     $availableFields = array();
     $systemColumns = array("id", "fullpath", "published", "creationDate", "modificationDate", "filename", "classname");
     if (empty($gridConfig)) {
         $count = 0;
         if (!$this->getParam("no_system_columns")) {
             $vis = $class->getPropertyVisibility();
             foreach ($systemColumns as $sc) {
                 $key = $sc;
                 if ($key == "fullpath") {
                     $key = "path";
                 }
                 if (empty($types) && ($vis[$gridType][$key] || $gridType == "all")) {
                     $availableFields[] = array("key" => $sc, "type" => "system", "label" => $sc, "position" => $count);
                     $count++;
                 }
             }
         }
         $includeBricks = !$this->getParam("no_brick_columns");
         foreach ($fields as $key => $field) {
             if ($field instanceof Object\ClassDefinition\Data\Localizedfields) {
                 foreach ($field->getFieldDefinitions() as $fd) {
                     if (empty($types) || in_array($fd->getFieldType(), $types)) {
                         $fieldConfig = $this->getFieldGridConfig($fd, $gridType, $count);
                         if (!empty($fieldConfig)) {
                             $availableFields[] = $fieldConfig;
                             $count++;
                         }
                     }
                 }
             } else {
                 if ($field instanceof Object\ClassDefinition\Data\Objectbricks && $includeBricks) {
                     if (in_array($field->getFieldType(), $types)) {
                         $fieldConfig = $this->getFieldGridConfig($field, $gridType, $count);
                         if (!empty($fieldConfig)) {
                             $availableFields[] = $fieldConfig;
                             $count++;
                         }
                     } else {
                         $allowedTypes = $field->getAllowedTypes();
                         if (!empty($allowedTypes)) {
                             foreach ($allowedTypes as $t) {
                                 $brickClass = Object\Objectbrick\Definition::getByKey($t);
                                 $brickFields = $brickClass->getFieldDefinitions();
                                 if (!empty($brickFields)) {
                                     foreach ($brickFields as $bf) {
                                         $fieldConfig = $this->getFieldGridConfig($bf, $gridType, $count, false, $t . "~");
                                         if (!empty($fieldConfig)) {
                                             $availableFields[] = $fieldConfig;
                                             $count++;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     if (empty($types) || in_array($field->getFieldType(), $types)) {
                         $fieldConfig = $this->getFieldGridConfig($field, $gridType, $count, !empty($types));
                         if (!empty($fieldConfig)) {
                             $availableFields[] = $fieldConfig;
                             $count++;
                         }
                     }
                 }
             }
         }
     } else {
         $savedColumns = $gridConfig['columns'];
         foreach ($savedColumns as $key => $sc) {
             if (!$sc['hidden']) {
                 if (in_array($key, $systemColumns)) {
                     $colConfig = array("key" => $key, "type" => "system", "label" => $key, "position" => $sc['position']);
                     if (isset($sc['width'])) {
                         $colConfig['width'] = $sc['width'];
                     }
                     $availableFields[] = $colConfig;
                 } else {
                     $keyParts = explode("~", $key);
                     if (substr($key, 0, 1) == "~") {
                         // not needed for now
                         //                            $type = $keyParts[1];
                         //                            $field = $keyParts[2];
                         //                            $keyid = $keyParts[3];
                     } else {
                         if (count($keyParts) > 1) {
                             $brick = $keyParts[0];
                             $key = $keyParts[1];
                             $brickClass = Object\Objectbrick\Definition::getByKey($brick);
                             $fd = $brickClass->getFieldDefinition($key);
                             if (!empty($fd)) {
                                 $fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true, $brick . "~");
                                 if (!empty($fieldConfig)) {
                                     if (isset($sc['width'])) {
                                         $fieldConfig['width'] = $sc['width'];
                                     }
                                     $availableFields[] = $fieldConfig;
                                 }
                             }
                         } else {
                             $fd = $class->getFieldDefinition($key);
                             //if not found, look for localized fields
                             if (empty($fd)) {
                                 foreach ($localizedFields as $lf) {
                                     $fd = $lf->getFieldDefinition($key);
                                     if (!empty($fd)) {
                                         break;
                                     }
                                 }
                             }
                             if (!empty($fd)) {
                                 $fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true);
                                 if (!empty($fieldConfig)) {
                                     if (isset($sc['width'])) {
                                         $fieldConfig['width'] = $sc['width'];
                                     }
                                     $availableFields[] = $fieldConfig;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     usort($availableFields, function ($a, $b) {
         if ($a["position"] == $b["position"]) {
             return 0;
         }
         return $a["position"] < $b["position"] ? -1 : 1;
     });
     $config = \Pimcore\Config::getSystemConfig();
     $frontendLanguages = Tool\Admin::reorderWebsiteLanguages(\Pimcore\Tool\Admin::getCurrentUser(), $config->general->validLanguages);
     if ($frontendLanguages) {
         $language = explode(',', $frontendLanguages)[0];
     } else {
         $language = $this->getLanguage();
     }
     if (!Tool::isValidLanguage($language)) {
         $validLanguages = Tool::getValidLanguages();
         $language = $validLanguages[0];
     }
     if (!empty($gridConfig) && !empty($gridConfig['language'])) {
         $language = $gridConfig['language'];
     }
     $this->_helper->json(array("sortinfo" => $gridConfig['sortinfo'], "language" => $language, "availableFields" => $availableFields, "onlyDirectChildren" => $gridConfig['onlyDirectChildren'], "pageSize" => $gridConfig['pageSize']));
 }
示例#14
0
文件: Site.php 项目: solverat/pimcore
 /**
  * @param mixed $domains
  * @return void
  */
 public function setDomains($domains)
 {
     if (is_string($domains)) {
         $domains = \Pimcore\Tool\Serialize::unserialize($domains);
     }
     $this->domains = $domains;
     return $this;
 }
示例#15
0
 /**
  * @see Document\Tag\TagInterface::setDataFromResource
  * @param mixed $data
  * @return void
  */
 public function setDataFromResource($data)
 {
     if (!empty($data)) {
         $data = \Pimcore\Tool\Serialize::unserialize($data);
     }
     $this->id = $data["id"];
     $this->type = $data["type"];
     $this->poster = $data["poster"];
     $this->title = $data["title"];
     $this->description = $data["description"];
     return $this;
 }
示例#16
0
 public function getFolderAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "object")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "object")));
     }
     Element\Editlock::lock($this->getParam("id"), "object");
     $object = Object::getById(intval($this->getParam("id")));
     if ($object->isAllowed("view")) {
         $objectData = array();
         $objectData["general"] = array();
         $objectData["idPath"] = Element\Service::getIdPath($object);
         $allowedKeys = array("o_published", "o_key", "o_id", "o_type", "o_path", "o_modificationDate", "o_creationDate", "o_userOwner", "o_userModification");
         foreach (get_object_vars($object) as $key => $value) {
             if (strstr($key, "o_") && in_array($key, $allowedKeys)) {
                 $objectData["general"][$key] = $value;
             }
         }
         $objectData["general"]["fullpath"] = $object->getFullPath();
         $objectData["general"]["o_locked"] = $object->isLocked();
         $objectData["properties"] = Element\Service::minimizePropertiesForEditmode($object->getProperties());
         $objectData["userPermissions"] = $object->getUserPermissions();
         $objectData["classes"] = $object->getDao()->getClasses();
         // grid-config
         $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf";
         if (is_file($configFile)) {
             $gridConfig = Tool\Serialize::unserialize(file_get_contents($configFile));
             if ($gridConfig) {
                 $objectData["selectedClass"] = $gridConfig["classId"];
             }
         }
         $this->_helper->json($objectData);
     } else {
         \Logger::debug("prevented getting folder id [ " . $object->getId() . " ] because of missing permissions");
         $this->_helper->json(array("success" => false, "message" => "missing_permission"));
     }
 }
 public function getSendStatusAction()
 {
     $letter = Newsletter\Config::getByName($this->getParam("name"));
     $data = null;
     if (file_exists($letter->getPidFile())) {
         $data = Tool\Serialize::unserialize(file_get_contents($letter->getPidFile()));
     }
     $this->_helper->json(array("data" => $data, "success" => true));
 }
示例#18
0
 /**
  * @param mixed $data
  * @return $this
  */
 public function setDataFromResource($data)
 {
     if (strlen($data) > 2) {
         $data = Serialize::unserialize($data);
     }
     $rewritePath = function ($data) {
         if (!is_array($data)) {
             return array();
         }
         foreach ($data as &$element) {
             if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) {
                 foreach ($element["data"] as &$metaData) {
                     // this is for backward compatibility (Array vs. MarkerHotspotItem)
                     if (is_array($metaData)) {
                         $metaData = new Element\Data\MarkerHotspotItem($metaData);
                     }
                 }
             }
         }
         return $data;
     };
     if (array_key_exists("marker", $data) && is_array($data["marker"]) && count($data["marker"]) > 0) {
         $data["marker"] = $rewritePath($data["marker"]);
     }
     if (array_key_exists("hotspots", $data) && is_array($data["hotspots"]) && count($data["hotspots"]) > 0) {
         $data["hotspots"] = $rewritePath($data["hotspots"]);
     }
     $this->id = $data["id"];
     $this->alt = $data["alt"];
     $this->cropPercent = $data["cropPercent"];
     $this->cropWidth = $data["cropWidth"];
     $this->cropHeight = $data["cropHeight"];
     $this->cropTop = $data["cropTop"];
     $this->cropLeft = $data["cropLeft"];
     $this->marker = $data["marker"];
     $this->hotspots = $data["hotspots"];
     return $this;
 }
示例#19
0
 /**
  * @param array $customSettings
  * @return void
  */
 public function setCustomSettings($customSettings)
 {
     if (is_string($customSettings)) {
         $customSettings = \Pimcore\Tool\Serialize::unserialize($customSettings);
     }
     if ($customSettings instanceof \stdClass) {
         $customSettings = (array) $customSettings;
     }
     if (!is_array($customSettings)) {
         $customSettings = array();
     }
     $this->customSettings = $customSettings;
     return $this;
 }
示例#20
0
 /**
  * @see Object\ClassDefinition\Data::getDataFromResource
  * @param string $data
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return string
  */
 public function getDataFromResource($data, $object = null, $params = [])
 {
     return Serialize::unserialize($data);
 }
示例#21
0
 /**
  * Takes data from resource and convert it to internal objects
  *
  * @param mixed $data
  * @return static
  */
 public function setDataFromResource($data)
 {
     // IMPORTANT: if you use this method be sure that the type of the property is already set
     // do not set data for object, asset and document here, this is loaded dynamically when calling $this->getData();
     if ($this->type == "date") {
         $this->data = \Pimcore\Tool\Serialize::unserialize($data);
     } elseif ($this->type == "bool") {
         $this->data = false;
         if (!empty($data)) {
             $this->data = true;
         }
     } else {
         // plain text
         $this->data = $data;
     }
     return $this;
 }
示例#22
0
 /**
  * @see Document\Tag\TagInterface::setDataFromResource
  * @param mixed $data
  * @return void
  */
 public function setDataFromResource($data)
 {
     if ($data = \Pimcore\Tool\Serialize::unserialize($data)) {
         $this->setDataFromEditmode($data);
     }
     return $this;
 }
示例#23
0
 /**
  * @param $key
  * @throws \Exception
  */
 public static function getByKey($key)
 {
     $fc = null;
     $cacheKey = "fieldcollection_" . $key;
     try {
         $fc = \Zend_Registry::get($cacheKey);
         if (!$fc) {
             throw new \Exception("FieldCollection in registry is not valid");
         }
     } catch (\Exception $e) {
         $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections";
         $fieldFile = $fieldCollectionFolder . "/" . $key . ".psf";
         if (is_file($fieldFile)) {
             $fcData = file_get_contents($fieldFile);
             $fc = Serialize::unserialize($fcData);
             \Zend_Registry::set($cacheKey, $fc);
         }
     }
     if ($fc) {
         return $fc;
     }
     throw new \Exception("Field-Collection with key: " . $key . " does not exist.");
 }
示例#24
0
 /**
  * @param string $importValue
  * @return mixed|null|Object\ClassDefinition\Data
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $value = Serialize::unserialize(base64_decode($importValue));
     if ($value instanceof Object\Data\Hotspotimage) {
         return $value;
     } else {
         return null;
     }
 }
示例#25
0
 /**
  * @param $importValue
  * @return mixed|null
  */
 public function getFromCsvImport($importValue)
 {
     $value = Serialize::unserialize(base64_decode($importValue));
     if (is_array($value)) {
         return $value;
     } else {
         return null;
     }
 }
示例#26
0
 /**
  * @see Object\ClassDefinition\Data::getDataFromResource
  * @param string $data
  * @return string
  */
 public function getDataFromResource($data)
 {
     return Serialize::unserialize($data);
 }
示例#27
0
 /**
  * @see Document\Tag\TagInterface::setDataFromResource
  * @param mixed $data
  * @return void
  */
 public function setDataFromResource($data)
 {
     $this->data = \Pimcore\Tool\Serialize::unserialize($data);
     return $this;
 }
示例#28
0
 /**
  * Object
  *
  * @return mixed
  */
 public function loadData()
 {
     $data = null;
     $zipped = false;
     // check both the legacy file path and the new structure
     foreach ([$this->getFilePath(), $this->getLegacyFilePath()] as $path) {
         if (file_exists($path)) {
             $filePath = $path;
             break;
         }
         if (file_exists($path . ".gz")) {
             $filePath = $path . ".gz";
             $zipped = true;
             break;
         }
     }
     if ($zipped && is_file($filePath) && is_readable($filePath)) {
         $data = gzdecode(file_get_contents($filePath));
     } elseif (is_file($filePath) && is_readable($filePath)) {
         $data = file_get_contents($filePath);
     }
     if (!$data) {
         \Logger::err("Version: cannot read version data from file system.");
         $this->delete();
         return;
     }
     if ($this->getSerialized()) {
         $data = Serialize::unserialize($data);
     }
     if ($data instanceof Asset && file_exists($this->getBinaryFilePath())) {
         $binaryHandle = fopen($this->getBinaryFilePath(), "r+");
         $data->setStream($binaryHandle);
     } elseif ($data instanceof Asset && $data->data) {
         // this is for backward compatibility
         $data->setData($data->data);
     }
     $data = Element\Service::renewReferences($data);
     $this->setData($data);
     return $data;
 }
示例#29
0
 /**
  * @see Document\Tag\TagInterface::setDataFromResource
  * @param mixed $data
  * @return void
  */
 public function setDataFromResource($data)
 {
     if (!empty($data)) {
         $data = \Pimcore\Tool\Serialize::unserialize($data);
     }
     $rewritePath = function ($data) {
         if (!is_array($data)) {
             return array();
         }
         foreach ($data as &$page) {
             foreach ($page as &$element) {
                 if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) {
                     foreach ($element["data"] as &$metaData) {
                         if (in_array($metaData["type"], array("object", "asset", "document", "link"))) {
                             $elTtype = $metaData["type"];
                             if ($metaData["type"] == "link") {
                                 $elTtype = "document";
                             }
                             $el = Element\Service::getElementById($elTtype, $metaData["value"]);
                             if (!$el && $metaData["type"] == "link") {
                                 $metaData["value"] = $metaData["value"];
                             } else {
                                 $metaData["value"] = $el;
                             }
                         }
                     }
                 }
             }
         }
         return $data;
     };
     if (array_key_exists("hotspots", $data) && is_array($data["hotspots"]) && count($data["hotspots"]) > 0) {
         $data["hotspots"] = $rewritePath($data["hotspots"]);
     }
     $this->id = $data["id"];
     $this->hotspots = $data["hotspots"];
     $this->texts = $data["texts"];
     $this->chapters = $data["chapters"];
     return $this;
 }
示例#30
0
 /**
  * @param $serializedFilename
  * @return void
  */
 private function cleanupOldFiles($serializedFilename)
 {
     $this->oldClassDefinitions = array();
     if (file_exists($serializedFilename)) {
         $prevSerialized = file_get_contents($serializedFilename);
     }
     $oldObject = Serialize::unserialize($prevSerialized);
     if (!empty($oldObject->classDefinitions)) {
         foreach ($oldObject->classDefinitions as $cl) {
             $this->oldClassDefinitions[$cl['classname']] = $cl['classname'];
             $class = Object\ClassDefinition::getById($cl['classname']);
             if ($class) {
                 $path = $this->getContainerClassFolder($class->getName());
                 @unlink($path . "/" . ucfirst($cl['fieldname'] . ".php"));
                 foreach ($class->getFieldDefinitions() as $fieldDef) {
                     if ($fieldDef instanceof Object\ClassDefinition\Data\Objectbricks) {
                         $allowedTypes = $fieldDef->getAllowedTypes();
                         $idx = array_search($this->getKey(), $allowedTypes);
                         if ($idx !== false) {
                             array_splice($allowedTypes, $idx, 1);
                         }
                         $fieldDef->setAllowedTypes($allowedTypes);
                     }
                 }
                 $class->save();
             }
         }
     }
 }