r77921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77920‎ | r77921 | r77922 >
Date:22:11, 6 December 2010
Author:nhuffschmid
Status:deferred
Tags:
Comment:
update to hawhaw V5.25 with Windows Phone support
Modified paths:
  • /trunk/wap/hawhaw/hawhaw.inc (modified) (history)

Diff [purge]

Index: trunk/wap/hawhaw/hawhaw.inc
@@ -2,8 +2,8 @@
33
44 // HAWHAW: HTML and WML hybrid adapted webserver
55 // PHP class library
6 -// Copyright (C) 2008 Norbert Huffschmid
7 -// Last modified: 24. June 2008
 6+// Copyright (C) 2009 Norbert Huffschmid
 7+// Last modified: 6. December 2010
88 //
99 // This library is free software; you can redistribute it and/or modify it under the
1010 // terms of the GNU Library General Public License as published by the Free Software
@@ -20,12 +20,6 @@
2121 //
2222 // For further information about this library and its license terms please visit:
2323 // http://www.hawhaw.de/
24 -//
25 -// changes against V5.19:
26 -// - added support of Amazon Kindle device
27 -// - disabling of simulator supported
28 -// - improved detection of desktop browsers
29 -// - improved W3C mobileOK compliance
3024
3125 ###################################
3226 # BEGIN OF CONFIGURATION PART #
@@ -46,7 +40,7 @@
4741 ###################################
4842
4943 // miscellaneous constants
50 -define("HAW_HAW_VERSION", "HAWHAW V5.20B");
 44+define("HAW_HAW_VERSION", "HAWHAW V5.25");
5145 define("HAW_COPYRIGHT", "(C) Norbert Huffschmid");
5246 if (defined("HAW_TERA_WURFL_PATH"))
5347 define("HAW_VERSION", HAW_HAW_VERSION . "/Tera-WURFL");
@@ -552,7 +546,8 @@
553547 var $timeout;
554548 var $red_url;
555549 var $disable_cache = false;
556 - var $css = "";
 550+ var $css = ""; // css file
 551+ var $css_class = ""; // class of deck within css file
557552 var $ml;
558553 var $element = array();
559554 var $number_of_elements = 0;
@@ -578,7 +573,7 @@
579574 var $owgui_1_3 = false; // Openwave GUI Extensions for WML 1.3
580575 var $MMLstyle = false; // Mobile Markup Language
581576 var $lynx = false; // Lynx text browser
582 - var $iPhoneAlike = false; // iPhone, iPod Touch etc.
 577+ var $iPhoneAlike = false; // iPhone, iPod Touch, iPad etc.
583578 var $xhtml = false; // XHTML MP (mobile profile)
584579 var $gif_enabled = false; // browser can not deal with GIF images
585580 var $submitViaLink = false; // use link instead of <do>
@@ -594,7 +589,7 @@
595590 var $skin = ""; // contains css url, where skinning is defined
596591
597592 // character set properties
598 - var $charset = "iso-8859-1"; // default charset
 593+ var $charset = "utf-8"; // default charset
599594 var $unicodemaptab; // filename of cross mapping table to map country
600595 // specific character code into unicode
601596 var $unicodearray; // array containing cross mapping table
@@ -708,18 +703,18 @@
709704 // resp. other value defined above for HAW_OUTPUT_...
710705 // query parameter "hawoutput" can be used for overwrite output type
711706 // enter http://wap.yourdomain.com/yourscript.php?hawoutput=wap
712 - global $HTTP_GET_VARS;
 707+
713708 $forced_output = "";
714709
715 - if (isset ($HTTP_GET_VARS["hawdebug"]))
 710+ if (isset ($_GET["hawdebug"]))
716711 {
717 - $forced_output = $HTTP_GET_VARS["hawdebug"];
 712+ $forced_output = $_GET["hawdebug"];
718713 $this->debug = true;
719714 }
720 - elseif (isset ($HTTP_GET_VARS["hawoutput"]))
 715+ elseif (isset ($_GET["hawoutput"]))
721716 {
722 - $forced_output = $HTTP_GET_VARS["hawoutput"];
723 - $this->hawoutput = $HTTP_GET_VARS["hawoutput"];
 717+ $forced_output = $_GET["hawoutput"];
 718+ $this->hawoutput = $_GET["hawoutput"];
724719 }
725720 elseif ($output != HAW_OUTPUT_AUTOMATIC)
726721 $forced_output = $output;
@@ -801,8 +796,8 @@
802797
803798 if (strstr($HTTP_USER_AGENT, "(iPhone") ||
804799 strstr($HTTP_USER_AGENT, "(iPod") ||
805 - strstr($HTTP_USER_AGENT, "(Aspen Simulator") ||
806 - strstr($HTTP_USER_AGENT, "Android") )
 800+ strstr($HTTP_USER_AGENT, "(iPad") ||
 801+ strstr($HTTP_USER_AGENT, "(Aspen Simulator"))
807802 $this->iPhoneAlike = true;
808803
809804 if (defined("HAW_TERA_WURFL_PATH") && !$forced_output)
@@ -1170,7 +1165,8 @@
11711166 Mapping tables are available at:
11721167 <a href="http://www.unicode.org/Public/MAPPINGS/" target="_blank">
11731168 http://www.unicode.org/Public/MAPPINGS/</a>
1174 - @param charset Character set that is used in your country.<br>Default: iso-8859-1
 1169+ @param charset Character set used.<br>
 1170+ Default: utf-8 (until hawhaw.inc V5.19: iso-8859-1)
11751171 @param unicodemaptab (optional)<br>
11761172 Cross mapping table from country specific character coding to
11771173 unicode (default: no mapping to unicode activated).<br>
@@ -1254,6 +1250,16 @@
12551251
12561252
12571253 /**
 1254+ Sets a css class for this object in a (X)HTML page.
 1255+ @param css_class CSS class to be defined in the deck's central CSS file
 1256+ */
 1257+ function set_css_class($css_class)
 1258+ {
 1259+ $this->css_class = $css_class;
 1260+ }
 1261+
 1262+
 1263+ /**
12581264 Sets a window wallpaper for a HTML (big-screen browser) page.
12591265 Has no effect on WML/handheld pages.
12601266 @param background e.g. "backgrnd.gif"
@@ -1688,12 +1694,14 @@
16891695 {
16901696 global $haw_license_holder;
16911697 global $haw_license_domain;
 1698+ global $haw_license_key;
16921699 global $haw_signature;
16931700 global $haw_sig_text;
16941701 global $haw_sig_link;
16951702
16961703 // add hawoutput query parameter to redirection url, if required
1697 - HAW_handle_forced_output($this->red_url, $this->hawoutput);
 1704+ if ($this->red_url)
 1705+ HAW_handle_forced_output($this->red_url, $this->hawoutput);
16981706
16991707 if ($this->debug)
17001708 header("content-type: text/plain");
@@ -1773,6 +1781,12 @@
17741782 printf("<meta name=\"GENERATOR\" content=\"%s (PHP) %s%s\" %s\n",
17751783 HAW_VERSION, HAW_COPYRIGHT, $license, $endtag);
17761784
 1785+ if ($this->desktopBrowser && isset($haw_license_key))
 1786+ {
 1787+ printf("<meta name=\"LICENSE_KEY\" content=\"%s\" %s\n",
 1788+ $haw_license_key, $endtag);
 1789+ }
 1790+
17771791 if ($this->timeout > 0)
17781792 {
17791793 printf("<meta http-equiv=\"refresh\" content=\"%d; URL=%s\" %s\n",
@@ -1939,7 +1953,13 @@
19401954 {
19411955 // use skin design
19421956 echo "<div id=\"skin\">\n";
1943 - echo "<div id=\"display\">\n";
 1957+
 1958+ if ($this->css_class)
 1959+ $class_param = " class=\"" . $this->css_class . "\"";
 1960+ else
 1961+ $class_param = "";
 1962+
 1963+ printf("<div id=\"display\"%s>\n", $class_param);
19441964 }
19451965 else if ($this->use_simulator == HAW_SIM_CLASSIC)
19461966 {
@@ -2187,7 +2207,30 @@
21882208 if ($this->ml == HAW_HTML)
21892209 {
21902210 if ($this->css_enabled)
2191 - printf("<div id=\"canvas\" style=\"%s\">\n", $divstyle);
 2211+ {
 2212+ if ($this->css_class)
 2213+ {
 2214+ $class = $this->css_class;
 2215+
 2216+ if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], " MSIE "))
 2217+ $class .= " peekaboo"; // CSS hook for peekaboo handling
 2218+ }
 2219+ else
 2220+ {
 2221+ if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], " MSIE "))
 2222+ $class = "peekaboo";
 2223+ else
 2224+ $class = "";
 2225+ }
 2226+
 2227+ if ($class)
 2228+ $class_param = " class=\"" . $class . "\"";
 2229+ else
 2230+ $class_param = "";
 2231+
 2232+ printf("<div id=\"canvas\" style=\"%s\"%s>\n", $divstyle, $class_param);
 2233+ echo "<span id=\"hawcsshook1\"></span>\n"; // universal CSS hook for toolbars etc.
 2234+ }
21922235 else
21932236 printf("<div id=\"canvas\" align=\"%s\">\n", $this->alignment);
21942237 }
@@ -2232,10 +2275,10 @@
22332276 // IF YOU DO SO, YOU ARE VIOLATING THE LICENSE TERMS
22342277 // OF THIS SOFTWARE! YOU HAVE TO PAY NOTHING FOR THIS
22352278 // SOFTWARE, SO PLEASE BE SO FAIR TO ACCEPT THE RULES.
2236 - // IF YOU DON'T, YOUR WEBSITE WILL AT LEAST BE LISTED IN
2237 - // THE HAWHAW HALL OF SHAME!
 2279+ //
22382280 // PLEASE REFER TO THE LIBRARY HEADER AND THE HAWHAW
2239 - // HOMEPAGE FOR MORE INFORMATION.
 2281+ // HOMEPAGE FOR MORE INFORMATION:
 2282+ // http://www.hawhaw.de/#license
22402283
22412284 echo "</div>\n";
22422285
@@ -2274,10 +2317,7 @@
22752318 $this->waphome, $default_text);
22762319
22772320 if ($signature && ($this->use_simulator == HAW_SIM_NONE))
2278 - {
2279 - echo "<hr width=\"150px\"/>\n"; // seperate content from signature
2280 - printf("<span style=\"font-size:8pt;\">%s</span>\n", $signature);
2281 - }
 2321+ printf("<br /><span style=\"font-size:8pt;\">%s</span>\n", $signature);
22822322 else
22832323 echo $signature;
22842324 }
@@ -2374,6 +2414,7 @@
23752415 strstr($ua_low, "o2imode") ||
23762416 strstr($ua_low, "opera ") ||
23772417 strstr($ua_low, "reqwirelessweb") ||
 2418+ strstr($acc_low, "xhtml+xml") ||
23782419 strstr($acc_low, "vnd.wap.xhtml"))
23792420 {
23802421 $this->ml = HAW_HTML; // create HTML (even when device accepts text/vnd.wap.wml too!)
@@ -2446,10 +2487,12 @@
24472488 strstr($HTTP_USER_AGENT, "Firefox") ||
24482489 strstr($HTTP_USER_AGENT, "Macintosh") || // Safari desktop browser
24492490 strstr($HTTP_USER_AGENT, "Iceweasel") ||
 2491+ strstr($HTTP_USER_AGENT, "Chrome") ||
24502492 strstr($HTTP_USER_AGENT, "Konqueror") ||
24512493 strstr($HTTP_USER_AGENT, "Opera")) // can be Opera Mini!
24522494 {
24532495 $this->desktopBrowser = true;
 2496+ $this->css_enabled = true;
24542497 $this->display_banners = true;
24552498 }
24562499
@@ -2459,6 +2502,7 @@
24602503 (strstr($ua_low, "symbianos") && strstr($acc_low, "xhtml+xml")) ||
24612504 ($this->iPhoneAlike == true) ||
24622505 strstr($HTTP_USER_AGENT, "(Linux; U; Android") ||
 2506+ strstr($HTTP_USER_AGENT, "Windows Phone OS") ||
24632507 strstr($HTTP_USER_AGENT, "Kindle/"))
24642508 {
24652509 // XHTML device detected
@@ -2485,6 +2529,7 @@
24862530 {
24872531 // PDA browser detected (or poor old Netscape 4.7x which messes with CSS)
24882532 $this->PDAstyle = true;
 2533+ $this->css_enabled = false;
24892534 $this->desktopBrowser = false;
24902535 $this->display_banners = false;
24912536 }
@@ -2512,13 +2557,6 @@
25132558 $this->xhtmlmp_preferred_mime_type = "text/html";
25142559 }
25152560
2516 - // determine if browser is CSS-enbled
2517 - if (($this->ml == HAW_HTML) &&
2518 - (strstr($HTTP_USER_AGENT, "MSIE") ||
2519 - strstr($HTTP_USER_AGENT, "Mozilla") ||
2520 - strstr($HTTP_USER_AGENT, "Opera")))
2521 - $this->css_enabled = true;
2522 -
25232561 // determine if browser is able to display GIF images
25242562 if (($this->ml == HAW_HTML) ||
25252563 (strstr($acc_low, "image/gif")) ||
@@ -2606,8 +2644,11 @@
26072645 else
26082646 {
26092647 // treat it as normal web browser
 2648+ $this->desktopBrowser = true;
26102649 $this->ml = HAW_HTML;
 2650+ $this->xhtml = true;
26112651 $this->css_enabled = true;
 2652+ $this->display_banners = true;
26122653 }
26132654 }
26142655
@@ -3248,6 +3289,11 @@
32493290 {
32503291 // HTML or WML
32513292
 3293+ if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
 3294+ {
 3295+ printf("<span class=\"%s\">\n", $this->css_class);
 3296+ }
 3297+
32523298 if (($this->attrib & HAW_TEXTFORMAT_BOXED) && ($deck->ml == HAW_HTML))
32533299 {
32543300 // determine text and background color, if not already assigned
@@ -3278,7 +3324,7 @@
32793325 if ($this->br >= 1)
32803326 $this->br--;
32813327 }
3282 -
 3328+
32833329 if ($this->attrib & HAW_TEXTFORMAT_BOLD)
32843330 echo "<b>\n";
32853331
@@ -3307,20 +3353,10 @@
33083354 printf("<font color=\"%s\">", $this->color);
33093355 }
33103356
3311 - if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
3312 - {
3313 - printf("<span class=\"%s\">\n", $this->css_class);
3314 - }
3315 -
33163357 // print text
33173358 if (isset($this->text))
33183359 printf("%s\n", HAW_specchar($this->text, $deck));
33193360
3320 - if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
3321 - {
3322 - echo "</span>\n";
3323 - }
3324 -
33253361 if (($deck->ml == HAW_HTML) && $this->color)
33263362 {
33273363 if ($deck->css_enabled)
@@ -3360,6 +3396,9 @@
33613397 // create required amount of carriage return's
33623398 for ($i=0; $i < $this->br; $i++)
33633399 echo "<br />\n";
 3400+
 3401+ if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
 3402+ echo "</span>\n";
33643403 }
33653404 elseif($deck->ml == HAW_VXML)
33663405 {
@@ -4227,11 +4266,23 @@
42284267
42294268 function create(&$deck)
42304269 {
 4270+ $class_param = "";
 4271+
42314272 if ($this->type == HAW_INPUT_PASSWORD)
 4273+ {
42324274 $type = "type=\"password\"";
 4275+
 4276+ if ($deck->css_enabled)
 4277+ $class_param = " class=\"hawinputpassword\"";
 4278+ }
42334279 else
 4280+ {
42344281 $type = "type=\"text\"";
4235 -
 4282+
 4283+ if ($deck->css_enabled)
 4284+ $class_param = " class=\"hawinputtext\"";
 4285+ }
 4286+
42364287 if ($this->size)
42374288 $size = sprintf("size=\"%d\"", $this->size);
42384289 else
@@ -4266,14 +4317,14 @@
42674318 {
42684319 printf("<label for=\"%s\">%s</label>\n",
42694320 $this->name, HAW_specchar($this->label, $deck));
4270 - printf("<input %s name=\"%s\" id=\"%s\" value=\"%s\" %s %s%s /> ",
 4321+ printf("<input %s name=\"%s\" id=\"%s\" value=\"%s\" %s %s%s%s /> ",
42714322 $type, $this->name,
4272 - $this->name, $this->value, $size, $maxlength, $mode);
 4323+ $this->name, $this->value, $size, $maxlength, $mode, $class_param);
42734324 }
42744325 else
4275 - printf("%s <input %s name=\"%s\" value=\"%s\" %s %s%s /> ",
 4326+ printf("%s <input %s name=\"%s\" value=\"%s\" %s %s%s%s /> ",
42764327 HAW_specchar($this->label, $deck), $type,
4277 - $this->name, $this->value, $size, $maxlength, $mode);
 4328+ $this->name, $this->value, $size, $maxlength, $mode, $class_param);
42784329
42794330 for ($i=0; $i < $this->br; $i++)
42804331 echo "<br />\n";
@@ -4833,6 +4884,7 @@
48344885 $this->name = $name;
48354886 $this->value = "";
48364887 $this->number_of_buttons = 0;
 4888+ $this->buttons = array();
48374889 $this->voice_text = HAW_VOICE_ENUMERATE;
48384890 $this->voice_audio_src = "";
48394891 $this->voice_help = array();
@@ -5361,7 +5413,7 @@
53625414 {
53635415 var $label;
53645416 var $name;
5365 -
 5417+
53665418 /**
53675419 Constructor
53685420 @param label What's written on the button.
@@ -5397,7 +5449,7 @@
53985450
53995451 $name = ($this->name ? "name=\"" . "$this->name" ."\"" : "");
54005452
5401 - printf("<input type=\"submit\" %s value=\"%s\" /><br />\n", $name,
 5453+ printf("<input type=\"submit\" %s value=\"%s\" id=\"hawinputsubmit\" /><br />\n", $name,
54025454 HAW_specchar($this->label, $deck));
54035455
54045456 }
@@ -5907,6 +5959,7 @@
59085960 var $title;
59095961 var $accesskey; // "1", "2", ... "0", "*", "#"
59105962 var $image;
 5963+ var $css_class;
59115964 var $br;
59125965 var $voice_text;
59135966 var $voice_audio_src;
@@ -5938,6 +5991,7 @@
59395992 $this->title = $title;
59405993 $this->accesskey = HAW_NO_ACCESSKEY;
59415994 $this->image = false;
 5995+ $this->css_class = "";
59425996 $this->br = 1; // default: 1 line break
59435997 $this->voice_text = $destination;
59445998 $this->voice_audio_src = "";
@@ -5956,6 +6010,15 @@
59576011 }
59586012
59596013 /**
 6014+ Sets a css class for this object in a (X)HTML page.
 6015+ @param css_class CSS class to be defined in the deck's central CSS file
 6016+ */
 6017+ function set_css_class($css_class)
 6018+ {
 6019+ $this->css_class = $css_class;
 6020+ }
 6021+
 6022+ /**
59606023 Sets the number of line breaks (CRLF) after phone link. (default: 1)
59616024 @param br Some number of line breaks.
59626025 */
@@ -6065,6 +6128,11 @@
60666129 $dest = $this->destination;
60676130 }
60686131
 6132+ if ($deck->css_enabled && $this->css_class)
 6133+ {
 6134+ printf("<span class=\"%s\">\n", $this->css_class);
 6135+ }
 6136+
60696137 if ($deck->link_brackets == true)
60706138 echo "[";
60716139
@@ -6074,13 +6142,20 @@
60756143 // image available for this link, let it create itself
60766144 $this->image->create($deck);
60776145
6078 - printf("%s</a>", HAW_specchar($this->label, $deck));
6079 -
 6146+ if ($deck->css_enabled)
 6147+ printf("<span class=\"hawphonelabel\">%s</span></a>", HAW_specchar($this->label, $deck));
 6148+ else
 6149+ printf("%s</a>", HAW_specchar($this->label, $deck));
 6150+
60806151 if ($deck->link_brackets == true)
60816152 echo "]";
60826153
60836154 printf("%s\n", $br);
60846155
 6156+ if ($deck->css_enabled && $this->css_class)
 6157+ {
 6158+ echo "</span>\n";
 6159+ }
60856160 }
60866161 elseif ($deck->ml == HAW_WML)
60876162 {
@@ -6303,6 +6378,14 @@
63046379 $this->number_of_elements++;
63056380 }
63066381
 6382+ function add_link_without_reference($link)
 6383+ {
 6384+ // workaround for Phalanger duck-typing issue
 6385+ $this->add_link($link);
 6386+
 6387+ return $link->get_accesskey();
 6388+ }
 6389+
63076390 /**
63086391 Sets text to be spoken by voice browsers. <br>
63096392 @param text Some alternative text that precedes the enumeration of link &lt;label&gt;s.
@@ -6334,8 +6417,8 @@
63356418 {
63366419 // create links inside a frame
63376420
6338 - echo "<div id=\"hawlinkset\" style=\"padding: 5px;\">\n";
6339 -
 6421+ echo "<div id=\"hawlinkset\">\n";
 6422+
63406423 if ($deck->lynx)
63416424 {
63426425 // create link list to avoid whitespace between links

Status & tagging log