Backend\Modules\Blog\Engine\Model::getRevision PHP Method

getRevision() public static method

Get all data for a given revision
public static getRevision ( integer $id, integer $revisionId ) : array
$id integer The id of the item.
$revisionId integer The revision to get.
return array
    public static function getRevision($id, $revisionId)
    {
        return (array) BackendModel::getContainer()->get('database')->getRecord('SELECT i.*, UNIX_TIMESTAMP(i.publish_on) AS publish_on, UNIX_TIMESTAMP(i.created_on) AS created_on, UNIX_TIMESTAMP(i.edited_on) AS edited_on, m.url
             FROM blog_posts AS i
             INNER JOIN meta AS m ON m.id = i.meta_id
             WHERE i.id = ? AND i.revision_id = ?', array((int) $id, (int) $revisionId));
    }

Usage Example

Example #1
0
 /**
  * Get the data
  * If a revision-id was specified in the URL we load the revision and not the actual data.
  */
 private function getData()
 {
     $this->record = (array) BackendBlogModel::get($this->id);
     $this->imageIsAllowed = $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true);
     // is there a revision specified?
     $revisionToLoad = $this->getParameter('revision', 'int');
     // if this is a valid revision
     if ($revisionToLoad !== null) {
         // overwrite the current record
         $this->record = (array) BackendBlogModel::getRevision($this->id, $revisionToLoad);
         // show warning
         $this->tpl->assign('usingRevision', true);
     }
     // is there a revision specified?
     $draftToLoad = $this->getParameter('draft', 'int');
     // if this is a valid revision
     if ($draftToLoad !== null) {
         // overwrite the current record
         $this->record = (array) BackendBlogModel::getRevision($this->id, $draftToLoad);
         // show warning
         $this->tpl->assign('usingDraft', true);
         // assign draft
         $this->tpl->assign('draftId', $draftToLoad);
     }
     // no item found, throw an exceptions, because somebody is f*****g with our URL
     if (empty($this->record)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }