/**
  * Constructor function.
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  array  &$page Page data
  * @return void
  **/
 function start()
 {
     $this->pageAction = $this->lang['history'];
     if (!$this->hasPerms(PERM_HISTORY)) {
         $this->messageEnd('wiki_perm_denied');
     }
     $tpl =& singleton('template');
     $this->pageVersions = diff::getVersions();
     if ($this->page['page_id'] == 0) {
         $this->HTTPRedirect($this->genUrl($this->getUniqueName($this->page)));
     }
     if (isset($this->get['o'])) {
         $op = $this->get['o'];
     } else {
         $op = 'list';
     }
     switch ($op) {
         case 'list':
             $this->opList();
             break;
         case 'diff':
             $this->opDiff();
             break;
         default:
             $this->opList();
             break;
     }
 }
 /**
  * This function creates a older version of the current page.
  *
  * @author Johannes Klose <*****@*****.**>
  * @param  string $version Version number of the old text
  * @return array           Text, version and date of the old text
  **/
 function getOldPageText($version)
 {
     $tpl =& singleton('template');
     $versions = diff::getVersions();
     if (!isset($versions[$version])) {
         return false;
     }
     $oldText = diff::createVersion($this->page['page_text'], $versions, $version);
     return array('text' => $oldText, 'version' => $version, 'time' => $versions[$version]['log_time']);
 }
 /**
  * Checks if the changes conflict to a version submited
  * while editing.
  *
  * @author Johannes Klose <*****@*****.**>
  * @return bool True if there is a conflict, false otherwise
  **/
 function editConflicts($editText, $editUsername, $editSummary, $editStart)
 {
     $tpl =& singleton('template');
     if ($this->page['page_version'] != $editStart) {
         $pageVersions = diff::getVersions();
         $orig = $editStart;
         $final = $this->page['page_version'];
         $finalText = $this->page['page_text'];
         $origText = diff::createVersion($this->page['page_text'], $pageVersions, $orig);
         $diff = diff::makeDiff($origText, $finalText, $pageVersions);
         $tpl->assign('diffOrig', $diff['orig']);
         $tpl->assign('diffFinal', $diff['final']);
         $tpl->assign('isConflict', true);
         $tpl->assign('editStart', $this->time);
         $tpl->assign('editText', htmlentities($editText));
         $tpl->assign('valAuthor', htmlentities($editUsername));
         $tpl->assign('valSummary', htmlentities($editSummary));
         $tpl->assign('isMessage', true);
         $tpl->assign('message', $this->lang['edit_conflicts']);
         $this->lang['history_original'] = sprintf($this->lang['history_original'], $orig, $final, $pageVersions[$final]['log_time']);
         $this->lang['history_final'] = sprintf($this->lang['history_final'], $orig, $final, $pageVersions[$final]['log_time']);
         return true;
     } else {
         return false;
     }
 }