From: <ja...@gn...> - 2000-10-24 07:49:41
|
Hi Arno, I'll maybe have a quick look at these too... 7.And what about a WikiLink? and another WikiLink?WithSameStem on one line? 8.Other way around: WikiLink?WithSameStem plus WikiLink? diff -urN --exclude=CVS --exclude=*~ --exclude=#* ../phpwiki/lib/pageinfo.php ./lib/pageinfo.php --- ../phpwiki/lib/pageinfo.php Thu Oct 19 23:36:50 2000 +++ ./lib/pageinfo.php Mon Oct 23 03:48:39 2000 @@ -6,16 +6,20 @@ } $encname = htmlspecialchars($info); + $enter .= gettext ("Enter a page name"); + $go = gettext ("Go"); $html = "<form action=\"$ScriptUrl\" METHOD=GET>\n" . "<input name=\"info\" value=\"$encname\">" . - " Enter a page name\n" . - "<input type=submit value=Go><br>\n" . + " $enter\n" . + "<input type=submit value=$go><br>\n" . "<input type=checkbox name=showpagesource"; if ($showpagesource == "on") { $html .= " checked"; } - $html .= "> Show the page source and references\n</form>\n"; + $html .= "> "; + $html .= gettext ("Show the page source and references"); + $html .= "\n</form>\n"; // don't bother unless we were asked if (! $info) { @@ -29,7 +33,8 @@ $pagehash = RetrievePage($dbi, $name, $pagestore); if ($pagehash == -1) { - $table = "Page name '$name' is not in the database<br>\n"; + $table = sprintf (gettext ("Page name '%s' is not in the database"), + $name) . "\n"; } else { $table = "<table border=1 bgcolor=white>\n"; @@ -55,11 +60,15 @@ return $table; } - $html .= "<P><B>Current version</B></p>"; + $html .= "<P><B>"; + $html .= gettext ("Current version"); + $html .= "</B></p>"; // $dbi = OpenDataBase($WikiPageStore); --- done by index.php $html .= ViewPageProps($info, $WikiPageStore); - $html .= "<P><B>Archived version</B></p>"; + $html .= "<P><B>"; + $html .= gettext ("Archived version"); + $html .= "</B></p>"; // $dbi = OpenDataBase($ArchivePageStore); $html .= ViewPageProps($info, $ArchivePageStore); Binary files ../phpwiki/locale/nl/LC_MESSAGES/phpwiki.mo and ./locale/nl/LC_MESSAGES/phpwiki.mo differ diff -urN --exclude=CVS --exclude=*~ --exclude=#* ../phpwiki/locale/nl/LC_MESSAGES/phpwiki.php ./locale/nl/LC_MESSAGES/phpwiki.php --- ../phpwiki/locale/nl/LC_MESSAGES/phpwiki.php Fri Oct 20 15:22:03 2000 +++ ./locale/nl/LC_MESSAGES/phpwiki.php Tue Oct 24 09:34:18 2000 @@ -69,8 +69,20 @@ "MySQL fout: %s"; $locale["Error writing page '%s'"] = "Fout bij schrijven pagina `%s'"; +$locale["Enter a page name"] = + "Geef de naam van een pagina"; +$locale["Go"] = + "Ga"; +$locale["Show the page source and references"] = + "Toon de bron tekst en de koppelingen van de pagina"; $locale["PageInfo"] = "PaginaInfo"; +$locale["Page name '%s' is not in the database"] = + "Pagina naam `%s' staat niet in de data base"; +$locale["Current version"] = + "Actuele versie:"; +$locale["Archived version"] = + "Gearchiveerde versie:"; $locale["Thank you for editing %s."] = "Bedankt voor het veranderen van %s."; $locale["Your careful attention to detail is much appreciated."] = diff -urN --exclude=CVS --exclude=*~ --exclude=#* ../phpwiki/locale/po/nl.po ./locale/po/nl.po --- ../phpwiki/locale/po/nl.po Fri Oct 20 15:22:04 2000 +++ ./locale/po/nl.po Tue Oct 24 09:34:18 2000 @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: phpwiki 1.1.7\n" -"POT-Creation-Date: 2000-10-20 13:43+0200\n" +"POT-Creation-Date: 2000-10-24 09:34+0200\n" "PO-Revision-Date: 2000-09-30 02:23+0200\n" "Last-Translator: Jan Nieuwenhuizen <ja...@gn...>\n" "Language-Team: Dutch <nl...@li...>\n" @@ -24,19 +24,19 @@ msgid "./pgsrc" msgstr "locale/nl/pgsrc" -#: lib/config.php:168 +#: lib/config.php:174 msgid "templates/browse.html" msgstr "locale/nl/templates/browse.html" -#: lib/config.php:169 +#: lib/config.php:175 msgid "templates/editpage.html" msgstr "locale/nl/templates/editpage.html" -#: lib/config.php:170 +#: lib/config.php:176 msgid "templates/editlinks.html" msgstr "locale/nl/templates/editlinks.html" -#: lib/config.php:171 +#: lib/config.php:177 msgid "templates/message.html" msgstr "locale/nl/templates/message.html" @@ -140,7 +140,7 @@ msgid "Full Text Search Results" msgstr "Volledige tekst zoek resultaten" -#: lib/msql.php:29 lib/mysql.php:33 +#: lib/msql.php:29 lib/mysql.php:42 msgid "Cannot establish connection to database, giving up." msgstr "Kan verbinding naar data base niet tot stand brengen, geef op." @@ -149,7 +149,7 @@ msgid "Error message: %s" msgstr "Foutboodschap: %s" -#: lib/msql.php:35 lib/mysql.php:39 +#: lib/msql.php:35 lib/mysql.php:48 #, c-format msgid "Cannot open database %s, giving up." msgstr "Kan data base %s niet openen, geef op." @@ -169,19 +169,44 @@ msgid "Insert into %s failed: %s" msgstr "Insert in %s gefaald: %s" -#: lib/mysql.php:35 lib/mysql.php:41 lib/mysql.php:115 +#: lib/mysql.php:44 lib/mysql.php:50 lib/mysql.php:124 #, c-format msgid "MySQL error: %s" msgstr "MySQL fout: %s" -#: lib/mysql.php:113 +#: lib/mysql.php:122 #, c-format msgid "Error writing page '%s'" msgstr "Fout bij schrijven pagina `%s'" -#: lib/pageinfo.php:22 lib/pageinfo.php:66 +#: lib/pageinfo.php:9 +msgid "Enter a page name" +msgstr "Geef de naam van een pagina" + +#: lib/pageinfo.php:10 +msgid "Go" +msgstr "Ga" + +#: lib/pageinfo.php:21 +msgid "Show the page source and references" +msgstr "Toon de bron tekst en de koppelingen van de pagina" + +#: lib/pageinfo.php:26 lib/pageinfo.php:75 msgid "PageInfo" msgstr "PaginaInfo" + +#: lib/pageinfo.php:36 +#, c-format +msgid "Page name '%s' is not in the database" +msgstr "Pagina naam `%s' staat niet in de data base" + +#: lib/pageinfo.php:64 +msgid "Current version" +msgstr "Actuele versie:" + +#: lib/pageinfo.php:70 +msgid "Archived version" +msgstr "Gearchiveerde versie:" #: lib/savepage.php:60 #, c-format diff -urN --exclude=CVS --exclude=*~ --exclude=#* ../phpwiki/locale/po/phpwiki.pot ./locale/po/phpwiki.pot --- ../phpwiki/locale/po/phpwiki.pot Fri Oct 20 15:22:04 2000 +++ ./locale/po/phpwiki.pot Tue Oct 24 09:34:18 2000 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-10-20 13:43+0200\n" +"POT-Creation-Date: 2000-10-24 09:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" @@ -18,19 +18,19 @@ msgid "./pgsrc" msgstr "" -#: lib/config.php:168 +#: lib/config.php:174 msgid "templates/browse.html" msgstr "" -#: lib/config.php:169 +#: lib/config.php:175 msgid "templates/editpage.html" msgstr "" -#: lib/config.php:170 +#: lib/config.php:176 msgid "templates/editlinks.html" msgstr "" -#: lib/config.php:171 +#: lib/config.php:177 msgid "templates/message.html" msgstr "" @@ -133,7 +133,7 @@ msgid "Full Text Search Results" msgstr "" -#: lib/msql.php:29 lib/mysql.php:33 +#: lib/msql.php:29 lib/mysql.php:42 msgid "Cannot establish connection to database, giving up." msgstr "" @@ -142,7 +142,7 @@ msgid "Error message: %s" msgstr "" -#: lib/msql.php:35 lib/mysql.php:39 +#: lib/msql.php:35 lib/mysql.php:48 #, c-format msgid "Cannot open database %s, giving up." msgstr "" @@ -162,18 +162,43 @@ msgid "Insert into %s failed: %s" msgstr "" -#: lib/mysql.php:35 lib/mysql.php:41 lib/mysql.php:115 +#: lib/mysql.php:44 lib/mysql.php:50 lib/mysql.php:124 #, c-format msgid "MySQL error: %s" msgstr "" -#: lib/mysql.php:113 +#: lib/mysql.php:122 #, c-format msgid "Error writing page '%s'" msgstr "" -#: lib/pageinfo.php:22 lib/pageinfo.php:66 +#: lib/pageinfo.php:9 +msgid "Enter a page name" +msgstr "" + +#: lib/pageinfo.php:10 +msgid "Go" +msgstr "" + +#: lib/pageinfo.php:21 +msgid "Show the page source and references" +msgstr "" + +#: lib/pageinfo.php:26 lib/pageinfo.php:75 msgid "PageInfo" +msgstr "" + +#: lib/pageinfo.php:36 +#, c-format +msgid "Page name '%s' is not in the database" +msgstr "" + +#: lib/pageinfo.php:64 +msgid "Current version" +msgstr "" + +#: lib/pageinfo.php:70 +msgid "Archived version" msgstr "" #: lib/savepage.php:60 -- Jan Nieuwenhuizen <ja...@gn...> | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org |
From: Arno H. <aho...@in...> - 2000-10-24 10:37:02
|
infopage translations committed. > I'll maybe have a quick look at these too... > 7.And what about a WikiLink? and another WikiLink?WithSameStem on one line? > 8.Other way around: WikiLink?WithSameStem plus WikiLink? Where the @$#! came this bug from? We've killed it a number of times already. Anyway, I've fixed it for good now (a hack - but it has its merrits). My solution limits WikiNames to 9876 characters, though. I hope that doesn't disturb anyone :o) Test cases added to TestPage as well. /Arno |
From: Steve W. <sw...@wc...> - 2000-10-24 15:51:03
|
On Tue, 24 Oct 2000, Arno Hollosi wrote: > Where the @$#! came this bug from? We've killed it a number of times already. > Anyway, I've fixed it for good now (a hack - but it has its merrits). My > solution limits WikiNames to 9876 characters, though. I hope that doesn't > disturb anyone :o) Too bad it's not shorter; WikiWords over 256 chars are a problem for the mSQL version. Ah, something for the task list! sw ...............................ooo0000ooo................................. Hear FM quality freeform radio through the Internet: http://wcsb.org/ home page: www.wcsb.org/~swain |
From: Neil B. <ne...@cs...> - 2000-10-25 02:05:17
|
On Tuesday October 24, aho...@in... wrote: > > > > I'll maybe have a quick look at these too... > > 7.And what about a WikiLink? and another WikiLink?WithSameStem on one line? > > 8.Other way around: WikiLink?WithSameStem plus WikiLink? > I would like to suggest the following patch (against current CVS) which takes a different approach which makes this sort of bug much less likely. To me, it makes the code a whole lot cleaner, but may it's just me. The basic approach is to cope the line up while matching rather than extracting strings and then searching for those strings. It also fixes a bug whereby ;WikiWord: definition there-of ;OtherWikiWord: other definition gets converted into bad html because the WikiWord gets converted into a full reference (containing a :) before the search for /^;+.*?:/ is done. I simple delay replacing the token until (nearly) the last moment. Let me know what yo think? NeilBrown Index: lib/transform.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v retrieving revision 1.4 diff -u -r1.4 transform.php --- lib/transform.php 2000/10/24 10:32:37 1.4 +++ lib/transform.php 2000/10/25 01:58:48 @@ -1,5 +1,23 @@ <!-- $Id: transform.php,v 1.4 2000/10/24 10:32:37 ahollosi Exp $ --> <?php + function tokenize($str, $pattern, &$orig, &$ntokens) { + global $FieldSeparator; + // Find any strings in $str that patch $pattern and + // store them in $tokens[], replacing them with a token + $new = ""; + while (preg_match("/^(.*?)($pattern)/", $str, $matches)) { + $linktoken = $FieldSeparator . $FieldSeparator . ($ntokens++) . $FieldSeparator; + $new .= $matches[1].$linktoken; + $orig[] = $matches[2]; + $str = substr($str, strlen($matches[0])); + } + $new .= $str; + return $new; + } + + + + // expects $pagehash and $html to be set // Set up inline links and images @@ -29,6 +47,7 @@ unset($tokens); unset($replacements); $ntokens = 0; + $replacements = array(); $tmpline = $pagehash["content"][$index]; @@ -54,70 +73,40 @@ ////////////////////////////////////////////////////////// // New linking scheme: links are in brackets. This will // emulate typical HTML linking as well as Wiki linking. + + // First need to protect [[. + $tmpline = tokenize($tmpline, "\[\[", $replacements, $ntokens); + - // match anything between brackets except only numbers - // trying: - $numBracketLinks = preg_match_all("/\[.+?\]/", $tmpline, $brktlinks); - /* On 12 Jul,2000 Jeff <da...@da...> adds: - * - * Simple sorting doesnt work, since (in ASCII) '[' comes between - * the upper- and lower-case characters. - * - * Using sort "[[Link] [Link]" will come out wrong, using - * rsort "[[link] [link]" will come out wrong. - * (An appropriate usort would work.) - * - * I've added a look-behind assertion to the preg_replace which, - * I think, fixes the problem. I only hope that all PHP versions - * support look-behind assertions.... - // sort instead of rsort or "[[link] [link]" will be rendered wrong. - sort($brktlinks[0]); - reset($brktlinks[0]); - */ - - for ($i = 0; $i < $numBracketLinks; $i++) { - $brktlink = preg_quote($brktlinks[0][$i]); - $linktoken = $FieldSeparator . $FieldSeparator . ++$ntokens . $FieldSeparator; - /* PS: - * If you're wondering about the double $FieldSeparator, - * consider what happens to (the admittedly sick): - * "[Link1] [Link2]1[Link3]" - * - * Answer: without the double field separator, it gets - * tokenized to "%1% %2%1%3%" (using % to represent $FieldSeparator), - * which will get munged as soon as '%1%' is substituted with it's - * final value. - */ - $tmpline = preg_replace("|(?<!\[)$brktlink|", - $linktoken, - $tmpline); - - $tokens[] = $linktoken; - $link = ParseAndLink($brktlinks[0][$i]); - $replacements[] = $link['link']; + // Now process the [\d+] links which are numeric references + $oldn = $ntokens; + $tmpline = tokenize($tmpline, "\[\d+\]", $replacements ,$ntokens); + while ($oldn < $ntokens) { + preg_match("/\[(\d+)\]/", $replacements[$oldn], $m); + $num = $m[1]; + if (! empty($embedded[$num])) { + $replacements[$oldn] = $embedded[$num]; + } + $oldn++; + } + // match anything else between brackets + + $oldn = $ntokens; + $tmpline = tokenize($tmpline, "\[.+?\]", $replacements, $ntokens); + while ($oldn < $ntokens) { + $link = ParseAndLink($replacements[$oldn]); + $replacements[$oldn] = $link['link']; + $oldn++; } ////////////////////////////////////////////////////////// // replace all URL's with tokens, so we don't confuse them // with Wiki words later. Wiki words in URL's break things. - - $hasURLs = preg_match_all("/\b($AllowedProtocols):[^\s\<\>\[\]\"'\(\)]*[^\s\<\>\[\]\"'\(\)\,\.\?]/", $tmpline, $urls); - // have to sort, otherwise errors creep in when the domain appears - // in two consecutive URL's on the same line, but the second is - // longer e.g. http://c2.com followed by http://c2.com/wiki - rsort($urls[0]); - reset($urls[0]); - - for ($i = 0; $i < $hasURLs; $i++) { - $inplaceURL = preg_quote($urls[0][$i]); - $URLtoken = $FieldSeparator . $FieldSeparator . ++$ntokens . $FieldSeparator; - $tmpline = preg_replace("|$inplaceURL|", - $URLtoken, - $tmpline); - - $tokens[] = $URLtoken; - $replacements[] = LinkURL($urls[0][$i]); + $tmpline = tokenize($tmpline, "\b($AllowedProtocols):[^\s\<\>\[\]\"'\(\)]*[^\s\<\>\[\]\"'\(\)\,\.\?]", $replacements, $ntokens); + while ($oldn < $ntokens) { + $replacements[$oldn] = LinkURL($replacements[$oldn]); + $oldn++; } // escape HTML metachars @@ -154,56 +143,20 @@ // Link Wiki words // Wikiwords preceeded by a '!' are not linked - if (preg_match_all("#!?\b(([A-Z][a-z]+){2,})\b#", - $tmpline, $link)) { - // uniq the list of matches - unset($hash); - for ($i = 0; $link[0][$i]; $i++) { - if(strstr($link[0][$i], '!')) // hashval sports a value - $hashval = "0000:".$link[0][$i]; // in front that guarantees - else // correct sorting - $hashval = sprintf("%04d:%s", 9876-strlen($link[0][$i]) - , $link[0][$i]); - $hash[$hashval] = 1; - } - - // all '!WikiName' entries are sorted first - ksort($hash); - while (list($realfile, $val) = each($hash)) { - $realfile = substr($realfile, 5); // get rid of sort value - $token = $FieldSeparator . $FieldSeparator . ++$ntokens . $FieldSeparator; - $tmpline = str_replace($realfile, $token, $tmpline); - - $tokens[] = $token; - if (strstr($realfile, '!')) { - $replacements[] = substr($realfile, 1); - } - elseif (IsWikiPage($dbi, $realfile)) { - $replacements[] = LinkExistingWikiWord($realfile); - } else { - $replacements[] = LinkUnknownWikiWord($realfile); - } - } + $oldn = $ntokens; + $tmpline = tokenize($tmpline, "!?\b(([A-Z][a-z]+){2,})\b", $replacements, $ntokens); + while ($oldn < $ntokens) { + $old = $replacements[$oldn]; + if (substr($old,0,1)=='!') { + $replacements[$oldn] = substr($old,1); + } elseif (IsWikiPage($dbi, $old)) { + $replacements[$oldn] = LinkExistingWikiWord($old); + } else { + $replacements[$oldn] = LinkUnknownWikiWord($old); + } + $oldn++; } - /////////////////////////////////////////////////////// - // Replace tokens - for ($i = 0; $i < $ntokens; $i++) - $tmpline = str_replace($tokens[$i], $replacements[$i], $tmpline); - - - // match and replace all user-defined links ([1], [2], [3]...) - preg_match_all("|\[(\d+)\]|", $tmpline, $match); - if (count($match[0])) { - for ($k = 0; $k < count($match[0]); $k++) { - if (! empty($embedded[$match[1][$k]])) { - $linkpattern = preg_quote($match[0][$k]); - $tmpline = preg_replace("|$linkpattern|", - $embedded[$match[1][$k]], - $tmpline); - } - } - } // HTML modes: pre, unordered/ordered lists, term/def (using TAB) if (preg_match("/(^\t+)(.*?)(:\t)(.*$)/", $tmpline, $matches)) { @@ -279,6 +232,11 @@ // it's ordinary output if nothing else $html .= SetHTMLOutputMode("", ZERO_DEPTH, 0); } + + /////////////////////////////////////////////////////// + // Replace tokens + for ($i = 0; $i < $ntokens; $i++) + $tmpline = str_replace($FieldSeparator.$FieldSeparator.$i.$FieldSeparator, $replacements[$i], $tmpline); $tmpline = str_replace("%%Search%%", $quick_search_box, $tmpline); $tmpline = str_replace("%%Fullsearch%%", $full_search_box, $tmpline); |
From: Arno H. <aho...@in...> - 2000-10-25 14:58:08
|
Neil, > I would like to suggest the following patch (against current CVS) > less likely. To me, it makes the code a whole lot cleaner, but may I really like that one and have committed it already. Nicely done! Sometimes it seems we don't see the forrest because of the trees. /Arno |