From 25b056c9a3311713b36781caec1a2ecf7df55427 Mon Sep 17 00:00:00 2001 From: rurban Date: Mon, 19 Aug 2002 11:32:30 +0000 Subject: [PATCH] fixed TitleSearch and other plugin-form problems with USE_PATH_INFO = false renamed the constant HomePage to HOME_PAGE fix it in your templates with: cd themes find . -name \*.tmpl -exec \ perl -pi~ -e's/([^ ])HomePage/$1HOME_PAGE/g' \{\} \; changed version string to 1.3.3 removed -jeffs-hacks, since it's officially released. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@2259 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- getimg.php | 4 +- index.php | 4 +- lib/HtmlElement.php | 5 +- lib/WikiPlugin.php | 13 +- lib/config.php | 6 +- lib/loadsave.php | 12 +- lib/main.php | 6 +- lib/plugin/VisualWiki.php | 17 +- lib/plugin/WikiForm.php | 11 +- lib/transform.php | 257 ++++++++++----------- themes/Portland/templates/body.tmpl | 6 +- themes/default/templates/README | 22 +- themes/default/templates/body.tmpl | 16 +- themes/default/templates/navbar.tmpl | 5 +- themes/default/templates/top-htmldump.tmpl | 8 +- themes/default/templates/top.tmpl | 6 +- 16 files changed, 201 insertions(+), 197 deletions(-) diff --git a/getimg.php b/getimg.php index e87666b68..76b543c46 100644 --- a/getimg.php +++ b/getimg.php @@ -78,9 +78,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ///////////////////////////////////////////////////////////////////// // Part Null: Don't touch this! -define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks'); +define ('PHPWIKI_VERSION', '1.3.3'); require "lib/prepend.php"; -rcs_id('$Id: getimg.php,v 1.1 2002-08-17 15:52:51 rurban Exp $'); +rcs_id('$Id: getimg.php,v 1.2 2002-08-19 11:32:29 rurban Exp $'); ///////////////////////////////////////////////////////////////////// // diff --git a/index.php b/index.php index 7da0c0493..5ffb761ba 100644 --- a/index.php +++ b/index.php @@ -78,9 +78,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ///////////////////////////////////////////////////////////////////// // Part Null: Don't touch this! -define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks'); +define ('PHPWIKI_VERSION', '1.3.3'); require "lib/prepend.php"; -rcs_id('$Id: index.php,v 1.85 2002-08-17 15:52:51 rurban Exp $'); +rcs_id('$Id: index.php,v 1.86 2002-08-19 11:32:29 rurban Exp $'); ///////////////////////////////////////////////////////////////////// // diff --git a/lib/HtmlElement.php b/lib/HtmlElement.php index 210155dfc..f001858b9 100644 --- a/lib/HtmlElement.php +++ b/lib/HtmlElement.php @@ -1,4 +1,4 @@ - $val) { + if (in_array($key,$exclude)) continue; $name = $pfx ? $pfx . "[$key]" : $key; if (is_array($val)) $inputs->pushContent(HiddenInputs($val, $name)); diff --git a/lib/WikiPlugin.php b/lib/WikiPlugin.php index bee74f11b..8dff8f4c0 100644 --- a/lib/WikiPlugin.php +++ b/lib/WikiPlugin.php @@ -1,5 +1,5 @@ WikiURL($args['targetpage']), - 'method' => $args['method'], - 'class' => $args['class'], - 'accept-charset' => CHARSET)); + 'method' => $args['method'], + 'class' => $args['class'], + 'accept-charset' => CHARSET)); + if (! USE_PATH_INFO ) { + $pagename = $request->get('pagename'); + $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pagename', + 'value' => $args['targetpage']))); + } $contents = HTML::div(); $contents->setAttr('class', $args['class']); diff --git a/lib/config.php b/lib/config.php index 11577e503..4146cd313 100644 --- a/lib/config.php +++ b/lib/config.php @@ -1,5 +1,5 @@ array(), 'versiondata' => array()); @@ -592,9 +592,9 @@ function LoadDir (&$request, $dirname, $files = false, $exclude = false) { // Defer HomePage loading until the end. If anything goes wrong // the pages can still be loaded again. $files = $fileset->getFiles(); - if (in_array(HomePage, $files)) { - $files = array_diff($files, array(HomePage)); - $files[] = HomePage; + if (in_array(HOME_PAGE, $files)) { + $files = array_diff($files, array(HOME_PAGE)); + $files[] = HOME_PAGE; } foreach ($files as $file) LoadFile($request, "$dirname/$file"); diff --git a/lib/main.php b/lib/main.php index 82458cd27..d357da2b2 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ getArg('action') != 'browse') return; - if ($this->getArg('pagename') != HomePage) + if ($this->getArg('pagename') != HOME_PAGE) return; $page = $this->getPage(); @@ -449,7 +449,7 @@ class WikiRequest extends Request { return urldecode($query_string); } - return HomePage; + return HOME_PAGE; } function _deduceAction () { diff --git a/lib/plugin/VisualWiki.php b/lib/plugin/VisualWiki.php index 7855b20d8..cce0ba0eb 100644 --- a/lib/plugin/VisualWiki.php +++ b/lib/plugin/VisualWiki.php @@ -1,4 +1,4 @@ - 'png', 'width' => 5, 'height' => 7, - 'colorby' => 'age', + 'colorby' => 'age', // sort by 'age' or 'revtime' 'fillnodes' => 'off', 'label' => 'name', 'shape' => 'ellipse', @@ -126,6 +123,7 @@ class WikiPlugin_VisualWiki extends WikiPluginCached { if (($recent_nb<0) ||($recent_nb>50)) $arg['recent_nb'] = $def['recent_nb']; if (($refined_nb<0) ||($refined_nb>50)) $arg['refined_nb'] = $def['refined_nb']; if (($backlink_nb<0)||($backlink_nb>50)) $arg['backlink_nb'] = $def['backlink_nb']; + // ToDo: check if "ImageCreateFrom$imgtype"() exists. if (!in_array($imgtype,$GLOBALS['CacheParams']['imgtypes'])) $arg['imgtype'] = $def['imgtype']; if (empty($fontname)) $arg['fontname'] = VISUALWIKIFONT; @@ -451,8 +449,8 @@ class WikiPlugin_VisualWiki extends WikiPluginCached { foreach ($names as $name) { $url = rawurlencode($name); - // patch to allow page/subpage as with the Calender plugin - $url = preg_replace('/%2F/','/',$url); + // patch to allow Page/SubPage + $url = preg_replace('/' . urlencode(SUBPAGE_SEPERATOR) . '/',SUBPAGE_SEPERATOR,$url); $nodename = ($label!='name'?$nametonumber[$name]+1:$name); $dot .= " \"$nodename\" [URL=\"$url\""; @@ -567,13 +565,14 @@ class WikiPlugin_VisualWiki extends WikiPluginCached { 'shape' => 'rect', 'coords' => "$x1,$y1,$x2,$y2", 'href' => $url, - 'title' => rawurldecode($url) ))); + 'title' => rawurldecode($url), + 'alt' => $url))); } fclose($fp); } // clean up tempfiles - if ($ok and isset($_GET['debug']) and $tempfiles) { + if ($ok and empty($_GET['debug']) and $tempfiles) { unlink($tempfiles); unlink("$tempfiles.$gif"); unlink($tempfiles.'.map'); diff --git a/lib/plugin/WikiForm.php b/lib/plugin/WikiForm.php index 3730fec68..511a0620e 100644 --- a/lib/plugin/WikiForm.php +++ b/lib/plugin/WikiForm.php @@ -1,5 +1,5 @@ getArgs($argstr, $request)); - $form = HTML::form(array('action' => USE_PATH_INFO ? WikiURL($request->getPage()) : SCRIPT_NAME, 'method' => 'post', 'class' => 'wikiadmin', 'accept-charset' => CHARSET), HTML::input(array('type' => 'hidden', 'name' => 'action', - 'value' => $action))); - + 'value' => $action)), + USE_PATH_INFO + ? false + : HTML::input(array('type' => 'hidden', + 'name' => 'pagename', + 'value' => $targetpage))); $input = array('type' => 'text', 'value' => $default, 'size' => $size); diff --git a/lib/transform.php b/lib/transform.php index 7c9985cf8..93bf283a8 100644 --- a/lib/transform.php +++ b/lib/transform.php @@ -1,4 +1,4 @@ -register(WT_TOKENIZER, 'wtt_bracketlinks', '\[.+?\]'); $this->register(WT_TOKENIZER, 'wtt_urls', "!?\b($AllowedProtocols):[^\s<>\[\]\"'()]*[^\s<>\[\]\"'(),.?]"); - + // Todo: get the map only when a interwikilink occurs. $map = InterWikiMap::GetMap($request); $this->register(WT_TOKENIZER, 'wtt_interwikilinks', pcre_fix_posix_classes("!?(?getArg('pagename')); + // FIXME: should this set HTML mode? + $ftnt = trim(substr($match,1,-1)) + 0; + $fntext = "[$ftnt]"; + $html = HTML(HTML::br()); - $fnlist = $trfrm->user_data['footnotes'][$ftnt]; - if (!is_array($fnlist)) { - $html->pushContent($fntext); - } - else { - $trfrm->user_data['footnotes'][$ftnt] = 'footnote_seen'; - - while (list($k, $anchor) = each($fnlist)) { - $html->pushContent(HTML::a(array("name" => "footnote-$ftnt", - "href" => "#$anchor", - "class" => "footnote-rev"), - $fntext)); - $fntext = '+'; - } - } - return $html; + $fnlist = $trfrm->user_data['footnotes'][$ftnt]; + if (!is_array($fnlist)) { + $html->pushContent($fntext); + } + else { + $trfrm->user_data['footnotes'][$ftnt] = 'footnote_seen'; + while (list($k, $anchor) = each($fnlist)) { + $html->pushContent(HTML::a(array("name" => "footnote-$ftnt", + "href" => "$page#$anchor", + "class" => "footnote-rev"), + $fntext)); + $fntext = '+'; + } + } + return $html; } -function wtt_footnoterefs($match, &$trfrm) -{ - $ftnt = trim(substr($match,1,-1)) + 0; +function wtt_footnoterefs($match, &$trfrm) { + global $request; + $ftnt = trim(substr($match,1,-1)) + 0; $footnote_definition_seen = false; - if (empty($trfrm->user_data['footnotes'])) - $trfrm->user_data['footnotes'] = array(); - if (empty($trfrm->user_data['footnotes'][$ftnt])) - $trfrm->user_data['footnotes'][$ftnt] = array(); - else if (!is_array($trfrm->user_data['footnotes'][$ftnt])) - $footnote_definition_seen = true; + if (empty($trfrm->user_data['footnotes'])) + $trfrm->user_data['footnotes'] = array(); + if (empty($trfrm->user_data['footnotes'][$ftnt])) + $trfrm->user_data['footnotes'][$ftnt] = array(); + else if (!is_array($trfrm->user_data['footnotes'][$ftnt])) + $footnote_definition_seen = true; - - $link = HTML::a(array('href' => "#footnote-$ftnt"), "[$ftnt]"); - if (!$footnote_definition_seen) { - $name = "footrev-$ftnt-" . count($trfrm->user_data['footnotes'][$ftnt]); - $link->setAttr('name', $name); - $trfrm->user_data['footnotes'][$ftnt][] = $name; - } - return HTML::sup(array('class' => 'footnote'), $link); + $page = rawurlencode($request->getArg('pagename')); + $link = HTML::a(array('href' => "$page#footnote-$ftnt"), "[$ftnt]"); + if (!$footnote_definition_seen) { + $name = "footrev-$ftnt-" . count($trfrm->user_data['footnotes'][$ftnt]); + $link->setAttr('name', $name); + $trfrm->user_data['footnotes'][$ftnt][] = $name; + } + return HTML::sup(array('class' => 'footnote'), $link); } -function wtt_bracketlinks($match, &$trfrm) -{ +function wtt_bracketlinks($match, &$trfrm) { if (preg_match('/^\[\s*\]$/', $match)) return $match; @@ -501,9 +499,7 @@ function wtt_urls($match, &$trfrm) { function wtt_interwikilinks($match, &$trfrm) { if ($match[0] == '!') return substr($match, 1); - - global $request; - $map = InterWikiMap::GetMap($request); + $map = InterWikiMap::GetMap($GLOBALS['request']); return $map->link($match); } @@ -538,17 +534,17 @@ function wtm_linebreak($line, &$transformer) { return str_replace('%%%', '
', $line); } - // bold and italics - function wtm_bold_italics($line, &$transformer) { - $line = preg_replace('|(__)(.*?)(__)|', '\2', $line); - $line = preg_replace("|('')(.*?)('')|", '\2', $line); - return $line; - } +// bold and italics +function wtm_bold_italics($line, &$transformer) { + $line = preg_replace('|(__)(.*?)(__)|', '\2', $line); + $line = preg_replace("|('')(.*?)('')|", '\2', $line); + return $line; +} - ////////////////////////////////////////////////////////// - // some tokens to be replaced by (dynamic) content +////////////////////////////////////////////////////////// +// some tokens to be replaced by (dynamic) content // FIXME: some plugins are in-line (maybe?) and some are block level. // Here we treat them all as inline, which will probably @@ -556,12 +552,10 @@ function wtm_linebreak($line, &$transformer) { // function wtm_plugin_link($line, &$transformer) { // FIXME: is this good syntax? - global $request; // FIXME: make these non-global? - if (preg_match('/^(.*?)(<\?plugin-link\s+.*?\?>)(.*)$/', $line, $m)) { list(, $prematch, $plugin_pi, $postmatch) = $m; $loader = new WikiPluginLoader; - $html = $loader->expandPI($plugin_pi, $request); + $html = $loader->expandPI($plugin_pi, $GLOBALS['request']); $line = $prematch . $transformer->token($html) . $postmatch; } return $line; @@ -569,83 +563,80 @@ function wtm_plugin_link($line, &$transformer) { function wtm_plugin($line, &$transformer) { // FIXME: is this good syntax? - global $request; // FIXME: make these non-global? - if (preg_match('/^<\?plugin(-form)?\s.*\?>\s*$/', $line)) { $loader = new WikiPluginLoader; - $html = $loader->expandPI($line, $request); + $html = $loader->expandPI($line, $GLOBALS['request']); $line = $transformer->SetHTMLMode('', 0) . $transformer->token($html); } return $line; } - ////////////////////////////////////////////////////////// - // mode markup functions +////////////////////////////////////////////////////////// +// mode markup functions - // tabless markup for unordered, ordered, and dictionary lists - // ul/ol list types can be mixed, so we only look at the last - // character. Changes e.g. from "**#*" to "###*" go unnoticed. - // and wouldn't make a difference to the HTML layout anyway. +// tabless markup for unordered, ordered, and dictionary lists +// ul/ol list types can be mixed, so we only look at the last +// character. Changes e.g. from "**#*" to "###*" go unnoticed. +// and wouldn't make a difference to the HTML layout anyway. - // unordered lists