3 * sac-a-push - Obj/transports.phh
5 * Copyright (C) 2012 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. You should have received a
19 * copy of the GNU General Public License along with this program; if
20 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 * Suite 330, Boston, MA 02111-1307, USA.
25 class Transport_template {
27 function Transport_template() {
30 function init($enc, &$header_out, $init_string, $base, $step)
34 static function fini($init_string, $blockerr)
38 function chunk($step, $cont)
45 function Transport_xhr() {
48 function init($enc, &$header_out, $init_string, $base, $step)
52 static function fini($init_string, $blockerr)
56 function chunk($step, $cont)
61 class Transport_iframe {
63 function Transport_iframe() {
66 function init($enc, &$header_out, $init_string, $base, $step)
71 $header_out['Content-Encoding'] = $enc;
72 $header_out['Cache-Control'] = 'no-cache, must-revalidate'; // HTTP/1.1
73 $header_out['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; // Date in the past
74 $header_out['Content-type'] = 'text/html; charset="utf-8"';
76 $ret .= sprintf("<html>
78 <script type=\"text/javascript\" src=\"%scommons.js\"></script>
79 <script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
80 <script type=\"text/javascript\">
81 var xynt_streaming = \"ready\";", $base, $base);
83 $ret .= sprintf("last_clean = %d;\n", ($step-1));
85 window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
89 $ret .= sprintf("<!-- \n%s -->\n", $init_string);
94 static function fini($init_string, $blockerr)
97 $ret .= sprintf("<html>
99 <script type=\"text/javascript\" src=\"%scommons.js\"></script>
100 <script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
101 <script type=\"text/javascript\">
102 var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
104 window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
108 $ret .= sprintf("<!-- \n%s -->\n", $init_string);
109 $ret .= sprintf("<script id='hs%d' type='text/javascript'><!--
112 </script>", 0, escpush($blockerr) );
116 function chunk($step, $cont)
119 return sprintf("<script id='hs%d' type='text/javascript'><!--
120 push(null);\n// -->\n</script>", $step);
123 return sprintf("<script id='hs%d' type='text/javascript'><!--
124 push(\"%s\");\n// -->\n</script>", $step, escpush($cont) );