Example #1
0
 /**
  * Check and update the given process page for hidden/visible status depending on useBookmarks setting
  *
  * @param Process $process
  * @param Page $page
  *
  */
 public function checkProcessPage(Page $page)
 {
     $hidden = $page->isHidden();
     if ($this->process->useBookmarks) {
         if ($hidden) {
             $page->removeStatus(Page::statusHidden);
             $page->save();
         }
     } else {
         if (!$hidden) {
             $page->addStatus(Page::statusHidden);
             $page->save();
         }
     }
 }
Example #2
0
 /**
  * Restore a page from the trash back to a non-trash state
  *
  * Note that this method assumes already have set a new parent, but have not yet saved.
  * If you do not set a new parent, then it will restore to the original parent, when possible.
  *
  * @param Page $page
  * @param bool $save Set to false if you only want to prep the page for restore (i.e. being saved elsewhere)
  * @return bool
  *
  */
 protected function ___restore(Page $page, $save = true)
 {
     if (preg_match('/^(' . $page->id . ')((?:\\.\\d+\\.\\d+)?)_(.+)$/', $page->name, $matches)) {
         if ($matches[2]) {
             list($unused, $parentID, $sort) = explode('.', $matches[2]);
             $parentID = (int) $parentID;
             $sort = (int) $sort;
         } else {
             $parentID = 0;
             $sort = 0;
         }
         $name = $matches[3];
         if ($parentID && $page->parent->isTrash() && !$page->parentPrevious) {
             // no new parent was defined, so use the one in the page name
             $newParent = $this->get($parentID);
             if ($newParent->id && $newParent->id != $page->id) {
                 $page->parent = $newParent;
                 $page->sort = $sort;
             }
         }
         if (!count($page->parent->children("name={$name}, include=all"))) {
             $page->name = $name;
             // remove namespace collision info if no collision
         }
     }
     if (!$page->parent->isTrash()) {
         $page->removeStatus(Page::statusTrash);
         if ($save) {
             $page->save();
         }
         $this->savePageStatus($page->id, Page::statusTrash, true, true);
         $this->restored($page);
         $this->debugLog('restore', $page, true);
     } else {
         if ($save) {
             $page->save();
         }
     }
     return true;
 }
Example #3
0
 /**
  * Restore a page from the trash back to a non-trash state
  *
  * Note that this method assumes already have set a new parent, but have not yet saved
  *
  * @param Page $page
  * @param bool $save Set to false if you only want to prep the page for restore (i.e. being saved elsewhere)
  * @return bool
  *
  */
 protected function ___restore(Page $page, $save = true)
 {
     if (preg_match('/^(' . $page->id . ')_(.+)$/', $page->name, $matches)) {
         $name = $matches[2];
         if (!count($page->parent->children("name={$name}"))) {
             $page->name = $name;
         }
         // remove namespace collision info if no collision
     }
     $page->removeStatus(Page::statusTrash);
     if ($save) {
         $page->save();
     }
     $this->savePageStatus($page->id, Page::statusTrash, true, true);
     $this->restored($page);
     $this->debugLog('restore', $page, true);
     return true;
 }