Changeset 4414 in subversion
- Timestamp:
- Jan 12, 2011 3:56:31 PM (2 years ago)
- Location:
- trunk/roundcubemail/program/include
- Files:
-
- 2 edited
-
rcube_html_page.php (modified) (9 diffs)
-
rcube_plugin_api.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_html_page.php
r4410 r4414 29 29 protected $scripts_path = ''; 30 30 protected $script_files = array(); 31 protected $css_files = array(); 31 32 protected $scripts = array(); 32 33 protected $charset = RCMAIL_CHARSET; … … 34 35 protected $script_tag_file = "<script type=\"text/javascript\" src=\"%s\"></script>\n"; 35 36 protected $script_tag = "<script type=\"text/javascript\">\n/* <![CDATA[ */\n%s\n/* ]]> */\n</script>"; 37 protected $link_css_file = "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n"; 36 38 protected $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>"; 37 39 … … 62 64 return; 63 65 } 66 67 $sa_files[] = $file; 68 64 69 if (!is_array($this->script_files[$position])) { 65 70 $this->script_files[$position] = array(); … … 81 86 $this->scripts[$position] .= "\n".rtrim($script); 82 87 } 88 } 89 90 /** 91 * Link an external css file 92 * 93 * @param string File URL 94 */ 95 public function include_css($file) 96 { 97 $this->css_files[] = $file; 83 98 } 84 99 … … 164 179 165 180 // replace specialchars in content 166 $__page_title = Q($this->title, 'show', FALSE); 167 $__page_header = $__page_body = $__page_footer = ''; 181 $page_title = Q($this->title, 'show', FALSE); 182 $page_header = ''; 183 $page_footer = ''; 168 184 169 185 // include meta tag with charset … … 172 188 header('Content-Type: text/html; charset=' . $this->charset); 173 189 } 174 $ __page_header = '<meta http-equiv="content-type"';175 $ __page_header.= ' content="text/html; charset=';176 $ __page_header.= $this->charset . '" />'."\n";190 $page_header = '<meta http-equiv="content-type"'; 191 $page_header.= ' content="text/html; charset='; 192 $page_header.= $this->charset . '" />'."\n"; 177 193 } 178 194 … … 180 196 if (is_array($this->script_files['head'])) { 181 197 foreach ($this->script_files['head'] as $file) { 182 $ __page_header .= sprintf($this->script_tag_file, $file);198 $page_header .= sprintf($this->script_tag_file, $file); 183 199 } 184 200 } … … 186 202 $head_script = $this->scripts['head_top'] . $this->scripts['head']; 187 203 if (!empty($head_script)) { 188 $ __page_header .= sprintf($this->script_tag, $head_script);204 $page_header .= sprintf($this->script_tag, $head_script); 189 205 } 190 206 191 207 if (!empty($this->header)) { 192 $ __page_header .= $this->header;208 $page_header .= $this->header; 193 209 } 194 210 195 211 if (is_array($this->script_files['foot'])) { 196 212 foreach ($this->script_files['foot'] as $file) { 197 $ __page_footer .= sprintf($this->script_tag_file, $file);213 $page_footer .= sprintf($this->script_tag_file, $file); 198 214 } 199 215 } 200 216 201 217 if (!empty($this->scripts['foot'])) { 202 $ __page_footer .= sprintf($this->script_tag, $this->scripts['foot']);218 $page_footer .= sprintf($this->script_tag, $this->scripts['foot']); 203 219 } 204 220 205 221 if (!empty($this->footer)) { 206 $ __page_footer .= $this->footer;222 $page_footer .= $this->footer; 207 223 } 208 224 209 225 // find page header 210 226 if ($hpos = stripos($output, '</head>')) { 211 $ __page_header .= "\n";227 $page_header .= "\n"; 212 228 } 213 229 else { … … 221 237 $hpos++; 222 238 } 223 $ __page_header = "<head>\n<title>$__page_title</title>\n$__page_header\n</head>\n";239 $page_header = "<head>\n<title>$page_title</title>\n$page_header\n</head>\n"; 224 240 } 225 241 226 242 // add page hader 227 243 if ($hpos) { 228 $output = substr($output,0,$hpos) . $ __page_header . substr($output,$hpos,strlen($output));244 $output = substr($output,0,$hpos) . $page_header . substr($output,$hpos,strlen($output)); 229 245 } 230 246 else { 231 $output = $__page_header . $output; 232 } 233 234 // find page body 235 if ($bpos = stripos($output, '<body')) { 236 while ($output[$bpos] != '>') { 237 $bpos++; 238 } 239 $bpos++; 247 $output = $page_header . $output; 248 } 249 250 // add page footer 251 if (($fpos = strripos($output, '</body>')) || ($fpos = strripos($output, '</html>'))) { 252 $output = substr($output, 0, $fpos) . "$page_footer\n" . substr($output, $fpos); 240 253 } 241 254 else { 242 $bpos = stripos($output, '</head>')+7; 243 } 244 245 // add page body 246 if ($bpos && $__page_body) { 247 $output = substr($output,0,$bpos) . "\n$__page_body\n" . substr($output,$bpos,strlen($output)); 248 } 249 250 // find and add page footer 251 if (($fpos = strripos($output, '</body>')) || ($fpos = strripos($output, '</html>'))) { 252 $output = substr($output, 0, $fpos) . "$__page_footer\n" . substr($output, $fpos); 253 } 254 else { 255 $output .= "\n".$__page_footer; 256 } 257 258 // reset those global vars 259 $__page_header = $__page_footer = ''; 255 $output .= "\n".$page_footer; 256 } 257 258 // add css files in head, before scripts, for speed up with parallel downloads 259 if (!empty($this->css_files) && 260 (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>'))) 261 ) { 262 $css = ''; 263 foreach ($this->css_files as $file) { 264 $css .= sprintf($this->link_css_file, $file); 265 } 266 $output = substr($output, 0, $pos) . $css . substr($output, $pos); 267 } 260 268 261 269 $this->base_path = $base_path; 270 262 271 // correct absolute paths in images and other tags 263 272 // add timestamp to .js and .css filename 264 $output = preg_replace_callback('!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i', 265 array($this, 'file_callback'), $output); 273 $output = preg_replace_callback( 274 '!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i', 275 array($this, 'file_callback'), $output); 266 276 $output = str_replace('$__skin_path', $base_path, $output); 267 277 -
trunk/roundcubemail/program/include/rcube_plugin_api.php
r4410 r4414 396 396 if ($this->output->type == 'html') { 397 397 $src = $this->resource_url($fn); 398 $this->output-> add_header(html::tag('link', array('rel' => "stylesheet", 'type' => "text/css", 'href' => $src)));398 $this->output->include_css($src); 399 399 } 400 400 } … … 438 438 439 439 } 440
Note: See TracChangeset
for help on using the changeset viewer.
