From: Joel U. <uck...@us...> - 2001-06-26 18:08:35
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv7797 Modified Files: editpage.php loadsave.php savepage.php stdlib.php Log Message: lib/editpage.php - Added $version to RetrievePage calls. - Removed EditCopy, since it's no longer needed. lib/loadsave.php - Changed call to InsertPage to ReplaceCurrentPage. - Changed call to SaveCopyToArchive to SavePageToArchive. - Added $version to RetrievePage calls. lib/savepage.php - Changed call to InsertPage to ReplaceCurrentPage. - Changed call to SaveCopyToArchive to SavePageToArchive. - All old versions of pages are now saved to archive. - Added $version to RetrievePage calls. lib/stdlib.php - Changed call to InsertPage to ReplaceCurrentPage. - Added $version to RetrievePage call. - Added $WikiPageStore as global in GeneratePage. - Added CURRENT as _iftoken. This is needed so users can edit from archived pages, but still be prevented from completing their edit if the current page version changes while they are editing. VERSION doesn't work for this anymore, since the version being edited might not be CURRENT. Index: editpage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/editpage.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** editpage.php 2001/02/27 23:22:30 1.15 --- editpage.php 2001/06/26 18:08:32 1.16 *************** *** 4,48 **** // editpage relies on $pagename, $version ! $currentpage = RetrievePage($dbi, $pagename, $WikiPageStore); ! $editing_copy = isset($version) && $version == 'archive'; ! if ($editing_copy) { ! $banner = htmlspecialchars (sprintf (gettext ("Copy of %s"), $pagename)); ! $pagehash = RetrievePage($dbi, $pagename, $ArchivePageStore); ! } else { ! $banner = htmlspecialchars($pagename); ! $pagehash = $currentpage; ! } if (is_array($pagehash)) { ! ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !$user->is_admin()) { ! $html = "<p>"; ! $html .= gettext ("This page has been locked by the administrator and cannot be edited."); ! $html .= "\n<p>"; ! $html .= gettext ("Sorry for the inconvenience."); ! $html .= "\n"; ! echo GeneratePage('MESSAGE', $html, ! sprintf (gettext ("Problem while editing %s"), $pagename), 0); ! ExitWiki (""); ! } ! ! $textarea = htmlspecialchars(implode("\n", $pagehash["content"])); ! if ($editing_copy) { ! $pagehash["version"] = $currentpage["version"]; } - else { - if ($pagehash["version"] > 1 && IsInArchive($dbi, $pagename)) { - $pagehash["copy"] = 1; - } - } - } else { - if (preg_match("/^${WikiNameRegexp}\$/", $pagename)) - $newpage = $pagename; - else - $newpage = "[$pagename]"; ! $textarea = htmlspecialchars( ! sprintf(gettext ("Describe %s here."), $newpage)); unset($pagehash); --- 4,30 ---- // editpage relies on $pagename, $version ! $currentpage = RetrievePage($dbi, $pagename, SelectStore($dbi, $pagename, $version, $WikiPageStore, $ArchivePageStore), $version); ! $banner = htmlspecialchars($pagename); ! $pagehash = $currentpage; if (is_array($pagehash)) { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !$user->is_admin()) { ! $html = "<p>"; ! $html .= gettext ("This page has been locked by the administrator and cannot be edited."); ! $html .= "\n<p>"; ! $html .= gettext ("Sorry for the inconvenience."); ! $html .= "\n"; ! echo GeneratePage('MESSAGE', $html, sprintf (gettext ("Problem while editing %s"), $pagename), 0); ! ExitWiki (""); } ! $textarea = htmlspecialchars(implode("\n", $pagehash["content"])); ! } ! else { ! if (preg_match("/^${WikiNameRegexp}\$/", $pagename)) $newpage = $pagename; ! else $newpage = "[$pagename]"; ! ! $textarea = htmlspecialchars(sprintf(gettext("Describe %s here."), $newpage)); unset($pagehash); *************** *** 51,78 **** $pagehash["author"] = ''; $currentpage = $pagehash; - } - - if (empty($pagehash['copy'])) - $do_archive = false; - else if ( $user->is_admin() ) - $do_archive = 'probably'; - else if ( $user->id() == $currentpage['author'] ) - { - $page_age = time() - $currentpage['lastmodified']; - if ($page_age < MINOR_EDIT_TIMEOUT) - $do_archive = 'maybe'; - else - $do_archive = 'probably'; - } - else - $do_archive = 'force'; - - if ($do_archive == 'probably' || $do_archive == 'maybe') - { - $pagehash['minor_edit_checkbox'] - = Element('input', array('type' => 'checkbox', - 'name' => 'minor_edit', - 'value' => 'yes', - 'checked' => ($do_archive == 'maybe'))); } --- 33,36 ---- Index: loadsave.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/loadsave.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** loadsave.php 2001/05/31 17:43:05 1.6 --- loadsave.php 2001/06/26 18:08:32 1.7 *************** *** 13,18 **** { // FIXME: This is a hack ! echo Element('p', QElement('b', gettext ("Complete."))); ! echo Element('p', gettext ("Return to ") . LinkExistingWikiWord($GLOBALS['pagename'])); echo "</body></html>\n"; } --- 13,18 ---- { // FIXME: This is a hack ! echo Element('p', QElement('b', gettext("Complete."))); ! echo Element('p', "Return to " . LinkExistingWikiWord($GLOBALS['pagename'])); echo "</body></html>\n"; } *************** *** 69,73 **** { set_time_limit(30); // Reset watchdog. ! $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore); if (! is_array($pagehash)) --- 69,73 ---- { set_time_limit(30); // Reset watchdog. ! $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore, 0); if (! is_array($pagehash)) *************** *** 75,79 **** if ($include_archive) ! $oldpagehash = RetrievePage($dbi, $pagename, $ArchivePageStore); else $oldpagehash = false; --- 75,79 ---- if ($include_archive) ! $oldpagehash = RetrievePage($dbi, $pagename, $ArchivePageStore, 0); else $oldpagehash = false; *************** *** 122,126 **** echo "<small>saved as $filename</small> ... "; ! $page = RetrievePage($dbi, $pagename, $WikiPageStore); //$data = serialize($page); --- 122,126 ---- echo "<small>saved as $filename</small> ... "; ! $page = RetrievePage($dbi, $pagename, $WikiPageStore, 0); //$data = serialize($page); *************** *** 175,179 **** $mesg[] = sprintf(gettext("from %s"), $source); ! if (is_array($current = RetrievePage($dbi, $pagename, $WikiPageStore))) { $isnew = false; --- 175,179 ---- $mesg[] = sprintf(gettext("from %s"), $source); ! if (is_array($current = RetrievePage($dbi, $pagename, $WikiPageStore, 0))) { $isnew = false; *************** *** 194,198 **** else { ! SaveCopyToArchive($dbi, $pagename, $current); if ( $version <= $current['version'] ) --- 194,198 ---- else { ! SavePageToArchive($pagename, $current); if ( $version <= $current['version'] ) *************** *** 206,210 **** if ($page) { ! InsertPage($dbi, $pagename, $page); UpdateRecentChanges($dbi, $pagename, $isnew); --- 206,210 ---- if ($page) { ! ReplaceCurrentPage($pagename, $page); UpdateRecentChanges($dbi, $pagename, $isnew); *************** *** 260,270 **** usort($parts, 'SortByPageVersion'); for (reset($parts); $page = current($parts); next($parts)) ! SavePage($dbi, $page, $defaults, ! gettext ("MIME file") . " $filename", $basename); } else if ( ($page = ParseSerializedPage($text)) ) { ! SavePage($dbi, $page, $defaults, ! gettext ("Serialized file") . " $filename", $basename); } else --- 260,268 ---- usort($parts, 'SortByPageVersion'); for (reset($parts); $page = current($parts); next($parts)) ! SavePage($dbi, $page, $defaults, "MIME file $filename", $basename); } else if ( ($page = ParseSerializedPage($text)) ) { ! SavePage($dbi, $page, $defaults, "Serialized file $filename", $basename); } else *************** *** 272,277 **** // Assume plain text file. $page['content'] = preg_split('/[ \t\r]*\n/', chop($text)); ! SavePage($dbi, $page, $defaults, ! gettext ("plain file") . " $filename", $basename); } } --- 270,274 ---- // Assume plain text file. $page['content'] = preg_split('/[ \t\r]*\n/', chop($text)); ! SavePage($dbi, $page, $defaults, "plain file $filename", $basename); } } *************** *** 287,292 **** || ($exclude && in_array($fn, $exclude)) ) { ! print Element('dt', LinkExistingWikiWord($fn)) ! . QElement('dd', gettext("Skipping")); continue; } --- 284,288 ---- || ($exclude && in_array($fn, $exclude)) ) { ! print Element('dt', LinkExistingWikiWord($fn)) . QElement('dd', 'Skipping'); continue; } *************** *** 362,366 **** StartLoadDump("Loading '$source'"); echo "<dl>\n"; ! LoadAny($dbi, $source, false, array(gettext("RecentChanges"))); echo "</dl>\n"; EndLoadDump(); --- 358,362 ---- StartLoadDump("Loading '$source'"); echo "<dl>\n"; ! LoadAny($dbi, $source, false, array(gettext('RecentChanges'))); echo "</dl>\n"; EndLoadDump(); *************** *** 372,381 **** //FIXME: This is a hack ! $user->userid = gettext("The PhpWiki programming team"); ! StartLoadDump(gettext("Loading up virgin wiki")); echo "<dl>\n"; ! $ignore = array(gettext("RecentChanges")); LoadAny($dbi, FindLocalizedFile(WIKI_PGSRC), false, $ignore); --- 368,377 ---- //FIXME: This is a hack ! $user->userid = 'The PhpWiki programming team'; ! StartLoadDump('Loading up virgin wiki'); echo "<dl>\n"; ! $ignore = array(gettext('RecentChanges')); LoadAny($dbi, FindLocalizedFile(WIKI_PGSRC), false, $ignore); *************** *** 408,412 **** if (IsZipFile($fd)) ! LoadZip($dbi, $fd, false, array(gettext("RecentChanges"))); else Loadfile($dbi, $name, fread($fd, MAX_UPLOAD_SIZE)); --- 404,408 ---- if (IsZipFile($fd)) ! LoadZip($dbi, $fd, false, array(gettext('RecentChanges'))); else Loadfile($dbi, $name, fread($fd, MAX_UPLOAD_SIZE)); Index: savepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** savepage.php 2001/03/14 19:45:42 1.14 --- savepage.php 2001/06/26 18:08:32 1.15 *************** *** 39,43 **** ! $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore); // if this page doesn't exist yet, now's the time! --- 39,43 ---- ! $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore, 0); // if this page doesn't exist yet, now's the time! *************** *** 49,58 **** $newpage = 1; } else { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && ! $user->is_admin()) { ! $html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited."); ! $html .= "\n<p>" . gettext ("Sorry for the inconvenience."); ! echo GeneratePage('MESSAGE', $html, ! sprintf (gettext ("Problem while editing %s"), $pagename), 0); ! ExitWiki (""); } --- 49,58 ---- $newpage = 1; } else { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && ! $user->is_admin()) { ! $html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited."); ! $html .= "\n<p>" . gettext ("Sorry for the inconvenience."); ! echo GeneratePage('MESSAGE', $html, ! sprintf (gettext ("Problem while editing %s"), $pagename), 0); ! ExitWiki (""); } *************** *** 61,73 **** } ! if ($user->id() != $pagehash['author'] && ! $user->is_admin()) ! unset($minor_edit); // Force archive ! ! if (empty($minor_edit)) ! SaveCopyToArchive($dbi, $pagename, $pagehash); - $newpage = 0; - } - // set new pageinfo $pagehash['lastmodified'] = time(); --- 61,68 ---- } ! SavePageToArchive($pagename, $pagehash); ! $newpage = 0; ! } // set new pageinfo $pagehash['lastmodified'] = time(); *************** *** 92,97 **** } ! InsertPage($dbi, $pagename, $pagehash); ! UpdateRecentChanges($dbi, $pagename, $newpage); $html .= gettext ("Your careful attention to detail is much appreciated."); --- 87,92 ---- } ! ReplaceCurrentPage($pagename, $pagehash); ! UpdateRecentChanges($dbi, $pagename, $newpage); $html .= gettext ("Your careful attention to detail is much appreciated."); Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** stdlib.php 2001/05/31 17:43:05 1.39 --- stdlib.php 2001/06/26 18:08:32 1.40 *************** *** 473,476 **** --- 473,477 ---- global $datetimeformat, $dbi, $logo, $FieldSeparator; global $user, $pagename; + global $WikiPageStore; if (!is_array($hash)) *************** *** 519,522 **** --- 520,524 ---- _iftoken('ADMIN', $user->is_admin(), $page); _iftoken('ANONYMOUS', !$user->is_authenticated(), $page); + _iftoken('CURRENT', isset($hash['version']) && $hash['version'] == GetMaxVersionNumber($dbi, $hash['pagename'], $WikiPageStore), $page); if (empty($hash['minor_edit_checkbox'])) *************** *** 575,578 **** --- 577,582 ---- if (!empty($hash['version'])) _dotoken('VERSION', $hash['version'], $page); + if (!empty($hash['pagename'])) + _dotoken('CURRENT_VERSION', GetMaxVersionNumber($dbi, $hash['pagename'], $WikiPageStore), $page); if (strstr($page, "$FieldSeparator#HITS$FieldSeparator#")) { _dotoken('HITS', GetHitCount($dbi, $name), $page); *************** *** 593,597 **** global $WikiPageStore; ! $recentchanges = RetrievePage($dbi, gettext ("RecentChanges"), $WikiPageStore); // this shouldn't be necessary, since PhpWiki loads --- 597,601 ---- global $WikiPageStore; ! $recentchanges = RetrievePage($dbi, gettext ("RecentChanges"), $WikiPageStore, 0); // this shouldn't be necessary, since PhpWiki loads *************** *** 643,647 **** // add the updated page's name to the array if($isnewpage) { ! $newpage[$k++] = "* [$pagename] " . gettext("(new)") . " ..... $userid\r"; } else { $diffurl = "phpwiki:" . rawurlencode($pagename) . "?action=diff"; --- 647,651 ---- // add the updated page's name to the array if($isnewpage) { ! $newpage[$k++] = "* [$pagename] (new) ..... $userid\r"; } else { $diffurl = "phpwiki:" . rawurlencode($pagename) . "?action=diff"; *************** *** 662,666 **** $recentchanges['content'] = $newpage; ! InsertPage($dbi, gettext ("RecentChanges"), $recentchanges); } --- 666,670 ---- $recentchanges['content'] = $newpage; ! ReplaceCurrentPage(gettext ("RecentChanges"), $recentchanges); } |