From: Geoffrey T. D. <da...@us...> - 2001-11-14 21:05:41
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv31659/lib Modified Files: diff.php editpage.php savepage.php stdlib.php transform.php Log Message: XHTML fixes. At this point, PhpWiki's output is almost valid XHTML. (Most of these changes are based on patches by Tara/Steph.) Index: diff.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/diff.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** diff.php 2001/09/18 19:16:23 1.13 --- diff.php 2001/11/14 21:05:38 1.14 *************** *** 1136,1145 **** . PageInfoRow($pagename, gettext ("Older page:"), $old)); - $html .= "<p>\n"; if ($new && $old) { $diff = new WikiDiff($old->getContent(), $new->getContent()); if ($diff->isEmpty()) { ! $html .= '<hr>[' . gettext ("Versions are identical") . ']'; } else { --- 1136,1145 ---- . PageInfoRow($pagename, gettext ("Older page:"), $old)); if ($new && $old) { $diff = new WikiDiff($old->getContent(), $new->getContent()); if ($diff->isEmpty()) { ! $html .= Element('hr'); ! $html .= QElement('p', '[' . gettext ("Versions are identical") . ']'); } else { Index: editpage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/editpage.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** editpage.php 2001/09/18 19:16:23 1.17 --- editpage.php 2001/11/14 21:05:38 1.18 *************** *** 23,34 **** global $user; // FIXME: make this non-global. if ($page->get('locked') && !$user->is_admin()) { ! $html = "<p>"; ! $html .= gettext ("This page has been locked by the administrator and cannot be edited."); ! $html .= "\n<p>"; ! $html .= gettext ("Sorry for the inconvenience."); $html .= "\n"; echo GeneratePage('MESSAGE', $html, ! sprintf(gettext("Problem while editing %s"), $args->pagename), $selected); ExitWiki (""); --- 23,34 ---- global $user; // FIXME: make this non-global. if ($page->get('locked') && !$user->is_admin()) { ! $html = QElement('p', ! gettext ("This page has been locked by the administrator and cannot be edited.")); $html .= "\n"; + $html .= QElement('p', gettext ("Sorry for the inconvenience.")) . "\n"; echo GeneratePage('MESSAGE', $html, ! sprintf(gettext("Problem while editing %s"), ! $request->getArg('pagename')), $selected); ExitWiki (""); Index: savepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** savepage.php 2001/09/18 19:16:23 1.16 --- savepage.php 2001/11/14 21:05:38 1.17 *************** *** 19,39 **** We want to translate this entire paragraph as one string, of course. */ ! $html = "<P>"; $html .= gettext ("PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost."); ! $html .= "</P>\n<P>"; $html .= gettext ("In order to recover from this situation follow these steps:"); ! $html .= "\n<OL><LI>"; $html .= gettext ("Use your browser's <b>Back</b> button to go back to the edit page."); ! $html .= "\n<LI>"; $html .= gettext ("Copy your changes to the clipboard or to another temporary place (e.g. text editor)."); ! $html .= "\n<LI>"; $html .= gettext ("<b>Reload</b> the page. You should now see the most current version of the page. Your changes are no longer there."); ! $html .= "\n<LI>"; $html .= gettext ("Make changes to the file again. Paste your additions from the clipboard (or text editor)."); ! $html .= "\n<LI>"; $html .= gettext ("Press <b>Save</b> again."); ! $html .= "</OL>\n<P>"; ! $html .= gettext ("Sorry for the inconvenience."); ! $html .= "</P>"; echo GeneratePage('MESSAGE', $html, --- 19,38 ---- We want to translate this entire paragraph as one string, of course. */ ! $html = "<p>"; $html .= gettext ("PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost."); ! $html .= "</p>\n<p>"; $html .= gettext ("In order to recover from this situation follow these steps:"); ! $html .= "\n<ol><li>"; $html .= gettext ("Use your browser's <b>Back</b> button to go back to the edit page."); ! $html .= "</li>\n<li>"; $html .= gettext ("Copy your changes to the clipboard or to another temporary place (e.g. text editor)."); ! $html .= "</li>\n<li>"; $html .= gettext ("<b>Reload</b> the page. You should now see the most current version of the page. Your changes are no longer there."); ! $html .= "</li>\n<li>"; $html .= gettext ("Make changes to the file again. Paste your additions from the clipboard (or text editor)."); ! $html .= "</li>\n<li>"; $html .= gettext ("Press <b>Save</b> again."); ! $html .= "</li></ol></p>\n"; ! $html .= QElement('p', gettext ("Sorry for the inconvenience.")); echo GeneratePage('MESSAGE', $html, Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** stdlib.php 2001/10/29 18:41:11 1.43 --- stdlib.php 2001/11/14 21:05:38 1.44 *************** *** 50,53 **** --- 50,60 ---- } + define('NO_END_TAG_PAT', + '/^' . join('|', array('area', 'base', 'basefont', + 'br', 'col', 'frame', + 'hr', 'img', 'input', + 'isindex', 'link', 'meta', + 'param')) . '$/i'); + function StartTag($tag, $args = '') { *************** *** 60,64 **** $s .= sprintf(' %s="%s"', $key, htmlspecialchars($val)); else if ($val) ! $s .= " $key"; } } --- 67,71 ---- $s .= sprintf(' %s="%s"', $key, htmlspecialchars($val)); else if ($val) ! $s .= " $key=\"$key\""; } } *************** *** 67,109 **** ! define('NO_END_TAG_PAT', ! '/^' . join('|', array('area', 'base', 'basefont', ! 'br', 'col', 'frame', ! 'hr', 'image', 'input', ! 'isindex', 'link', 'meta', ! 'param')) . '$/i'); ! ! function Element($tag, $args = '', $content = '') ! { ! $html = "<$tag"; ! if (!is_array($args)) ! { ! $content = $args; ! $args = false; ! } ! $html = StartTag($tag, $args); ! if (!preg_match(NO_END_TAG_PAT, $tag)) ! { ! $html .= $content; ! $html .= "</$tag>";//FIXME: newline might not always be desired. ! } ! return $html; ! } ! function QElement($tag, $args = '', $content = '') ! { ! if (is_array($args)) ! return Element($tag, $args, htmlspecialchars($content)); ! else ! { ! $content = $args; ! return Element($tag, htmlspecialchars($content)); ! } ! } function LinkURL($url, $linktext='') { // FIXME: Is this needed (or sufficient?) if(ereg("[<>\"]", $url)) { ! return "<b><u>BAD URL -- remove all of <, >, "</u></b>"; } --- 74,111 ---- ! function Element($tag, $args = '', $content = '') ! { ! $html = "<$tag"; ! if (!is_array($args)) { ! $content = $args; ! $args = false; ! } ! $html = StartTag($tag, $args); ! if (preg_match(NO_END_TAG_PAT, $tag)) { ! assert(! $content); ! return preg_replace('/>$/', " />", $html); ! } else { ! $html .= $content; ! $html .= "</$tag>";//FIXME: newline might not always be desired. ! } ! return $html; ! } ! function QElement($tag, $args = '', $content = '') ! { ! if (is_array($args)) ! return Element($tag, $args, htmlspecialchars($content)); ! else { ! $content = $args; ! return Element($tag, htmlspecialchars($content)); ! } ! } function LinkURL($url, $linktext='') { // FIXME: Is this needed (or sufficient?) if(ereg("[<>\"]", $url)) { ! return Element('strong', ! QElement('u', array('class' => 'baduri'), ! 'BAD URL -- remove all of <, >, "')); } *************** *** 163,167 **** // As long as the src in htmlspecialchars()ed I think it's safe. if(ereg('[<>"]', $url)) { ! return "<b><u>BAD URL -- remove all of <, >, "</u></b>"; } return Element('img', array('src' => $url, 'alt' => $alt)); --- 165,171 ---- // As long as the src in htmlspecialchars()ed I think it's safe. if(ereg('[<>"]', $url)) { ! return Element('strong', ! QElement('u', array('class' => 'baduri'), ! 'BAD URL -- remove all of <, >, "')); } return Element('img', array('src' => $url, 'alt' => $alt)); *************** *** 268,273 **** if (!preg_match('/^ phpwiki: ([^?]*) [?]? (.*) $/x', $url, $m)) ! return "<b><u>BAD phpwiki: URL</u></b>"; ! if ($m[1]) $pagename = urldecode($m[1]); --- 272,278 ---- if (!preg_match('/^ phpwiki: ([^?]*) [?]? (.*) $/x', $url, $m)) ! return Element('strong', ! QElement('u', array('class' => 'baduri'), ! 'BAD phpwiki: URL')); if ($m[1]) $pagename = urldecode($m[1]); *************** *** 421,427 **** $links = GetWikiPageLinks($dbi, $pagename); ! $txt = "<b>"; ! $txt .= sprintf (gettext ("%d best incoming links:"), NUM_RELATED_PAGES); ! $txt .= "</b>\n"; for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['in'][$i])) { --- 426,431 ---- $links = GetWikiPageLinks($dbi, $pagename); ! $txt = QElement('strong', ! sprintf (gettext ("%d best incoming links:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['in'][$i])) { *************** *** 430,437 **** } } ! ! $txt .= "\n<br><b>"; ! $txt .= sprintf (gettext ("%d best outgoing links:"), NUM_RELATED_PAGES); ! $txt .= "</b>\n"; for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['out'][$i])) { --- 434,441 ---- } } ! ! $txt .= "\n" . Element('br'); ! $txt .= Element('strong', ! sprintf (gettext ("%d best outgoing links:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['out'][$i])) { *************** *** 442,448 **** } ! $txt .= "\n<br><b>"; ! $txt .= sprintf (gettext ("%d most popular nearby:"), NUM_RELATED_PAGES); ! $txt .= "</b>\n"; for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['popular'][$i])) { --- 446,452 ---- } ! $txt .= "\n" . Element('br'); ! $txt .= Element('strong', ! sprintf (gettext ("%d most popular nearby:"), NUM_RELATED_PAGES)); for($i = 0; $i < NUM_RELATED_PAGES; $i++) { if(isset($links['popular'][$i])) { *************** *** 494,501 **** function NoSuchRevision ($page, $version) { ! $html = "<p><b>" . gettext("Bad Version") . "</b>\n<p>"; ! $html .= sprintf(gettext("I'm sorry. Version %d of %s is not in my database."), ! $version, htmlspecialchars($page->getName())); ! $html .= "\n"; include_once('lib/Template.php'); --- 498,505 ---- function NoSuchRevision ($page, $version) { ! $html = Element('p', QElement('strong', gettext("Bad Version"))) . "\n"; ! $html .= QElement('p', ! sprintf(gettext("I'm sorry. Version %d of %s is not in my database."), ! $version, $page->getName())) . "\n"; include_once('lib/Template.php'); Index: transform.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** transform.php 2001/11/14 17:54:45 1.24 --- transform.php 2001/11/14 21:05:38 1.25 *************** *** 354,358 **** $ftnt = trim(substr($match,1,-1)) + 0; $fntext = "[$ftnt]"; ! $html = "<br>"; $fnlist = $trfrm->user_data['footnotes'][$ftnt]; --- 354,358 ---- $ftnt = trim(substr($match,1,-1)) + 0; $fntext = "[$ftnt]"; ! $html = Element('br'); $fnlist = $trfrm->user_data['footnotes'][$ftnt]; *************** *** 450,454 **** // %%% are linebreaks function wtm_linebreak($line, &$transformer) { ! return str_replace('%%%', '<br>', $line); } --- 450,454 ---- // %%% are linebreaks function wtm_linebreak($line, &$transformer) { ! return str_replace('%%%', Element('br'), $line); } *************** *** 510,515 **** $numtabs = strlen($matches[1]); $line = preg_replace("/^([#*]*\*)/", '', $line); ! $html = $trfrm->SetHTMLMode('ul', $numtabs) . '<li>'; ! $line = $html . $line; } return $line; --- 510,515 ---- $numtabs = strlen($matches[1]); $line = preg_replace("/^([#*]*\*)/", '', $line); ! $html = $trfrm->SetHTMLMode('ul', $numtabs); ! $line = $html . Element('li', $line); } return $line; *************** *** 521,526 **** $numtabs = strlen($matches[1]); $line = preg_replace("/^([#*]*\#)/", "", $line); ! $html = $trfrm->SetHTMLMode('ol', $numtabs) . '<li>'; ! $line = $html . $line; } return $line; --- 521,526 ---- $numtabs = strlen($matches[1]); $line = preg_replace("/^([#*]*\#)/", "", $line); ! $html = $trfrm->SetHTMLMode('ol', $numtabs); ! $line = $html . Element('li', $line); } return $line; *************** *** 534,539 **** $line = $trfrm->SetHTMLMode('dl', $numtabs); if(trim($matches[2])) ! $line .= '<dt>' . $matches[2]; ! $line .= '<dd>' . $matches[3]; } return $line; --- 534,539 ---- $line = $trfrm->SetHTMLMode('dl', $numtabs); if(trim($matches[2])) ! $line .= Element('dt', $matches[2]); ! $line .= Element('dd', $matches[3]); } return $line; *************** *** 550,558 **** // mode: headings, i.e. <h1>, <h2>, <h3> // lines starting with !,!!,!!! are headings function wtm_headings($line, &$trfrm) { if (preg_match("/^(!{1,3})[^!]/", $line, $whichheading)) { ! if($whichheading[1] == '!') $heading = 'h3'; ! elseif($whichheading[1] == '!!') $heading = 'h2'; ! elseif($whichheading[1] == '!!!') $heading = 'h1'; $line = preg_replace("/^!+/", '', $line); $line = $trfrm->SetHTMLMode($heading) . $line; --- 550,560 ---- // mode: headings, i.e. <h1>, <h2>, <h3> // lines starting with !,!!,!!! are headings + // Patch from steph/tara <te...@cl...>: + // use <h2>, <h3>, <h4> since <h1> is page title. function wtm_headings($line, &$trfrm) { if (preg_match("/^(!{1,3})[^!]/", $line, $whichheading)) { ! if($whichheading[1] == '!') $heading = 'h4'; ! elseif($whichheading[1] == '!!') $heading = 'h3'; ! elseif($whichheading[1] == '!!!') $heading = 'h2'; $line = preg_replace("/^!+/", '', $line); $line = $trfrm->SetHTMLMode($heading) . $line; *************** *** 602,606 **** function wtm_hr($line, &$trfrm) { if (preg_match('/^-{4,}(.*)$/', $line, $m)) { ! $line = $trfrm->SetHTMLMode('', 0) . '<hr>'; if ($m[1]) $line .= $trfrm->SetHTMLMode('p') . $m[1]; --- 604,608 ---- function wtm_hr($line, &$trfrm) { if (preg_match('/^-{4,}(.*)$/', $line, $m)) { ! $line = $trfrm->SetHTMLMode('', 0) . Element('hr'); if ($m[1]) $line .= $trfrm->SetHTMLMode('p') . $m[1]; |