transports isolation in php code
[brisk.git] / web / Obj / transports.phh
1 <?php
2 /*
3  *  sac-a-push - Obj/transports.phh
4  *
5  *  Copyright (C) 2012 Matteo Nastasi
6  *                          mailto: nastasi@alternativeoutput.it 
7  *                                  matteo.nastasi@milug.org
8  *                          web: http://www.alternativeoutput.it
9  *
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.
14  *
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.
22  *
23  */
24
25 class Transport_template {
26
27     function Transport_template() {
28     }
29
30     function init($enc, &$header_out, $init_string, $base, $step)
31     {
32     }
33
34     static function fini($init_string, $blockerr)
35     {
36     }
37
38     function chunk($step, $cont)
39     {
40     }
41 }
42
43 class Transport_xhr {
44
45     function Transport_xhr() {
46     }
47
48     function init($enc, &$header_out, $init_string, $base, $step)
49     {
50     }
51
52     static function fini($init_string, $blockerr)
53     {
54     }
55
56     function chunk($step, $cont)
57     {
58     }
59 }
60
61 class Transport_iframe {
62
63     function Transport_iframe() {
64     }
65
66     function init($enc, &$header_out, $init_string, $base, $step)
67     {
68         $ret = "";
69
70         if ($enc != 'plain')
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"';
75         
76         $ret .= sprintf("<html>
77 <head>
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);
82         if ($step > 0)
83             $ret .= sprintf("last_clean = %d;\n", ($step-1));
84         $ret .= sprintf("
85 window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
86 </script> 
87 </head>
88 <body>");
89         $ret .= sprintf("<!-- \n%s -->\n", $init_string);
90
91         return ($ret);
92     }
93
94     static function fini($init_string, $blockerr)
95     {
96         $ret = "";
97         $ret .= sprintf("<html>
98 <head>
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());
103         $ret .= sprintf("
104 window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
105 </script>
106 </head>
107 <body>");
108         $ret .= sprintf("<!-- \n%s -->\n", $init_string);
109         $ret .= sprintf("<script id='hs%d' type='text/javascript'><!--
110 push(\"%s\");
111 // -->
112 </script>", 0, escpush($blockerr) );
113         return ($ret);
114     }
115
116     function chunk($step, $cont)
117     {
118         if ($cont == NULL) {
119             return sprintf("<script id='hs%d' type='text/javascript'><!--
120 push(null);\n// -->\n</script>", $step);
121         }
122         else {
123             return sprintf("<script id='hs%d' type='text/javascript'><!--
124 push(\"%s\");\n// -->\n</script>", $step, escpush($cont) );
125         }
126     }
127 }
128 ?>