Example #1
0
 /**
  * Initialize the factory for the given item.
  *
  * If there is a versionNumber provided, just use it.
  *
  * If there is no versionNumber provided, the default wiki version id is
  * the one of the latest approval table linked to the item.
  * If there is no approval table linked to the item, pick-up the last
  * version id of the wiki page.
  * If there is no version for the given wiki page, default to 0.
  */
 function __construct($item, $versionNumber = null)
 {
     parent::__construct($item);
     $dao = $this->_getDao();
     $lastTableVersionId = $dao->getLastTableVersionIdByItemId($item->getId());
     if ($versionNumber !== null) {
         $this->wikiVersionId = $versionNumber;
         if ($versionNumber == $lastTableVersionId) {
             $this->customizable = true;
         } else {
             $this->customizable = false;
         }
     } else {
         // Works on the last available version, so is customizable.
         $this->customizable = true;
         if ($lastTableVersionId !== false) {
             $this->wikiVersionId = $lastTableVersionId;
         } else {
             // If there is no table attached to the item yet, just get the list version id.
             $lastWikiVersion = $dao->getLastWikiVersionIdByItemId($item->getId());
             if ($lastWikiVersion !== false) {
                 $this->wikiVersionId = $lastWikiVersion;
             } else {
                 // If the page doesn't exists yet, default to zero.
                 $this->wikiVersionId = 0;
             }
         }
     }
 }
Example #2
0
 /**
  *
  */
 function __construct($item, $versionNumber = null)
 {
     parent::__construct($item);
     $dao = $this->_getDao();
     $vFactory = new Docman_VersionFactory();
     $dar = $dao->getLatestTableByItemId($item->getId(), 'ver.number');
     if ($dar && !$dar->isError() && $dar->rowCount() == 1) {
         $row = $dar->getRow();
         $lastVersionNumber = $row['number'];
         $lastItemVersion = $vFactory->getSpecificVersion($item, $lastVersionNumber);
         if ($versionNumber !== null && $lastItemVersion->getNumber() != $versionNumber) {
             $this->itemVersion = $vFactory->getSpecificVersion($item, $versionNumber);
             $this->customizable = false;
         } else {
             $this->itemVersion = $lastItemVersion;
         }
     } else {
         $this->itemVersion = $item->getCurrentVersion();
     }
 }