wez Mon May 10 06:20:42 2004 EDT
Modified files: /livedocs common.php style_mapping.php /livedocs/themes/default html_format.php /livedocs/themes/php.net html_format.php /livedocs/themes/smarty html_format.php Log: RTL patch by Moshe Doron.
http://cvs.php.net/diff.php/livedocs/common.php?r1=1.12&r2=1.13&ty=u Index: livedocs/common.php diff -u livedocs/common.php:1.12 livedocs/common.php:1.13 --- livedocs/common.php:1.12 Tue May 4 21:37:03 2004 +++ livedocs/common.php Mon May 10 06:20:42 2004 @@ -18,7 +18,7 @@ // | Common PHP header, with some basic settings | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.12 2004/05/05 01:37:03 wez Exp $ +// $Id: common.php,v 1.13 2004/05/10 10:20:42 wez Exp $ set_magic_quotes_runtime(0); /*$compare = version_compare(phpversion(), '5.0.0RC1'); @@ -84,4 +84,16 @@ } +$rtl_langs = array('he'=>true,'ar'=>true); +if(isset($rtl_langs[$lang])) { + define('RTL', ' dir="rtl"'); + define('LTR', ' dir="ltr"'); +} else { + define('RTL', ''); + define('LTR', ''); +} + +$chars = array( 'he'=>'windows-1255', + 'en'=>'iso-8859-1'); +define('CHARSET', isset($chars[$lang]) ? $chars[$lang] : 'iso-8859-1'); ?> http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.13&r2=1.14&ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.13 livedocs/style_mapping.php:1.14 --- livedocs/style_mapping.php:1.13 Sat May 8 05:20:43 2004 +++ livedocs/style_mapping.php Mon May 10 06:20:42 2004 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +----------------------------------------------------------------------+ // -// $Id: style_mapping.php,v 1.13 2004/05/08 09:20:43 wez Exp $ +// $Id: style_mapping.php,v 1.14 2004/05/10 10:20:42 wez Exp $ // almost XPATH.. ;-) $map = array( @@ -149,7 +149,6 @@ $holder = $child->content; } } - return sprintf('<div class="copyright">' . bind_entities('&livedocs.copyright;') . '</div>', implode(", ", $y), $holder); } @@ -199,31 +198,33 @@ function format_parameter($node) { - return sprintf('<span class="%s">$%s</span>', $node->tagname, $node->content); + return sprintf('<span class="%s">$%s</span>', $node->tagname, htmlspecialchars($node->content, ENT_NOQUOTES)); } function format_pubdate($node) { - return sprintf('<div class="%s">Published on: %s</div>', $node->tagname, $node->content); + return sprintf('<div class="%s">Published on: %s</div>', $node->tagname, htmlspecialchars($node->content, ENT_NOQUOTES)); } function format_ulink($node) { - return sprintf('<a target="_blank" class="ulink" href="%s">%s</a>', + $dir = (RTL && !ereg("([à-ú]+)",$node->content)) ? LTR : ""; + return sprintf('<a target="_blank" class="ulink" href="%s"%s>%s</a>', $node->attributes['url'], - $node->content + $dir, + htmlspecialchars($node->content, ENT_NOQUOTES) ); } function format_warning_title($node) { - return sprintf('<span class="warning_title">%s</span>', $node->content); + return sprintf('<span class="warning_title">%s</span>', htmlspecialchars($node->content, ENT_NOQUOTES)); } function format_link($node) { global $lang; - + $caption = $node->content; if (strlen($caption) == 0) { $caption = lookup_title($node->attributes['linkend']); @@ -232,9 +233,14 @@ $caption = $node->attributes['linkend']; } $url = generate_url_for_id($lang, $node->attributes['linkend']); - return sprintf('<a class="%s" href="%s">%s</a>', + $dir=''; + if(isset($node->attributes['dir'])) { + $dir = ' dir="'.$node->attributes['dir'].'"'; + } + return sprintf('<a class="%s" href="%s"%s>%s</a>', $node->tagname, $url, + $dir, $caption ); } @@ -257,16 +263,17 @@ } else { $dest = 'function.' . $itemid; } - + if ($current_page == $dest) { - return sprintf('<span class="%s">%s()</span>', $class, $node->content); + return sprintf('<span class="%s"%s>%s()</span>', $class, LTR, $node->content); } $url = generate_url_for_id($lang, $dest); - return sprintf('<a class="%s" href="%s">%s()</a>', + return sprintf('<a class="%s" href="%s"%s>%s()</a>', $class, $url, - $node->content + LTR, + htmlspecialchars($node->content, ENT_NOQUOTES) ); } @@ -282,7 +289,6 @@ function format_listing($node) { $content = trim($node->content); - if (substr($content, 0, 5) == '<?php') { $node->attributes['role'] = 'php'; } @@ -292,7 +298,6 @@ switch ($node->attributes['role']) { case 'php': - // Small hack because highlight_string has changed its behaviour in PHP 5 RC1 if (version_compare(phpversion(), '5.0.0RC1') == -1){ $content = preg_replace(array( @@ -325,13 +330,12 @@ case 'html': case 'xml': case 'c': - $content = '<pre>' . htmlentities($content) . '</pre>'; + $content = '<pre>' . htmlspecialchars($content) . '</pre>'; break; default: $content = htmlspecialchars($content); } - - return sprintf('<div class="%scode">%s</div>', $node->attributes['role'], $content); + return sprintf('<div class="%scode"%s>%s</div>', $node->attributes['role'], LTR, $content); } function format_params($node) @@ -405,8 +409,7 @@ $params .= $p; } - - return "<div class=\"methodsynopsis\"><span class=\"type\">$type</span> <span class=\"function\">$fname(</span>$params$optclose<span class=\"function\">)</span></div>"; + return "<div".LTR." class=\"methodsynopsis\"><span class=\"type\">$type</span> <span class=\"function\">$fname(</span>$params$optclose<span class=\"function\">)</span></div>"; } function format_class_synopsis($node) @@ -555,4 +558,23 @@ return $html . "</div>"; } -?> + +if(RTL) { + $map['emphasis'] = 'format_em'; + $map['literal'] = 'format_ltr_span'; + $map['option'] = 'format_ltr_span'; + $map['term'] = 'format_ltr_span'; + $map['varname'] = 'format_ltr_span'; + $map['filename'] = 'format_ltr_span'; + + function format_em($node) + { + return sprintf('<em class="%s" dir="ltr">%s</em>', $node->tagname, htmlspecialchars($node->content, ENT_NOQUOTES)); + } + + function format_ltr_span($node) + { + return sprintf('<span class="%s" dir="ltr">%s</span>', $node->tagname, htmlspecialchars($node->content, ENT_NOQUOTES)); + } +} +?> \ No newline at end of file http://cvs.php.net/diff.php/livedocs/themes/default/html_format.php?r1=1.7&r2=1.8&ty=u Index: livedocs/themes/default/html_format.php diff -u livedocs/themes/default/html_format.php:1.7 livedocs/themes/default/html_format.php:1.8 --- livedocs/themes/default/html_format.php:1.7 Sun Mar 21 10:06:55 2004 +++ livedocs/themes/default/html_format.php Mon May 10 06:20:42 2004 @@ -18,22 +18,25 @@ // | headers and footers for the HTML rendering | // +----------------------------------------------------------------------+ // -// $Id: html_format.php,v 1.7 2004/03/21 15:06:55 didou Exp $ +// $Id: html_format.php,v 1.8 2004/05/10 10:20:42 wez Exp $ // in livedoc.php function manual_page_header() { global $lang, $title, $css_url; + $charset = CHARSET; + $dir = RTL; $head =<<<HEAD <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="$lang"> <head> +<meta http-equiv="Content-Type" content="text/html; charset="$charset"/> <title>$title</title> <link rel="stylesheet" href="$css_url" /> </head> -<body> +<body $dir> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td height="1"></td><td rowspan="2" valign="top"> HEAD; http://cvs.php.net/diff.php/livedocs/themes/php.net/html_format.php?r1=1.9&r2=1.10&ty=u Index: livedocs/themes/php.net/html_format.php diff -u livedocs/themes/php.net/html_format.php:1.9 livedocs/themes/php.net/html_format.php:1.10 --- livedocs/themes/php.net/html_format.php:1.9 Sun Mar 21 10:08:11 2004 +++ livedocs/themes/php.net/html_format.php Mon May 10 06:20:42 2004 @@ -18,7 +18,7 @@ // | headers and footers for the HTML rendering | // +----------------------------------------------------------------------+ // -// $Id: html_format.php,v 1.9 2004/03/21 15:08:11 didou Exp $ +// $Id: html_format.php,v 1.10 2004/05/10 10:20:42 wez Exp $ // in livedoc.php define( @@ -30,11 +30,14 @@ function manual_page_header() { global $lang, $title, $css_url, $nav; + $charset = CHARSET; + $dir = RTL; $head =<<<HEAD <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="$lang"> <head> +<meta http-equiv="Content-Type" content="text/html; charset="$charset"/> <title>PHP: $title - Manual</title> <link rel="stylesheet" href="/style.css" /> <link rel="stylesheet" href="/styles/mirror.css" /> @@ -42,7 +45,7 @@ <link rel="shortcut icon" href="/favicon.ico" /> <script language="Javascript" type="text/javascript" src="/userprefs.js" /> </head> -<body> +<body $dir> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#9999cc"> <td align="center" rowspan="2" width="126"><a href="/"><img src="/images/php.gif" alt="PHP" width="120" height="67" hspace="3" /></a></td> http://cvs.php.net/diff.php/livedocs/themes/smarty/html_format.php?r1=1.1&r2=1.2&ty=u Index: livedocs/themes/smarty/html_format.php diff -u livedocs/themes/smarty/html_format.php:1.1 livedocs/themes/smarty/html_format.php:1.2 --- livedocs/themes/smarty/html_format.php:1.1 Tue Apr 20 16:59:31 2004 +++ livedocs/themes/smarty/html_format.php Mon May 10 06:20:42 2004 @@ -18,7 +18,7 @@ // | headers and footers for the HTML rendering | // +----------------------------------------------------------------------+ // -// $Id: html_format.php,v 1.1 2004/04/20 20:59:31 didou Exp $ +// $Id: html_format.php,v 1.2 2004/05/10 10:20:42 wez Exp $ // in livedoc.php $WEBSITE = 'http://smarty.php.net'; @@ -26,12 +26,15 @@ function manual_page_header() { global $lang, $title, $css_url, $nav, $WEBSITE; + $charset = CHARSET; + $dir = RTL; $date = strftime("%A, %B %d, %Y"); $head =<<<HEAD <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="$lang"> <head> +<meta http-equiv="Content-Type" content="text/html; charset="$charset"/> <title>Smarty: $title - Manual</title> <link rel="stylesheet" href="$css_url" /> <link rel="stylesheet" href="$WEBSITE/style.css" /> @@ -94,7 +97,7 @@ </table> -<table cellpadding="0" cellspacing="0"> +<table cellpadding="0" cellspacing="0" $dir> <tr valign="top"> <td bgcolor="#f0ead8"> <table width="170" cellpadding="4" cellspacing="0">