示例#1
0
 public function savePage()
 {
     if (!isset($_POST['revisionId'])) {
         return $this->_errorAnswer('Missing revisionId POST variable');
     }
     $revisionId = $_POST['revisionId'];
     $publish = !empty($_POST['publish']);
     $revision = \Ip\Internal\Revision::getRevision($revisionId);
     if (!$revision) {
         return $this->_errorAnswer('Can\'t find revision. RevisionId \'' . $revisionId . '\'');
     }
     if ($publish) {
         $pageOptions = array();
         $pageOptions['updatedAt'] = date("Y-m-d");
         $pageOptions['isVisible'] = 1;
         \Ip\Internal\Pages\Model::updatePageProperties($revision['pageId'], $pageOptions);
     }
     \Ip\Internal\Revision::publishRevision($revisionId);
     $newRevisionId = \Ip\Internal\Revision::duplicateRevision($revisionId);
     $page = new \Ip\Page($revision['pageId']);
     $data = array('status' => 'success', 'action' => '_savePageResponse', 'newRevisionId' => $newRevisionId, 'newRevisionUrl' => $page->getLink());
     return new \Ip\Response\Json($data);
 }
示例#2
0
 /**
  * If in management state and the last revision was published, create a new revision.
  * @ignore
  */
 public function getCurrentRevision()
 {
     if ($this->currentRevision !== null) {
         return $this->currentRevision;
     }
     if (!$this->currentPage) {
         return null;
     }
     $revision = null;
     $pageId = $this->currentPage->getId();
     if (ipRequest()->getQuery('_revision') && ipAdminId()) {
         $revisionId = ipRequest()->getQuery('_revision');
         $revision = \Ip\Internal\Revision::getRevision($revisionId);
         if ($revision['pageId'] != $pageId) {
             $revision = null;
         }
     }
     if (!$revision && ipIsManagementState()) {
         $revision = \Ip\Internal\Revision::getLastRevision($pageId);
         if ($revision['isPublished']) {
             $duplicatedId = \Ip\Internal\Revision::duplicateRevision($revision['revisionId']);
             $revision = \Ip\Internal\Revision::getRevision($duplicatedId);
         }
     }
     if (!$revision) {
         $revision = \Ip\Internal\Revision::getPublishedRevision($this->currentPage->getId());
     }
     $this->currentRevision = $revision;
     return $this->currentRevision;
 }
示例#3
0
 /**
  * @param int $sourceId
  * @param int $targetId
  */
 private static function _copyWidgets($sourceId, $targetId)
 {
     $oldRevision = \Ip\Internal\Revision::getPublishedRevision($sourceId);
     \Ip\Internal\Revision::duplicateRevision($oldRevision['revisionId'], $targetId, 1);
 }