r27302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r27301‎ | r27302 | r27303 >
Date:19:43, 7 November 2007
Author:nhuffschmid
Status:old
Tags:
Comment:
update to newest hawhaw.inc version
Modified paths:
  • /trunk/wap/hawhaw/hawhaw.inc (modified) (history)

Diff [purge]

Index: trunk/wap/hawhaw/hawhaw.inc
@@ -3,7 +3,7 @@
44 // HAWHAW: HTML and WML hybrid adapted webserver
55 // PHP class library
66 // Copyright (C) 2007 Norbert Huffschmid
7 -// Last modified: 11. April 2007
 7+// Last modified: 7. November 2007
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
@@ -13,7 +13,7 @@
1414 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
1515 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1616 // PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
17 -// http://www.gnu.org/copyleft/lgpl.html
 17+// http://www.gnu.org/copyleft/library.html
1818 //
1919 // If you modify this library, you have to make sure that the "powered by HAWHAW"
2020 // copyright link below the display area is kept unchanged.
@@ -21,15 +21,34 @@
2222 // For further information about this library and its license terms please visit:
2323 // http://www.hawhaw.de/
2424 //
25 -// modifications against V5.13:
26 -// - bugfix: no VoiceXML timeout for non-triggerable HAW_phone objects
27 -// - new feature: dotmobi compliance
28 -// - optimization: create "submit links" for Nokia WAP browsers
29 -// - bugfix: "0"-string in add_option() and add_button()
 25+// changes against V5.15:
 26+// - optimization: consider HTTP_UA_OS header in browser detection
3027
 28+###################################
 29+# BEGIN OF CONFIGURATION PART #
 30+###################################
 31+
 32+# path to your TeraWurfl installation (if any)
 33+# http://www.tera-wurfl.com/
 34+# Tera-WURFL can be used OPTIONALLY for improved device detection
 35+# recommended settings in tera_wurfl_config.php:
 36+# define("MATCH_TO_UA_PREFIX", false);
 37+# define("RETURN_GENERIC", true);
 38+# un-comment and adapt the following define statement
 39+# in order to activate Tera-WURFL usage
 40+//define("HAW_TERA_WURFL_PATH", "../TeraWurfl");
 41+
 42+###################################
 43+# END OF CONFIGURATION PART #
 44+###################################
 45+
3146 // miscellaneous constants
32 -define("HAW_VERSION", "HAWHAW V5.14B");
 47+define("HAW_HAW_VERSION", "HAWHAW V5.16B");
3348 define("HAW_COPYRIGHT", "(C) Norbert Huffschmid");
 49+if (defined("HAW_TERA_WURFL_PATH"))
 50+ define("HAW_VERSION", HAW_HAW_VERSION . "/Tera-WURFL");
 51+else
 52+ define("HAW_VERSION", HAW_HAW_VERSION);
3453
3554 // constants for markup languages
3655 define("HAW_HTML", 1);
@@ -523,13 +542,14 @@
524543 var $timeout;
525544 var $red_url;
526545 var $disable_cache = false;
 546+ var $css = "";
527547 var $ml;
528548 var $element = array();
529 - var $number_of_elements;
530 - var $number_of_forms;
531 - var $number_of_linksets;
532 - var $number_of_links;
533 - var $number_of_phones;
 549+ var $number_of_elements = 0;
 550+ var $number_of_forms = 0;
 551+ var $number_of_linksets = 0;
 552+ var $number_of_links = 0;
 553+ var $number_of_phones = 0;
534554 var $top_banners;
535555 var $number_of_top_banners = 0;
536556 var $bottom_banners;
@@ -646,7 +666,12 @@
647667 else
648668 $HTTP_ACCEPT = "";
649669
650 - if (isset($_SERVER['HTTP_HOST']))
 670+ if (isset($_SERVER['HTTP_UA_OS']))
 671+ $HTTP_UA_OS = $_SERVER['HTTP_UA_OS'];
 672+ else
 673+ $HTTP_UA_OS = "";
 674+
 675+ if (isset($_SERVER['HTTP_HOST']))
651676 $HTTP_HOST = $_SERVER['HTTP_HOST'];
652677 else
653678 $HTTP_HOST = "";
@@ -755,154 +780,14 @@
756781 }
757782 }
758783
759 - // determine markup language to create
760 -
761 - if (strstr(strtolower($HTTP_USER_AGENT), "docomo") ||
762 - strstr(strtolower($HTTP_USER_AGENT), "portalmmm") ||
763 - strstr(strtolower($HTTP_USER_AGENT), "o2imode") ||
764 - strstr(strtolower($HTTP_USER_AGENT), "opera ") ||
765 - strstr(strtolower($HTTP_USER_AGENT), "reqwirelessweb") ||
766 - strstr(strtolower($HTTP_ACCEPT), "vnd.wap.xhtml"))
 784+ if (defined("HAW_TERA_WURFL_PATH") && !$forced_output)
767785 {
768 - $this->ml = HAW_HTML; // create HTML (even when device accepts text/vnd.wap.wml too!)
 786+ $this->determine_capabilities_terawurfl();
769787 }
770 - elseif (strstr(strtolower($HTTP_ACCEPT), "text/vnd.wap.wml"))
771 - {
772 - $this->ml = HAW_WML; // create WML
773 -
774 - if (strstr($HTTP_USER_AGENT, "UP/") ||
775 - strstr($HTTP_USER_AGENT, "UP.B"))
776 - $this->upbrowser = true; // UP browser
777 -
778 - if ((strstr($HTTP_USER_AGENT, "UP/") ||
779 - strstr($HTTP_USER_AGENT, "UP.B")) &&
780 - strstr($HTTP_USER_AGENT, "GUI") &&
781 - strstr($HTTP_USER_AGENT, "UP.Link")) // Non-UP.Link gateways sometimes have problems!
782 - $this->owgui_1_3 = true; // device accepts Openwave GUI extensions for WML 1.3
783 - }
784 - elseif (strstr(strtolower($HTTP_ACCEPT), "hdml;version=3.")) // HDML 3.0 and 3.1
785 - $this->ml = HAW_HDML; // create HDML
786 - elseif (strstr(strtolower($HTTP_ACCEPT), "vxml") || // VoiceXML signalled in accept header
787 - strstr(strtolower($HTTP_ACCEPT), "voicexml") || // alternative accept header
788 - strstr($HTTP_USER_AGENT, "OpenVXI") || // Speechworks OpenVXI
789 - strstr(strtolower($HTTP_USER_AGENT), "publicvoicexml") || // PublicVoiceXML voice browser
790 - strstr(strtolower($HTTP_USER_AGENT), "hastenix") || // hawhaw asterisk adapter
791 - strstr($HTTP_USER_AGENT, "Tellme")) // Tellme studio voice browser
792 - {
793 - $this->ml = HAW_VXML; // create VoiceXML
794 -
795 - // PublicVoiceXML browser cannot handle <break> elements!!!
796 - if (strstr(strtolower($HTTP_USER_AGENT), "publicvoicexml"))
797 - {
798 - $this->supportsVXMLBreakTag = false;
799 - }
800 -
801 - // detect Motorola VoiceXML platform
802 - if (strstr(strtolower($HTTP_USER_AGENT), "motorola"))
803 - {
804 - $this->MotorolaVoiceXML = true;
805 - }
806 - }
807788 else
808789 {
809 - if (strstr($HTTP_USER_AGENT, "Mozilla") ||
810 - strstr($HTTP_USER_AGENT, "MSIE") ||
811 - strstr(strtolower($HTTP_USER_AGENT), "lynx") ||
812 - strstr(strtolower($HTTP_USER_AGENT), "avantgo") ||
813 - strstr(strtolower($HTTP_USER_AGENT), "pendragonweb") ||
814 - strstr(strtolower($HTTP_USER_AGENT), "j-"))
815 - $this->ml = HAW_HTML; // HTML-based browser
816 - else
817 - {
818 - if (!$HTTP_ACCEPT ||
819 - (strcmp(substr($_SERVER['HTTP_HOST'], -5), '.mobi') == 0))
820 - {
821 - // let's be dotmobi compliant ...
822 - $this->ml = HAW_HTML;
823 - $this->xhtml = true;
824 - $this->pureHTML = false;
825 - $this->display_banners = false;
826 - $this->gif_enabled = true;
827 - $this->css_enabled = true;
828 - }
829 - else
830 - $this->ml = HAW_WML; // try it with WML
831 - }
 790+ $this->determine_capabilities_generic($HTTP_USER_AGENT, $HTTP_ACCEPT, $HTTP_UA_OS);
832791 }
833 -
834 - $this->number_of_elements = 0;
835 - $this->number_of_forms = 0;
836 - $this->number_of_linksets = 0;
837 - $this->number_of_links = 0;
838 - $this->number_of_phones = 0;
839 -
840 -
841 -
842 - if (strstr(strtolower($HTTP_ACCEPT), "vnd.wap.xhtml") ||
843 - strstr(strtolower($HTTP_USER_AGENT), "opera mini") ||
844 - strstr(strtolower($HTTP_USER_AGENT), "google wireless transcoder"))
845 - {
846 - // XHTML device detected
847 - $this->xhtml = true;
848 - $this->pureHTML = false;
849 - $this->display_banners = false;
850 - $this->gif_enabled = true;
851 - $this->css_enabled = true;
852 - }
853 - elseif ( strstr(strtolower($HTTP_USER_AGENT), "avantgo") ||
854 - strstr(strtolower($HTTP_USER_AGENT), "reqwirelessweb") ||
855 - strstr(strtolower($HTTP_USER_AGENT), "pendragonweb") ||
856 - strstr(strtolower($HTTP_USER_AGENT), "palmos") ||
857 - strstr(strtolower($HTTP_USER_AGENT), "windows ce") ||
858 - strstr($HTTP_USER_AGENT, "Mozilla/4.7"))
859 - {
860 - // PDA browser detected (or poor old Netscape 4.7x which messes with CSS)
861 - $this->PDAstyle = true;
862 - $this->pureHTML = false;
863 - $this->display_banners = false;
864 - }
865 - elseif (strstr(strtolower($HTTP_USER_AGENT), "docomo") ||
866 - strstr(strtolower($HTTP_USER_AGENT), "portalmmm") ||
867 - strstr(strtolower($HTTP_USER_AGENT), "o2imode"))
868 - {
869 - // i-mode browser detected
870 - $this->iModestyle = true;
871 - $this->pureHTML = false;
872 - $this->display_banners = false;
873 - }
874 - elseif (strstr(strtolower($HTTP_USER_AGENT), "j-"))
875 - {
876 - // MML browser detected
877 - $this->MMLstyle = true;
878 - $this->pureHTML = false;
879 - $this->display_banners = false;
880 - }
881 - elseif (strstr(strtolower($HTTP_USER_AGENT), "lynx"))
882 - {
883 - // text browser detected
884 - $this->lynx = true;
885 - $this->css_enabled = true; // enabled in the meaning of silently discarding it ...
886 - $this->pureHTML = true;
887 - $this->display_banners = false;
888 - }
889 -
890 - // determine if browser is CSS-enbled
891 - if (($this->ml == HAW_HTML) &&
892 - (strstr($HTTP_USER_AGENT, "MSIE") ||
893 - strstr($HTTP_USER_AGENT, "Mozilla") ||
894 - strstr($HTTP_USER_AGENT, "Opera")))
895 - $this->css_enabled = true;
896 -
897 - // determine if browser is able to display GIF images
898 - if (($this->ml == HAW_HTML) ||
899 - (strstr(strtolower($HTTP_ACCEPT), "image/gif")) ||
900 - (strstr(strtolower($HTTP_USER_AGENT), "t68")))
901 - $this->gif_enabled = true; // browsers can display GIF
902 -
903 - // determine how forms are to be transmitted
904 - if (strstr(strtolower($HTTP_USER_AGENT), "ericsson") ||
905 - (strstr(strtolower($HTTP_USER_AGENT), "nokia")))
906 - $this->submitViaLink = true; // with some WAP devices it's quite difficult to submit WML forms
907792 }
908793
909794
@@ -1324,6 +1209,16 @@
13251210
13261211
13271212 /**
 1213+ Sets a css file for css-enabled browsers.
 1214+ @param css file with css (cascading style sheets) declarations.
 1215+ */
 1216+ function set_css($css)
 1217+ {
 1218+ $this->css = $css;
 1219+ }
 1220+
 1221+
 1222+ /**
13281223 Sets a window wallpaper for a HTML (big-screen browser) page.
13291224 Has no effect on WML/handheld pages.
13301225 @param background e.g. "backgrnd.gif"
@@ -1774,6 +1669,10 @@
17751670
17761671 if ($this->xhtml)
17771672 {
 1673+ // advice transcoding proxies (http://dev.mobi/node/611)
 1674+ header("cache-control: no-transform");
 1675+ header("vary: User-Agent, Accept");
 1676+
17781677 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $this->charset);
17791678
17801679 if ($this->lynx)
@@ -1840,6 +1739,11 @@
18411740 echo "<meta name=\"HandheldFriendly\" content=\"True\" $endtag\n";
18421741 }
18431742
 1743+ if ($this->css_enabled && $this->css)
 1744+ {
 1745+ printf("<link href=\"%s\" type=\"text/css\" rel=\"stylesheet\" />\n", $this->css);
 1746+ }
 1747+
18441748 // init style properties
18451749 $bgcolor = "";
18461750 $background = "";
@@ -1872,15 +1776,18 @@
18731777 $bodystyle .= sprintf("background-image:url(%s); ", $this->background);
18741778 }
18751779
1876 - // set display defaults, if not assigned by yet
1877 - if (!$this->disp_bgcolor)
1878 - $this->disp_bgcolor = HAW_DISP_BGCOLOR;
1879 - if (!$this->link_color)
1880 - $this->link_color = HAW_DISP_LINKCOLOR;
1881 - if (!$this->vlink_color)
1882 - $this->vlink_color = HAW_DISP_VLINKCOLOR;
1883 - if (!$this->face)
1884 - $this->face = HAW_DISP_FACE;
 1780+ if (!$this->css) // settings in css-file have priority
 1781+ {
 1782+ // set display defaults, if not assigned by yet
 1783+ if (!$this->disp_bgcolor)
 1784+ $this->disp_bgcolor = HAW_DISP_BGCOLOR;
 1785+ if (!$this->link_color)
 1786+ $this->link_color = HAW_DISP_LINKCOLOR;
 1787+ if (!$this->vlink_color)
 1788+ $this->vlink_color = HAW_DISP_VLINKCOLOR;
 1789+ if (!$this->face)
 1790+ $this->face = HAW_DISP_FACE;
 1791+ }
18851792 }
18861793 else
18871794 {
@@ -2291,10 +2198,11 @@
22922199
22932200 if (!$this->lynx)
22942201 {
 2202+ $default_text = "Powered by HAWHAW (C)";
22952203 if ($haw_license_holder && $haw_signature)
22962204 {
22972205 if ($haw_signature == 1)
2298 - $signature = "<small>Powered by HAWHAW (C)</small>\n";
 2206+ $signature = "<small>" . $default_text . "</small>\n";
22992207 else
23002208 if ($haw_sig_text)
23012209 if ($haw_sig_link)
@@ -2303,7 +2211,8 @@
23042212 $signature = sprintf("<small>%s</small>\n", $haw_sig_text);
23052213 }
23062214 else
2307 - $signature = sprintf("<a href=\"http://info.hawhaw.de/index.htm?host=%s\" target=\"_blank\"><small>Powered by HAWHAW (C)</small></a>\n", $this->waphome);
 2215+ $signature = sprintf("<a href=\"http://info.hawhaw.de/index.htm?host=%s\" target=\"_blank\"><small>%s</small></a>\n",
 2216+ $this->waphome, $default_text);
23082217
23092218 echo $signature;
23102219 }
@@ -2388,6 +2297,238 @@
23892298 echo "</vxml>\n";
23902299 }
23912300 }
 2301+
 2302+ function determine_capabilities_generic($HTTP_USER_AGENT, $HTTP_ACCEPT, $HTTP_UA_OS)
 2303+ {
 2304+ if (strstr(strtolower($HTTP_USER_AGENT), "docomo") ||
 2305+ strstr(strtolower($HTTP_USER_AGENT), "portalmmm") ||
 2306+ strstr(strtolower($HTTP_USER_AGENT), "o2imode") ||
 2307+ strstr(strtolower($HTTP_USER_AGENT), "opera ") ||
 2308+ strstr(strtolower($HTTP_USER_AGENT), "reqwirelessweb") ||
 2309+ strstr(strtolower($HTTP_ACCEPT), "vnd.wap.xhtml"))
 2310+ {
 2311+ $this->ml = HAW_HTML; // create HTML (even when device accepts text/vnd.wap.wml too!)
 2312+ }
 2313+ elseif (strstr(strtolower($HTTP_ACCEPT), "text/vnd.wap.wml"))
 2314+ {
 2315+ $this->ml = HAW_WML; // create WML
 2316+
 2317+ if (strstr($HTTP_USER_AGENT, "UP/") ||
 2318+ strstr($HTTP_USER_AGENT, "UP.B"))
 2319+ $this->upbrowser = true; // UP browser
 2320+
 2321+ if ((strstr($HTTP_USER_AGENT, "UP/") ||
 2322+ strstr($HTTP_USER_AGENT, "UP.B")) &&
 2323+ strstr($HTTP_USER_AGENT, "GUI") &&
 2324+ strstr($HTTP_USER_AGENT, "UP.Link")) // Non-UP.Link gateways sometimes have problems!
 2325+ $this->owgui_1_3 = true; // device accepts Openwave GUI extensions for WML 1.3
 2326+ }
 2327+ elseif (strstr(strtolower($HTTP_ACCEPT), "hdml;version=3.")) // HDML 3.0 and 3.1
 2328+ $this->ml = HAW_HDML; // create HDML
 2329+ elseif (strstr(strtolower($HTTP_ACCEPT), "vxml") || // VoiceXML signalled in accept header
 2330+ strstr(strtolower($HTTP_ACCEPT), "voicexml") || // alternative accept header
 2331+ strstr($HTTP_USER_AGENT, "OpenVXI") || // Speechworks OpenVXI
 2332+ strstr(strtolower($HTTP_USER_AGENT), "publicvoicexml") || // PublicVoiceXML voice browser
 2333+ strstr(strtolower($HTTP_USER_AGENT), "hastenix") || // hawhaw asterisk adapter
 2334+ strstr($HTTP_USER_AGENT, "Tellme")) // Tellme studio voice browser
 2335+ {
 2336+ $this->ml = HAW_VXML; // create VoiceXML
 2337+
 2338+ // PublicVoiceXML browser cannot handle <break> elements!!!
 2339+ if (strstr(strtolower($HTTP_USER_AGENT), "publicvoicexml"))
 2340+ {
 2341+ $this->supportsVXMLBreakTag = false;
 2342+ }
 2343+
 2344+ // detect Motorola VoiceXML platform
 2345+ if (strstr(strtolower($HTTP_USER_AGENT), "motorola"))
 2346+ {
 2347+ $this->MotorolaVoiceXML = true;
 2348+ }
 2349+ }
 2350+ else
 2351+ {
 2352+ if (strstr($HTTP_USER_AGENT, "Mozilla") ||
 2353+ strstr($HTTP_USER_AGENT, "MSIE") ||
 2354+ strstr(strtolower($HTTP_USER_AGENT), "lynx") ||
 2355+ strstr(strtolower($HTTP_USER_AGENT), "avantgo") ||
 2356+ strstr(strtolower($HTTP_USER_AGENT), "pendragonweb") ||
 2357+ strstr(strtolower($HTTP_USER_AGENT), "j-"))
 2358+ $this->ml = HAW_HTML; // HTML-based browser
 2359+ else
 2360+ {
 2361+ if (!$HTTP_ACCEPT ||
 2362+ (strcmp(substr($_SERVER['HTTP_HOST'], -5), '.mobi') == 0))
 2363+ {
 2364+ // let's be dotmobi compliant ...
 2365+ $this->ml = HAW_HTML;
 2366+ $this->xhtml = true;
 2367+ $this->pureHTML = false;
 2368+ $this->display_banners = false;
 2369+ $this->gif_enabled = true;
 2370+ $this->css_enabled = true;
 2371+ }
 2372+ else
 2373+ $this->ml = HAW_WML; // try it with WML
 2374+ }
 2375+ }
 2376+
 2377+ if (strstr(strtolower($HTTP_ACCEPT), "vnd.wap.xhtml") ||
 2378+ strstr(strtolower($HTTP_USER_AGENT), "opera mini") ||
 2379+ strstr(strtolower($HTTP_USER_AGENT), "google wireless transcoder") ||
 2380+ strstr($HTTP_USER_AGENT, "iPhone"))
 2381+ {
 2382+ // XHTML device detected
 2383+ $this->xhtml = true;
 2384+ $this->pureHTML = false;
 2385+ $this->display_banners = false;
 2386+ $this->gif_enabled = true;
 2387+ $this->css_enabled = true;
 2388+ }
 2389+ elseif ( strstr(strtolower($HTTP_USER_AGENT), "avantgo") ||
 2390+ strstr(strtolower($HTTP_USER_AGENT), "reqwirelessweb") ||
 2391+ strstr(strtolower($HTTP_USER_AGENT), "pendragonweb") ||
 2392+ strstr(strtolower($HTTP_USER_AGENT), "palmos") ||
 2393+ strstr(strtolower($HTTP_USER_AGENT), "windows ce") ||
 2394+ strstr(strtolower($HTTP_UA_OS), "windows ce") ||
 2395+ strstr($HTTP_USER_AGENT, "Mozilla/4.7"))
 2396+ {
 2397+ // PDA browser detected (or poor old Netscape 4.7x which messes with CSS)
 2398+ $this->PDAstyle = true;
 2399+ $this->pureHTML = false;
 2400+ $this->display_banners = false;
 2401+ }
 2402+ elseif (strstr(strtolower($HTTP_USER_AGENT), "docomo") ||
 2403+ strstr(strtolower($HTTP_USER_AGENT), "portalmmm") ||
 2404+ strstr(strtolower($HTTP_USER_AGENT), "o2imode"))
 2405+ {
 2406+ // i-mode browser detected
 2407+ $this->iModestyle = true;
 2408+ $this->pureHTML = false;
 2409+ $this->display_banners = false;
 2410+ }
 2411+ elseif (strstr(strtolower($HTTP_USER_AGENT), "j-"))
 2412+ {
 2413+ // MML browser detected
 2414+ $this->MMLstyle = true;
 2415+ $this->pureHTML = false;
 2416+ $this->display_banners = false;
 2417+ }
 2418+ elseif (strstr(strtolower($HTTP_USER_AGENT), "lynx"))
 2419+ {
 2420+ // text browser detected
 2421+ $this->lynx = true;
 2422+ $this->css_enabled = true; // enabled in the meaning of silently discarding it ...
 2423+ $this->pureHTML = true;
 2424+ $this->display_banners = false;
 2425+ }
 2426+
 2427+ // determine if browser is CSS-enbled
 2428+ if (($this->ml == HAW_HTML) &&
 2429+ (strstr($HTTP_USER_AGENT, "MSIE") ||
 2430+ strstr($HTTP_USER_AGENT, "Mozilla") ||
 2431+ strstr($HTTP_USER_AGENT, "Opera")))
 2432+ $this->css_enabled = true;
 2433+
 2434+ // determine if browser is able to display GIF images
 2435+ if (($this->ml == HAW_HTML) ||
 2436+ (strstr(strtolower($HTTP_ACCEPT), "image/gif")) ||
 2437+ (strstr(strtolower($HTTP_USER_AGENT), "t68")))
 2438+ $this->gif_enabled = true; // browsers can display GIF
 2439+
 2440+ // determine how forms are to be transmitted
 2441+ if (strstr(strtolower($HTTP_USER_AGENT), "ericsson") ||
 2442+ (strstr(strtolower($HTTP_USER_AGENT), "nokia")))
 2443+ $this->submitViaLink = true; // with some WAP devices it's quite difficult to submit WML forms
 2444+ }
 2445+
 2446+ function determine_capabilities_terawurfl()
 2447+ {
 2448+ require_once(dirname(__FILE__) . '/' . HAW_TERA_WURFL_PATH . '/tera_wurfl_config.php');
 2449+ require_once(WURFL_CLASS_FILE);
 2450+
 2451+ $wurflObj = new tera_wurfl();
 2452+
 2453+ // get the capabilites from the user agent and take a look at the
 2454+ // HTTP-ACCEPT headers in case the user agent is not found
 2455+ $identified = $wurflObj->GetDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT'], true);
 2456+
 2457+ if ($identified)
 2458+ {
 2459+ $cap = $wurflObj->capabilities;
 2460+
 2461+ if ($cap['product_info']['is_wireless_device'])
 2462+ {
 2463+ // wireless device
 2464+
 2465+ $this->pureHTML = false;
 2466+ $this->display_banners = false;
 2467+
 2468+ if ($cap['markup']['xhtml_support_level'] >= 1)
 2469+ {
 2470+ // XHTML-capable device
 2471+ $this->ml = HAW_HTML;
 2472+ $this->xhtml = true;
 2473+ $this->css_enabled = true;
 2474+ }
 2475+ else if ($cap['markup']['html_wi_imode_html_1'] ||
 2476+ $cap['markup']['html_wi_imode_html_2'] ||
 2477+ $cap['markup']['html_wi_imode_html_3'] ||
 2478+ $cap['markup']['html_wi_imode_html_4'] ||
 2479+ $cap['markup']['html_wi_imode_html_5'])
 2480+ {
 2481+ // i-Mode device
 2482+ $this->ml = HAW_HTML;
 2483+ $this->iModestyle = true;
 2484+ }
 2485+ else if ($cap['markup']['html_web_3_2'] ||
 2486+ $cap['markup']['html_web_4_0'])
 2487+ {
 2488+ // HTML-prefering device
 2489+ $this->ml = HAW_HTML;
 2490+ $this->PDAstyle = true;
 2491+ }
 2492+ else if ($cap['markup']['wml_1_1'] ||
 2493+ $cap['markup']['wml_1_2'] ||
 2494+ $cap['markup']['wml_1_3'])
 2495+ {
 2496+ // WML device
 2497+ $this->ml = HAW_WML;
 2498+
 2499+ if ($cap['wml_ui']['opwv_wml_extensions_support'])
 2500+ $this->owgui_1_3 = true; // device accepts Openwave GUI extensions for WML 1.3
 2501+ }
 2502+ }
 2503+ else
 2504+ {
 2505+ // no wireless device
 2506+
 2507+ if ($cap['markup']['voicexml'])
 2508+ {
 2509+ $this->ml = HAW_VXML;
 2510+ }
 2511+ else
 2512+ {
 2513+ // treat it as normal web browser
 2514+ $this->ml = HAW_HTML;
 2515+ $this->css_enabled = true;
 2516+ }
 2517+ }
 2518+
 2519+ if ($cap['image_format']['gif'])
 2520+ $this->gif_enabled = true;
 2521+ }
 2522+ else
 2523+ {
 2524+ // Tera-WURFL was not able to identify device
 2525+ $this->pureHTML = false;
 2526+ $this->display_banners = false;
 2527+ $this->ml = HAW_HTML;
 2528+ $this->xhtml = true;
 2529+ $this->css_enabled = true;
 2530+ $this->gif_enabled = true;
 2531+ }
 2532+ }
23922533 };
23932534
23942535
@@ -2861,6 +3002,7 @@
28623003 var $attrib;
28633004 var $color;
28643005 var $boxcolor;
 3006+ var $css_class;
28653007 var $br;
28663008 var $voice_text;
28673009 var $voice_audio_src;
@@ -2884,6 +3026,7 @@
28853027 $this->attrib = $attrib;
28863028 $this->color = "";
28873029 $this->boxcolor = "";
 3030+ $this->css_class = "";
28883031 $this->br = 1; // default: 1 line break after text
28893032 $this->voice_text = $text;
28903033 $this->voice_audio_src = "";
@@ -2904,6 +3047,15 @@
29053048 }
29063049
29073050 /**
 3051+ Sets a css class for this object in a (X)HTML page.
 3052+ @param css_class CSS class to be defined in the deck's central CSS file
 3053+ */
 3054+ function set_css_class($css_class)
 3055+ {
 3056+ $this->css_class = $css_class;
 3057+ }
 3058+
 3059+ /**
29083060 Sets the number of line breaks (CRLF) after text. (default: 1)
29093061 @param br Some number of line breaks.
29103062 */
@@ -3048,10 +3200,20 @@
30493201 printf("<font color=\"%s\">", $this->color);
30503202 }
30513203
 3204+ if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
 3205+ {
 3206+ printf("<span class=\"%s\">\n", $this->css_class);
 3207+ }
 3208+
30523209 // print text
30533210 if (isset($this->text))
30543211 printf("%s\n", HAW_specchar($this->text, $deck));
30553212
 3213+ if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class)
 3214+ {
 3215+ echo "</span>\n";
 3216+ }
 3217+
30563218 if (($deck->ml == HAW_HTML) && $this->color)
30573219 {
30583220 if ($deck->css_enabled)
@@ -3156,6 +3318,8 @@
31573319 var $localsrc;
31583320 var $chtml_icon;
31593321 var $mml_icon;
 3322+ var $html_width;
 3323+ var $html_height;
31603324 var $voice_text;
31613325 var $voice_audio_src;
31623326
@@ -3180,6 +3344,8 @@
31813345 $this->localsrc = ""; // no localsrc attribute
31823346 $this->chtml_icon = 0; // no cHTML icon
31833347 $this->mml_icon = 0; // no MML icon
 3348+ $this->html_width = ""; // not specified
 3349+ $this->html_height = "";// not specified
31843350 $this->voice_text = "";
31853351 $this->voice_audio_src = "";
31863352 }
@@ -3241,6 +3407,24 @@
32423408 }
32433409
32443410 /**
 3411+ Specifies the width of the HTML image.
 3412+ @param width image width in pixels.
 3413+ */
 3414+ function set_html_width($width)
 3415+ {
 3416+ $this->html_width = $width;
 3417+ }
 3418+
 3419+ /**
 3420+ Specifies the height of the HTML image.
 3421+ @param height image height in pixels.
 3422+ */
 3423+ function set_html_height($height)
 3424+ {
 3425+ $this->html_height = $height;
 3426+ }
 3427+
 3428+ /**
32453429 Sets text to be spoken by voice browsers. <br>
32463430 @param text Some text that represents the image for voice users.
32473431 @param audio_src Some audio file (e.g. *.wav file) to play (optional).
@@ -3294,6 +3478,12 @@
32953479 {
32963480 // HTML or WML
32973481
 3482+ $size = "";
 3483+ if ($this->html_width)
 3484+ $size .= sprintf(" width=\"%d\"", $this->html_width);
 3485+ if ($this->html_height)
 3486+ $size .= sprintf(" height=\"%d\"", $this->html_height);
 3487+
32983488 if ($deck->ml == HAW_HTML)
32993489 {
33003490 // HTML
@@ -3312,8 +3502,8 @@
33133503 {
33143504 // use HTML bitmap
33153505
3316 - printf("<img src=\"%s\" alt=\"%s\" />\n",
3317 - $this->src_html, HAW_specchar($this->alt, $deck));
 3506+ printf("<img src=\"%s\" alt=\"%s\"%s />\n",
 3507+ $this->src_html, HAW_specchar($this->alt, $deck), $size);
33183508 }
33193509
33203510 // evaluate HTML break instruction
@@ -3335,8 +3525,8 @@
33363526
33373527 if ($deck->gif_enabled && (substr(strtolower($this->src_html), -4) == ".gif"))
33383528 // user agent is able to display the provided GIF image
3339 - printf("<img src=\"%s\" alt=\"%s\"%s/>\n", $this->src_html,
3340 - HAW_specchar($this->alt, $deck), $localsrc);
 3529+ printf("<img src=\"%s\" alt=\"%s\"%s%s/>\n", $this->src_html,
 3530+ HAW_specchar($this->alt, $deck), $localsrc, $size);
33413531
33423532 elseif (strstr(strtolower($HTTP_ACCEPT), "image/vnd.wap.wbmp"))
33433533 // user agent is able to display .wbmp image
@@ -3469,7 +3659,7 @@
34703660 if ($deck->ml == HAW_HTML)
34713661 {
34723662 // HTML
3473 - if ($deck->xhtml)
 3663+ if ($deck->xhtml && !$deck->css)
34743664 // border attribute is not allowed in XHTML
34753665 echo "<table style=\"border-width:1px; border-style:solid;\">\n";
34763666 else
@@ -5250,6 +5440,7 @@
52515441 var $url;
52525442 var $title;
52535443 var $accesskey; // "1", "2", ... "0", "*", "#"
 5444+ var $css_class;
52545445 var $br;
52555446 var $voice_text;
52565447 var $voice_audio_src;
@@ -5272,6 +5463,7 @@
52735464 $this->title = $title;
52745465 $this->accesskey = HAW_NO_ACCESSKEY; // no accesskey assigned
52755466 // can be assigned later e.g. from HAW_linkset object if required
 5467+ $this->css_class = "";
52765468 $this->br = 1; // default: 1 line break after text
52775469 $this->voice_text = $label;
52785470 $this->voice_audio_src = "";
@@ -5280,6 +5472,15 @@
52815473 }
52825474
52835475 /**
 5476+ Sets a css class for this object in a (X)HTML page.
 5477+ @param css_class CSS class to be defined in the deck's central CSS file
 5478+ */
 5479+ function set_css_class($css_class)
 5480+ {
 5481+ $this->css_class = $css_class;
 5482+ }
 5483+
 5484+ /**
52845485 Sets the number of line breaks (CRLF) after link. (default: 1)
52855486 @param br Some number of line breaks.
52865487 */
@@ -5409,9 +5610,19 @@
54105611 for ($i=0; $i < $this->br; $i++)
54115612 $br .= "<br />";
54125613
 5614+ if ($deck->css_enabled && $this->css_class)
 5615+ {
 5616+ printf("<span class=\"%s\">\n", $this->css_class);
 5617+ }
 5618+
54135619 printf("[<a href=\"%s\"%s%s>%s</a>]%s\n",
54145620 HAW_specchar($this->url, $deck), $title_option, $accesskey_option,
54155621 HAW_specchar($this->label, $deck), $br);
 5622+
 5623+ if ($deck->css_enabled && $this->css_class)
 5624+ {
 5625+ echo "</span>\n";
 5626+ }
54165627 }
54175628
54185629 elseif ($deck->ml == HAW_WML)

Status & tagging log