当前位置: 首页>>代码示例>>PHP>>正文


PHP Version::getById方法代码示例

本文整理汇总了PHP中Pimcore\Model\Version::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::getById方法的具体用法?PHP Version::getById怎么用?PHP Version::getById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Model\Version的用法示例。


在下文中一共展示了Version::getById方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLatestVersion

 /**
  * Get latest available version, using $force always returns a version no matter if it is the same as the published one
  * @param bool $force
  * @return array
  */
 public function getLatestVersion($force = false)
 {
     $versionData = $this->db->fetchRow("SELECT id,date FROM versions WHERE cid = ? AND ctype='document' ORDER BY `id` DESC LIMIT 1", $this->model->getId());
     if ($versionData["id"] && $versionData["date"] > $this->model->getModificationDate() || $force) {
         $version = Version::getById($versionData["id"]);
         return $version;
     }
     return;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:14,代码来源:Dao.php

示例2: load

 /**
  * Loads a list of thumanils for the specicifies parameters, returns an array of Schedule\Task elements
  *
  * @return array
  */
 public function load()
 {
     $versions = array();
     $data = $this->db->fetchCol("SELECT id FROM versions" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $id) {
         $versions[] = Model\Version::getById($id);
     }
     $this->model->setVersions($versions);
     return $versions;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:15,代码来源:Dao.php

示例3: diffVersionsAction

 public function diffVersionsAction()
 {
     Pimcore\Model\Object\AbstractObject::setDoNotRestoreKeyAndPath(true);
     $id1 = intval($this->getParam("from"));
     $id2 = intval($this->getParam("to"));
     $version1 = Model\Version::getById($id1);
     $object1 = $version1->loadData();
     $version2 = Model\Version::getById($id2);
     $object2 = $version2->loadData();
     Pimcore\Model\Object\AbstractObject::setDoNotRestoreKeyAndPath(false);
     if ($object1 && $object2) {
         if ($object1->isAllowed("versions") && $object2->isAllowed("versions")) {
             $this->view->object1 = $object1;
             $this->view->object2 = $object2;
         } else {
             throw new \Exception("Permission denied, version ids [" . $id1 . ", " . $id2 . "]");
         }
     } else {
         throw new \Exception("Version with ids [" . $id1 . ", " . $id2 . "] doesn't exist");
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:21,代码来源:ObjectController.php

示例4: deleteVersionAction

 public function deleteVersionAction()
 {
     $version = Model\Version::getById($this->getParam("id"));
     $version->delete();
     $this->_helper->json(["success" => true]);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:6,代码来源:Element.php

示例5: init

 /**
  * @throws \Zend_Controller_Router_Exception
  */
 public function init()
 {
     // this is only executed once per request (first request)
     if (self::$isInitial) {
         \Pimcore::getEventManager()->trigger("frontend.controller.preInit", $this);
     }
     parent::init();
     // log exceptions if handled by error_handler
     $this->checkForErrors();
     // general definitions
     if (self::$isInitial) {
         \Pimcore::unsetAdminMode();
         Document::setHideUnpublished(true);
         Object\AbstractObject::setHideUnpublished(true);
         Object\AbstractObject::setGetInheritedValues(true);
         Object\Localizedfield::setGetFallbackValues(true);
     }
     // assign variables
     $this->view->controller = $this;
     // init website config
     $config = Config::getWebsiteConfig();
     $this->config = $config;
     $this->view->config = $config;
     $document = $this->getParam("document");
     if (!$document instanceof Document) {
         \Zend_Registry::set("pimcore_editmode", false);
         $this->editmode = false;
         $this->view->editmode = false;
         self::$isInitial = false;
         // check for a locale first, and set it if available
         if ($this->getParam("pimcore_parentDocument")) {
             // this is a special exception for renderlets in editmode (ajax request), because they depend on the locale of the parent document
             // otherwise there'll be notices like:  Notice: 'No translation for the language 'XX' available.'
             if ($parentDocument = Document::getById($this->getParam("pimcore_parentDocument"))) {
                 if ($parentDocument->getProperty("language")) {
                     $this->setLocaleFromDocument($parentDocument->getProperty("language"));
                 }
             }
         }
         // no document available, continue, ...
         return;
     } else {
         $this->setDocument($document);
         // register global locale if the document has the system property "language"
         if ($this->getDocument()->getProperty("language")) {
             $this->setLocaleFromDocument($this->getDocument()->getProperty("language"));
         }
         if (self::$isInitial) {
             // append meta-data to the headMeta() view helper,  if it is a document-request
             if (!Model\Staticroute::getCurrentRoute() && $this->getDocument() instanceof Document\Page) {
                 if (is_array($this->getDocument()->getMetaData())) {
                     foreach ($this->getDocument()->getMetaData() as $meta) {
                         // only name
                         if (!empty($meta["idName"]) && !empty($meta["idValue"]) && !empty($meta["contentValue"])) {
                             $method = "append" . ucfirst($meta["idName"]);
                             $this->view->headMeta()->{$method}($meta["idValue"], $meta["contentValue"]);
                         }
                     }
                 }
             }
         }
     }
     // this is only executed once per request (first request)
     if (self::$isInitial) {
         // contains the logged in user if necessary
         $user = null;
         // default is to set the editmode to false, is enabled later if necessary
         \Zend_Registry::set("pimcore_editmode", false);
         if (Tool::isFrontentRequestByAdmin()) {
             $this->disableBrowserCache();
             // start admin session & get logged in user
             $user = Authentication::authenticateSession();
         }
         if (\Pimcore::inDebugMode()) {
             $this->disableBrowserCache();
         }
         if (!$this->document->isPublished()) {
             if (Tool::isFrontentRequestByAdmin()) {
                 if (!$user) {
                     throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
                 }
             } else {
                 throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
             }
         }
         // logged in users only
         if ($user) {
             // set the user to registry so that it is available via \Pimcore\Tool\Admin::getCurrentUser();
             \Zend_Registry::set("pimcore_admin_user", $user);
             // document editmode
             if ($this->getParam("pimcore_editmode")) {
                 \Zend_Registry::set("pimcore_editmode", true);
                 // check if there is the document in the session
                 $docKey = "document_" . $this->getDocument()->getId();
                 $docSession = Session::getReadOnly("pimcore_documents");
                 if ($docSession->{$docKey}) {
                     // if there is a document in the session use it
//.........这里部分代码省略.........
开发者ID:tododo,项目名称:pimcore,代码行数:101,代码来源:Frontend.php

示例6: versionUpdateAction

 public function versionUpdateAction()
 {
     $data = \Zend_Json::decode($this->getParam("data"));
     $version = Version::getById($data["id"]);
     $version->setPublic($data["public"]);
     $version->setNote($data["note"]);
     $version->save();
     $this->_helper->json(["success" => true]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:9,代码来源:ElementController.php

示例7: maintenanceCleanUp

 /**
  *
  */
 public function maintenanceCleanUp()
 {
     $conf["document"] = Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Config::getSystemConfig()->assets->versions;
     $conf["object"] = Config::getSystemConfig()->objects->versions;
     $elementTypes = array();
     foreach ($conf as $elementType => $tConf) {
         if (intval($tConf->days) > 0) {
             $versioningType = "days";
             $value = intval($tConf->days);
         } else {
             $versioningType = "steps";
             $value = intval($tConf->steps);
         }
         if ($versioningType) {
             $elementTypes[] = array("elementType" => $elementType, $versioningType => $value);
         }
     }
     $ignoredIds = array();
     while (true) {
         $versions = $this->getDao()->maintenanceGetOutdatedVersions($elementTypes, $ignoredIds);
         if (count($versions) == 0) {
             break;
         }
         $counter = 0;
         \Logger::debug("versions to check: " . count($versions));
         if (is_array($versions) && !empty($versions)) {
             $totalCount = count($versions);
             foreach ($versions as $index => $id) {
                 try {
                     $version = Version::getById($id);
                 } catch (\Exception $e) {
                     $ignoredIds[] = $id;
                     \Logger::debug("Version with " . $id . " not found\n");
                     continue;
                 }
                 $counter++;
                 // do not delete public versions
                 if ($version->getPublic()) {
                     $ignoredIds[] = $version->getId();
                     continue;
                 }
                 if ($version->getCtype() == "document") {
                     $element = Document::getById($version->getCid());
                 } elseif ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } elseif ($version->getCtype() == "object") {
                     $element = Object::getById($version->getCid());
                 }
                 if ($element instanceof ElementInterface) {
                     \Logger::debug("currently checking Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element) . " in cycle: " . $counter . "/" . $totalCount);
                     if ($element->getModificationDate() >= $version->getDate()) {
                         // delete version if it is outdated
                         \Logger::debug("delete version: " . $version->getId() . " because it is outdated");
                         $version->delete();
                     } else {
                         $ignoredIds[] = $version->getId();
                         \Logger::debug("do not delete version (" . $version->getId() . ") because version's date is newer than the actual modification date of the element. Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element));
                     }
                 } else {
                     // delete version if the corresponding element doesn't exist anymore
                     \Logger::debug("delete version (" . $version->getId() . ") because the corresponding element doesn't exist anymore");
                     $version->delete();
                 }
                 // call the garbage collector if memory consumption is > 100MB
                 if (memory_get_usage() > 100000000) {
                     \Pimcore::collectGarbage();
                 }
             }
         }
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:75,代码来源:Version.php

示例8: execute

 /**
  *
  */
 public static function execute()
 {
     $list = new Listing();
     $list->setCondition("active = 1 AND date < ?", time());
     $tasks = $list->load();
     foreach ($tasks as $task) {
         try {
             if ($task->getCtype() == "document") {
                 $document = Document::getById($task->getCid());
                 if ($document instanceof Document) {
                     if ($task->getAction() == "publish-version" && $task->getVersion()) {
                         try {
                             $version = Version::getById($task->getVersion());
                             $document = $version->getData();
                             if ($document instanceof Document) {
                                 $document->setPublished(true);
                                 $document->save();
                             } else {
                                 \Logger::err("Schedule\\Task\\Executor: Could not restore document from version data.");
                             }
                         } catch (\Exception $e) {
                             \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                         }
                     } else {
                         if ($task->getAction() == "publish") {
                             $document->setPublished(true);
                             $document->save();
                         } else {
                             if ($task->getAction() == "unpublish") {
                                 $document->setPublished(false);
                                 $document->save();
                             } else {
                                 if ($task->getAction() == "delete") {
                                     $document->delete();
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if ($task->getCtype() == "asset") {
                     $asset = Asset::getById($task->getCid());
                     if ($asset instanceof Asset) {
                         if ($task->getAction() == "publish-version" && $task->getVersion()) {
                             try {
                                 $version = Version::getById($task->getVersion());
                                 $asset = $version->getData();
                                 if ($asset instanceof Asset) {
                                     $asset->save();
                                 } else {
                                     \Logger::err("Schedule\\Task\\Executor: Could not restore asset from version data.");
                                 }
                             } catch (\Exception $e) {
                                 \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                             }
                         } else {
                             if ($task->getAction() == "delete") {
                                 $asset->delete();
                             }
                         }
                     }
                 } else {
                     if ($task->getCtype() == "object") {
                         $object = Object::getById($task->getCid());
                         if ($object instanceof Object) {
                             if ($task->getAction() == "publish-version" && $task->getVersion()) {
                                 try {
                                     $version = Version::getById($task->getVersion());
                                     $object = $version->getData();
                                     if ($object instanceof Object\AbstractObject) {
                                         $object->setPublished(true);
                                         $object->save();
                                     } else {
                                         \Logger::err("Schedule\\Task\\Executor: Could not restore object from version data.");
                                     }
                                 } catch (\Exception $e) {
                                     \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                                 }
                             } else {
                                 if ($task->getAction() == "publish") {
                                     $object->setPublished(true);
                                     $object->save();
                                 } else {
                                     if ($task->getAction() == "unpublish") {
                                         $object->setPublished(false);
                                         $object->save();
                                     } else {
                                         if ($task->getAction() == "delete") {
                                             $object->delete();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:ptaferner,项目名称:pimcore,代码行数:101,代码来源:Executor.php

示例9: showVersionAction

 public function showVersionAction()
 {
     $id = intval($this->getParam("id"));
     $version = Model\Version::getById($id);
     $asset = $version->loadData();
     if ($asset->isAllowed("versions")) {
         $this->view->asset = $asset;
         $this->render("show-version-" . $asset->getType());
     } else {
         throw new \Exception("Permission denied, version id [" . $id . "]");
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:12,代码来源:AssetController.php

示例10: diffVersionsAction

 public function diffVersionsAction()
 {
     include_once 'DaisyDiff/HTMLDiff.php';
     include_once 'simple_html_dom.php';
     $versionFrom = Version::getById($this->getParam("from"));
     $versionTo = Version::getById($this->getParam("to"));
     $docFrom = $versionFrom->loadData();
     $docTo = $versionTo->loadData();
     // unlock the current session to access the version files
     session_write_close();
     $request = $this->getRequest();
     $fromSourceHtml = Tool::getHttpData($request->getScheme() . "://" . $request->getHttpHost() . $docFrom->getFullPath() . "?pimcore_version=" . $this->getParam("from") . "&pimcore_admin_sid=" . $_COOKIE["pimcore_admin_sid"]);
     $toSourceHtml = Tool::getHttpData($request->getScheme() . "://" . $request->getHttpHost() . $docTo->getFullPath() . "?pimcore_version=" . $this->getParam("to") . "&pimcore_admin_sid=" . $_COOKIE["pimcore_admin_sid"]);
     $fromSource = str_get_html($fromSourceHtml);
     $toSource = str_get_html($toSourceHtml);
     if ($fromSource && $toSource) {
         if ($docFrom instanceof Document\Page) {
             $from = $fromSource->find("body", 0);
             $to = $toSource->find("body", 0);
         } else {
             $from = $fromSource;
             $to = $toSource;
         }
         $diff = new HTMLDiffer();
         $text = $diff->htmlDiff($from, $to);
         if ($docFrom instanceof Document\Page) {
             $fromSource->find("head", 0)->innertext = $fromSource->find("head", 0)->innertext . '<link rel="stylesheet" type="text/css" href="/pimcore/static/css/daisydiff.css" />';
             $fromSource->find("body", 0)->innertext = $text;
             echo $fromSource;
         } else {
             echo '<link rel="stylesheet" type="text/css" href="/pimcore/static/css/daisydiff.css" />';
             echo $text;
         }
     } else {
         echo "Unable to create diff";
     }
     $this->removeViewRenderer();
 }
开发者ID:pawansgi92,项目名称:pimcore2,代码行数:38,代码来源:DocumentController.php

示例11: diffVersionsAction

 public function diffVersionsAction()
 {
     $versionFrom = Version::getById($this->getParam("from"));
     $docFrom = $versionFrom->loadData();
     $request = $this->getRequest();
     $sessionName = Tool\Session::getOption("name");
     $prefix = $request->getScheme() . "://" . $request->getHttpHost() . $docFrom->getFullPath() . "?pimcore_version=";
     $fromUrl = $prefix . $this->getParam("from") . "&" . $sessionName . "=" . $_COOKIE[$sessionName];
     $toUrl = $prefix . $this->getParam("to") . "&" . $sessionName . "=" . $_COOKIE[$sessionName];
     $fromFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     $toFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     $diffFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     if (\Pimcore\Image\HtmlToImage::isSupported() && class_exists("Imagick")) {
         \Pimcore\Image\HtmlToImage::convert($fromUrl, $fromFile);
         \Pimcore\Image\HtmlToImage::convert($toUrl, $toFile);
         $image1 = new Imagick($fromFile);
         $image2 = new Imagick($toFile);
         if ($image1->getImageWidth() == $image2->getImageWidth() && $image1->getImageHeight() == $image2->getImageHeight()) {
             $result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
             $result[0]->setImageFormat("png");
             $result[0]->writeImage($diffFile);
             $result[0]->clear();
             $result[0]->destroy();
             $this->view->image = base64_encode(file_get_contents($diffFile));
             unlink($diffFile);
         } else {
             $this->view->image1 = base64_encode(file_get_contents($fromFile));
             $this->view->image2 = base64_encode(file_get_contents($toFile));
         }
         // cleanup
         $image1->clear();
         $image1->destroy();
         $image2->clear();
         $image2->destroy();
         unlink($fromFile);
         unlink($toFile);
     } else {
         $this->renderScript("document/diff-versions-unsupported.php");
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:40,代码来源:DocumentController.php


注:本文中的Pimcore\Model\Version::getById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。