function action_loadfile() { include_once "lib/loadsave.php"; LoadFileOrDir($this); }
function editPage() { global $WikiTheme; $saveFailed = false; $tokens =& $this->tokens; $tokens['PAGE_LOCKED_MESSAGE'] = ''; $tokens['LOCK_CHANGED_MSG'] = ''; $tokens['CONCURRENT_UPDATE_MESSAGE'] = ''; $r =& $this->request; if (isset($r->args['pref']['editWidth']) and $r->getPref('editWidth') != $r->args['pref']['editWidth']) { $r->_prefs->set('editWidth', $r->args['pref']['editWidth']); } if (isset($r->args['pref']['editHeight']) and $r->getPref('editHeight') != $r->args['pref']['editHeight']) { $r->_prefs->set('editHeight', $r->args['pref']['editHeight']); } if ($this->isModerated()) { $tokens['PAGE_LOCKED_MESSAGE'] = $this->getModeratedMessage(); } if (!$this->canEdit()) { if ($this->isInitialEdit()) { return $this->viewSource(); } $tokens['PAGE_LOCKED_MESSAGE'] = $this->getLockedMessage(); } elseif ($r->getArg('save_and_redirect_to') != "") { if (ENABLE_CAPTCHA && $this->Captcha->Failed()) { $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML::p(HTML::h1($this->Captcha->failed_msg)); } elseif ($this->savePage()) { // noreturn $request->setArg('action', false); $r->redirect(WikiURL($r->getArg('save_and_redirect_to'))); return true; // Page saved. } $saveFailed = true; } elseif ($this->editaction == 'save') { if (ENABLE_CAPTCHA && $this->Captcha->Failed()) { $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML::p(HTML::h1($this->Captcha->failed_msg)); } elseif ($this->savePage()) { return true; // Page saved. } else { $saveFailed = true; } } elseif ($this->editaction == 'keep_old') { // keep old page and do nothing $this->_redirectToBrowsePage(); //$r->redirect(WikiURL($r->getArg('save_and_redirect_to'))); return true; } elseif ($this->editaction == 'overwrite') { // take the new content without diff $source = $this->request->getArg('loadfile'); require_once 'lib/loadsave.php'; $this->request->setArg('loadfile', 1); $this->request->setArg('overwrite', 1); $this->request->setArg('merge', 0); LoadFileOrDir($this->request); $this->_redirectToBrowsePage(); //$r->redirect(WikiURL($r->getArg('save_and_redirect_to'))); return true; } elseif ($this->editaction == 'upload') { // run plugin UpLoad $plugin = WikiPluginLoader("UpLoad"); $plugin->run(); // add link to content } if ($saveFailed and $this->isConcurrentUpdate()) { // Get the text of the original page, and the two conflicting edits // The diff3 class takes arrays as input. So retrieve content as // an array, or convert it as necesary. $orig = $this->page->getRevision($this->_currentVersion); // FIXME: what if _currentVersion has be deleted? $orig_content = $orig->getContent(); $this_content = explode("\n", $this->_content); $other_content = $this->current->getContent(); require_once "lib/diff3.php"; $diff = new diff3($orig_content, $this_content, $other_content); $output = $diff->merged_output(_("Your version"), _("Other version")); // Set the content of the textarea to the merged diff // output, and update the version $this->_content = implode("\n", $output); $this->_currentVersion = $this->current->getVersion(); $this->version = $this->_currentVersion; $unresolved = $diff->ConflictingBlocks; $tokens['CONCURRENT_UPDATE_MESSAGE'] = $this->getConflictMessage($unresolved); } elseif ($saveFailed && !$this->_isSpam) { $tokens['CONCURRENT_UPDATE_MESSAGE'] = HTML(HTML::h2(_("Some internal editing error")), HTML::p(_("Your are probably trying to edit/create an invalid version of this page.")), HTML::p(HTML::em(_("&version=-1 might help.")))); } if ($this->editaction == 'edit_convert') { $tokens['PREVIEW_CONTENT'] = $this->getConvertedPreview(); } if ($this->editaction == 'preview') { $tokens['PREVIEW_CONTENT'] = $this->getPreview(); } // FIXME: convert to _MESSAGE? if ($this->editaction == 'diff') { $tokens['PREVIEW_CONTENT'] = $this->getDiff(); } // FIXME: NOT_CURRENT_MESSAGE? $tokens = array_merge($tokens, $this->getFormElements()); if (ENABLE_EDIT_TOOLBAR and !ENABLE_WYSIWYG) { require_once "lib/EditToolbar.php"; $toolbar = new EditToolbar(); $tokens = array_merge($tokens, $toolbar->getTokens()); } return $this->output('editpage', _("Edit: %s")); }