Update of /cvsroot/phpweather/phpweather/output
In directory usw-pr-cvs1:/tmp/cvs-serv28913/output
Modified Files:
pw_text.php
Log Message:
Rewrite to accommodate for the charset header. pw_text::print_pretty()
does no longer output anything, instead it returns a string with the
output. Perhaps it should be renamed, since 'print' implies that it
generates output?
Index: pw_text.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- pw_text.php 27 Mar 2002 15:13:40 -0000 1.6
+++ pw_text.php 28 Mar 2002 15:49:09 -0000 1.7
@@ -42,25 +42,32 @@
* use one of it's subclasses such as pw_text_en, pw_text_da, or
* another language.
*
- * The constructor in the subclass will finish off by calling this
- * constructor. At that time, there should be a 'charset' entry in
- * the $strings array. This entry will be placed in the global
- * namespace so that things outside of PHP Weather can send the
- * right header to the browser.
- *
- * @param phpweather The object with the weather.
+ * @param phpweather The object with the weather.
* @access public
*/
function pw_text($w, $input) {
- /* The charset should be part of the $strings array. We set it
- * globally so that the outside world can react on it. */
-
- $GLOBALS['charset'] = $this->strings['charset'];
$this->weather = $w;
/* We call the parent constructor. */
$this->base_object($input);
}
+
+ /**
+ * Returns the character encoding used in the current language.
+ *
+ * This information should be used to send a HTTP header to the
+ * browser like this, where $charset has been set by calling this
+ * method:
+ *
+ * header("Content-Type: text/html; charset=$charset");
+ *
+ * @return string The character encoding, e.g. ISO-8859-1 for
+ * Western languages, ISO-8859-2 for Central European languages and
+ * so on.
+ */
+ function get_charset() {
+ return $this->strings['charset'];
+ }
/**
* Sets the marks (the strings inserted before and after every number)
@@ -1103,25 +1110,8 @@
/*
* This is where we make the HTML output.
*/
-
- echo '<!-- Generated by PHP Weather ' . $this->version . " -->\n";
-
- if (defined('DEBUG')) {
- while (list($key, $val) = each($output)) {
- echo "<p><i>$key</i>: $val</p>";
- }
-
- echo "<pre>\n";
- print_r ($data);
- echo "</pre>\n";
- } else {
- print "<blockquote>\n";
- while (list($key, $val) = each($output)) {
- echo $val . "\n";
- }
- print "</blockquote>\n";
- }
- return 0;
+ return '<!-- Generated by PHP Weather ' . $this->version . " -->\n" .
+ implode("\n", $output);
}
|