Changeset 688 in subversion for branches/devel-vnext/program/include/rcmail_template.inc
- Timestamp:
- Aug 15, 2007 6:32:25 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-vnext/program/include/rcmail_template.inc
r655 r688 28 28 * @todo Documentation 29 29 * @todo CS 30 * @todo Remove globals31 30 * @todo PHP5? 32 31 * @uses rcube_html_page … … 110 109 } 111 110 112 /** 113 * Register a list of template object handlers 114 * 115 * @param array Hash array with object=>handler pairs 116 */ 117 function add_handlers($arr) 118 { 119 $this->object_handlers = array_merge($this->object_handlers, $arr); 120 } 121 122 /** 123 * Register a GUI object to the client script 124 * 125 * @param string Object name 126 * @param string Object ID 127 */ 128 function add_gui_object($obj, $id) 129 { 130 $this->add_script(JS_OBJECT_NAME.".gui_object('$obj', '$id');"); 131 } 132 133 134 /** 135 * Call a client method 136 * 137 * @param string Method to call 138 * @param ... Additional arguments 139 */ 140 function command() 141 { 142 $this->js_commands[] = func_get_args(); 143 } 144 145 146 /** 147 * Invoke display_message command 148 */ 149 function show_message($message, $type='notice', $vars=NULL) 150 { 151 $this->command( 152 'display_message', 153 rcube_label(array('name' => $message, 'vars' => $vars)), 154 $type); 155 } 156 157 158 /** 159 * Delete all stored env variables and commands 160 */ 161 function reset() 162 { 163 $this->env = array(); 164 $this->js_env = array(); 165 $this->js_commands = array(); 166 $this->object_handlers = array(); 167 parent::reset(); 168 } 169 170 /** 171 * Send the request output to the client. 172 * This will either parse a skin tempalte or send an AJAX response 173 * 174 * @param string Template name 175 * @param boolean True if script should terminate (default) 176 */ 111 /** 112 * Register a list of template object handlers 113 * 114 * @param array Hash array with object=>handler pairs 115 * @return void 116 */ 117 function add_handlers($arr) 118 { 119 $this->object_handlers = array_merge($this->object_handlers, $arr); 120 } 121 122 /** 123 * Register a GUI object to the client script 124 * 125 * @param string Object name 126 * @param string Object ID 127 * @return void 128 */ 129 function add_gui_object($obj, $id) 130 { 131 $this->add_script(JS_OBJECT_NAME.".gui_object('$obj', '$id');"); 132 } 133 134 /** 135 * Call a client method 136 * 137 * @param string Method to call 138 * @param ... Additional arguments 139 */ 140 function command() 141 { 142 $this->js_commands[] = func_get_args(); 143 } 144 145 /** 146 * Invoke display_message command 147 * 148 * @param string $message 149 * @param string $type 150 * @param mixed $vars 151 * @return void 152 * @uses self::command() 153 */ 154 function show_message($message, $type='notice', $vars=NULL) 155 { 156 $this->command( 157 'display_message', 158 rcube_label(array('name' => $message, 'vars' => $vars)), 159 $type 160 ); 161 } 162 163 /** 164 * Delete all stored env variables and commands 165 * 166 * @access public 167 * @return void 168 * @uses rcube_html::reset() 169 * @uses self::$env 170 * @uses self::$js_env 171 * @uses self::$js_commands 172 * @uses self::$object_handlers 173 */ 174 public function reset() 175 { 176 $this->env = array(); 177 $this->js_env = array(); 178 $this->js_commands = array(); 179 $this->object_handlers = array(); 180 parent::reset(); 181 } 182 183 /** 184 * Send the request output to the client. 185 * This will either parse a skin tempalte or send an AJAX response 186 * 187 * @access public 188 * @param string $templ Template name 189 * @param boolean $exit True if script should terminate (default) 190 */ 177 191 function send($templ=null, $exit=true) 178 192 { … … 195 209 196 210 197 /** 198 * Send an AJAX response with executable JS code 199 * 200 * @param string Additional JS code 201 * @param boolean True if output buffer should be flushed 202 */ 203 function remote_response($add='', $flush=false) 204 { 205 static $s_header_sent = FALSE; 206 207 if (!$s_header_sent) 208 { 209 $s_header_sent = TRUE; 210 send_nocacheing_headers(); 211 header('Content-Type: application/x-javascript; charset='.RCMAIL_CHARSET); 212 print '/** ajax response ['.date('d/M/Y h:i:s O')."] **/\n"; 213 } 214 215 // unset default env vars 216 unset($this->js_env['task'], $this->js_env['action'], $this->js_env['comm_path']); 217 218 // send response code 219 echo rc_main::rcube_charset_convert($this->get_js_commands() . $add, RCMAIL_CHARSET, $this->get_charset()); 220 221 if ($flush) // flush the output buffer 222 flush(); 223 } 224 225 226 /** 227 * @override 228 */ 211 /** 212 * Send an AJAX response with executable JS code 213 * 214 * @param string Additional JS code 215 * @param boolean True if output buffer should be flushed 216 * @return void 217 */ 218 function remote_response($add='', $flush=false) 219 { 220 static $s_header_sent = FALSE; 221 222 if (!$s_header_sent) { 223 $s_header_sent = TRUE; 224 send_nocacheing_headers(); 225 header('Content-Type: application/x-javascript; charset='.RCMAIL_CHARSET); 226 print '/** ajax response ['.date('d/M/Y h:i:s O')."] **/\n"; 227 } 228 229 // unset default env vars 230 unset($this->js_env['task'], $this->js_env['action'], $this->js_env['comm_path']); 231 232 // send response code 233 echo rc_main::rcube_charset_convert( 234 $this->get_js_commands() . $add, 235 RCMAIL_CHARSET, 236 $this->get_charset() 237 ); 238 239 if ($flush) { // flush the output buffer 240 flush(); 241 } 242 } 243 244 /** 245 * @override 246 */ 229 247 function write($template='') 230 248 { … … 237 255 parent::write($template, $this->config['skin_path']); 238 256 } 239 240 257 241 258 /** … … 360 377 } 361 378 379 /** 380 * Public wrapper to dipp into template parsing. 381 * 382 * @access public 383 * @param string $input 384 * @return string 385 * @uses rcmail_template::parse_conditions() 386 * @since 0.1-rc1 387 */ 388 public function just_parse($input) 389 { 390 return $this->parse_xml($input); 391 } 362 392 363 393 /** … … 368 398 * @return string 369 399 */ 370 function parse_conditions($input)400 protected function parse_conditions($input) 371 401 { 372 402 $matches = preg_split( … … 440 470 * @todo Maybe a cache. 441 471 */ 442 function parse_xml($input)472 protected function parse_xml($input) 443 473 { 444 474 return preg_replace('/<roundcube:([-_a-z]+)\s+([^>]+)>/Uie', "\$this->xml_command('\\1', '\\2')", $input); … … 454 484 * @return Tag/Object content string 455 485 */ 456 function xml_command($command, $str_attrib, $add_attrib=array())486 protected function xml_command($command, $str_attrib, $add_attrib=array()) 457 487 { 458 488 $command = strtolower($command); 459 489 $attrib = rc_main::parse_attrib_string($str_attrib) + $add_attrib; 490 //var_dump($attrib); exit; 460 491 461 492 //rc_main::tfk_debug("// $command"); … … 472 503 // return a button 473 504 case 'button': 474 if ($attrib['command']) 475 return $this->button($attrib); 505 if ($attrib['command']) { 506 return $this->button($attrib); 507 } 476 508 break; 477 509 478 510 // show a label 479 511 case 'label': 480 if ($attrib['name'] || $attrib['command']) 481 return rc_main::Q(rcube_label($attrib + array('vars' => array('product' => $this->config['product_name'])))); 512 if ($attrib['name'] || $attrib['command']) { 513 return rc_main::Q( 514 rcube_label( 515 $attrib + array('vars' => array('product' => $this->config['product_name'])) 516 ) 517 ); 518 } 482 519 break; 483 520 … … 520 557 $object = strtolower($attrib['name']); 521 558 559 rc_main::tfk_debug("// object: $object"); 560 rc_main::tfk_debug(var_export($this->object_handlers[$object], true)); 561 522 562 // execute object handler function 523 563 if ($this->object_handlers[$object] && function_exists($this->object_handlers[$object])) { … … 562 602 * Create and register a button 563 603 * 604 * @access public 564 605 * @param array Button attributes 565 606 * @return HTML button … … 567 608 * @todo Remove all sprintf()'s - they are pretty, but also slow. 568 609 */ 569 function button($attrib)610 public function button($attrib) 570 611 { 571 612 $registry = rc_registry::getInstance(); … … 755 796 // generate html code for button 756 797 if ($btn_content) { 798 if ($command == 'logout') { 799 $btn_content = '<span>Hallo ' . $_SESSION['username'] . ', ' . $btn_content . '</span>'; 800 } 757 801 $attrib_str = rc_main::create_attrib_string($attrib, $link_attrib); 758 802 $out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
Note: See TracChangeset
for help on using the changeset viewer.
