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


PHP Version::getById方法代码示例

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


在下文中一共展示了Version::getById方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:shanky0110,项目名称:pimcore-custom,代码行数:14,代码来源:Resource.php

示例2: 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();
     $fromSource = file_get_html($request->getScheme() . "://" . $request->getHttpHost() . $docFrom->getFullPath() . "?pimcore_version=" . $this->_getParam("from") . "&pimcore_admin_sid=" . $_COOKIE["pimcore_admin_sid"]);
     $toSource = file_get_html($request->getScheme() . "://" . $request->getHttpHost() . $docTo->getFullPath() . "?pimcore_version=" . $this->_getParam("to") . "&pimcore_admin_sid=" . $_COOKIE["pimcore_admin_sid"]);
     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;
     }
     $this->removeViewRenderer();
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:32,代码来源:DocumentController.php

示例3: showVersionAction

 public function showVersionAction()
 {
     $version = Version::getById($this->_getParam("id"));
     $asset = $version->loadData();
     $this->view->asset = $asset;
     $this->render("show-version-" . $asset->getType());
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:7,代码来源:AssetController.php

示例4: 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(array("success" => true));
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:9,代码来源:ElementController.php

示例5: init


//.........这里部分代码省略.........
         $user = Pimcore_Tool_Authentication::authenticateSession();
     }
     if (!$this->document->isPublished()) {
         if ($specialAdminRequest) {
             if (!$user) {
                 throw new Exception("access denied for " . $this->document->getFullPath());
             }
         } else {
             throw new Exception("access denied for " . $this->document->getFullPath());
         }
     }
     // register global locale if the document has the system property "language"
     if ($this->document->getProperty("language")) {
         $locale = new Zend_Locale($this->document->getProperty("language"));
         Zend_Registry::set('Zend_Locale', $locale);
         $this->getResponse()->setHeader("Content-Language", strtolower(str_replace("_", "-", (string) $locale)), true);
     }
     // for editmode
     if ($user) {
         if ($this->_getParam("pimcore_editmode") and !Zend_Registry::isRegistered("pimcore_editmode")) {
             Zend_Registry::set("pimcore_editmode", true);
             // check if there is the document in the session
             $docKey = "document_" . $this->getDocument()->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 // if there is a document in the session use it
                 $this->setDocument($docSession->{$docKey});
             } else {
                 // set the latest available version for editmode if there is no doc in the session
                 $latestVersion = $this->getDocument()->getLatestVersion();
                 if ($latestVersion) {
                     $latestDoc = $latestVersion->loadData();
                     if ($latestDoc instanceof Document_PageSnippet) {
                         $this->setDocument($latestDoc);
                     }
                 }
             }
             // register editmode plugin
             $front = Zend_Controller_Front::getInstance();
             $front->registerPlugin(new Pimcore_Controller_Plugin_Frontend_Editmode($this), 1000);
         } else {
             Zend_Registry::set("pimcore_editmode", false);
         }
     } else {
         Zend_Registry::set("pimcore_editmode", false);
     }
     // for preview
     if ($user) {
         // document preview
         if ($this->_getParam("pimcore_preview")) {
             // get document from session
             $docKey = "document_" . $this->_getParam("document")->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 $this->setDocument($docSession->{$docKey});
             }
         }
         // object preview
         if ($this->_getParam("pimcore_object_preview")) {
             $key = "object_" . $this->_getParam("pimcore_object_preview");
             $session = new Zend_Session_Namespace("pimcore_objects");
             if ($session->{$key}) {
                 $object = $session->{$key};
                 // add the object to the registry so every call to Object_Abstract::getById() will return this object instead of the real one
                 Zend_Registry::set("object_" . $object->getId(), $object);
             }
         }
     }
     // for version preview
     if ($this->_getParam("pimcore_version")) {
         if ($user) {
             // only get version data at the first call || because of embedded Snippets ...
             if (!Zend_Registry::isRegistered("pimcore_version_active")) {
                 $version = Version::getById($this->_getParam("pimcore_version"));
                 $this->setDocument($version->getData());
                 Zend_Registry::set("pimcore_version_active", true);
             }
         }
     }
     // for public versions
     if ($this->_getParam("v")) {
         try {
             $version = Version::getById($this->_getParam("v"));
             if ($version->getPublic()) {
                 $this->setDocument($version->getData());
             }
         } catch (Exception $e) {
         }
     }
     // check if document is a wrapped hardlink, if this is the case send a rel=canonical header to the source document
     if ($this->getDocument() instanceof Document_Hardlink_Wrapper_Interface) {
         // get the cononical (source) document
         $hardlinkCanonicalSourceDocument = Document::getById($this->getDocument()->getId());
         $request = $this->getRequest();
         $this->getResponse()->setHeader("Link", '<' . $request->getScheme() . "://" . $request->getHttpHost() . $hardlinkCanonicalSourceDocument->getFullPath() . '>; rel="canonical"');
     }
     // set some parameters
     $this->editmode = Zend_Registry::get("pimcore_editmode");
     $this->view->editmode = Zend_Registry::get("pimcore_editmode");
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Frontend.php

示例6: diffVersionsAction

 public function diffVersionsAction()
 {
     $version1 = Version::getById($this->_getParam("from"));
     $object1 = $version1->loadData();
     $version2 = Version::getById($this->_getParam("to"));
     $object2 = $version2->loadData();
     $this->view->object1 = $object1;
     $this->view->object2 = $object2;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:9,代码来源:ObjectController.php

示例7: getLatestVersion

 /**
  * Get latest available version
  *
  * @return array
  */
 public function getLatestVersion()
 {
     if ($this->model->getType() != "folder") {
         $versionData = $this->db->fetchRow("SELECT id,date FROM versions WHERE cid = ? AND ctype='asset' ORDER BY `id` DESC LIMIT 1", $this->model->getId());
         if ($versionData["id"] && $versionData["date"] > $this->model->getModificationDate()) {
             $version = Version::getById($versionData["id"]);
             return $version;
         }
     }
     return;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:16,代码来源:Resource.php

示例8: maintenanceCleanUp

 /**
  *
  */
 public function maintenanceCleanUp()
 {
     $conf["document"] = Pimcore_Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Pimcore_Config::getSystemConfig()->assets->versions;
     $conf["object"] = Pimcore_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);
         }
     }
     $versions = $this->getResource()->maintenanceGetOutdatedVersions($elementTypes);
     if (is_array($versions)) {
         foreach ($versions as $index => $id) {
             $version = Version::getById($id);
             if ($version->getCtype() == "document") {
                 $element = Document::getById($version->getCid());
             } else {
                 if ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } else {
                     if ($version->getCtype() == "object") {
                         $element = Object_Abstract::getById($version->getCid());
                     }
                 }
             }
             if ($element instanceof Element_Interface) {
                 if ($element->getModificationDate() > $version->getDate()) {
                     // delete version if it is outdated
                     $version->delete();
                 }
             } else {
                 // delete version if the correspondening element doesn't exist anymore
                 $version->delete();
             }
             // call the garbage collector every 100 iterations, to avoid a out-of-memory
             if ($index % 100 == 0) {
                 Pimcore::collectGarbage();
             }
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:52,代码来源:Version.php

示例9: init


//.........这里部分代码省略.........
         $this->setDocument($this->_getParam("document"));
     }
     if ($this->_getParam("pimcore_editmode") || $this->_getParam("pimcore_version") || $this->_getParam("pimcore_preview") || $this->_getParam("pimcore_admin") || $this->_getParam("pimcore_object_preview")) {
         $specialAdminRequest = true;
         Pimcore_Tool_Authentication::initSession();
         // start admin session
         $adminSession = new Zend_Session_Namespace("pimcore_admin");
     }
     if (!$this->document->isPublished()) {
         if ($specialAdminRequest) {
             if (!$adminSession->user instanceof User) {
                 throw new Exception("access denied for " . $this->document->getFullPath());
             }
         } else {
             throw new Exception("access denied for " . $this->document->getFullPath());
         }
     }
     // register global locale if the document has the system property "language"
     if ($this->document->getProperty("language")) {
         $locale = new Zend_Locale($this->document->getProperty("language"));
         Zend_Registry::set('Zend_Locale', $locale);
     }
     // for editmode
     if ($adminSession && $adminSession->user instanceof User) {
         if ($this->_getParam("pimcore_editmode") and !Zend_Registry::isRegistered("pimcore_editmode")) {
             Zend_Registry::set("pimcore_editmode", true);
             // check if there is the document in the session
             $docKey = "document_" . $this->getDocument()->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 // if there is a document in the session use it
                 $this->setDocument($docSession->{$docKey});
             } else {
                 // set the latest available version for editmode if there is no doc in the session
                 $latestVersion = $this->getDocument()->getLatestVersion();
                 if ($latestVersion) {
                     $latestDoc = $latestVersion->loadData();
                     if ($latestDoc instanceof Document_PageSnippet) {
                         $this->setDocument($latestDoc);
                     }
                 }
             }
             // register editmode plugin
             $front = Zend_Controller_Front::getInstance();
             $front->registerPlugin(new Pimcore_Controller_Plugin_Frontend_Editmode($this), 1000);
         } else {
             Zend_Registry::set("pimcore_editmode", false);
         }
     } else {
         Zend_Registry::set("pimcore_editmode", false);
     }
     // for preview
     if ($adminSession && $adminSession->user instanceof User) {
         // document preview
         if ($this->_getParam("pimcore_preview")) {
             // get document from session
             $docKey = "document_" . $this->_getParam("document")->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 $this->setDocument($docSession->{$docKey});
             }
         }
         // object preview
         if ($this->_getParam("pimcore_object_preview")) {
             $key = "object_" . $this->_getParam("pimcore_object_preview");
             $session = new Zend_Session_Namespace("pimcore_objects");
             if ($session->{$key}) {
                 $object = $session->{$key};
                 // add the object to the registry so every call to Object_Abstract::getById() will return this object instead of the real one
                 Zend_Registry::set("object_" . $object->getId(), $object);
             }
         }
     }
     // for version preview
     if ($this->_getParam("pimcore_version")) {
         if ($adminSession && $adminSession->user instanceof User) {
             // only get version data at the first call || because of embedded Snippets ...
             try {
                 Zend_Registry::get("pimcore_version_active");
             } catch (Exception $e) {
                 $version = Version::getById($this->_getParam("pimcore_version"));
                 $this->setDocument($version->getData());
                 Zend_Registry::set("pimcore_version_active", true);
             }
         }
     }
     // for public versions
     if ($this->_getParam("v")) {
         try {
             $version = Version::getById($this->_getParam("v"));
             if ($version->getPublic()) {
                 $this->setDocument($version->getData());
             }
         } catch (Exception $e) {
         }
     }
     // set some parameters
     $this->editmode = Zend_Registry::get("pimcore_editmode");
     $this->view->editmode = Zend_Registry::get("pimcore_editmode");
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:101,代码来源:Frontend.php

示例10: execute

 public static function execute()
 {
     $list = new Schedule_Task_List();
     $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_Abstract::getById($task->getCid());
                         if ($object instanceof Object_Abstract) {
                             if ($task->getAction() == "publish-version" && $task->getVersion()) {
                                 try {
                                     $version = Version::getById($task->getVersion());
                                     $object = $version->getData();
                                     if ($object instanceof Object_Abstract) {
                                         $object->setO_Published(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->setO_Published(true);
                                     $object->save();
                                 } else {
                                     if ($task->getAction() == "unpublish") {
                                         $object->setO_Published(false);
                                         $object->save();
                                     } else {
                                         if ($task->getAction() == "delete") {
                                             $object->delete();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $task->setActive(false);
             $task->save();
         } catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Executor.php

示例11: maintenanceCleanUp

 public function maintenanceCleanUp()
 {
     $conf["document"] = Pimcore_Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Pimcore_Config::getSystemConfig()->assets->versions;
     $conf["object"] = Pimcore_Config::getSystemConfig()->objects->versions;
     $types = array();
     foreach ($conf as $type => $tConf) {
         if (intval($tConf->days) > 0) {
             $types[] = array("type" => $type, "days" => intval($tConf->days));
         }
     }
     $versions = $this->getResource()->maintenanceGetOutdatedVersions($types);
     if (is_array($versions)) {
         foreach ($versions as $id) {
             $version = Version::getById($id);
             if ($version->getCtype() == "document") {
                 $element = Document::getById($version->getCid());
             } else {
                 if ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } else {
                     if ($version->getCtype() == "object") {
                         $element = Object_Abstract::getById($version->getCid());
                     }
                 }
             }
             if ($element instanceof Element_Interface) {
                 if ($element->getModificationDate() > $version->getDate()) {
                     // delete version if it is outdated
                     $version->delete();
                 }
             } else {
                 // delete version if the correspondening element doesn't exist anymore
                 $version->delete();
             }
         }
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:38,代码来源:Version.php

示例12: getVersions

 /**
  * get versions from database, and assign it to object
  *
  * @return array
  */
 public function getVersions()
 {
     $versionIds = $this->db->fetchAll("SELECT id FROM versions WHERE cid = ? AND ctype='asset' ORDER BY `id` DESC", $this->model->getId());
     $versions = array();
     foreach ($versionIds as $versionId) {
         $versions[] = Version::getById($versionId["id"]);
     }
     $this->model->setVersions($versions);
     return $versions;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:15,代码来源:Resource.php


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