1 <?php rcs_id('$Id: savepage.php,v 1.13 2001-02-14 05:22:49 dairiki Exp $');
4 All page saving events take place here.
5 All page info is also taken care of here.
6 This is klugey. But it works. There's probably a slicker way of
11 function ConcurrentUpdates($pagename)
13 /* xgettext only knows about c/c++ line-continuation strings
14 is does not know about php's dot operator.
15 We want to translate this entire paragraph as one string, of course.
18 $html .= gettext ("PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost.");
20 $html .= gettext ("In order to recover from this situation follow these steps:");
21 $html .= "\n<OL><LI>";
22 $html .= gettext ("Use your browser's <b>Back</b> button to go back to the edit page.");
24 $html .= gettext ("Copy your changes to the clipboard or to another temporary place (e.g. text editor).");
26 $html .= gettext ("<b>Reload</b> the page. You should now see the most current version of the page. Your changes are no longer there.");
28 $html .= gettext ("Make changes to the file again. Paste your additions from the clipboard (or text editor).");
30 $html .= gettext ("Press <b>Save</b> again.");
31 $html .= "</OL>\n<P>";
32 $html .= gettext ("Sorry for the inconvenience.");
35 echo GeneratePage('MESSAGE', $html,
36 sprintf (gettext ("Problem while updating %s"), $pagename), 0);
41 $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
43 // if this page doesn't exist yet, now's the time!
44 if (! is_array($pagehash)) {
46 $pagehash['version'] = 0;
47 $pagehash['created'] = time();
48 $pagehash['flags'] = 0;
51 if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && ! $user->is_admin()) {
52 $html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited.");
53 $html .= "\n<p>" . gettext ("Sorry for the inconvenience.");
54 echo GeneratePage('MESSAGE', $html,
55 sprintf (gettext ("Problem while editing %s"), $pagename), 0);
59 if(isset($editversion) && ($editversion != $pagehash['version'])) {
60 ConcurrentUpdates($pagename);
63 if ($user->id() != $pagehash['author'] && ! $user->is_admin())
64 unset($minor_edit); // Force archive
66 if (empty($minor_edit))
67 SaveCopyToArchive($dbi, $pagename, $pagehash);
73 $pagehash['lastmodified'] = time();
74 $pagehash['version']++;
75 $pagehash['author'] = $user->id();
78 $html = sprintf(gettext("Thank you for editing %s."),
79 LinkExistingWikiWord($pagename));
82 if (! empty($content)) {
83 // patch from Grant Morgan <grant@ryuuguu.com> for magic_quotes_gpc
84 fix_magic_quotes_gpc($content);
86 $pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($content));
88 // convert spaces to tabs at user request
89 if (isset($convert)) {
90 $pagehash['content'] = CookSpaces($pagehash['content']);
94 InsertPage($dbi, $pagename, $pagehash);
95 UpdateRecentChanges($dbi, $pagename, $newpage);
97 $html .= gettext ("Your careful attention to detail is much appreciated.");
100 // fixme: no test for flat file db system
101 if (!empty($DBWarning)) {
102 $html .= "<P><B>Warning: $DBWarning" .
103 "Please read the INSTALL file and move " .
104 "the DB file to a permanent location or risk losing " .
105 "all the pages!</B>\n";
108 if (!empty($SignatureImg))
109 $html .= sprintf("<P><img src=\"%s\"></P>\n", DataURL($SignatureImg));
111 $html .= "<hr noshade><P>";
112 include('lib/transform.php');
114 echo GeneratePage('BROWSE', $html, $pagename, $pagehash);