From f59804a2b841b45750d616c62d0db58e74072713 Mon Sep 17 00:00:00 2001 From: rurban Date: Thu, 8 Jul 2004 20:30:07 +0000 Subject: [PATCH] plugin->run consistency: request as reference, added basepage. encountered strange bug in AllPages (and the test) which destroys ->_dbi git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3885 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/WikiPlugin.php | 16 ++++++---- lib/plugin/AllPages.php | 55 +++++++++++++++++++------------- lib/plugin/CategoryPage.php | 6 ++-- lib/plugin/CreatePage.php | 9 ++++-- lib/plugin/CreateToc.php | 9 ++++-- lib/plugin/FoafViewer.php | 15 +++++++-- lib/plugin/GoTo.php | 9 ++++-- lib/plugin/IncludePage.php | 9 ++++-- lib/plugin/ListPages.php | 10 +++--- lib/plugin/PhotoAlbum.php | 11 +++++-- lib/plugin/PreferenceApp.php | 6 ++-- lib/plugin/RateIt.php | 11 ++++--- lib/plugin/RssFeed.php | 9 ++++-- lib/plugin/SyntaxHighlighter.php | 9 ++++-- lib/plugin/TranslateText.php | 9 ++++-- lib/plugin/UserRatings.php | 6 ++-- lib/plugin/_WikiTranslation.php | 9 ++++-- lib/wikilens/PageListColumns.php | 10 +++++- 18 files changed, 142 insertions(+), 76 deletions(-) diff --git a/lib/WikiPlugin.php b/lib/WikiPlugin.php index ab87c54f3..e66d123c0 100644 --- a/lib/WikiPlugin.php +++ b/lib/WikiPlugin.php @@ -1,5 +1,5 @@ getDefaultArguments(); + } //Fixme: on POST argstr is empty list ($argstr_args, $argstr_defaults) = $this->parseArgStr($argstr); $args = array(); @@ -106,9 +107,11 @@ class WikiPlugin $args[$arg] = (string) $argstr_defaults[$arg]; else $args[$arg] = $default_val; - - if ($request) + + // only expand given args + if ($request and !empty($argstr)) { $args[$arg] = $this->expandArg($args[$arg], $request); + } unset($argstr_args[$arg]); unset($argstr_defaults[$arg]); @@ -151,7 +154,8 @@ class WikiPlugin $args = array(); $defaults = array(); - + if (empty($argstr)) + return array($args,$defaults); while (preg_match("/^$opt_ws $argspec_p $opt_ws/x", $argstr, $m)) { @ list(,$arg,$op,$qq_val,$q_val,$gt_val,$word_val) = $m; $argstr = substr($argstr, strlen($m[0])); diff --git a/lib/plugin/AllPages.php b/lib/plugin/AllPages.php index cab3be7a4..acf4ef22d 100644 --- a/lib/plugin/AllPages.php +++ b/lib/plugin/AllPages.php @@ -1,5 +1,5 @@ false )); } + // info arg allows multiple columns // info=mtime,hits,summary,version,author,locked,minor,markup or all // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges // sortby: [+|-] pagename|mtime|hits + // 2004-07-08 22:05:35 rurban: turned off &$request to prevent from strange bug below function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); - extract($args); + // very strange php reference bug: dbi gets destroyed at array_merge with defaults + if (!is_object($dbi)) $dbi = $request->getDbh(); + if (!is_object($request->_dbi)) { + trigger_error("strange php reference bug destroyed request->_dbi", E_USER_WARNING); + return HTML(); + } + //extract($args); // Todo: extend given _GET args if ($sorted = $request->getArg('sortby')) - $sortby = $sorted; - elseif ($sortby) - $request->setArg('sortby',$sortby); + $args['sortby'] = $sorted; + elseif (!empty($args['sortby'])) + $request->setArg('sortby',$args['sortby']); - if ($debug) + if ($args['debug']) $timer = new DebugTimer; if ( !empty($args['owner']) ) - $pages = PageList::allPagesByOwner($args['owner'],$include_empty,$args['sortby'],$args['limit']); + $pages = PageList::allPagesByOwner($args['owner'],$args['include_empty'],$args['sortby'],$args['limit']); elseif ( !empty($args['author']) ) - $pages = PageList::allPagesByAuthor($args['author'],$include_empty,$args['sortby'],$args['limit']); + $pages = PageList::allPagesByAuthor($args['author'],$args['include_empty'],$args['sortby'],$args['limit']); elseif ( !empty($args['creator']) ) { - $pages = PageList::allPagesByCreator($args['creator'],$include_empty,$args['sortby'],$args['limit']); + $pages = PageList::allPagesByCreator($args['creator'],$args['include_empty'],$args['sortby'],$args['limit']); } else { - if (! $request->getArg('count')) $args['count'] = $dbi->numPages(false,$exclude); + if (! $request->getArg('count')) $args['count'] = $dbi->numPages(false,$args['exclude']); else $args['count'] = $request->getArg('count'); - $pages = false; + $args['pages'] = false; } - if (empty($args['count']) and is_array($pages)) - $args['count'] = count($pages); - $pagelist = new PageList($info, $exclude, $args); + if (empty($args['count']) and is_array($args['pages'])) + $args['count'] = count($args['pages']); + $pagelist = new PageList($args['info'], $args['exclude'], $args); //if (!$sortby) $sorted='pagename'; - if (!$noheader) { - if (!is_array($pages)) + if (!$args['noheader']) { + if (!is_array($args['pages'])) $pagelist->setCaption(_("All pages in this wiki (%d total):")); else $pagelist->setCaption(_("List of pages (%d total):")); } // deleted pages show up as version 0. - if ($include_empty) + if ($args['include_empty']) $pagelist->_addColumn('version'); - if (is_array($pages)) - $pagelist->addPageList($pages); + if (is_array($args['pages'])) + $pagelist->addPageList($args['pages']); else - $pagelist->addPages( $dbi->getAllPages($include_empty, $sortby, $limit) ); - if ($debug) { + $pagelist->addPages( $dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit']) ); + if ($args['debug']) { return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats()))); } else { @@ -115,6 +123,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.27 2004/07/08 17:31:43 rurban +// improve numPages for file (fixing AllPagesTest) +// // Revision 1.26 2004/06/21 16:22:32 rurban // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps, // fixed dumping buttons locally (images/buttons/), diff --git a/lib/plugin/CategoryPage.php b/lib/plugin/CategoryPage.php index 90365e52d..a8bfe7a8f 100644 --- a/lib/plugin/CategoryPage.php +++ b/lib/plugin/CategoryPage.php @@ -1,5 +1,5 @@ false); } - function run($dbi, $argstr, $request) { + function run($dbi, $argstr, &$request) { $args = $this->getArgs($argstr, $request); if (empty($args['singular'])) { diff --git a/lib/plugin/CreatePage.php b/lib/plugin/CreatePage.php index a60aafa2f..50d9f593c 100644 --- a/lib/plugin/CreatePage.php +++ b/lib/plugin/CreatePage.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); if (!$s) return ''; @@ -101,6 +101,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.4 2004/04/21 16:14:50 zorloc +// Prevent spaces at the start and end of a created page name -- submitted by Dan Frankowski (dfrankow). +// // Revision 1.3 2004/03/24 19:41:04 rurban // fixed the name // diff --git a/lib/plugin/CreateToc.php b/lib/plugin/CreateToc.php index 79c7227ca..6b0091cff 100644 --- a/lib/plugin/CreateToc.php +++ b/lib/plugin/CreateToc.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); if ($pagename) { // Expand relative page names. @@ -276,6 +276,9 @@ function toggletoc(a) { }; // $Log: not supported by cvs2svn $ +// Revision 1.24 2004/06/28 13:27:03 rurban +// CreateToc disabled for old markup and Apache2 only +// // Revision 1.23 2004/06/28 13:13:58 rurban // CreateToc disabled for old markup // diff --git a/lib/plugin/FoafViewer.php b/lib/plugin/FoafViewer.php index b2898237a..6002cc549 100644 --- a/lib/plugin/FoafViewer.php +++ b/lib/plugin/FoafViewer.php @@ -1,5 +1,5 @@ 32); } - function run($dbi, $argstr, $request, $basepage) { + function run($dbi, $argstr, &$request, $basepage) { $request->setArg('action',false); $args = $this->getArgs($argstr, $request); extract($args); @@ -66,6 +66,11 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.3 2004/04/18 01:11:52 rurban +// more numeric pagename fixes. +// fixed action=upload with merge conflict warnings. +// charset changed from constant to global (dynamic utf-8 switching) +// // Revision 1.2 2004/04/12 16:21:01 rurban // fix lib/plugin/RssFeed.php:81: Notice[8]: Undefined variable: th // diff --git a/lib/plugin/IncludePage.php b/lib/plugin/IncludePage.php index 6608c5b4f..594aa71be 100644 --- a/lib/plugin/IncludePage.php +++ b/lib/plugin/IncludePage.php @@ -1,5 +1,5 @@ name); } - function run($dbi, $argstr, $request, $basepage) { + function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if ($page) { // Expand relative page names. @@ -191,6 +191,9 @@ extends WikiPlugin // $Log: not supported by cvs2svn $ +// Revision 1.24 2004/02/17 12:11:36 rurban +// added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...) +// // Revision 1.23 2003/03/25 21:01:52 dairiki // Remove debugging cruft. // diff --git a/lib/plugin/ListPages.php b/lib/plugin/ListPages.php index fae7d2743..3fb1a95f3 100755 --- a/lib/plugin/ListPages.php +++ b/lib/plugin/ListPages.php @@ -1,5 +1,5 @@ getArgs($argstr, $request); extract($args); @@ -124,6 +123,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.3 2004/06/28 18:58:18 rurban +// fixed another pass-by-reference +// // Revision 1.2 2004/06/18 14:42:17 rurban // added wikilens libs (not yet merged good enough, some work for DanFr) // diff --git a/lib/plugin/PhotoAlbum.php b/lib/plugin/PhotoAlbum.php index 1a10e1bc7..888458eaa 100644 --- a/lib/plugin/PhotoAlbum.php +++ b/lib/plugin/PhotoAlbum.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); $attributes = $attrib ? explode(",", $attrib) : array(); @@ -502,6 +502,11 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.8 2004/06/01 15:28:01 rurban +// AdminUser only ADMIN_USER not member of Administrators +// some RateIt improvements by dfrankow +// edit_toolbar buttons +// // Revision 1.7 2004/05/03 20:44:55 rurban // fixed gettext strings // new SqlResult plugin diff --git a/lib/plugin/PreferenceApp.php b/lib/plugin/PreferenceApp.php index 525961338..98833a926 100644 --- a/lib/plugin/PreferenceApp.php +++ b/lib/plugin/PreferenceApp.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); if($pageTextLabel == null && $category != null && $group == null){ diff --git a/lib/plugin/RateIt.php b/lib/plugin/RateIt.php index 22dd67491..0c3fe2e5e 100644 --- a/lib/plugin/RateIt.php +++ b/lib/plugin/RateIt.php @@ -1,5 +1,5 @@ _request = & $request; - $this->_dbi = & $dbi; + //$this->_request = & $request; + //$this->_dbi = & $dbi; $user = & $request->getUser(); + //FIXME: fails on test with DumpHtml:RateIt if (!is_object($user)) return HTML(); $this->userid = $user->UserName(); $args = $this->getArgs($argstr, $request); diff --git a/lib/plugin/RssFeed.php b/lib/plugin/RssFeed.php index ff5ecb1de..9b27e3dd1 100644 --- a/lib/plugin/RssFeed.php +++ b/lib/plugin/RssFeed.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); $rss_parser = new RSSParser(); @@ -116,6 +116,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.7 2004/06/08 21:03:20 rurban +// updated RssParser for XmlParser quirks (store parser object params in globals) +// // Revision 1.6 2004/05/24 17:36:06 rurban // new interface // diff --git a/lib/plugin/SyntaxHighlighter.php b/lib/plugin/SyntaxHighlighter.php index 5b05f087c..b1c21c74b 100644 --- a/lib/plugin/SyntaxHighlighter.php +++ b/lib/plugin/SyntaxHighlighter.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); $source =& $this->source; if (empty($syntax)) return $this->error(_("Syntax language not specified.")); @@ -183,6 +183,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.6 2004/06/29 18:47:40 rurban +// use predefined constants, and added sf.net defaults +// // Revision 1.5 2004/06/14 11:31:39 rurban // renamed global $Theme to $WikiTheme (gforge nameclash) // inherit PageList default options from PageList diff --git a/lib/plugin/TranslateText.php b/lib/plugin/TranslateText.php index 01bd50594..6f09e59d7 100644 --- a/lib/plugin/TranslateText.php +++ b/lib/plugin/TranslateText.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); if (!$lang) return $this->error( @@ -137,6 +137,9 @@ extends WikiPlugin__WikiTranslation }; // $Log: not supported by cvs2svn $ +// Revision 1.4 2004/05/18 13:58:39 rurban +// verbatim needs a linebreak +// // Revision 1.3 2004/03/17 15:38:03 rurban // more translations // diff --git a/lib/plugin/UserRatings.php b/lib/plugin/UserRatings.php index 2f1015b26..45cf736b6 100644 --- a/lib/plugin/UserRatings.php +++ b/lib/plugin/UserRatings.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); // XXX: fix to reflect multi-user ratings? diff --git a/lib/plugin/_WikiTranslation.php b/lib/plugin/_WikiTranslation.php index fcee50080..d1b622f76 100644 --- a/lib/plugin/_WikiTranslation.php +++ b/lib/plugin/_WikiTranslation.php @@ -1,5 +1,5 @@ args = $this->getArgs($argstr, $request); extract($this->args); $this->request = &$request; @@ -401,6 +401,9 @@ class _PageList_Column_customlang extends _PageList_Column { } // $Log: not supported by cvs2svn $ +// Revision 1.13 2004/06/18 14:38:22 rurban +// adopt new PageList style +// // Revision 1.12 2004/06/17 10:39:18 rurban // fix reverse translation of possible actionpage // diff --git a/lib/wikilens/PageListColumns.php b/lib/wikilens/PageListColumns.php index 1d7dcc90d..fea686ba4 100644 --- a/lib/wikilens/PageListColumns.php +++ b/lib/wikilens/PageListColumns.php @@ -1,5 +1,5 @@ getUser(); + if (is_string($active_user)) { + //FIXME: try to find the bug at test.php which sets request->_user and ->_group + trigger_error("request->getUser => string: $active_user", E_USER_WARNING); + $active_user = new MockUser($active_user,true); + } // No, I don't know exactly why, but this needs to be a reference for // the memoization in pearson_similarity and mean_rating to work $this->_active_ratings_user =& new RatingsUser($active_user->getId()); @@ -372,6 +377,9 @@ $WikiTheme->addPageListColumn )); // $Log: not supported by cvs2svn $ +// Revision 1.5 2004/07/07 15:01:44 dfrankow +// Allow ratingvalue, ratingwidget, prediction, numbacklinks columns to be sortable +// // Revision 1.4 2004/06/30 20:12:09 dfrankow // + Change numbacklinks function to use existing core functions. // It's slower, but it'll work. -- 2.45.0