From: Dan F. <dfr...@cs...> - 2004-07-14 20:27:53
|
I am looking at how the InterWikiMap page displays, because this is an example of a page whose content and rendering are noticeably different from each other. I am wondering whether I should declare a new page type PageType_WikilensList analogous to PageType_InterWikiMap, and use that to scrape what I want out of the page source (list items which are term-definition style, list owner, list type for example "favorites") and display it however I want. ** Question: Is that a good idea? Anyway, while I was looking at it, I got very confused about how it's displayed, and that's because if you save version N of InterWikiMap, it displays version N-1. This is a bug, no? I have caching NONE, and furthermore I instrumented WikiDB_Page::save() to print "wikitext" (the actual text of the page) and "type" (the PageType_InterWikiMap-interpreted version, which turns out to be N-1). I include it below my sig, and you can see that the wikitext doesn't match the type. Note: I'm running phpwiki 1.3.9+ with a 'SQL' backend on Linux with Apache. ** Question: Should I be filing these as bugs @ SourceForge, or is it sufficient to email phpwiki-talk? I am currently trying to figure out where the interpretation happens. For some reason, I find InlineParser, BlockParser, etc. incredibly time consuming to figure out. Dan wikitext: The InterWiki map used on this wiki is listed below. The map is taken from the text in the verbatim block below. (But this only works if this page is locked.) <verbatim> WikiPedia http://www.wikipedia.com/wiki </verbatim> type: pagetype_interwikimap Object ( [_map] => Array ( [WikiPedia] => http://www.wikipedia.com/wiki [foo] => bar50 [InterWLink] => http:/ [Upload] => http://gibson/../uploads/ ) [_regexp] => (?:WikiPedia|foo|InterWLink|Upload) ) |
From: Dan F. <dfr...@cs...> - 2004-07-15 21:22:22
|
Dan Frankowski wrote: > Anyway, while I was looking at it, I got very confused about how it's > displayed, and that's because if you save version N of InterWikiMap, > it displays version N-1. This is a bug, no? I have caching NONE, and > furthermore I instrumented WikiDB_Page::save() to print "wikitext" > (the actual text of the page) and "type" (the > PageType_InterWikiMap-interpreted version, which turns out to be N-1). > I include it below my sig, and you can see that the wikitext doesn't > match the type. > > Note: I'm running phpwiki 1.3.9+ with a 'SQL' backend on Linux with > Apache. > > ** Question: Should I be filing these as bugs @ SourceForge, or is it > sufficient to email phpwiki-talk? > > I am currently trying to figure out where the interpretation happens. > For some reason, I find InlineParser, BlockParser, etc. incredibly > time consuming to figure out. > > Dan I attach a patch that fixes this bug. The basic idea is to pass the pagetext itself for getting the map while rendering, instead of having it go to the database (which has not yet been updated). If no pagetext is passed, it falls back to the DB page. PageType.php has the only substantial changes. The other files just change the call not to pass the request object. I changed function PageType_interwikimap($request = false) to function PageType_interwikimap($pagetext = false) since the request object wasn't being used (or was being pulled up through "global $request;" instead) and I needed the $pagetext parameter. Please advise on what to do with the patch. Dan Files affected: lib/CachedMarkup.php lib/InlineParser.php lib/PageType.php lib/stdlib.php lib/plugin/ExternalSearch.php ========================== diff -b -u -r1.4 CachedMarkup.php --- lib/CachedMarkup.php 16 Jun 2004 19:26:06 -0000 1.4 +++ lib/CachedMarkup.php 15 Jul 2004 18:57:51 -0000 @@ -412,7 +412,7 @@ function expand($basepage, &$markup) { //include_once('lib/interwiki.php'); - $intermap = PageType_interwikimap::GetMap($GLOBALS['request']); + $intermap = PageType_interwikimap::GetMap(); $label = isset($this->_label) ? $this->_label : false; return $intermap->link($this->_link, $label); } ========================== diff -b -u -r1.5 InlineParser.php --- lib/InlineParser.php 3 Jun 2004 18:23:48 -0000 1.5 +++ lib/InlineParser.php 15 Jul 2004 18:58:17 -0000 @@ -286,7 +286,7 @@ global $request, $AllowedProtocols, $InlineImages; //include_once("lib/interwiki.php"); - $intermap = PageType_interwikimap::GetMap($request); + $intermap = PageType_interwikimap::GetMap(); // $bracketlink will start and end with brackets; in between will // be either a page name, a URL or both separated by a pipe. @@ -423,13 +423,13 @@ { function getMatchRegexp () { global $request; - $map = PageType_interwikimap::GetMap($request); + $map = PageType_interwikimap::GetMap(); return "(?<! [[:alnum:]])" . $map->getRegexp(). ": \S+ (?<![ ,.?;! \] \) \" \' ])"; } function markup ($match) { global $request; - $map = PageType_interwikimap::GetMap($request); + $map = PageType_interwikimap::GetMap(); return new Cached_InterwikiLink(UnWikiEscape($match)); } } ========================== diff -b -u -r1.2 PageType.php --- lib/PageType.php 7 Jul 2004 19:07:20 -0000 1.2 +++ lib/PageType.php 15 Jul 2004 19:09:28 -0000 @@ -128,10 +128,21 @@ class PageType_interwikimap extends PageType { - function PageType_interwikimap() { + function PageType_interwikimap($pagetext = false) { global $request; $dbi = $request->getDbh(); - $intermap = $this->_getMapFromWikiPage($dbi->getPage(_("InterWikiMap"))); + + if (!$pagetext) { + $page = $dbi->getPage(_("InterWikiMap")); + if ($page->get('locked')) { + $current = $page->getCurrentRevision(); + $pagetext = $current->getPackedContent(); + } + else { + trigger_error(_("WARNING: InterWikiMap page is unlocked, so not using those links.")); + } + } + $intermap = $this->_getMapFromWikiPageText($pagetext); if (!$intermap && defined('INTERWIKI_MAP_FILE')) $intermap = $this->_getMapFromFile(INTERWIKI_MAP_FILE); @@ -139,13 +150,8 @@ $this->_regexp = $this->_getRegexp(); } - function GetMap ($request = false) { - if (empty($this->_map)) { - $map = new PageType_interwikimap(); - return $map; - } else { - return $this; - } + function GetMap ($pagetext = false) { + return new PageType_interwikimap($pagetext); } function getRegexp() { @@ -153,7 +159,6 @@ } function link ($link, $linktext = false) { - list ($moniker, $page) = split (":", $link, 2); if (!isset($this->_map[$moniker])) { @@ -201,14 +206,9 @@ return $map; } - function _getMapFromWikiPage ($page) { - if (! $page->get('locked')) - return false; - - $current = $page->getCurrentRevision(); - + function _getMapFromWikiPageText ($pagetext) { if (preg_match('|^<verbatim>\n(.*)^</verbatim>|ms', - $current->getPackedContent(), $m)) { + $pagetext, $m)) { return $m[1]; } return false; @@ -287,7 +287,7 @@ function format($text) { return HTML::div(array('class' => 'wikitext'), $this->_transform($this->_getHeader($text)), - $this->_formatMap(), + $this->_formatMap($text), $this->_transform($this->_getFooter($text))); } @@ -299,13 +299,13 @@ return preg_replace('@.*?(</verbatim>|\Z)@s', '', $text, 1); } - function _getMap() { - $map = PageType_interwikimap::getMap(); + function _getMap($pagetext) { + $map = PageType_interwikimap::getMap($pagetext); return $map->_map; } - function _formatMap() { - $map = $this->_getMap(); + function _formatMap($pagetext) { + $map = $this->_getMap($pagetext); if (!$map) return HTML::p("<No map found>"); // Shouldn't happen. diff -b -u -r1.1.1.2 stdlib.php --- lib/stdlib.php 14 Apr 2004 21:22:35 -0000 1.1.1.2 +++ lib/stdlib.php 15 Jul 2004 18:58:48 -0000 @@ -559,7 +559,7 @@ // change ! escapes to ~'s. global $AllowedProtocols, $WikiNameRegexp, $request; //include_once('lib/interwiki.php'); - $map = PageType_interwikimap::GetMap($request); + $map = PageType_interwikimap::GetMap(); $bang_esc[] = "(?:$AllowedProtocols):[^\s<>\[\]\"'()]*[^\s<>\[\]\"'(),.?]"; $bang_esc[] = $map->getRegexp() . ":[^\\s.,;?()]+"; // FIXME: is this really needed? $bang_esc[] = $WikiNameRegexp; @@ -1375,6 +1375,26 @@ } return $a; } ========================== diff -b -u -r1.1.1.2 ExternalSearch.php --- lib/plugin/ExternalSearch.php 14 Apr 2004 21:22:39 -0000 1.1.1.2 +++ lib/plugin/ExternalSearch.php 15 Jul 2004 18:59:07 -0000 @@ -42,7 +42,7 @@ } function _getInterWikiUrl(&$request) { - $intermap = PageType_interwikimap::GetMap($request); + $intermap = PageType_interwikimap::GetMap(); $map = $intermap->_map; if (in_array($this->_url, array_keys($map))) { |
From: Frederik De B. <fre...@pa...> - 2004-07-16 07:21:04
Attachments:
smime.p7s
|
Hi, I've been following up on the whole PhpWikiUserNew story, and reading all the documentation over and over, but still haven't been able to figure out how to user personal home pages to do security. My setup: only a limited set of users should be able to edit pages on my wiki. Ideally, user management should be as simple as possible. How do I create those homepages? Do I do that as an admin? Then, later on, how do I add a password to these homepages? (the sparse documentation talks about storing a password in the page's metadata, but doesn't explain how) Is creating a homepage enough for a user to gain access to the system, or do I need to do something else? Kind regards, Frederik |