alecpl
2011-05-21 bc8c2c57880523472b30f475d566a8133e2d2e20
commit | author | age
47124c 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/include/rcube_template.php                                    |
6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
044d66 8  | Copyright (C) 2006-2011, The Roundcube Dev Team                       |
47124c 9  | Licensed under the GNU GPL                                            |
T 10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Class to handle HTML page output using a skin template.             |
13  |   Extends rcube_html_page class from rcube_shared.inc                 |
14  |                                                                       |
15  +-----------------------------------------------------------------------+
16  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
17  +-----------------------------------------------------------------------+
18
19  $Id$
20
21  */
22
23
24 /**
25  * Class to create HTML page output using a skin template
26  *
27  * @package View
28  * @todo Documentation
29  * @uses rcube_html_page
30  */
31 class rcube_template extends rcube_html_page
32 {
1ac543 33     private $app;
A 34     private $config;
35     private $pagetitle = '';
36     private $message = null;
37     private $js_env = array();
38     private $js_commands = array();
39     private $object_handlers = array();
fbe24e 40     private $plugin_skin_path;
8e99ff 41     private $template_name;
47124c 42
115158 43     public $browser;
1ac543 44     public $framed = false;
A 45     public $env = array();
c8a21d 46     public $type = 'html';
47124c 47     public $ajax_call = false;
T 48
7fcb56 49     // deprecated names of templates used before 0.5
T 50     private $deprecated_templates = array(
51         'contact' => 'showcontact',
52         'contactadd' => 'addcontact',
53         'contactedit' => 'editcontact',
54         'identityedit' => 'editidentity',
55         'messageprint' => 'printmessage',
56     );
57
47124c 58     /**
T 59      * Constructor
60      *
197601 61      * @todo   Replace $this->config with the real rcube_config object
47124c 62      */
197601 63     public function __construct($task, $framed = false)
47124c 64     {
T 65         parent::__construct();
66
197601 67         $this->app = rcmail::get_instance();
T 68         $this->config = $this->app->config->all();
a3f149 69         $this->browser = new rcube_browser();
ad334a 70
197601 71         //$this->framed = $framed;
83a763 72         $this->set_env('task', $task);
47124c 73
423065 74         // load the correct skin (in case user-defined)
T 75         $this->set_skin($this->config['skin']);
e58df3 76
47124c 77         // add common javascripts
79cd6c 78         $this->add_script('var '.JS_OBJECT_NAME.' = new rcube_webmail();', 'head_top');
47124c 79
T 80         // don't wait for page onload. Call init at the bottom of the page (delayed)
044d66 81         $this->add_script(JS_OBJECT_NAME.'.init();', 'docready');
47124c 82
T 83         $this->scripts_path = 'program/js/';
79275b 84         $this->include_script('jquery.min.js');
47124c 85         $this->include_script('common.js');
T 86         $this->include_script('app.js');
87
88         // register common UI objects
89         $this->add_handlers(array(
90             'loginform'       => array($this, 'login_form'),
8e211a 91             'preloader'       => array($this, 'preloader'),
47124c 92             'username'        => array($this, 'current_username'),
T 93             'message'         => array($this, 'message_container'),
94             'charsetselector' => array($this, 'charset_selector'),
95         ));
96     }
97
98     /**
99      * Set environment variable
100      *
101      * @param string Property name
102      * @param mixed Property value
103      * @param boolean True if this property should be added to client environment
104      */
105     public function set_env($name, $value, $addtojs = true)
106     {
107         $this->env[$name] = $value;
108         if ($addtojs || isset($this->js_env[$name])) {
109             $this->js_env[$name] = $value;
110         }
111     }
112
113     /**
114      * Set page title variable
115      */
116     public function set_pagetitle($title)
117     {
118         $this->pagetitle = $title;
119     }
f645ce 120
T 121     /**
122      * Getter for the current page title
123      *
124      * @return string The page title
125      */
126     public function get_pagetitle()
127     {
128         if (!empty($this->pagetitle)) {
129             $title = $this->pagetitle;
130         }
131         else if ($this->env['task'] == 'login') {
132             $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name'])));
133         }
134         else {
135             $title = ucfirst($this->env['task']);
136         }
ad334a 137
f645ce 138         return $title;
T 139     }
140
e58df3 141     /**
A 142      * Set skin
143      */
144     public function set_skin($skin)
145     {
62c791 146         $valid = false;
ad334a 147
62c791 148         if (!empty($skin) && is_dir('skins/'.$skin) && is_readable('skins/'.$skin)) {
423065 149             $skin_path = 'skins/'.$skin;
62c791 150             $valid = true;
T 151         }
152         else {
423065 153             $skin_path = $this->config['skin_path'] ? $this->config['skin_path'] : 'skins/default';
62c791 154             $valid = !$skin;
T 155         }
423065 156
T 157         $this->app->config->set('skin_path', $skin_path);
158         $this->config['skin_path'] = $skin_path;
ad334a 159
62c791 160         return $valid;
e58df3 161     }
A 162
163     /**
164      * Check if a specific template exists
165      *
166      * @param string Template name
167      * @return boolean True if template exists
168      */
169     public function template_exists($name)
170     {
423065 171         $filename = $this->config['skin_path'] . '/templates/' . $name . '.html';
7fcb56 172         return (is_file($filename) && is_readable($filename)) || ($this->deprecated_templates[$name] && $this->template_exists($this->deprecated_templates[$name]));
e58df3 173     }
47124c 174
T 175     /**
176      * Register a template object handler
177      *
178      * @param  string Object name
179      * @param  string Function name to call
180      * @return void
181      */
182     public function add_handler($obj, $func)
183     {
184         $this->object_handlers[$obj] = $func;
185     }
186
187     /**
188      * Register a list of template object handlers
189      *
190      * @param  array Hash array with object=>handler pairs
191      * @return void
192      */
193     public function add_handlers($arr)
194     {
195         $this->object_handlers = array_merge($this->object_handlers, $arr);
196     }
197
198     /**
199      * Register a GUI object to the client script
200      *
201      * @param  string Object name
202      * @param  string Object ID
203      * @return void
204      */
205     public function add_gui_object($obj, $id)
206     {
207         $this->add_script(JS_OBJECT_NAME.".gui_object('$obj', '$id');");
208     }
209
210     /**
211      * Call a client method
212      *
213      * @param string Method to call
214      * @param ... Additional arguments
215      */
216     public function command()
217     {
0e99d3 218         $cmd = func_get_args();
T 219         if (strpos($cmd[0], 'plugin.') === false)
220           $this->js_commands[] = $cmd;
47124c 221     }
T 222
223     /**
224      * Add a localized label to the client environment
225      */
226     public function add_label()
227     {
cc97ea 228         $args = func_get_args();
T 229         if (count($args) == 1 && is_array($args[0]))
230           $args = $args[0];
ad334a 231
cc97ea 232         foreach ($args as $name) {
47124c 233             $this->command('add_label', $name, rcube_label($name));
T 234         }
235     }
236
237     /**
238      * Invoke display_message command
239      *
240      * @param string Message to display
241      * @param string Message type [notice|confirm|error]
242      * @param array Key-value pairs to be replaced in localized text
69f18a 243      * @param boolean Override last set message
47124c 244      * @uses self::command()
T 245      */
69f18a 246     public function show_message($message, $type='notice', $vars=null, $override=true)
47124c 247     {
69f18a 248         if ($override || !$this->message) {
T 249             $this->message = $message;
07b95d 250             $msgtext = rcube_label_exists($message) ? rcube_label(array('name' => $message, 'vars' => $vars)) : $message;
T 251             $this->command('display_message', $msgtext, $type);
69f18a 252         }
47124c 253     }
T 254
255     /**
256      * Delete all stored env variables and commands
257      *
258      * @return void
259      * @uses   rcube_html::reset()
260      * @uses   self::$env
261      * @uses   self::$js_env
262      * @uses   self::$js_commands
263      * @uses   self::$object_handlers
264      */
c719f3 265     public function reset()
47124c 266     {
T 267         $this->env = array();
268         $this->js_env = array();
269         $this->js_commands = array();
270         $this->object_handlers = array();
271         parent::reset();
272     }
273
274     /**
c719f3 275      * Redirect to a certain url
T 276      *
277      * @param mixed Either a string with the action or url parameters as key-value pairs
278      * @see rcmail::url()
279      */
280     public function redirect($p = array())
281     {
282         $location = $this->app->url($p);
283         header('Location: ' . $location);
284         exit;
285     }
286
287     /**
47124c 288      * Send the request output to the client.
T 289      * This will either parse a skin tempalte or send an AJAX response
290      *
291      * @param string  Template name
292      * @param boolean True if script should terminate (default)
293      */
294     public function send($templ = null, $exit = true)
295     {
296         if ($templ != 'iframe') {
a366a3 297             // prevent from endless loops
f78dab 298             if ($exit != 'recur' && $this->app->plugins->is_processing('render_page')) {
10eedb 299                 raise_error(array('code' => 505, 'type' => 'php',
030db5 300                   'file' => __FILE__, 'line' => __LINE__,
T 301                   'message' => 'Recursion alert: ignoring output->send()'), true, false);
a366a3 302                 return;
T 303             }
47124c 304             $this->parse($templ, false);
T 305         }
306         else {
307             $this->framed = $templ == 'iframe' ? true : $this->framed;
308             $this->write();
309         }
310
c6514e 311         // set output asap
T 312         ob_flush();
313         flush();
ad334a 314
c6514e 315         if ($exit) {
47124c 316             exit;
T 317         }
318     }
319
320     /**
321      * Process template and write to stdOut
322      *
323      * @param string HTML template
324      * @see rcube_html_page::write()
325      * @override
326      */
327     public function write($template = '')
328     {
329         // unlock interface after iframe load
ad334a 330         $unlock = preg_replace('/[^a-z0-9]/i', '', $_GET['_unlock']);
47124c 331         if ($this->framed) {
ad334a 332             array_unshift($this->js_commands, array('set_busy', false, null, $unlock));
A 333         }
334         else if ($unlock) {
335             array_unshift($this->js_commands, array('hide_message', $unlock));
47124c 336         }
ef27a6 337
49dac9 338         if (!empty($this->script_files))
T 339           $this->set_env('request_token', $this->app->get_request_token());
ef27a6 340
47124c 341         // write all env variables to client
T 342         $js = $this->framed ? "if(window.parent) {\n" : '';
343         $js .= $this->get_js_commands() . ($this->framed ? ' }' : '');
344         $this->add_script($js, 'head_top');
ad334a 345
549933 346         // make sure all <form> tags have a valid request token
T 347         $template = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $template);
efbe9e 348         $this->footer = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $this->footer);
47124c 349
T 350         // call super method
351         parent::write($template, $this->config['skin_path']);
352     }
353
354     /**
c739c7 355      * Parse a specific skin template and deliver to stdout (or return)
47124c 356      *
T 357      * @param  string  Template name
358      * @param  boolean Exit script
c739c7 359      * @param  boolean Don't write to stdout, return parsed content instead
A 360      *
47124c 361      * @link   http://php.net/manual/en/function.exit.php
T 362      */
c739c7 363     function parse($name = 'main', $exit = true, $write = true)
47124c 364     {
T 365         $skin_path = $this->config['skin_path'];
ca18a9 366         $plugin    = false;
A 367         $realname  = $name;
368         $temp      = explode('.', $name, 2);
8e99ff 369
fbe24e 370         $this->plugin_skin_path = null;
8e99ff 371         $this->template_name    = $realname;
ad334a 372
e7008c 373         if (count($temp) > 1) {
ca18a9 374             $plugin    = $temp[0];
A 375             $name      = $temp[1];
376             $skin_dir  = $plugin . '/skins/' . $this->config['skin'];
fbe24e 377             $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
ca18a9 378
A 379             // fallback to default skin
380             if (!is_dir($skin_path)) {
20d50d 381                 $skin_dir = $plugin . '/skins/default';
fbe24e 382                 $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
20d50d 383             }
e7008c 384         }
ad334a 385
e7008c 386         $path = "$skin_path/templates/$name.html";
47124c 387
ca18a9 388         if (!is_readable($path) && $this->deprecated_templates[$realname]) {
A 389             $path = "$skin_path/templates/".$this->deprecated_templates[$realname].".html";
7fcb56 390             if (is_readable($path))
T 391                 raise_error(array('code' => 502, 'type' => 'php',
392                     'file' => __FILE__, 'line' => __LINE__,
ca18a9 393                     'message' => "Using deprecated template '".$this->deprecated_templates[$realname]
A 394                         ."' in ".$this->config['skin_path']."/templates. Please rename to '".$realname."'"),
7fcb56 395                 true, false);
T 396         }
397
ff73e0 398         // read template file
7f22f2 399         if (($templ = @file_get_contents($path)) === false) {
f92b2f 400             raise_error(array(
47124c 401                 'code' => 501,
T 402                 'type' => 'php',
403                 'line' => __LINE__,
404                 'file' => __FILE__,
ca18a9 405                 'message' => 'Error loading template for '.$realname
47124c 406                 ), true, true);
T 407             return false;
408         }
ad334a 409
66f68e 410         // replace all path references to plugins/... with the configured plugins dir
T 411         // and /this/ to the current plugin skin directory
e7008c 412         if ($plugin) {
20d50d 413             $templ = preg_replace(array('/\bplugins\//', '/(["\']?)\/this\//'), array($this->app->plugins->url, '\\1'.$this->app->plugins->url.$skin_dir.'/'), $templ);
e7008c 414         }
47124c 415
T 416         // parse for specialtags
417         $output = $this->parse_conditions($templ);
418         $output = $this->parse_xml($output);
ad334a 419
742d61 420         // trigger generic hook where plugins can put additional content to the page
ca18a9 421         $hook = $this->app->plugins->exec_hook("render_page", array('template' => $realname, 'content' => $output));
47124c 422
c739c7 423         $output = $this->parse_with_globals($hook['content']);
A 424
425         if ($write) {
426             // add debug console
427             if ($this->config['debug_level'] & 8) {
428                 $this->add_footer('<div id="console" style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;z-index:9000;">
429                     <a href="#toggle" onclick="con=$(\'#dbgconsole\');con[con.is(\':visible\')?\'hide\':\'show\']();return false">console</a>
430                     <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>'
431                 );
432             }
433             $this->write(trim($output));
434         }
435         else {
436             return $output;
47124c 437         }
ad334a 438
47124c 439         if ($exit) {
T 440             exit;
441         }
442     }
443
444     /**
445      * Return executable javascript code for all registered commands
446      *
447      * @return string $out
448      */
449     private function get_js_commands()
450     {
451         $out = '';
452         if (!$this->framed && !empty($this->js_env)) {
2717f9 453             $out .= JS_OBJECT_NAME . '.set_env('.json_serialize($this->js_env).");\n";
47124c 454         }
T 455         foreach ($this->js_commands as $i => $args) {
456             $method = array_shift($args);
457             foreach ($args as $i => $arg) {
2717f9 458                 $args[$i] = json_serialize($arg);
47124c 459             }
T 460             $parent = $this->framed || preg_match('/^parent\./', $method);
461             $out .= sprintf(
462                 "%s.%s(%s);\n",
cc97ea 463                 ($parent ? 'if(window.parent && parent.'.JS_OBJECT_NAME.') parent.' : '') . JS_OBJECT_NAME,
T 464                 preg_replace('/^parent\./', '', $method),
465                 implode(',', $args)
47124c 466             );
T 467         }
ad334a 468
47124c 469         return $out;
T 470     }
471
472     /**
473      * Make URLs starting with a slash point to skin directory
474      *
475      * @param  string Input string
476      * @return string
477      */
478     public function abs_url($str)
479     {
2aa2b3 480         if ($str[0] == '/')
A 481             return $this->config['skin_path'] . $str;
482         else
483             return $str;
47124c 484     }
T 485
486
487     /*****  Template parsing methods  *****/
488
489     /**
490      * Replace all strings ($varname)
491      * with the content of the according global variable.
492      */
493     private function parse_with_globals($input)
494     {
533e86 495         $GLOBALS['__version'] = Q(RCMAIL_VERSION);
197601 496         $GLOBALS['__comm_path'] = Q($this->app->comm_path);
5740c0 497         return preg_replace_callback('/\$(__[a-z0-9_\-]+)/',
A 498         array($this, 'globals_callback'), $input);
499     }
500
501     /**
502      * Callback funtion for preg_replace_callback() in parse_with_globals()
503      */
504     private function globals_callback($matches)
505     {
506         return $GLOBALS[$matches[1]];
47124c 507     }
T 508
509     /**
510      * Public wrapper to dipp into template parsing.
511      *
512      * @param  string $input
513      * @return string
514      * @uses   rcube_template::parse_xml()
515      * @since  0.1-rc1
516      */
517     public function just_parse($input)
518     {
519         return $this->parse_xml($input);
520     }
521
522     /**
523      * Parse for conditional tags
524      *
525      * @param  string $input
526      * @return string
527      */
528     private function parse_conditions($input)
529     {
84581e 530         $matches = preg_split('/<roundcube:(if|elseif|else|endif)\s+([^>]+)>\n?/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
47124c 531         if ($matches && count($matches) == 4) {
T 532             if (preg_match('/^(else|endif)$/i', $matches[1])) {
533                 return $matches[0] . $this->parse_conditions($matches[3]);
534             }
535             $attrib = parse_attrib_string($matches[2]);
536             if (isset($attrib['condition'])) {
537                 $condmet = $this->check_condition($attrib['condition']);
84581e 538                 $submatches = preg_split('/<roundcube:(elseif|else|endif)\s+([^>]+)>\n?/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
47124c 539                 if ($condmet) {
T 540                     $result = $submatches[0];
84581e 541                     $result.= ($submatches[1] != 'endif' ? preg_replace('/.*<roundcube:endif\s+[^>]+>\n?/Uis', '', $submatches[3], 1) : $submatches[3]);
47124c 542                 }
T 543                 else {
544                     $result = "<roundcube:$submatches[1] $submatches[2]>" . $submatches[3];
545                 }
546                 return $matches[0] . $this->parse_conditions($result);
547             }
f92b2f 548             raise_error(array(
47124c 549                 'code' => 500,
T 550                 'type' => 'php',
551                 'line' => __LINE__,
552                 'file' => __FILE__,
553                 'message' => "Unable to parse conditional tag " . $matches[2]
554             ), true, false);
555         }
556         return $input;
557     }
558
559
560     /**
561      * Determines if a given condition is met
562      *
563      * @todo   Get rid off eval() once I understand what this does.
564      * @todo   Extend this to allow real conditions, not just "set"
565      * @param  string Condition statement
8e1d4a 566      * @return boolean True if condition is met, False if not
47124c 567      */
T 568     private function check_condition($condition)
569     {
549933 570         return eval("return (".$this->parse_expression($condition).");");
T 571     }
ad334a 572
A 573
549933 574     /**
2eb794 575      * Inserts hidden field with CSRF-prevention-token into POST forms
549933 576      */
T 577     private function alter_form_tag($matches)
578     {
579         $out = $matches[0];
580         $attrib  = parse_attrib_string($matches[1]);
ad334a 581
549933 582         if (strtolower($attrib['method']) == 'post') {
T 583             $hidden = new html_hiddenfield(array('name' => '_token', 'value' => $this->app->get_request_token()));
584             $out .= "\n" . $hidden->show();
585         }
ad334a 586
549933 587         return $out;
8e1d4a 588     }
A 589
590
591     /**
592      * Parses expression and replaces variables
593      *
594      * @param  string Expression statement
030db5 595      * @return string Expression value
8e1d4a 596      */
A 597     private function parse_expression($expression)
598     {
599         return preg_replace(
47124c 600             array(
T 601                 '/session:([a-z0-9_]+)/i',
f645ce 602                 '/config:([a-z0-9_]+)(:([a-z0-9_]+))?/i',
40353f 603                 '/env:([a-z0-9_]+)/i',
A 604                 '/request:([a-z0-9_]+)/i',
605                 '/cookie:([a-z0-9_]+)/i',
8e99ff 606                 '/browser:([a-z0-9_]+)/i',
A 607                 '/template:name/i',
47124c 608             ),
T 609             array(
610                 "\$_SESSION['\\1']",
f645ce 611                 "\$this->app->config->get('\\1',get_boolean('\\3'))",
47124c 612                 "\$this->env['\\1']",
ea373f 613                 "get_input_value('\\1', RCUBE_INPUT_GPC)",
a17fe6 614                 "\$_COOKIE['\\1']",
8e99ff 615                 "\$this->browser->{'\\1'}",
A 616                 $this->template_name,
47124c 617             ),
8e1d4a 618             $expression);
47124c 619     }
T 620
621
622     /**
623      * Search for special tags in input and replace them
624      * with the appropriate content
625      *
626      * @param  string Input string to parse
627      * @return string Altered input string
06655a 628      * @todo   Use DOM-parser to traverse template HTML
47124c 629      * @todo   Maybe a cache.
T 630      */
631     private function parse_xml($input)
632     {
cc97ea 633         return preg_replace_callback('/<roundcube:([-_a-z]+)\s+([^>]+)>/Ui', array($this, 'xml_command'), $input);
6f488b 634     }
A 635
636
637     /**
cc97ea 638      * Callback function for parsing an xml command tag
T 639      * and turn it into real html content
47124c 640      *
cc97ea 641      * @param  array Matches array of preg_replace_callback
47124c 642      * @return string Tag/Object content
T 643      */
cc97ea 644     private function xml_command($matches)
47124c 645     {
cc97ea 646         $command = strtolower($matches[1]);
T 647         $attrib  = parse_attrib_string($matches[2]);
47124c 648
T 649         // empty output if required condition is not met
650         if (!empty($attrib['condition']) && !$this->check_condition($attrib['condition'])) {
651             return '';
652         }
653
654         // execute command
655         switch ($command) {
656             // return a button
657             case 'button':
875a48 658                 if ($attrib['name'] || $attrib['command']) {
47124c 659                     return $this->button($attrib);
T 660                 }
661                 break;
662
663             // show a label
664             case 'label':
665                 if ($attrib['name'] || $attrib['command']) {
ae39c4 666                     $label = rcube_label($attrib + array('vars' => array('product' => $this->config['product_name'])));
T 667                     return !$attrbi['noshow'] ? Q($label) : '';
47124c 668                 }
T 669                 break;
670
671             // include a file
672             case 'include':
fbe24e 673                 if (!$this->plugin_skin_path || !is_file($path = realpath($this->plugin_skin_path . $attrib['file'])))
T 674                     $path = realpath(($attrib['skin_path'] ? $attrib['skin_path'] : $this->config['skin_path']).$attrib['file']);
675                 
ff73e0 676                 if (is_readable($path)) {
47124c 677                     if ($this->config['skin_include_php']) {
T 678                         $incl = $this->include_php($path);
679                     }
ff73e0 680                     else {
cc97ea 681                       $incl = file_get_contents($path);
T 682                     }
b4f7c6 683                     $incl = $this->parse_conditions($incl);
47124c 684                     return $this->parse_xml($incl);
T 685                 }
686                 break;
687
688             case 'plugin.include':
cc97ea 689                 $hook = $this->app->plugins->exec_hook("template_plugin_include", $attrib);
T 690                 return $hook['content'];
691                 break;
ad334a 692
cc97ea 693             // define a container block
T 694             case 'container':
695                 if ($attrib['name'] && $attrib['id']) {
696                     $this->command('gui_container', $attrib['name'], $attrib['id']);
697                     // let plugins insert some content here
698                     $hook = $this->app->plugins->exec_hook("template_container", $attrib);
699                     return $hook['content'];
47124c 700                 }
T 701                 break;
702
703             // return code for a specific application object
704             case 'object':
705                 $object = strtolower($attrib['name']);
cc97ea 706                 $content = '';
47124c 707
T 708                 // we are calling a class/method
709                 if (($handler = $this->object_handlers[$object]) && is_array($handler)) {
710                     if ((is_object($handler[0]) && method_exists($handler[0], $handler[1])) ||
711                     (is_string($handler[0]) && class_exists($handler[0])))
cc97ea 712                     $content = call_user_func($handler, $attrib);
47124c 713                 }
cc97ea 714                 // execute object handler function
47124c 715                 else if (function_exists($handler)) {
cc97ea 716                     $content = call_user_func($handler, $attrib);
47124c 717                 }
ae39c4 718                 else if ($object == 'logo') {
T 719                     $attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"')));
720                     if ($this->config['skin_logo'])
721                         $attrib['src'] = $this->config['skin_logo'];
722                     $content = html::img($attrib);
723                 }
cc97ea 724                 else if ($object == 'productname') {
e019f2 725                     $name = !empty($this->config['product_name']) ? $this->config['product_name'] : 'Roundcube Webmail';
cc97ea 726                     $content = Q($name);
47124c 727                 }
cc97ea 728                 else if ($object == 'version') {
c8fb2b 729                     $ver = (string)RCMAIL_VERSION;
T 730                     if (is_file(INSTALL_PATH . '.svn/entries')) {
731                         if (preg_match('/Revision:\s(\d+)/', @shell_exec('svn info'), $regs))
732                           $ver .= ' [SVN r'.$regs[1].']';
733                     }
cc97ea 734                     $content = Q($ver);
47124c 735                 }
cc97ea 736                 else if ($object == 'steptitle') {
T 737                   $content = Q($this->get_pagetitle());
f645ce 738                 }
cc97ea 739                 else if ($object == 'pagetitle') {
47124c 740                     $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '';
f645ce 741                     $title .= $this->get_pagetitle();
cc97ea 742                     $content = Q($title);
47124c 743                 }
ad334a 744
cc97ea 745                 // exec plugin hooks for this template object
T 746                 $hook = $this->app->plugins->exec_hook("template_object_$object", $attrib + array('content' => $content));
747                 return $hook['content'];
8e1d4a 748
A 749             // return code for a specified eval expression
750             case 'exp':
cc97ea 751                 $value = $this->parse_expression($attrib['expression']);
8e1d4a 752                 return eval("return Q($value);");
ad334a 753
47124c 754             // return variable
T 755             case 'var':
756                 $var = explode(':', $attrib['name']);
757                 $name = $var[1];
758                 $value = '';
759
760                 switch ($var[0]) {
761                     case 'env':
762                         $value = $this->env[$name];
763                         break;
764                     case 'config':
765                         $value = $this->config[$name];
766                         if (is_array($value) && $value[$_SESSION['imap_host']]) {
767                             $value = $value[$_SESSION['imap_host']];
768                         }
769                         break;
770                     case 'request':
771                         $value = get_input_value($name, RCUBE_INPUT_GPC);
772                         break;
773                     case 'session':
774                         $value = $_SESSION[$name];
775                         break;
d4273b 776                     case 'cookie':
A 777                         $value = htmlspecialchars($_COOKIE[$name]);
778                         break;
a17fe6 779                     case 'browser':
A 780                         $value = $this->browser->{$name};
781                         break;
47124c 782                 }
T 783
784                 if (is_array($value)) {
785                     $value = implode(', ', $value);
786                 }
787
788                 return Q($value);
789                 break;
790         }
791         return '';
792     }
793
794     /**
795      * Include a specific file and return it's contents
796      *
797      * @param string File path
798      * @return string Contents of the processed file
799      */
800     private function include_php($file)
801     {
802         ob_start();
803         include $file;
804         $out = ob_get_contents();
805         ob_end_clean();
806
807         return $out;
808     }
809
810     /**
811      * Create and register a button
812      *
813      * @param  array Named button attributes
814      * @return string HTML button
815      * @todo   Remove all inline JS calls and use jQuery instead.
816      * @todo   Remove all sprintf()'s - they are pretty, but also slow.
817      */
ed132e 818     public function button($attrib)
47124c 819     {
T 820         static $s_button_count = 100;
821
822         // these commands can be called directly via url
cc97ea 823         $a_static_commands = array('compose', 'list', 'preferences', 'folders', 'identities');
47124c 824
T 825         if (!($attrib['command'] || $attrib['name'])) {
826             return '';
827         }
ae0c82 828
47124c 829         // try to find out the button type
T 830         if ($attrib['type']) {
831             $attrib['type'] = strtolower($attrib['type']);
832         }
833         else {
834             $attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $attrib['imageact']) ? 'image' : 'link';
835         }
e9b5a6 836
47124c 837         $command = $attrib['command'];
T 838
e9b5a6 839         if ($attrib['task'])
T 840           $command = $attrib['task'] . '.' . $command;
ad334a 841
af3cf8 842         if (!$attrib['image']) {
T 843             $attrib['image'] = $attrib['imagepas'] ? $attrib['imagepas'] : $attrib['imageact'];
844         }
47124c 845
T 846         if (!$attrib['id']) {
847             $attrib['id'] =  sprintf('rcmbtn%d', $s_button_count++);
848         }
849         // get localized text for labels and titles
850         if ($attrib['title']) {
1c932d 851             $attrib['title'] = Q(rcube_label($attrib['title'], $attrib['domain']));
47124c 852         }
T 853         if ($attrib['label']) {
1c932d 854             $attrib['label'] = Q(rcube_label($attrib['label'], $attrib['domain']));
47124c 855         }
T 856         if ($attrib['alt']) {
1c932d 857             $attrib['alt'] = Q(rcube_label($attrib['alt'], $attrib['domain']));
47124c 858         }
9b2ccd 859
47124c 860         // set title to alt attribute for IE browsers
c9e9fe 861         if ($this->browser->ie && !$attrib['title'] && $attrib['alt']) {
A 862             $attrib['title'] = $attrib['alt'];
47124c 863         }
T 864
865         // add empty alt attribute for XHTML compatibility
866         if (!isset($attrib['alt'])) {
867             $attrib['alt'] = '';
868         }
869
870         // register button in the system
871         if ($attrib['command']) {
872             $this->add_script(sprintf(
873                 "%s.register_button('%s', '%s', '%s', '%s', '%s', '%s');",
874                 JS_OBJECT_NAME,
875                 $command,
876                 $attrib['id'],
877                 $attrib['type'],
ae0c82 878                 $attrib['imageact'] ? $this->abs_url($attrib['imageact']) : $attrib['classact'],
A 879                 $attrib['imagesel'] ? $this->abs_url($attrib['imagesel']) : $attrib['classsel'],
880                 $attrib['imageover'] ? $this->abs_url($attrib['imageover']) : ''
47124c 881             ));
T 882
883             // make valid href to specific buttons
197601 884             if (in_array($attrib['command'], rcmail::$main_tasks)) {
203ee4 885                 $attrib['href'] = rcmail_url(null, null, $attrib['command']);
47124c 886             }
e9b5a6 887             else if ($attrib['task'] && in_array($attrib['task'], rcmail::$main_tasks)) {
T 888                 $attrib['href'] = rcmail_url($attrib['command'], null, $attrib['task']);
889             }
47124c 890             else if (in_array($attrib['command'], $a_static_commands)) {
203ee4 891                 $attrib['href'] = rcmail_url($attrib['command']);
a25d39 892             }
29f977 893             else if ($attrib['command'] == 'permaurl' && !empty($this->env['permaurl'])) {
T 894               $attrib['href'] = $this->env['permaurl'];
895             }
47124c 896         }
T 897
898         // overwrite attributes
899         if (!$attrib['href']) {
900             $attrib['href'] = '#';
901         }
e9b5a6 902         if ($attrib['task']) {
T 903             if ($attrib['classact'])
904                 $attrib['class'] = $attrib['classact'];
905         }
906         else if ($command && !$attrib['onclick']) {
47124c 907             $attrib['onclick'] = sprintf(
T 908                 "return %s.command('%s','%s',this)",
909                 JS_OBJECT_NAME,
910                 $command,
911                 $attrib['prop']
912             );
913         }
914
915         $out = '';
916
917         // generate image tag
918         if ($attrib['type']=='image') {
919             $attrib_str = html::attrib_string(
920                 $attrib,
921                 array(
c9e9fe 922                     'style', 'class', 'id', 'width', 'height', 'border', 'hspace',
A 923                     'vspace', 'align', 'alt', 'tabindex', 'title'
47124c 924                 )
T 925             );
ae0c82 926             $btn_content = sprintf('<img src="%s"%s />', $this->abs_url($attrib['image']), $attrib_str);
47124c 927             if ($attrib['label']) {
T 928                 $btn_content .= ' '.$attrib['label'];
929             }
c9e9fe 930             $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'target');
47124c 931         }
T 932         else if ($attrib['type']=='link') {
356a67 933             $btn_content = isset($attrib['content']) ? $attrib['content'] : ($attrib['label'] ? $attrib['label'] : $attrib['command']);
203ee4 934             $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex', 'target');
47124c 935         }
T 936         else if ($attrib['type']=='input') {
937             $attrib['type'] = 'button';
938
939             if ($attrib['label']) {
940                 $attrib['value'] = $attrib['label'];
941             }
942
943             $attrib_str = html::attrib_string(
944                 $attrib,
945                 array(
c9e9fe 946                     'type', 'value', 'onclick', 'id', 'class', 'style', 'tabindex'
47124c 947                 )
T 948             );
949             $out = sprintf('<input%s disabled="disabled" />', $attrib_str);
950         }
951
952         // generate html code for button
953         if ($btn_content) {
954             $attrib_str = html::attrib_string($attrib, $link_attrib);
955             $out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
956         }
957
958         return $out;
959     }
960
961
962     /*  ************* common functions delivering gui objects **************  */
963
964
965     /**
197601 966      * Create a form tag with the necessary hidden fields
T 967      *
968      * @param array Named tag parameters
969      * @return string HTML code for the form
970      */
971     public function form_tag($attrib, $content = null)
972     {
57f0c8 973       if ($this->framed || !empty($_REQUEST['_framed'])) {
197601 974         $hiddenfield = new html_hiddenfield(array('name' => '_framed', 'value' => '1'));
T 975         $hidden = $hiddenfield->show();
976       }
ad334a 977
197601 978       if (!$content)
T 979         $attrib['noclose'] = true;
ad334a 980
197601 981       return html::tag('form',
T 982         $attrib + array('action' => "./", 'method' => "get"),
57f0c8 983         $hidden . $content,
T 984         array('id','class','style','name','method','action','enctype','onsubmit'));
985     }
ad334a 986
A 987
57f0c8 988     /**
T 989      * Build a form tag with a unique request token
990      *
991      * @param array Named tag parameters including 'action' and 'task' values which will be put into hidden fields
992      * @param string Form content
993      * @return string HTML code for the form
994      */
747797 995     public function request_form($attrib, $content = '')
57f0c8 996     {
T 997         $hidden = new html_hiddenfield();
998         if ($attrib['task']) {
999             $hidden->add(array('name' => '_task', 'value' => $attrib['task']));
1000         }
1001         if ($attrib['action']) {
1002             $hidden->add(array('name' => '_action', 'value' => $attrib['action']));
1003         }
ad334a 1004
57f0c8 1005         unset($attrib['task'], $attrib['request']);
T 1006         $attrib['action'] = './';
ad334a 1007
57f0c8 1008         // we already have a <form> tag
0501b6 1009         if ($attrib['form']) {
T 1010             if ($this->framed || !empty($_REQUEST['_framed']))
1011                 $hidden->add(array('name' => '_framed', 'value' => '1'));
57f0c8 1012             return $hidden->show() . $content;
0501b6 1013         }
57f0c8 1014         else
T 1015             return $this->form_tag($attrib, $hidden->show() . $content);
197601 1016     }
T 1017
1018
1019     /**
47124c 1020      * GUI object 'username'
T 1021      * Showing IMAP username of the current session
1022      *
1023      * @param array Named tag parameters (currently not used)
1024      * @return string HTML code for the gui object
1025      */
197601 1026     public function current_username($attrib)
47124c 1027     {
T 1028         static $username;
1029
1030         // alread fetched
1031         if (!empty($username)) {
1032             return $username;
1033         }
1034
e99991 1035         // Current username is an e-mail address
A 1036         if (strpos($_SESSION['username'], '@')) {
1037             $username = $_SESSION['username'];
1038         }
929a50 1039         // get e-mail address from default identity
e99991 1040         else if ($sql_arr = $this->app->user->get_identity()) {
7e9cec 1041             $username = $sql_arr['email'];
47124c 1042         }
T 1043         else {
7e9cec 1044             $username = $this->app->user->get_username();
47124c 1045         }
T 1046
e8d5bd 1047         return rcube_idn_to_utf8($username);
47124c 1048     }
T 1049
1050
1051     /**
1052      * GUI object 'loginform'
1053      * Returns code for the webmail login form
1054      *
1055      * @param array Named parameters
1056      * @return string HTML code for the gui object
1057      */
1058     private function login_form($attrib)
1059     {
197601 1060         $default_host = $this->config['default_host'];
1cca4f 1061         $autocomplete = (int) $this->config['login_autocomplete'];
47124c 1062
T 1063         $_SESSION['temp'] = true;
ad334a 1064
cc97ea 1065         // save original url
T 1066         $url = get_input_value('_url', RCUBE_INPUT_POST);
3a2b27 1067         if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING']))
cc97ea 1068             $url = $_SERVER['QUERY_STRING'];
47124c 1069
1cca4f 1070         // set atocomplete attribute
A 1071         $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
1072         $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
1073         $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
1074
c3be8e 1075         $input_task   = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
47124c 1076         $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
c8ae24 1077         $input_tzone  = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
cc97ea 1078         $input_url    = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
1cca4f 1079         $input_user   = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser')
A 1080             + $attrib + $user_attrib);
1081         $input_pass   = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd')
1082             + $attrib + $pass_attrib);
47124c 1083         $input_host   = null;
T 1084
f3e101 1085         if (is_array($default_host) && count($default_host) > 1) {
47124c 1086             $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
T 1087
1088             foreach ($default_host as $key => $value) {
1089                 if (!is_array($value)) {
1090                     $input_host->add($value, (is_numeric($key) ? $value : $key));
1091                 }
1092                 else {
1093                     $input_host = null;
1094                     break;
1095                 }
1096             }
f3e101 1097         }
A 1098         else if (is_array($default_host) && ($host = array_pop($default_host))) {
1099             $hide_host = true;
1100             $input_host = new html_hiddenfield(array(
1101                 'name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
47124c 1102         }
e3e597 1103         else if (empty($default_host)) {
1cca4f 1104             $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost')
A 1105                 + $attrib + $host_attrib);
47124c 1106         }
T 1107
1108         $form_name  = !empty($attrib['form']) ? $attrib['form'] : 'form';
1109         $this->add_gui_object('loginform', $form_name);
1110
1111         // create HTML table with two cols
1112         $table = new html_table(array('cols' => 2));
1113
1114         $table->add('title', html::label('rcmloginuser', Q(rcube_label('username'))));
1013ba 1115         $table->add(null, $input_user->show(get_input_value('_user', RCUBE_INPUT_GPC)));
47124c 1116
T 1117         $table->add('title', html::label('rcmloginpwd', Q(rcube_label('password'))));
1118         $table->add(null, $input_pass->show());
1119
1120         // add host selection row
f3e101 1121         if (is_object($input_host) && !$hide_host) {
47124c 1122             $table->add('title', html::label('rcmloginhost', Q(rcube_label('server'))));
1013ba 1123             $table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_GPC)));
47124c 1124         }
T 1125
c3be8e 1126         $out  = $input_task->show();
T 1127         $out .= $input_action->show();
c8ae24 1128         $out .= $input_tzone->show();
cc97ea 1129         $out .= $input_url->show();
47124c 1130         $out .= $table->show();
ad334a 1131
f3e101 1132         if ($hide_host) {
A 1133             $out .= $input_host->show();
1134         }
47124c 1135
T 1136         // surround html output with a form tag
1137         if (empty($attrib['form'])) {
f3e101 1138             $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
47124c 1139         }
T 1140
1141         return $out;
1142     }
1143
1144
1145     /**
8e211a 1146      * GUI object 'preloader'
A 1147      * Loads javascript code for images preloading
1148      *
1149      * @param array Named parameters
1150      * @return void
1151      */
1152     private function preloader($attrib)
1153     {
1154         $images = preg_split('/[\s\t\n,]+/', $attrib['images'], -1, PREG_SPLIT_NO_EMPTY);
1155         $images = array_map(array($this, 'abs_url'), $images);
1156
1157         if (empty($images) || $this->app->task == 'logout')
1158             return;
1159
044d66 1160         $this->add_script('var images = ' . json_serialize($images) .';
8e211a 1161             for (var i=0; i<images.length; i++) {
A 1162                 img = new Image();
1163                 img.src = images[i];
044d66 1164             }', 'docready');
8e211a 1165     }
A 1166
1167
1168     /**
47124c 1169      * GUI object 'searchform'
T 1170      * Returns code for search function
1171      *
1172      * @param array Named parameters
1173      * @return string HTML code for the gui object
1174      */
1175     private function search_form($attrib)
1176     {
1177         // add some labels to client
1178         $this->add_label('searching');
1179
1180         $attrib['name'] = '_q';
1181
1182         if (empty($attrib['id'])) {
1183             $attrib['id'] = 'rcmqsearchbox';
1184         }
a3f149 1185         if ($attrib['type'] == 'search' && !$this->browser->khtml) {
2eb794 1186             unset($attrib['type'], $attrib['results']);
a3f149 1187         }
ad334a 1188
47124c 1189         $input_q = new html_inputfield($attrib);
T 1190         $out = $input_q->show();
1191
1192         $this->add_gui_object('qsearchbox', $attrib['id']);
1193
1194         // add form tag around text field
1195         if (empty($attrib['form'])) {
197601 1196             $out = $this->form_tag(array(
T 1197                 'name' => "rcmqsearchform",
1198                 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;",
1199                 'style' => "display:inline"),
2eb794 1200                 $out);
47124c 1201         }
T 1202
1203         return $out;
1204     }
1205
1206
1207     /**
1208      * Builder for GUI object 'message'
1209      *
1210      * @param array Named tag parameters
1211      * @return string HTML code for the gui object
1212      */
1213     private function message_container($attrib)
1214     {
1215         if (isset($attrib['id']) === false) {
1216             $attrib['id'] = 'rcmMessageContainer';
1217         }
1218
1219         $this->add_gui_object('message', $attrib['id']);
1220         return html::div($attrib, "");
1221     }
1222
1223
1224     /**
1225      * GUI object 'charsetselector'
1226      *
1227      * @param array Named parameters for the select tag
1228      * @return string HTML code for the gui object
1229      */
e55ab0 1230     function charset_selector($attrib)
47124c 1231     {
T 1232         // pass the following attributes to the form class
1233         $field_attrib = array('name' => '_charset');
1234         foreach ($attrib as $attr => $value) {
e55ab0 1235             if (in_array($attr, array('id', 'name', 'class', 'style', 'size', 'tabindex'))) {
47124c 1236                 $field_attrib[$attr] = $value;
T 1237             }
1238         }
e55ab0 1239
47124c 1240         $charsets = array(
e55ab0 1241             'UTF-8'        => 'UTF-8 ('.rcube_label('unicode').')',
A 1242             'US-ASCII'     => 'ASCII ('.rcube_label('english').')',
1243             'ISO-8859-1'   => 'ISO-8859-1 ('.rcube_label('westerneuropean').')',
d8d467 1244             'ISO-8859-2'   => 'ISO-8859-2 ('.rcube_label('easterneuropean').')',
A 1245             'ISO-8859-4'   => 'ISO-8859-4 ('.rcube_label('baltic').')',
e55ab0 1246             'ISO-8859-5'   => 'ISO-8859-5 ('.rcube_label('cyrillic').')',
A 1247             'ISO-8859-6'   => 'ISO-8859-6 ('.rcube_label('arabic').')',
1248             'ISO-8859-7'   => 'ISO-8859-7 ('.rcube_label('greek').')',
1249             'ISO-8859-8'   => 'ISO-8859-8 ('.rcube_label('hebrew').')',
1250             'ISO-8859-9'   => 'ISO-8859-9 ('.rcube_label('turkish').')',
1251             'ISO-8859-10'   => 'ISO-8859-10 ('.rcube_label('nordic').')',
1252             'ISO-8859-11'   => 'ISO-8859-11 ('.rcube_label('thai').')',
1253             'ISO-8859-13'   => 'ISO-8859-13 ('.rcube_label('baltic').')',
1254             'ISO-8859-14'   => 'ISO-8859-14 ('.rcube_label('celtic').')',
1255             'ISO-8859-15'   => 'ISO-8859-15 ('.rcube_label('westerneuropean').')',
1256             'ISO-8859-16'   => 'ISO-8859-16 ('.rcube_label('southeasterneuropean').')',
1257             'WINDOWS-1250' => 'Windows-1250 ('.rcube_label('easterneuropean').')',
1258             'WINDOWS-1251' => 'Windows-1251 ('.rcube_label('cyrillic').')',
1259             'WINDOWS-1252' => 'Windows-1252 ('.rcube_label('westerneuropean').')',
1260             'WINDOWS-1253' => 'Windows-1253 ('.rcube_label('greek').')',
1261             'WINDOWS-1254' => 'Windows-1254 ('.rcube_label('turkish').')',
1262             'WINDOWS-1255' => 'Windows-1255 ('.rcube_label('hebrew').')',
1263             'WINDOWS-1256' => 'Windows-1256 ('.rcube_label('arabic').')',
1264             'WINDOWS-1257' => 'Windows-1257 ('.rcube_label('baltic').')',
1265             'WINDOWS-1258' => 'Windows-1258 ('.rcube_label('vietnamese').')',
1266             'ISO-2022-JP'  => 'ISO-2022-JP ('.rcube_label('japanese').')',
1267             'ISO-2022-KR'  => 'ISO-2022-KR ('.rcube_label('korean').')',
1268             'ISO-2022-CN'  => 'ISO-2022-CN ('.rcube_label('chinese').')',
1269             'EUC-JP'       => 'EUC-JP ('.rcube_label('japanese').')',
1270             'EUC-KR'       => 'EUC-KR ('.rcube_label('korean').')',
1271             'EUC-CN'       => 'EUC-CN ('.rcube_label('chinese').')',
1272             'BIG5'         => 'BIG5 ('.rcube_label('chinese').')',
1273             'GB2312'       => 'GB2312 ('.rcube_label('chinese').')',
1274         );
47124c 1275
e55ab0 1276         if (!empty($_POST['_charset']))
2eb794 1277             $set = $_POST['_charset'];
A 1278         else if (!empty($attrib['selected']))
1279             $set = $attrib['selected'];
1280         else
1281             $set = $this->get_charset();
47124c 1282
2eb794 1283         $set = strtoupper($set);
A 1284         if (!isset($charsets[$set]))
1285             $charsets[$set] = $set;
e55ab0 1286
A 1287         $select = new html_select($field_attrib);
1288         $select->add(array_values($charsets), array_keys($charsets));
1289
1290         return $select->show($set);
47124c 1291     }
T 1292
1293 }  // end class rcube_template
1294
1295