\");\n";
$btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $WikiTheme->getImageURL("ed_save.gif"));
$btn->addTooltip(_("Save"));
$toolbar.='document.writeln("'.addslashes($btn->asXml()).'");'."\n";
$btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $WikiTheme->getImageURL("ed_preview.gif"));
$btn->addTooltip(_("Preview"));
$toolbar.='document.writeln("'.addslashes($btn->asXml()).'");'."\n";
foreach ($toolarray as $tool) {
$image = $WikiTheme->getImageURL($tool["image"]);
$open = $tool["open"];
$close = $tool["close"];
$sample = addslashes( $tool["sample"] );
// Note that we use the tip both for the ALT tag and the TITLE tag of the image.
// Older browsers show a "speedtip" type message only for ALT.
// Ideally these should be different, realistically they
// probably don't need to be.
$tip = addslashes( $tool["tip"] );
$toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
}
$toolbar.="addInfobox('" . addslashes( _("Click a button to get an example text") ) . "');\n";
if (defined('JS_SEARCHREPLACE') and JS_SEARCHREPLACE) {
$undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.gif");
//$redo_btn = $WikiTheme->getImageURL("ed_redo.gif");
$sr_btn = $WikiTheme->getImageURL("ed_replace.gif");
$sr_js = ''
// . ''
. '';
$toolbar.='document.writeln("'.addslashes($sr_js).'");'."\n";
}
// More:
// Button to generate pagenames, display in extra window as pulldown and insert
// Button to generate plugins, display in extra window as pulldown and insert
// Button to generate categories, display in extra window as pulldown and insert
$toolbar.="document.writeln(\"
\");";
return Javascript($toolbar);
}
function output ($template, $title_fs) {
global $WikiTheme;
$selected = &$this->selected;
$current = &$this->current;
if ($selected && $selected->getVersion() != $current->getVersion()) {
$rev = $selected;
$pagelink = WikiLink($selected);
}
else {
$rev = $current;
$pagelink = WikiLink($this->page);
}
$title = new FormattedText ($title_fs, $pagelink);
if ($template == 'editpage' and USE_HTMLAREA) {
$WikiTheme->addMoreHeaders(Edit_HtmlArea_Head());
//$tokens['PAGE_SOURCE'] = Edit_HtmlArea_ConvertBefore($this->_content);
}
$template = Template($template, $this->tokens);
GeneratePage($template, $title, $rev);
return true;
}
function viewSource () {
assert($this->isInitialEdit());
assert($this->selected);
$this->tokens['PAGE_SOURCE'] = $this->_content;
return $this->output('viewsource', _("View Source: %s"));
}
function updateLock() {
if ((bool)$this->page->get('locked') == (bool)$this->locked)
return false; // Not changed.
if (!$this->user->isAdmin()) {
// FIXME: some sort of message
return false; // not allowed.
}
$this->page->set('locked', (bool)$this->locked);
$this->tokens['LOCK_CHANGED_MSG']
= $this->locked ? _("Page now locked.") : _("Page now unlocked.");
return true; // lock changed.
}
function savePage () {
$request = &$this->request;
if ($this->isUnchanged()) {
// Allow admin lock/unlock even if
// no text changes were made.
if ($this->updateLock()) {
$dbi = $request->getDbh();
$dbi->touch();
}
// Save failed. No changes made.
$this->_redirectToBrowsePage();
// user will probably not see the rest of this...
include_once('lib/display.php');
// force browse of current version:
$request->setArg('version', false);
displayPage($request, 'nochanges');
return true;
}
$page = &$this->page;
// Include any meta-data from original page version which
// has not been explicitly updated.
// (Except don't propagate pgsrc_version --- moot for now,
// because at present it never gets into the db...)
$meta = $this->selected->getMetaData();
unset($meta['pgsrc_version']);
$meta = array_merge($meta, $this->meta);
// Save new revision
$this->_content = $this->getContent();
$newrevision = $page->save($this->_content, $this->_currentVersion + 1, $meta);
if (!isa($newrevision, 'wikidb_pagerevision')) {
// Save failed. (Concurrent updates).
return false;
}
// New contents successfully saved...
$this->updateLock();
// Clean out archived versions of this page.
include_once('lib/ArchiveCleaner.php');
$cleaner = new ArchiveCleaner($GLOBALS['ExpireParams']);
$cleaner->cleanPageRevisions($page);
/* generate notification emails done in WikiDB::save to catch all direct calls
(admin plugins) */
$dbi = $request->getDbh();
$warnings = $dbi->GenericWarnings();
$dbi->touch();
global $WikiTheme;
if (empty($warnings) && ! $WikiTheme->getImageURL('signature')) {
// Do redirect to browse page if no signature has
// been defined. In this case, the user will most
// likely not see the rest of the HTML we generate
// (below).
$this->_redirectToBrowsePage();
}
// Force browse of current page version.
$request->setArg('version', false);
//$request->setArg('action', false);
$template = Template('savepage', $this->tokens);
$template->replace('CONTENT', $newrevision->getTransformedContent());
if (!empty($warnings))
$template->replace('WARNINGS', $warnings);
$pagelink = WikiLink($page);
GeneratePage($template, fmt("Saved: %s", $pagelink), $newrevision);
return true;
}
function isConcurrentUpdate () {
assert($this->current->getVersion() >= $this->_currentVersion);
return $this->current->getVersion() != $this->_currentVersion;
}
function canEdit () {
return !$this->page->get('locked') || $this->user->isAdmin();
}
function isInitialEdit () {
return $this->_initialEdit;
}
function isUnchanged () {
$current = &$this->current;
if ($this->meta['markup'] != $current->get('markup'))
return false;
return $this->_content == $current->getPackedContent();
}
function getPreview () {
include_once('lib/PageType.php');
$this->_content = $this->getContent();
return new TransformedText($this->page, $this->_content, $this->meta);
}
// possibly convert HTMLAREA content back to Wiki markup
function getContent () {
if (USE_HTMLAREA) {
$xml_output = Edit_HtmlArea_ConvertAfter($this->_content);
$this->_content = join("",$xml_output->_content);
return $this->_content;
} else {
return $this->_content;
}
}
function getLockedMessage () {
return
HTML(HTML::h2(_("Page Locked")),
HTML::p(_("This page has been locked by the administrator so your changes can not be saved.")),
HTML::p(_("(Copy your changes to the clipboard. You can try editing a different page or save your text in a text editor.)")),
HTML::p(_("Sorry for the inconvenience.")));
}
function getConflictMessage ($unresolved = false) {
/*
xgettext only knows about c/c++ line-continuation strings
it does not know about php's dot operator.
We want to translate this entire paragraph as one string, of course.
*/
//$re_edit_link = Button('edit', _("Edit the new version"), $this->page);
if ($unresolved)
$message = HTML::p(fmt("Some of the changes could not automatically be combined. Please look for sections beginning with '%s', and ending with '%s'. You will need to edit those sections by hand before you click Save.",
"<<<<<<< ". _("Your version"),
">>>>>>> ". _("Other version")));
else
$message = HTML::p(_("Please check it through before saving."));
/*$steps = HTML::ol(HTML::li(_("Copy your changes to the clipboard or to another temporary place (e.g. text editor).")),
HTML::li(fmt("%s of the page. You should now see the most current version of the page. Your changes are no longer there.",
$re_edit_link)),
HTML::li(_("Make changes to the file again. Paste your additions from the clipboard (or text editor).")),
HTML::li(_("Save your updated changes.")));
*/
return
HTML(HTML::h2(_("Conflicting Edits!")),
HTML::p(_("In the time since you started editing this page, another user has saved a new version of it.")),
HTML::p(_("Your changes can not be saved as they are, since doing so would overwrite the other author's changes. So, your changes and those of the other author have been combined. The result is shown below.")),
$message);
}
function getTextArea () {
$request = &$this->request;
// wrap=virtual is not HTML4, but without it NS4 doesn't wrap
// long lines
$readonly = ! $this->canEdit(); // || $this->isConcurrentUpdate();
if (USE_HTMLAREA) {
$html = $this->getPreview();
$this->_wikicontent = $this->_content;
$this->_content = $html->asXML();
}
/**