From 6f0f1ff5c5aac54dedd76fb04a7844a17fa5e445 Mon Sep 17 00:00:00 2001 From: dairiki Date: Fri, 21 Feb 2003 04:12:06 +0000 Subject: [PATCH] Minor fixes for new cached markup. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@2603 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/XmlRpcServer.php | 51 +++++++++++++---------------------- lib/display.php | 19 +++++-------- lib/loadsave.php | 15 +++++------ lib/plugin/IncludePage.php | 11 +++++--- lib/plugin/OldStyleTable.php | 12 ++++++--- lib/plugin/RecentChanges.php | 10 +++++-- lib/plugin/SiteMap.php | 13 ++++++--- lib/plugin/UnfoldSubpages.php | 13 ++++++--- 8 files changed, 75 insertions(+), 69 deletions(-) diff --git a/lib/XmlRpcServer.php b/lib/XmlRpcServer.php index 8c1d93a9e..86df446cb 100644 --- a/lib/XmlRpcServer.php +++ b/lib/XmlRpcServer.php @@ -1,5 +1,5 @@ * * LICENCE @@ -283,17 +283,15 @@ function getPageHTML($params) if (!$revision) return NoSuchPage(); - include_once('lib/PageType.php'); - $content = array(PageType($revision)); - - // Get rid of outer
- while (count($content) == 1 && isa($content[0], 'XmlContent')) { - if (isa($content[0], 'XmlElement') && $content[0]->getTag() != 'div') - break; - $content = $content[0]->getContent(); + $content = $revision->getTransformedContent(); + $html = $content->asXML(); + // HACK: Get rid of outer
+ if (preg_match('/^\s*
/', $html, $m1) + && preg_match('@
\s*$@', $html, $m2)) { + $html = substr($html, strlen($m1[0]), -strlen($m2[0])); } - return new xmlrpcresp(long_string(AsXML($content))); + return new xmlrpcresp(long_string($html)); } /** @@ -429,32 +427,19 @@ function listLinks($params) */ $current = $page->getCurrentRevision(); - list ($pages, $urls) = ExtractLinks($current->getContent()); - - $type = new xmlrpcval("internal"); - foreach ($pages as $wikiword) { - $name = short_string($wikiword); - $args = array(); - if (! $dbh->isWikiPage($wikiword)) - $args['action'] = 'edit'; - // FIXME: see comments in above commented sections - // about possible screwed up absolute URLS... - $href = short_string(WikiURL($wikiword, $args, 'abspath')); - $linkstruct[] = new xmlrpcval(array('name'=> $name, - 'type'=> $type, - 'href' => $href), + $content = $current->getTransformedContent(); + $links = $content->getLinkInfo(); + + foreach ($links as $link) { + // We used to give an href for unknown pages that + // included action=edit. I think that's probably the + // wrong thing to do. + $linkstruct[] = new xmlrpcval(array('name'=> short_string($link->page), + 'type'=> new xmlrpcval($link->type), + 'href' => short_string($link->href)), "struct"); } - $type = new xmlrpcval("external"); - foreach ($urls as $url) { - $href = short_string($url); - $linkstruct[] = new xmlrpcval(array('name'=> $href, - 'type'=> $type, - 'href' => $href), - "struct"); - } - return new xmlrpcresp(new xmlrpcval ($linkstruct, "array")); } diff --git a/lib/display.php b/lib/display.php index c37eee11c..5775bdae0 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,9 +1,8 @@ appendValidators(array('actionpagerev' => $actionrev->getVersion(), '%mtime' => $actionrev->get('mtime'))); - require_once('lib/PageType.php'); - $transformedContent = PageType($actionrev); + $transformedContent = $actionrev->getTransformedContent(); $template = Template('browse', array('CONTENT' => $transformedContent)); header("Content-Type: text/html; charset=" . CHARSET); - $request->checkValidators(); - - // $template = Template('browse', array('CONTENT' => TransformText($actionrev))); - GeneratePage($template, $pagetitle, $revision); + $request->checkValidators(); flush(); } @@ -146,28 +141,26 @@ function displayPage(&$request, $tmpl = 'browse') { $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime'))); - require_once('lib/PageType.php'); if ($frame = $request->getArg('frame')) { if (in_array($frame, array('body','browse','editpage'))) - $template = Template($frame, array('CONTENT' => PageType($revision))); + $template = Template($frame, array('CONTENT' => $revision->getTransformedContent())); elseif ($frame == 'top') $template = Template($frame, array('framesrc' => $request->getArg('framesrc'))); else $template = Template($frame); } else { - $transformedContent = PageType($revision); + $transformedContent = $revision->getTransformedContent(); $template = Template('browse', array('CONTENT' => $transformedContent)); } header("Content-Type: text/html; charset=" . CHARSET); // FIXME: this gets done twice? - $request->checkValidators(); GeneratePage($template, $pagetitle, $revision, array('ROBOTS_META' => 'index,follow', 'PAGE_DESCRIPTION' => GleanDescription($revision), 'REDIRECT_FROM' => $redirect_from)); + $request->checkValidators(); flush(); - $page->increaseHitCount(); } diff --git a/lib/loadsave.php b/lib/loadsave.php index 649050685..2a9005602 100644 --- a/lib/loadsave.php +++ b/lib/loadsave.php @@ -1,5 +1,5 @@ getCurrentRevision(); - require_once('lib/PageType.php'); - $transformedContent = PageType($revision); + $transformedContent = $revision->getTransformedContent(); $template = new Template('browse', $request, array('revision' => $revision, @@ -334,8 +333,7 @@ function MakeWikiZipHtml (&$request) $filename = FilenameForPage($pagename) . $Theme->HTML_DUMP_SUFFIX; $revision = $page->getCurrentRevision(); - require_once('lib/PageType.php'); - $transformedContent = PageType($revision); + $transformedContent = $revision->getTransformedContent(); $template = new Template('browse', $request, array('revision' => $revision, @@ -456,9 +454,7 @@ function SavePage (&$request, $pageinfo, $source, $filename) } if (! $skip) { - $new = $page->createRevision(WIKIDB_FORCE_CREATE, $content, - $versiondata, - ExtractWikiPageLinks($content)); + $new = $page->save($content, WIKIDB_FORCE_CREATE, $versiondata); $dbi->touch(); $mesg->pushContent(' ', fmt("- saved to database as version %d", $new->getVersion())); @@ -832,6 +828,9 @@ function LoadPostFile (&$request) /** $Log: not supported by cvs2svn $ + Revision 1.76 2003/02/16 19:47:17 dairiki + Update WikiDB timestamp when editing or deleting pages. + Revision 1.75 2003/02/15 03:04:30 dairiki Fix for WikiUser constructor API change. diff --git a/lib/plugin/IncludePage.php b/lib/plugin/IncludePage.php index 3deb8c3c3..1105784d3 100644 --- a/lib/plugin/IncludePage.php +++ b/lib/plugin/IncludePage.php @@ -1,5 +1,5 @@ get('markup')); + $content = TransformText(implode("\n", $c), $r->get('markup'), $page); array_pop($included_pages); @@ -176,6 +176,11 @@ extends WikiPlugin // $Log: not supported by cvs2svn $ +// Revision 1.20 2003/01/18 21:41:02 carstenklapp +// Code cleanup: +// Reformatting & tabs to spaces; +// Added copyleft, getVersion, getDescription, rcs_id. +// // For emacs users // Local Variables: diff --git a/lib/plugin/OldStyleTable.php b/lib/plugin/OldStyleTable.php index c228a236e..c71a3fbba 100644 --- a/lib/plugin/OldStyleTable.php +++ b/lib/plugin/OldStyleTable.php @@ -1,5 +1,5 @@ 1, 'cellspacing' => 1, @@ -114,6 +115,11 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.5 2003/01/18 21:48:59 carstenklapp +// Code cleanup: +// Reformatting & tabs to spaces; +// Added copyleft, getVersion, getDescription, rcs_id. +// // (c-file-style: "gnu") // Local Variables: diff --git a/lib/plugin/RecentChanges.php b/lib/plugin/RecentChanges.php index 41e00343e..2fa4e8735 100644 --- a/lib/plugin/RecentChanges.php +++ b/lib/plugin/RecentChanges.php @@ -1,5 +1,5 @@ title())); if (($desc = $this->description())) $html->pushContent(HTML::p(false, $desc)); @@ -606,7 +608,7 @@ extends WikiPlugin function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.72 $"); + "\$Revision: 1.73 $"); } function managesValidators() { @@ -769,6 +771,10 @@ class DayButtonBar extends HtmlElement { } // $Log: not supported by cvs2svn $ +// Revision 1.72 2003/02/17 02:19:01 dairiki +// Fix so that PageHistory will work when the current revision +// of a page has been "deleted". +// // Revision 1.71 2003/02/16 20:04:48 dairiki // Refactor the HTTP validator generation/checking code. // diff --git a/lib/plugin/SiteMap.php b/lib/plugin/SiteMap.php index 04aaf3fe7..e3fc56356 100644 --- a/lib/plugin/SiteMap.php +++ b/lib/plugin/SiteMap.php @@ -1,5 +1,5 @@ getArgs($argstr, $request, false); extract($args); if (!$page) @@ -177,11 +179,16 @@ extends WikiPlugin while (list($key, $link) = each($pagearr)) { $out .= $key . "\n"; } - return TransformText($out); + return TransformText($out, 1, $page /*dunno if this last arg is right...*/); } }; // $Log: not supported by cvs2svn $ +// Revision 1.6 2003/01/18 22:08:01 carstenklapp +// Code cleanup: +// Reformatting & tabs to spaces; +// Added copyleft, getVersion, getDescription, rcs_id. +// // For emacs users // Local Variables: diff --git a/lib/plugin/UnfoldSubpages.php b/lib/plugin/UnfoldSubpages.php index 3ade763d7..11e31c92d 100644 --- a/lib/plugin/UnfoldSubpages.php +++ b/lib/plugin/UnfoldSubpages.php @@ -1,5 +1,5 @@ getArg('pagename'); $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*'); if (! $subpages) { @@ -161,10 +163,10 @@ extends WikiPlugin // Use _("%s: %s") instead of .": ". for French punctuation $ct = TransformText(sprintf(_("%s: %s"), "[$pname|$page]", implode("\n", $c)), - $r->get('markup')); + $r->get('markup'), $page); } else { - $ct = TransformText(implode("\n", $c), $r->get('markup')); + $ct = TransformText(implode("\n", $c), $r->get('markup'), $page); } array_pop($included_pages); if (! $smalltitle) { @@ -183,6 +185,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.6 2003/02/11 09:34:34 rurban +// fix by Steven D. Brewer to respect the $pages argument +// // Revision 1.5 2003/01/18 22:11:44 carstenklapp // Code cleanup: // Reformatting & tabs to spaces; -- 2.45.0