Example #1
0
 /**
  * (non-PHPdoc)
  * @see FormlessAction::onView()
  */
 public function onView()
 {
     $out = $this->getOutput();
     $name = $this->getTitle()->getText();
     $class = $this->getItemClass();
     $object = false;
     if ($this->getRequest()->getCheck('revid')) {
         $currentObject = $class::get($name, 'id');
         if ($currentObject !== false) {
             $rev = EPRevision::selectRow(null, array('id' => $this->getRequest()->getInt('revid'), 'object_id' => $currentObject->getField('id')));
             if ($rev === false) {
                 // TODO
             } else {
                 $object = $rev->getObject();
                 $this->displayRevisionNotice($rev);
             }
         }
     }
     if ($object === false) {
         $object = $class::get($name);
     }
     if ($object === false) {
         $this->displayNavigation();
         if ($this->getUser()->isAllowed($class::getEditRight())) {
             $out->redirect($this->getTitle()->getLocalURL(array('action' => 'edit')));
         } else {
             $out->addWikiMsg(strtolower(get_called_class()) . '-none', $name);
         }
     } else {
         $this->displayPage($object);
     }
     return '';
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see FormlessAction::onView()
  */
 public function onView()
 {
     $this->getOutput()->setPageTitle($this->getPageTitle());
     $c = $this->getItemClass();
     // Yeah, this is needed in PHP 5.3 >_>
     $object = $c::get($this->getTitle()->getText());
     if ($object === false) {
         $this->getOutput()->addWikiMsg('ep-' . strtolower($this->getName()) . '-norevs');
         $lastRev = EPRevision::selectRow(null, array('type' => EPPageObject::getTypeForNS($this->getTitle()->getNamespace()), 'object_identifier' => $this->getTitle()->getText(), 'deleted' => true), array('SORT BY' => EPRevision::getPrefixedField('time'), 'ORDER' => 'DESC'));
         if ($lastRev !== false) {
             // TODO: show available info about deletion
             $this->getOutput()->addWikiMsg('ep-' . strtolower($this->getName()) . '-deleted');
         }
     } else {
         $this->displayRevisions($object);
     }
     return '';
 }
Example #3
0
 /**
  * Returns the the object stored in the revision with the provided id,
  * or false if there is no matching object.
  *
  * @since 0.1
  *
  * @param integer $revId
  * @param integer|null $objectId
  *
  * @return EPRevisionedObject|false
  */
 public static function getObjectFromRevId($revId, $objectId = null)
 {
     $conditions = array('id' => $revId);
     if (!is_null($objectId)) {
         $conditions['object_id'] = $objectId;
     }
     $rev = EPRevision::selectRow(array('type', 'data'), $conditions);
     if ($rev === false) {
         return false;
     } else {
         return $rev->getDataObject();
     }
 }