]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/editpage.php
PhpWiki 1.2.7 backport cvs release-1_2-branch enhancements never released with 1...
[SourceForge/phpwiki.git] / lib / editpage.php
1 <!-- $Id: editpage.php,v 1.8.2.5 2005-01-07 14:23:04 rurban Exp $ -->
2 <?php
3
4    // editpage relies on $pagename and $ScriptUrl
5
6    if ($edit) {
7       $pagename = rawurldecode($edit);
8       if (get_magic_quotes_gpc()) {
9          $pagename = stripslashes($pagename);
10       }
11       $banner = htmlspecialchars($pagename);
12       $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
13
14    } elseif ($copy) {
15       $pagename = rawurldecode($copy);
16       if (get_magic_quotes_gpc()) {
17          $pagename = stripslashes($pagename);
18       }
19       $banner = htmlspecialchars (sprintf (gettext ("Copy of %s"), $pagename));
20       $pagehash = RetrievePage($dbi, $pagename, $ArchivePageStore);
21
22    } else {
23       ExitWiki(gettext ("No page name passed into editpage!"));
24    }
25
26
27    if (is_array($pagehash)) {
28
29       if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !defined('WIKI_ADMIN')) {
30          $html = "<p>";
31          $html .= gettext ("This page has been locked by the administrator and cannot be edited.");
32          $html .= "</p>\n<p>";
33          $html .= gettext ("Sorry for the inconvenience.");
34          $html .= "</p>\n";
35          GeneratePage('MESSAGE', $html, sprintf (gettext ("Problem while editing %s"), $pagename), 0);
36          ExitWiki ("");
37       }
38
39       $textarea = htmlspecialchars(implode("\n", $pagehash["content"]));
40       if (isset($copy)) {
41          // $cdbi = OpenDataBase($WikiPageStore);
42          $currentpage = RetrievePage($dbi, $pagename, $WikiPageStore);
43          $pagehash["version"] = $currentpage["version"];
44       }
45       elseif ($pagehash["version"] > 1) {
46          if(IsInArchive($dbi, $pagename))
47            $pagehash["copy"] = 1;
48       }
49    } else {
50       if (preg_match("/^${WikiNameRegexp}\$/", $pagename))
51          $newpage = $pagename;
52       else
53          $newpage = "[$pagename]";
54
55       $textarea = htmlspecialchars(
56          sprintf(gettext ("Describe %s here."), $newpage));
57
58       unset($pagehash);
59       $pagehash["version"] = 0;
60       $pagehash["lastmodified"] = time();
61       $pagehash["author"] = '';
62    }
63
64    GeneratePage('EDITPAGE', $textarea, $pagename, $pagehash);   
65 ?>