Exemple #1
0
 function editPage($saveFailed = true)
 {
     $tokens =& $this->tokens;
     if (!$this->canEdit()) {
         if ($this->isInitialEdit()) {
             return $this->viewSource();
         }
         $tokens['PAGE_LOCKED_MESSAGE'] = $this->getLockedMessage();
     } elseif ($this->editaction == 'save') {
         if ($this->savePage()) {
             return true;
         }
         // Page saved.
         $saveFailed = true;
     }
     if ($saveFailed || $this->isConcurrentUpdate()) {
         // Get the text of the original page, and the two conflicting edits
         // The diff class takes arrays as input.  So retrieve content as
         // an array, or convert it as necesary.
         $orig = $this->page->getRevision($this->_currentVersion);
         $this_content = explode("\n", $this->_content);
         $other_content = $this->current->getContent();
         include_once "lib/diff.php";
         $diff2 = new Diff($other_content, $this_content);
         $context_lines = max(4, count($other_content) + 1, count($this_content) + 1);
         $fmt = new BlockDiffFormatter($context_lines);
         $this->_content = $fmt->format($diff2);
         // FIXME: integrate this into class BlockDiffFormatter
         $this->_content = str_replace(">>>>>>>\n<<<<<<<\n", "=======\n", $this->_content);
         $this->_content = str_replace("<<<<<<<\n>>>>>>>\n", "=======\n", $this->_content);
         $this->_currentVersion = $this->current->getVersion();
         $this->version = $this->_currentVersion;
         $tokens['CONCURRENT_UPDATE_MESSAGE'] = $this->getConflictMessage();
     }
     if ($this->editaction == 'edit_convert') {
         $tokens['PREVIEW_CONTENT'] = $this->getConvertedPreview();
     }
     if ($this->editaction == 'preview') {
         $tokens['PREVIEW_CONTENT'] = $this->getPreview();
     }
     // FIXME: convert to _MESSAGE?
     // FIXME: NOT_CURRENT_MESSAGE?
     $tokens = array_merge($tokens, $this->getFormElements());
     return $this->output('editpage', _("Merge and Edit: %s"));
     // FIXME: this doesn't display
 }
Exemple #2
0
 function editPage($saveFailed = true)
 {
     $tokens =& $this->tokens;
     if (!$this->canEdit()) {
         if ($this->isInitialEdit()) {
             return $this->viewSource();
         }
         $tokens['PAGE_LOCKED_MESSAGE'] = $this->getLockedMessage();
     } elseif ($this->editaction == 'save') {
         if ($this->savePage()) {
             return true;
             // Page saved.
         }
         $saveFailed = true;
     }
     if ($saveFailed || $this->isConcurrentUpdate()) {
         // Get the text of the original page, and the two conflicting edits
         // The diff class takes arrays as input.  So retrieve content as
         // an array, or convert it as necesary.
         $orig = $this->page->getRevision($this->_currentVersion);
         $this_content = explode("\n", $this->_content);
         $other_content = $this->current->getContent();
         require_once "lib/diff.php";
         $diff2 = new Diff($other_content, $this_content);
         $context_lines = max(4, count($other_content) + 1, count($this_content) + 1);
         $fmt = new BlockDiffFormatter($context_lines);
         $this->_content = $fmt->format($diff2);
         // FIXME: integrate this into class BlockDiffFormatter
         $this->_content = str_replace(">>>>>>>\n<<<<<<<\n", "=======\n", $this->_content);
         $this->_content = str_replace("<<<<<<<\n>>>>>>>\n", "=======\n", $this->_content);
         $this->_currentVersion = $this->current->getVersion();
         $this->version = $this->_currentVersion;
         $tokens['CONCURRENT_UPDATE_MESSAGE'] = $this->getConflictMessage();
     }
     if ($this->editaction == 'edit_convert') {
         $tokens['PREVIEW_CONTENT'] = $this->getConvertedPreview();
     }
     if ($this->editaction == 'preview') {
         $tokens['PREVIEW_CONTENT'] = $this->getPreview();
     }
     // FIXME: convert to _MESSAGE?
     // FIXME: NOT_CURRENT_MESSAGE?
     $tokens = array_merge($tokens, $this->getFormElements());
     // we need all GET params for loadfile overwrite
     if ($this->request->getArg('action') == 'loadfile') {
         $this->tokens['HIDDEN_INPUTS'] = HTML(HiddenInputs(array('source' => $this->request->getArg('source'), 'merge' => 1)), $this->tokens['HIDDEN_INPUTS']);
         // add two conflict resolution buttons before preview and save.
         $tokens['PREVIEW_B'] = HTML(Button('submit:edit[keep_old]', _("Keep old"), 'wikiaction'), $tokens['SEP'], Button('submit:edit[overwrite]', _("Overwrite with new"), 'wikiaction'), $tokens['SEP'], $tokens['PREVIEW_B']);
     }
     if (ENABLE_EDIT_TOOLBAR and !ENABLE_WYSIWYG) {
         include_once "lib/EditToolbar.php";
         $toolbar = new EditToolbar();
         $tokens = array_merge($tokens, $toolbar->getTokens());
     }
     return $this->output('editpage', _("Merge and Edit: %s"));
 }