From: Arno H. <aho...@us...> - 2001-01-04 18:30:31
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv8160 Modified Files: savepage.php Log Message: moved UpdateRecentChanges() to savepage.php Index: savepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** savepage.php 2000/11/08 15:40:00 1.6 --- savepage.php 2001/01/04 18:30:32 1.7 *************** *** 1,4 **** ! <!-- $Id$ --> ! <?php /* --- 1,3 ---- ! <?php rcs_id('$Id$'); /* *************** *** 9,12 **** --- 8,79 ---- */ + function UpdateRecentChanges($dbi, $pagename, $isnewpage) + { + global $remoteuser; // this is set in the config + global $dateformat; + global $WikiPageStore; + + $recentchanges = RetrievePage($dbi, gettext ("RecentChanges"), $WikiPageStore); + + // this shouldn't be necessary, since PhpWiki loads + // default pages if this is a new baby Wiki + if ($recentchanges == -1) { + $recentchanges = array(); + } + + $now = time(); + $today = date($dateformat, $now); + + if (date($dateformat, $recentchanges['lastmodified']) != $today) { + $isNewDay = TRUE; + $recentchanges['lastmodified'] = $now; + } else { + $isNewDay = FALSE; + } + + $numlines = sizeof($recentchanges['content']); + $newpage = array(); + $k = 0; + + // scroll through the page to the first date and break + // dates are marked with "____" at the beginning of the line + for ($i = 0; $i < $numlines; $i++) { + if (preg_match("/^____/", + $recentchanges['content'][$i])) { + break; + } else { + $newpage[$k++] = $recentchanges['content'][$i]; + } + } + + // if it's a new date, insert it + $newpage[$k++] = $isNewDay ? "____$today\r" + : $recentchanges['content'][$i++]; + + // add the updated page's name to the array + if($isnewpage) { + $newpage[$k++] = "* [$pagename] (new) ..... $remoteuser\r"; + } else { + $diffurl = "phpwiki:?diff=" . rawurlencode($pagename); + $newpage[$k++] = "* [$pagename] ([diff|$diffurl]) ..... $remoteuser\r"; + } + if ($isNewDay) + $newpage[$k++] = "\r"; + + // copy the rest of the page into the new array + // and skip previous entry for $pagename + $pagename = preg_quote($pagename); + for (; $i < $numlines; $i++) { + if (!preg_match("|\[$pagename\]|", $recentchanges['content'][$i])) { + $newpage[$k++] = $recentchanges['content'][$i]; + } + } + + $recentchanges['content'] = $newpage; + + InsertPage($dbi, gettext ("RecentChanges"), $recentchanges); + } + + function ConcurrentUpdates($pagename) { *************** *** 38,41 **** --- 105,110 ---- } + + $pagename = rawurldecode($post); $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore); *************** *** 44,50 **** if (! is_array($pagehash)) { $pagehash = array(); ! $pagehash["version"] = 0; ! $pagehash["created"] = time(); ! $pagehash["flags"] = 0; $newpage = 1; } else { --- 113,119 ---- if (! is_array($pagehash)) { $pagehash = array(); ! $pagehash['version'] = 0; ! $pagehash['created'] = time(); ! $pagehash['flags'] = 0; $newpage = 1; } else { *************** *** 56,65 **** } ! if(isset($editversion) && ($editversion != $pagehash["version"])) { ConcurrentUpdates($pagename); } // archive it if it's a new author ! if ($pagehash["author"] != $remoteuser) { SaveCopyToArchive($dbi, $pagename, $pagehash); } --- 125,134 ---- } ! if(isset($editversion) && ($editversion != $pagehash['version'])) { ConcurrentUpdates($pagename); } // archive it if it's a new author ! if ($pagehash['author'] != $remoteuser) { SaveCopyToArchive($dbi, $pagename, $pagehash); } *************** *** 67,73 **** } ! $pagehash["lastmodified"] = time(); ! $pagehash["version"]++; ! $pagehash["author"] = $remoteuser; // create page header --- 136,143 ---- } ! // set new pageinfo ! $pagehash['lastmodified'] = time(); ! $pagehash['version']++; ! $pagehash['author'] = $remoteuser; // create page header *************** *** 83,91 **** $content = stripslashes($content); ! $pagehash["content"] = preg_split('/[ \t\r]*\n/', chop($content)); // convert spaces to tabs at user request if (isset($convert)) { ! $pagehash["content"] = CookSpaces($pagehash["content"]); } } --- 153,161 ---- $content = stripslashes($content); ! $pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($content)); // convert spaces to tabs at user request if (isset($convert)) { ! $pagehash['content'] = CookSpaces($pagehash['content']); } } *************** *** 107,110 **** --- 177,181 ---- $html .= "\n"; + // fixme: no test for flat file db system if ($WikiPageStore == "/tmp/wikidb") { $html .= "<P><B>Warning: the Wiki DBM file still lives in the " . *************** *** 115,119 **** $html .= "<P><img src=\"$SignatureImg\"></P><hr noshade><P>"; ! include("lib/transform.php"); GeneratePage('BROWSE', $html, $pagename, $pagehash); --- 186,190 ---- $html .= "<P><img src=\"$SignatureImg\"></P><hr noshade><P>"; ! include('lib/transform.php'); GeneratePage('BROWSE', $html, $pagename, $pagehash); |