Index: trunk/wap/hawhaw/hawhaw.inc |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | // HAWHAW: HTML and WML hybrid adapted webserver |
5 | 5 | // PHP class library |
6 | 6 | // Copyright (C) 2007 Norbert Huffschmid |
7 | | -// Last modified: 11. April 2007 |
| 7 | +// Last modified: 7. November 2007 |
8 | 8 | // |
9 | 9 | // This library is free software; you can redistribute it and/or modify it under the |
10 | 10 | // terms of the GNU Library General Public License as published by the Free Software |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | // This library is distributed in the hope that it will be useful, but WITHOUT ANY |
15 | 15 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
16 | 16 | // 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 |
18 | 18 | // |
19 | 19 | // If you modify this library, you have to make sure that the "powered by HAWHAW" |
20 | 20 | // copyright link below the display area is kept unchanged. |
— | — | @@ -21,15 +21,34 @@ |
22 | 22 | // For further information about this library and its license terms please visit: |
23 | 23 | // http://www.hawhaw.de/ |
24 | 24 | // |
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 |
30 | 27 | |
| 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 | + |
31 | 46 | // miscellaneous constants |
32 | | -define("HAW_VERSION", "HAWHAW V5.14B"); |
| 47 | +define("HAW_HAW_VERSION", "HAWHAW V5.16B"); |
33 | 48 | 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); |
34 | 53 | |
35 | 54 | // constants for markup languages |
36 | 55 | define("HAW_HTML", 1); |
— | — | @@ -523,13 +542,14 @@ |
524 | 543 | var $timeout; |
525 | 544 | var $red_url; |
526 | 545 | var $disable_cache = false; |
| 546 | + var $css = ""; |
527 | 547 | var $ml; |
528 | 548 | 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; |
534 | 554 | var $top_banners; |
535 | 555 | var $number_of_top_banners = 0; |
536 | 556 | var $bottom_banners; |
— | — | @@ -646,7 +666,12 @@ |
647 | 667 | else |
648 | 668 | $HTTP_ACCEPT = ""; |
649 | 669 | |
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'])) |
651 | 676 | $HTTP_HOST = $_SERVER['HTTP_HOST']; |
652 | 677 | else |
653 | 678 | $HTTP_HOST = ""; |
— | — | @@ -755,154 +780,14 @@ |
756 | 781 | } |
757 | 782 | } |
758 | 783 | |
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) |
767 | 785 | { |
768 | | - $this->ml = HAW_HTML; // create HTML (even when device accepts text/vnd.wap.wml too!) |
| 786 | + $this->determine_capabilities_terawurfl(); |
769 | 787 | } |
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 | | - } |
807 | 788 | else |
808 | 789 | { |
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); |
832 | 791 | } |
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 |
907 | 792 | } |
908 | 793 | |
909 | 794 | |
— | — | @@ -1324,6 +1209,16 @@ |
1325 | 1210 | |
1326 | 1211 | |
1327 | 1212 | /** |
| 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 | + /** |
1328 | 1223 | Sets a window wallpaper for a HTML (big-screen browser) page. |
1329 | 1224 | Has no effect on WML/handheld pages. |
1330 | 1225 | @param background e.g. "backgrnd.gif" |
— | — | @@ -1774,6 +1669,10 @@ |
1775 | 1670 | |
1776 | 1671 | if ($this->xhtml) |
1777 | 1672 | { |
| 1673 | + // advice transcoding proxies (http://dev.mobi/node/611) |
| 1674 | + header("cache-control: no-transform"); |
| 1675 | + header("vary: User-Agent, Accept"); |
| 1676 | + |
1778 | 1677 | printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $this->charset); |
1779 | 1678 | |
1780 | 1679 | if ($this->lynx) |
— | — | @@ -1840,6 +1739,11 @@ |
1841 | 1740 | echo "<meta name=\"HandheldFriendly\" content=\"True\" $endtag\n"; |
1842 | 1741 | } |
1843 | 1742 | |
| 1743 | + if ($this->css_enabled && $this->css) |
| 1744 | + { |
| 1745 | + printf("<link href=\"%s\" type=\"text/css\" rel=\"stylesheet\" />\n", $this->css); |
| 1746 | + } |
| 1747 | + |
1844 | 1748 | // init style properties |
1845 | 1749 | $bgcolor = ""; |
1846 | 1750 | $background = ""; |
— | — | @@ -1872,15 +1776,18 @@ |
1873 | 1777 | $bodystyle .= sprintf("background-image:url(%s); ", $this->background); |
1874 | 1778 | } |
1875 | 1779 | |
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 | + } |
1885 | 1792 | } |
1886 | 1793 | else |
1887 | 1794 | { |
— | — | @@ -2291,10 +2198,11 @@ |
2292 | 2199 | |
2293 | 2200 | if (!$this->lynx) |
2294 | 2201 | { |
| 2202 | + $default_text = "Powered by HAWHAW (C)"; |
2295 | 2203 | if ($haw_license_holder && $haw_signature) |
2296 | 2204 | { |
2297 | 2205 | if ($haw_signature == 1) |
2298 | | - $signature = "<small>Powered by HAWHAW (C)</small>\n"; |
| 2206 | + $signature = "<small>" . $default_text . "</small>\n"; |
2299 | 2207 | else |
2300 | 2208 | if ($haw_sig_text) |
2301 | 2209 | if ($haw_sig_link) |
— | — | @@ -2303,7 +2211,8 @@ |
2304 | 2212 | $signature = sprintf("<small>%s</small>\n", $haw_sig_text); |
2305 | 2213 | } |
2306 | 2214 | 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); |
2308 | 2217 | |
2309 | 2218 | echo $signature; |
2310 | 2219 | } |
— | — | @@ -2388,6 +2297,238 @@ |
2389 | 2298 | echo "</vxml>\n"; |
2390 | 2299 | } |
2391 | 2300 | } |
| 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 | + } |
2392 | 2533 | }; |
2393 | 2534 | |
2394 | 2535 | |
— | — | @@ -2861,6 +3002,7 @@ |
2862 | 3003 | var $attrib; |
2863 | 3004 | var $color; |
2864 | 3005 | var $boxcolor; |
| 3006 | + var $css_class; |
2865 | 3007 | var $br; |
2866 | 3008 | var $voice_text; |
2867 | 3009 | var $voice_audio_src; |
— | — | @@ -2884,6 +3026,7 @@ |
2885 | 3027 | $this->attrib = $attrib; |
2886 | 3028 | $this->color = ""; |
2887 | 3029 | $this->boxcolor = ""; |
| 3030 | + $this->css_class = ""; |
2888 | 3031 | $this->br = 1; // default: 1 line break after text |
2889 | 3032 | $this->voice_text = $text; |
2890 | 3033 | $this->voice_audio_src = ""; |
— | — | @@ -2904,6 +3047,15 @@ |
2905 | 3048 | } |
2906 | 3049 | |
2907 | 3050 | /** |
| 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 | + /** |
2908 | 3060 | Sets the number of line breaks (CRLF) after text. (default: 1) |
2909 | 3061 | @param br Some number of line breaks. |
2910 | 3062 | */ |
— | — | @@ -3048,10 +3200,20 @@ |
3049 | 3201 | printf("<font color=\"%s\">", $this->color); |
3050 | 3202 | } |
3051 | 3203 | |
| 3204 | + if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class) |
| 3205 | + { |
| 3206 | + printf("<span class=\"%s\">\n", $this->css_class); |
| 3207 | + } |
| 3208 | + |
3052 | 3209 | // print text |
3053 | 3210 | if (isset($this->text)) |
3054 | 3211 | printf("%s\n", HAW_specchar($this->text, $deck)); |
3055 | 3212 | |
| 3213 | + if (($deck->ml == HAW_HTML) && $deck->css_enabled && $this->css_class) |
| 3214 | + { |
| 3215 | + echo "</span>\n"; |
| 3216 | + } |
| 3217 | + |
3056 | 3218 | if (($deck->ml == HAW_HTML) && $this->color) |
3057 | 3219 | { |
3058 | 3220 | if ($deck->css_enabled) |
— | — | @@ -3156,6 +3318,8 @@ |
3157 | 3319 | var $localsrc; |
3158 | 3320 | var $chtml_icon; |
3159 | 3321 | var $mml_icon; |
| 3322 | + var $html_width; |
| 3323 | + var $html_height; |
3160 | 3324 | var $voice_text; |
3161 | 3325 | var $voice_audio_src; |
3162 | 3326 | |
— | — | @@ -3180,6 +3344,8 @@ |
3181 | 3345 | $this->localsrc = ""; // no localsrc attribute |
3182 | 3346 | $this->chtml_icon = 0; // no cHTML icon |
3183 | 3347 | $this->mml_icon = 0; // no MML icon |
| 3348 | + $this->html_width = ""; // not specified |
| 3349 | + $this->html_height = "";// not specified |
3184 | 3350 | $this->voice_text = ""; |
3185 | 3351 | $this->voice_audio_src = ""; |
3186 | 3352 | } |
— | — | @@ -3241,6 +3407,24 @@ |
3242 | 3408 | } |
3243 | 3409 | |
3244 | 3410 | /** |
| 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 | + /** |
3245 | 3429 | Sets text to be spoken by voice browsers. <br> |
3246 | 3430 | @param text Some text that represents the image for voice users. |
3247 | 3431 | @param audio_src Some audio file (e.g. *.wav file) to play (optional). |
— | — | @@ -3294,6 +3478,12 @@ |
3295 | 3479 | { |
3296 | 3480 | // HTML or WML |
3297 | 3481 | |
| 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 | + |
3298 | 3488 | if ($deck->ml == HAW_HTML) |
3299 | 3489 | { |
3300 | 3490 | // HTML |
— | — | @@ -3312,8 +3502,8 @@ |
3313 | 3503 | { |
3314 | 3504 | // use HTML bitmap |
3315 | 3505 | |
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); |
3318 | 3508 | } |
3319 | 3509 | |
3320 | 3510 | // evaluate HTML break instruction |
— | — | @@ -3335,8 +3525,8 @@ |
3336 | 3526 | |
3337 | 3527 | if ($deck->gif_enabled && (substr(strtolower($this->src_html), -4) == ".gif")) |
3338 | 3528 | // 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); |
3341 | 3531 | |
3342 | 3532 | elseif (strstr(strtolower($HTTP_ACCEPT), "image/vnd.wap.wbmp")) |
3343 | 3533 | // user agent is able to display .wbmp image |
— | — | @@ -3469,7 +3659,7 @@ |
3470 | 3660 | if ($deck->ml == HAW_HTML) |
3471 | 3661 | { |
3472 | 3662 | // HTML |
3473 | | - if ($deck->xhtml) |
| 3663 | + if ($deck->xhtml && !$deck->css) |
3474 | 3664 | // border attribute is not allowed in XHTML |
3475 | 3665 | echo "<table style=\"border-width:1px; border-style:solid;\">\n"; |
3476 | 3666 | else |
— | — | @@ -5250,6 +5440,7 @@ |
5251 | 5441 | var $url; |
5252 | 5442 | var $title; |
5253 | 5443 | var $accesskey; // "1", "2", ... "0", "*", "#" |
| 5444 | + var $css_class; |
5254 | 5445 | var $br; |
5255 | 5446 | var $voice_text; |
5256 | 5447 | var $voice_audio_src; |
— | — | @@ -5272,6 +5463,7 @@ |
5273 | 5464 | $this->title = $title; |
5274 | 5465 | $this->accesskey = HAW_NO_ACCESSKEY; // no accesskey assigned |
5275 | 5466 | // can be assigned later e.g. from HAW_linkset object if required |
| 5467 | + $this->css_class = ""; |
5276 | 5468 | $this->br = 1; // default: 1 line break after text |
5277 | 5469 | $this->voice_text = $label; |
5278 | 5470 | $this->voice_audio_src = ""; |
— | — | @@ -5280,6 +5472,15 @@ |
5281 | 5473 | } |
5282 | 5474 | |
5283 | 5475 | /** |
| 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 | + /** |
5284 | 5485 | Sets the number of line breaks (CRLF) after link. (default: 1) |
5285 | 5486 | @param br Some number of line breaks. |
5286 | 5487 | */ |
— | — | @@ -5409,9 +5610,19 @@ |
5410 | 5611 | for ($i=0; $i < $this->br; $i++) |
5411 | 5612 | $br .= "<br />"; |
5412 | 5613 | |
| 5614 | + if ($deck->css_enabled && $this->css_class) |
| 5615 | + { |
| 5616 | + printf("<span class=\"%s\">\n", $this->css_class); |
| 5617 | + } |
| 5618 | + |
5413 | 5619 | printf("[<a href=\"%s\"%s%s>%s</a>]%s\n", |
5414 | 5620 | HAW_specchar($this->url, $deck), $title_option, $accesskey_option, |
5415 | 5621 | HAW_specchar($this->label, $deck), $br); |
| 5622 | + |
| 5623 | + if ($deck->css_enabled && $this->css_class) |
| 5624 | + { |
| 5625 | + echo "</span>\n"; |
| 5626 | + } |
5416 | 5627 | } |
5417 | 5628 | |
5418 | 5629 | elseif ($deck->ml == HAW_WML) |