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


PHP Model\Version类代码示例

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


在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // disable versioning
     Version::disable();
     // get all thumbnails
     $dir = Asset\Video\Thumbnail\Config::getWorkingDir();
     $thumbnails = array();
     $files = scandir($dir);
     foreach ($files as $file) {
         if (strpos($file, ".xml")) {
             $thumbnails[] = str_replace(".xml", "", $file);
         }
     }
     $allowedThumbs = array();
     if ($input->getOption("thumbnails")) {
         $allowedThumbs = explode(",", $input->getOption("thumbnails"));
     }
     // get only images
     $conditions = array("type = 'video'");
     if ($input->getOption("parent")) {
         $parent = Asset::getById($input->getOption("parent"));
         if ($parent instanceof Asset\Folder) {
             $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'";
         } else {
             $this->writeError($input->getOption("parent") . " is not a valid asset folder ID!");
             exit;
         }
     }
     $list = new Asset\Listing();
     $list->setCondition(implode(" AND ", $conditions));
     $total = $list->getTotalCount();
     $perLoop = 10;
     for ($i = 0; $i < ceil($total / $perLoop); $i++) {
         $list->setLimit($perLoop);
         $list->setOffset($i * $perLoop);
         $videos = $list->load();
         foreach ($videos as $video) {
             foreach ($thumbnails as $thumbnail) {
                 if (empty($allowedThumbs) && !$input->getOption("system") || in_array($thumbnail, $allowedThumbs)) {
                     $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage()));
                     $video->getThumbnail($thumbnail);
                     $this->waitTillFinished($video->getId(), $thumbnail);
                 }
             }
             if ($input->getOption("system")) {
                 $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: System Preview : " . formatBytes(memory_get_usage()));
                 $thumbnail = Asset\Video\Thumbnail\Config::getPreviewConfig();
                 $video->getThumbnail($thumbnail);
                 $this->waitTillFinished($video->getId(), $thumbnail);
             }
         }
     }
 }
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:53,代码来源:ThumbnailsVideoCommand.php

示例4: 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

示例5: deleteVersionAction

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

示例6: init


//.........这里部分代码省略.........
         \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
                     $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);
             }
             // document preview
             if ($this->getParam("pimcore_preview")) {
                 // get document from session
                 $docKey = "document_" . $this->getParam("document")->getId();
                 $docSession = Session::getReadOnly("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 = Session::getReadOnly("pimcore_objects");
                 if ($session->{$key}) {
                     $object = $session->{$key};
                     // add the object to the registry so every call to Object::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")) {
开发者ID:tododo,项目名称:pimcore,代码行数:67,代码来源:Frontend.php

示例7: 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

示例8: 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

示例9: array

    echo $e->getMessage();
}
// display help message
if ($opts->getOption("help")) {
    echo $opts->getUsageMessage();
    exit;
}
if ($opts->getOption("verbose")) {
    $writer = new \Zend_Log_Writer_Stream('php://output');
    $logger = new \Zend_Log($writer);
    \Logger::addLogger($logger);
    // set all priorities
    \Logger::setVerbosePriorities();
}
// disable versioning
Version::disable();
// get all thumbnails
$dir = Asset\Video\Thumbnail\Config::getWorkingDir();
$thumbnails = array();
$files = scandir($dir);
foreach ($files as $file) {
    if (strpos($file, ".xml")) {
        $thumbnails[] = str_replace(".xml", "", $file);
    }
}
$allowedThumbs = array();
if ($opts->getOption("thumbnails")) {
    $allowedThumbs = explode(",", $opts->getOption("thumbnails"));
}
// get only images
$conditions = array("type = 'video'");
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:31,代码来源:video-thumbnails.php

示例10: saveVersion

 /**
  * @param bool $setModificationDate
  * @param bool $callPluginHook
  * @return null|Version
  * @throws \Exception
  */
 public function saveVersion($setModificationDate = true, $callPluginHook = true)
 {
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         \Pimcore::getEventManager()->trigger("asset.preUpdate", $this, ["saveVersionOnly" => true]);
     }
     // set date
     if ($setModificationDate) {
         $this->setModificationDate(time());
     }
     // scheduled tasks are saved always, they are not versioned!
     $this->saveScheduledTasks();
     // create version
     $version = null;
     // only create a new version if there is at least 1 allowed
     if (Config::getSystemConfig()->assets->versions->steps || Config::getSystemConfig()->assets->versions->days) {
         $version = new Version();
         $version->setCid($this->getId());
         $version->setCtype("asset");
         $version->setDate($this->getModificationDate());
         $version->setUserId($this->getUserModification());
         $version->setData($this);
         $version->save();
     }
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         \Pimcore::getEventManager()->trigger("asset.postUpdate", $this, ["saveVersionOnly" => true]);
     }
     return $version;
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:36,代码来源:Asset.php

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: getDuration

 /**
  * @return mixed
  */
 public function getDuration()
 {
     $duration = $this->getCustomSetting("duration");
     if (!$duration) {
         $duration = $this->getDurationFromBackend();
         if ($duration) {
             $this->setCustomSetting("duration", $duration);
             Model\Version::disable();
             $this->save();
             // auto save
             Model\Version::enable();
         }
     }
     return $duration;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:18,代码来源:Video.php


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