nlopess Mon Apr 19 10:18:41 2004 EDT
Modified files:
/livedocs livedoc.php
Log:
fixing my crap: I hope that the message for outdated translations is bug free
http://cvs.php.net/diff.php/livedocs/livedoc.php?r1=1.89&r2=1.90&ty=u
Index: livedocs/livedoc.php
diff -u livedocs/livedoc.php:1.89 livedocs/livedoc.php:1.90
--- livedocs/livedoc.php:1.89 Sun Apr 18 12:30:50 2004
+++ livedocs/livedoc.php Mon Apr 19 10:18:41 2004
@@ -18,7 +18,7 @@
// | Generate an HTML version of a phpdoc/docbook page on the fly |
// +----------------------------------------------------------------------+
//
-// $Id: livedoc.php,v 1.89 2004/04/18 16:30:50 nlopess Exp $
+// $Id: livedoc.php,v 1.90 2004/04/19 14:18:41 nlopess Exp $
define('LIVEDOC_SOURCE', dirname(__FILE__));
include LIVEDOC_SOURCE . '/common.php';
@@ -97,7 +97,7 @@
handle_missing_index();
} else {
// load the content
- $page = load_xml_doc(BASE . $filename, false, FALLBACK_BASE .
$filename);
+ list($page, $lang_rev) = load_xml_doc(BASE . $filename, false,
FALLBACK_BASE . $filename, 1);
}
}
@@ -121,13 +121,7 @@
}
/* Checks if translated file is updated */
-if ($lang != 'en' && !isset($using_fallback)) {
-
- if (preg_match('/Revision: \d+\.(\d+)/', $file_revision, $matches)) {
- $lang_rev = $matches[1];
- } else {
- $lang_rev = 0;
- }
+if ($lang != 'en' && $lang_rev > 0) {
/* get english file revision */
$data = @file_get_contents(FALLBACK_BASE . $filename);
@@ -141,7 +135,9 @@
$link = FORCE_DYNAMIC ? WEBBASE . "index.php?l=en&q=$current_page" :
"en/$current_page.html";
echo '<div class="warning">The translation of this file is outdated. ';
echo "<a href ='$link'>Click here to read this file in
english.</a></div>";
- }
+ }
+
+ unset($data, $lang_rev, $en_rev, $matches, $link);
}
echo manual_page_footer();
@@ -324,9 +320,9 @@
/*****************************************************************************
* Helper functions for transformation
*/
-function &load_xml_doc($filename, $included = false, $fallback_filename = '')
+function &load_xml_doc($filename, $included = false, $fallback_filename = '',
$return_rev = 0)
{
- global $file_revision, $idx, $using_fallback;
+ global $file_revision, $idx, $lang;
$replace = array();
$search = array('æ', '©', 'é', 'è', 'à',
'ï', 'ö', 'ä', 'Ä',
@@ -336,14 +332,18 @@
}
$sanity = 0;
+ $lang_rev = 0;
+
$data = @file_get_contents($filename);
if (strlen($data) == 0 && strlen($fallback_filename)) {
$data = @file_get_contents($fallback_filename);
- $using_fallback = 1;
if (strlen($data) == 0) {
$data = "<warning>permissions problem for
$filename?</warning>";
}
+
+ } elseif ($lang != 'en' && preg_match('/<!-- EN-Revision: \d+\.(\d+)/', $data,
$matches)) {
+ $lang_rev = $matches[1];
}
/* get file revision */
@@ -353,6 +353,7 @@
/* strip comments */
$data = preg_replace('@<!--\s+.*\s-->@Usm', '', $data);
+
/* list the entities that are required */
$entities = array();
do {
@@ -398,7 +399,12 @@
$page = new DocBookToHTML($data);
- return $page;
+
+ if ($return_rev) {
+ return array($page, $lang_rev);
+ } else {
+ return $page;
+ }
}