/** * */ public function save() { $data = $this->model->getDataForResource(); if (is_array($data) or is_object($data)) { $data = \Pimcore\Tool\Serialize::serialize($data); } $element = array("data" => $data, "documentId" => $this->model->getDocumentId(), "name" => $this->model->getName(), "type" => $this->model->getType()); $this->db->insertOrUpdate("documents_elements", $element); }
/** * @param mixed $data * @param bool $sendNow * @param bool $keepLayouts * @param bool $encodeData * @return string|void */ public function direct($data, $sendNow = true, $keepLayouts = false, $encodeData = true) { if ($encodeData) { $data = \Pimcore\Tool\Serialize::removeReferenceLoops($data); } // hack for FCGI because ZF doesn't care of duplicate headers $this->getResponse()->clearHeader("Content-Type"); $this->suppressExit = !$sendNow; $d = $this->sendJson($data, $keepLayouts, $encodeData); return $d; }
/** * @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; }
public function encode($data, $returnData = false) { $data = \Pimcore\Tool\Serialize::removeReferenceLoops($data); $data = \Zend_Json::encode($data, null, array()); if ($returnData) { return $data; } else { $response = \Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader('Content-Type', 'application/json', true); $response->setBody($data); $response->sendResponse(); exit; } }
/** * Save changes to database, it's an good idea to use save() instead * * @return void */ public function update() { $site = get_object_vars($this->model); foreach ($site as $key => $value) { if (in_array($key, $this->getValidTableColumns("schedule_tasks"))) { if (is_array($value) || is_object($value)) { $value = \Pimcore\Tool\Serialize::serialize($value); } elseif (is_bool($value)) { $value = (int) $value; } $data[$key] = $value; } } $this->db->update("schedule_tasks", $data, $this->db->quoteInto("id = ?", $this->model->getId())); }
/** * @throws DAV\Exception\Forbidden * @throws \Exception */ function delete() { if ($this->asset->isAllowed("delete")) { Asset\Service::loadAllFields($this->asset); $this->asset->delete(); // add the asset to the delete history, this is used so come over problems with programs like photoshop (delete, create instead of replace => move) // for details see Asset\WebDAV\Tree::move() $log = Asset\WebDAV\Service::getDeleteLog(); $this->asset->_fulldump = true; $log[$this->asset->getFullpath()] = array("id" => $this->asset->getId(), "timestamp" => time(), "data" => \Pimcore\Tool\Serialize::serialize($this->asset)); unset($this->asset->_fulldump); Asset\WebDAV\Service::saveDeleteLog($log); } else { throw new DAV\Exception\Forbidden(); } }
/** * Save object to database * * @return void */ public function save() { $data = $this->model->getData(); if ($this->model->getType() == "object" || $this->model->getType() == "asset" || $this->model->getType() == "document") { if ($data instanceof Model\Element\ElementInterface) { $data = $data->getId(); } else { $data = null; } } if (is_array($data) || is_object($data)) { $data = \Pimcore\Tool\Serialize::serialize($data); } $saveData = array("cid" => $this->model->getCid(), "ctype" => $this->model->getCtype(), "cpath" => $this->model->getCpath(), "name" => $this->model->getName(), "type" => $this->model->getType(), "inheritable" => (int) $this->model->getInheritable(), "data" => $data); $this->db->insertOrUpdate("properties", $saveData); }
/** * @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; }
/** * @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; }
/** * 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; } }
/** * 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); } }
/** * @throws \Exception */ public function update() { try { $type = get_object_vars($this->model); foreach ($type as $key => $value) { if (in_array($key, $this->getValidTableColumns("targeting_personas"))) { if (is_array($value) || is_object($value)) { $value = Serialize::serialize($value); } if (is_bool($value)) { $value = (int) $value; } $data[$key] = $value; } } $this->db->update("targeting_personas", $data, $this->db->quoteInto("id = ?", $this->model->getId())); } catch (\Exception $e) { throw $e; } }
/** * @throws \Exception */ public function update() { try { $type = get_object_vars($this->model); foreach ($type as $key => $value) { if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_RELATIONS))) { if (is_bool($value)) { $value = (int) $value; } if (is_array($value) || is_object($value)) { $value = \Pimcore\Tool\Serialize::serialize($value); } $data[$key] = $value; } } $this->db->insertOrUpdate(self::TABLE_NAME_RELATIONS, $data); return $this->model; } catch (\Exception $e) { throw $e; } }
/** * @throws \Exception */ public function update() { try { $ts = time(); $this->model->setModificationDate($ts); $type = get_object_vars($this->model); foreach ($type as $key => $value) { if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_KEYS))) { if (is_bool($value)) { $value = (int) $value; } if (is_array($value) || is_object($value)) { if ($this->model->getType() == 'select') { $value = \Zend_Json::encode($value); } else { $value = \Pimcore\Tool\Serialize::serialize($value); } } $data[$key] = $value; } } $this->db->update(self::TABLE_NAME_KEYS, $data, $this->db->quoteInto("id = ?", $this->model->getId())); return $this->model; } catch (\Exception $e) { throw $e; } }
public function saveFolderAction() { $object = Object::getById($this->getParam("id")); $classId = $this->getParam("class_id"); // general settings $general = \Zend_Json::decode($this->getParam("general")); $object->setValues($general); $object->setUserModification($this->getUser()->getId()); $object = $this->assignPropertiesFromEditmode($object); if ($object->isAllowed("publish")) { try { // grid config $gridConfig = \Zend_Json::decode($this->getParam("gridconfig")); if ($classId) { $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "_" . $classId . "-user_" . $this->getUser()->getId() . ".psf"; } else { $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf"; } $configDir = dirname($configFile); if (!is_dir($configDir)) { File::mkdir($configDir); } File::put($configFile, Tool\Serialize::serialize($gridConfig)); $object->save(); $this->_helper->json(array("success" => true)); } catch (\Exception $e) { $this->_helper->json(array("success" => false, "message" => $e->getMessage())); } } $this->_helper->json(array("success" => false, "message" => "missing_permission")); }
/** * Update data from object to the database * * @throws \Exception */ public function update() { try { $this->model->setModificationDate(time()); $asset = get_object_vars($this->model); foreach ($asset as $key => $value) { if (in_array($key, $this->getValidTableColumns("assets"))) { if (is_array($value)) { $value = \Pimcore\Tool\Serialize::serialize($value); } $data[$key] = $value; } } // metadata $this->db->delete("assets_metadata", "cid = " . $this->model->getId()); $metadata = $this->model->getMetadata(); $data["hasMetaData"] = 0; if (!empty($metadata)) { foreach ($metadata as $metadataItem) { $metadataItem["cid"] = $this->model->getId(); unset($metadataItem['config']); if ($metadataItem["data"] instanceof Model\Element\ElementInterface) { $metadataItem["data"] = $metadataItem["data"]->getId(); } if (strlen($metadataItem["data"]) > 0) { $this->db->insert("assets_metadata", $metadataItem); $data["hasMetaData"] = 1; } } } $this->db->insertOrUpdate("assets", $data); // tree_locks $this->db->delete("tree_locks", "id = " . $this->model->getId() . " AND type = 'asset'"); if ($this->model->getLocked()) { $this->db->insert("tree_locks", array("id" => $this->model->getId(), "type" => "asset", "locked" => $this->model->getLocked())); } } catch (\Exception $e) { throw $e; } }
/** * @see Object\ClassDefinition\Data::getDataFromResource * @param string $data * @return string */ public function getDataFromResource($data) { return Serialize::unserialize($data); }
/** * This is just for compatibility, this method will be removed with the next major release * @depricated * @static * @param $config * @return self */ public static function getByLegacyConfig($config) { $pipe = new self(); if (isset($config["format"])) { $pipe->setFormat($config["format"]); } if (isset($config["quality"])) { $pipe->setQuality($config["quality"]); } if (isset($config["cover"])) { $pipe->addItem("cover", ["width" => $config["width"], "height" => $config["height"], "positioning" => "center"]); } elseif (isset($config["contain"])) { $pipe->addItem("contain", ["width" => $config["width"], "height" => $config["height"]]); } elseif (isset($config["frame"])) { $pipe->addItem("frame", ["width" => $config["width"], "height" => $config["height"]]); } elseif (isset($config["aspectratio"]) && $config["aspectratio"]) { if (isset($config["height"]) && isset($config["width"]) && $config["height"] > 0 && $config["width"] > 0) { $pipe->addItem("contain", ["width" => $config["width"], "height" => $config["height"]]); } elseif (isset($config["height"]) && $config["height"] > 0) { $pipe->addItem("scaleByHeight", ["height" => $config["height"]]); } else { $pipe->addItem("scaleByWidth", ["width" => $config["width"]]); } } else { if (!isset($config["width"]) && isset($config["height"])) { $pipe->addItem("scaleByHeight", ["height" => $config["height"]]); } elseif (isset($config["width"]) && !isset($config["height"])) { $pipe->addItem("scaleByWidth", ["width" => $config["width"]]); } elseif (isset($config["width"]) && isset($config["height"])) { $pipe->addItem("resize", ["width" => $config["width"], "height" => $config["height"]]); } } if (isset($config["highResolution"])) { $pipe->setHighResolution($config["highResolution"]); } $hash = md5(Serialize::serialize($pipe)); $pipe->setName("auto_" . $hash); return $pipe; }
/** * @param null $thumbnailName * @return mixed */ public function getThumbnail($thumbnailName = null) { if (!$this->getImage()) { return ""; } $crop = null; if (is_array($this->getCrop())) { $crop = $this->getCrop(); } $thumbConfig = $this->getImage()->getThumbnailConfig($thumbnailName); if (!$thumbConfig && $crop) { $thumbConfig = new Asset\Image\Thumbnail\Config(); } if ($crop) { $thumbConfig->addItemAt(0, "cropPercent", array("width" => $crop["cropWidth"], "height" => $crop["cropHeight"], "y" => $crop["cropTop"], "x" => $crop["cropLeft"])); $hash = md5(\Pimcore\Tool\Serialize::serialize($thumbConfig->getItems())); $thumbConfig->setName($thumbConfig->getName() . "_auto_" . $hash); } return $this->getImage()->getThumbnail($thumbConfig); }
/** * @throws \Exception */ public function save() { if (!$this->getKey()) { throw new \Exception("A field-collection needs a key to be saved!"); } $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections"; // create folder if not exist if (!is_dir($fieldCollectionFolder)) { File::mkdir($fieldCollectionFolder); } $serialized = Serialize::serialize($this); $definitionFile = $fieldCollectionFolder . "/" . $this->getKey() . ".psf"; if (!is_writable(dirname($definitionFile)) || is_file($definitionFile) && !is_writable($definitionFile)) { throw new \Exception("Cannot write definition file in: " . $definitionFile . " please check write permission on this directory."); } File::put($definitionFile, $serialized); $extendClass = "Object\\Fieldcollection\\Data\\AbstractData"; if ($this->getParentClass()) { $extendClass = $this->getParentClass(); $extendClass = "\\" . ltrim($extendClass, "\\"); } // create class file $cd = '<?php '; $cd .= "\n\n"; $cd .= "/** Generated at " . date('c') . " */"; $cd .= "\n\n"; $cd .= "/**\n"; if ($_SERVER["REMOTE_ADDR"]) { $cd .= "* IP: " . $_SERVER["REMOTE_ADDR"] . "\n"; } $cd .= "*/\n"; $cd .= "\n\n"; $cd .= "namespace Pimcore\\Model\\Object\\Fieldcollection\\Data;"; $cd .= "\n\n"; $cd .= "use Pimcore\\Model\\Object;"; $cd .= "\n\n"; $cd .= "class " . ucfirst($this->getKey()) . " extends " . $extendClass . " {"; $cd .= "\n\n"; $cd .= 'public $type = "' . $this->getKey() . "\";\n"; if (is_array($this->getFieldDefinitions()) && count($this->getFieldDefinitions())) { foreach ($this->getFieldDefinitions() as $key => $def) { $cd .= "public \$" . $key . ";\n"; } } $cd .= "\n\n"; if (is_array($this->getFieldDefinitions()) && count($this->getFieldDefinitions())) { $relationTypes = array(); foreach ($this->getFieldDefinitions() as $key => $def) { /** * @var $def Object\ClassDefinition\Data */ $cd .= $def->getGetterCodeFieldcollection($this); $cd .= $def->getSetterCodeFieldcollection($this); } } $cd .= "}\n"; $cd .= "\n"; $fieldClassFolder = PIMCORE_CLASS_DIRECTORY . "/Object/Fieldcollection/Data"; if (!is_dir($fieldClassFolder)) { File::mkdir($fieldClassFolder); } $classFile = $fieldClassFolder . "/" . ucfirst($this->getKey()) . ".php"; if (!is_writable(dirname($classFile)) || is_file($classFile) && !is_writable($classFile)) { throw new \Exception("Cannot write definition file in: " . $classFile . " please check write permission on this directory."); } File::put($classFile, $cd); // update classes $classList = new Object\ClassDefinition\Listing(); $classes = $classList->load(); if (is_array($classes)) { foreach ($classes as $class) { foreach ($class->getFieldDefinitions() as $fieldDef) { if ($fieldDef instanceof Object\ClassDefinition\Data\Fieldcollections) { if (in_array($this->getKey(), $fieldDef->getAllowedTypes())) { $this->getResource()->createUpdateTable($class); break; } } } } } }
/** * @throws \Exception * @throws \Zend_Db_Adapter_Exception */ public function update() { $class = get_object_vars($this->model); $data = array(); foreach ($class as $key => $value) { if (in_array($key, $this->getValidTableColumns("custom_layouts"))) { if (is_array($value) || is_object($value)) { $value = Serialize::serialize($value); } else { if (is_bool($value)) { $value = (int) $value; } } $data[$key] = $value; } } $this->db->update("custom_layouts", $data, $this->db->quoteInto("id = ?", $this->model->getId())); // save definition as a serialized file $definitionFile = PIMCORE_CUSTOMLAYOUT_DIRECTORY . "/custom_definition_" . $this->model->getId() . ".psf"; if (!is_writable(dirname($definitionFile)) || is_file($definitionFile) && !is_writable($definitionFile)) { throw new \Exception("Cannot write definition file in: " . $definitionFile . " please check write permission on this directory."); } File::put($definitionFile, Serialize::serialize($this->model->layoutDefinitions)); }
/** * @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'])); }
/** * 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; }
/** * @see Document\Tag\TagInterface::setDataFromResource * @param mixed $data * @return void */ public function setDataFromResource($data) { $this->data = \Pimcore\Tool\Serialize::unserialize($data); return $this; }
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)); }
/** * @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; }
/** * @param $importValue * @return mixed|null */ public function getFromCsvImport($importValue) { $value = Serialize::unserialize(base64_decode($importValue)); if (is_array($value)) { return $value; } else { return null; } }
/** * @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; }
/** * @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; } }