Changeset 6d969b4 in github for program/include/rcmail_template.inc
- Timestamp:
- Aug 7, 2007 5:02:12 PM (6 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 4b9efbb
- Parents:
- 93be5b7
- File:
-
- 1 edited
-
program/include/rcmail_template.inc (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcmail_template.inc
r41bece1 r6d969b4 11 11 | PURPOSE: | 12 12 | Class to handle HTML page output using a skin template. | 13 | Extends rcube_html_page class from rcube_ shared.inc|13 | Extends rcube_html_page class from rcube_html.inc | 14 14 | | 15 15 +-----------------------------------------------------------------------+ … … 21 21 */ 22 22 23 require_once('include/rcube_shared.inc'); 24 25 23 24 /** 25 * Classes and functions for HTML output 26 * 27 * @package View 28 */ 29 30 require_once('include/rcube_html.inc'); 31 32 33 /** 34 * Class to create HTML page output using a skin template 35 */ 26 36 class rcmail_template extends rcube_html_page 27 37 { … … 37 47 38 48 39 // PHP 5 constructor 49 /** 50 * Constructor 51 * 52 * @param array Configuration array 53 * @param string Current task 54 */ 40 55 function __construct(&$config, $task) 41 56 { 42 parent::__construct();43 44 57 $this->task = $task; 45 58 $this->config = $config; … … 62 75 } 63 76 64 // PHP 4 compatibility 77 /** 78 * PHP 4 compatibility 79 * @see rcmail_template::__construct() 80 */ 65 81 function rcmail_template(&$config, $task) 66 82 { … … 71 87 /** 72 88 * Set environment variable 89 * 90 * @param string Property name 91 * @param mixed Property value 92 * @param boolean True if this property should be added to client environment 73 93 */ 74 94 function set_env($name, $value, $addtojs=true) … … 136 156 /** 137 157 * Invoke display_message command 158 * 159 * @param string Message to display 160 * @param string Message type [notice|confirm|error] 161 * @param array Key-value pairs to be replaced in localized text 138 162 */ 139 163 function show_message($message, $type='notice', $vars=NULL) … … 212 236 213 237 /** 214 * @override 238 * Process template and write to stdOut 239 * 240 * @param string HTML template 241 * @see rcube_html_page::write() 215 242 */ 216 243 function write($template='') … … 274 301 /** 275 302 * Return executable javascript code for all registered commands 276 * @ private303 * @access private 277 304 */ 278 305 function get_js_commands() … … 301 328 /** 302 329 * Make URLs starting with a slash point to skin directory 330 * @access private 303 331 */ 304 332 function abs_url($str) … … 312 340 313 341 /** 314 * Replace all strings ($varname) with the content 315 * of the according global variable. 342 * Replace all strings ($varname) 343 * with the content of the according global variable. 344 * @access private 316 345 */ 317 346 function parse_with_globals($input) … … 324 353 /** 325 354 * Parse for conditional tags 355 * @access private 326 356 */ 327 357 function parse_conditions($input) … … 362 392 * 363 393 * @return True if condition is valid, False is not 394 * @access private 364 395 */ 365 396 function check_condition($condition) … … 380 411 * @param string Input string to parse 381 412 * @return Altered input string 413 * @access private 382 414 */ 383 415 function parse_xml($input) … … 393 425 * @param string Attribute string 394 426 * @return Tag/Object content string 427 * @access private 395 428 */ 396 429 function xml_command($command, $str_attrib, $add_attrib=array()) 397 {430 { 398 431 $command = strtolower($command); 399 432 $attrib = parse_attrib_string($str_attrib) + $add_attrib; … … 438 471 439 472 else if ($object=='productname') 440 {473 { 441 474 $name = !empty($this->config['product_name']) ? $this->config['product_name'] : 'RoundCube Webmail'; 442 475 return Q($name); 443 }476 } 444 477 else if ($object=='version') 445 {478 { 446 479 return (string)RCMAIL_VERSION; 447 }480 } 448 481 else if ($object=='pagetitle') 449 {482 { 450 483 $task = $this->task; 451 484 $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : ''; … … 459 492 460 493 return Q($title); 461 }494 } 462 495 463 496 break; … … 465 498 466 499 return ''; 467 }500 } 468 501 469 502 … … 473 506 * @param array Button attributes 474 507 * @return HTML button 508 * @access private 475 509 */ 476 510 function button($attrib) 477 {511 { 478 512 global $CONFIG, $OUTPUT, $BROWSER, $MAIN_TASKS; 479 513 static $sa_buttons = array(); … … 627 661 } 628 662 629 } 663 } // end class rcmail_template 664 665 666 667 // ************** common functions delivering gui objects ************** 668 669 670 /** 671 * Builder for GUI object 'message' 672 * 673 * @param array Named tag parameters 674 * @return string HTML code for the gui object 675 */ 676 function rcmail_message_container($attrib) 677 { 678 global $OUTPUT; 679 680 if (!$attrib['id']) 681 $attrib['id'] = 'rcmMessageContainer'; 682 683 // allow the following attributes to be added to the <table> tag 684 $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); 685 $out = '<div' . $attrib_str . "></div>"; 686 687 $OUTPUT->add_gui_object('message', $attrib['id']); 688 689 return $out; 690 } 691 692 693 /** 694 * GUI object 'username' 695 * Showing IMAP username of the current session 696 * 697 * @param array Named tag parameters (currently not used) 698 * @return string HTML code for the gui object 699 */ 700 function rcmail_current_username($attrib) 701 { 702 global $DB; 703 static $s_username; 704 705 // alread fetched 706 if (!empty($s_username)) 707 return $s_username; 708 709 // get e-mail address form default identity 710 $sql_result = $DB->query( 711 "SELECT email AS mailto 712 FROM ".get_table_name('identities')." 713 WHERE user_id=? 714 AND standard=1 715 AND del<>1", 716 $_SESSION['user_id']); 717 718 if ($DB->num_rows($sql_result)) 719 { 720 $sql_arr = $DB->fetch_assoc($sql_result); 721 $s_username = $sql_arr['mailto']; 722 } 723 else if (strstr($_SESSION['username'], '@')) 724 $s_username = $_SESSION['username']; 725 else 726 $s_username = $_SESSION['username'].'@'.$_SESSION['imap_host']; 727 728 return $s_username; 729 } 730 731 732 /** 733 * GUI object 'loginform' 734 * Returns code for the webmail login form 735 * 736 * @param array Named parameters 737 * @return string HTML code for the gui object 738 */ 739 function rcmail_login_form($attrib) 740 { 741 global $CONFIG, $OUTPUT, $SESS_HIDDEN_FIELD; 742 743 $labels = array(); 744 $labels['user'] = rcube_label('username'); 745 $labels['pass'] = rcube_label('password'); 746 $labels['host'] = rcube_label('server'); 747 748 $input_user = new textfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off')); 749 $input_pass = new passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'size' => 30)); 750 $input_action = new hiddenfield(array('name' => '_action', 'value' => 'login')); 751 752 $fields = array(); 753 $fields['user'] = $input_user->show(get_input_value('_user', RCUBE_INPUT_POST)); 754 $fields['pass'] = $input_pass->show(); 755 $fields['action'] = $input_action->show(); 756 757 if (is_array($CONFIG['default_host'])) 758 { 759 $select_host = new select(array('name' => '_host', 'id' => 'rcmloginhost')); 760 761 foreach ($CONFIG['default_host'] as $key => $value) 762 { 763 if (!is_array($value)) 764 $select_host->add($value, (is_numeric($key) ? $value : $key)); 765 else 766 { 767 unset($select_host); 768 break; 769 } 770 } 771 772 $fields['host'] = isset($select_host) ? $select_host->show($_POST['_host']) : null; 773 } 774 else if (!strlen($CONFIG['default_host'])) 775 { 776 $input_host = new textfield(array('name' => '_host', 'id' => 'rcmloginhost', 'size' => 30)); 777 $fields['host'] = $input_host->show($_POST['_host']); 778 } 779 780 $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; 781 $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; 782 $form_end = !strlen($attrib['form']) ? '</form>' : ''; 783 784 if ($fields['host']) 785 $form_host = <<<EOF 786 787 </tr><tr> 788 789 <td class="title"><label for="rcmloginhost">$labels[host]</label></td> 790 <td>$fields[host]</td> 791 792 EOF; 793 794 $OUTPUT->add_gui_object('loginform', $form_name); 795 796 $out = <<<EOF 797 $form_start 798 $SESS_HIDDEN_FIELD 799 $fields[action] 800 <table><tr> 801 802 <td class="title"><label for="rcmloginuser">$labels[user]</label></td> 803 <td>$fields[user]</td> 804 805 </tr><tr> 806 807 <td class="title"><label for="rcmloginpwd">$labels[pass]</label></td> 808 <td>$fields[pass]</td> 809 $form_host 810 </tr></table> 811 $form_end 812 EOF; 813 814 return $out; 815 } 816 817 818 /** 819 * GUI object 'charsetselector' 820 * 821 * @param array Named parameters for the select tag 822 * @return string HTML code for the gui object 823 */ 824 function rcmail_charset_selector($attrib) 825 { 826 global $OUTPUT; 827 828 // pass the following attributes to the form class 829 $field_attrib = array('name' => '_charset'); 830 foreach ($attrib as $attr => $value) 831 if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) 832 $field_attrib[$attr] = $value; 833 834 $charsets = array( 835 'US-ASCII' => 'ASCII (English)', 836 'EUC-JP' => 'EUC-JP (Japanese)', 837 'EUC-KR' => 'EUC-KR (Korean)', 838 'BIG5' => 'BIG5 (Chinese)', 839 'GB2312' => 'GB2312 (Chinese)', 840 'ISO-2022-JP' => 'ISO-2022-JP (Japanese)', 841 'ISO-8859-1' => 'ISO-8859-1 (Latin-1)', 842 'ISO-8859-2' => 'ISO-8895-2 (Central European)', 843 'ISO-8859-7' => 'ISO-8859-7 (Greek)', 844 'ISO-8859-9' => 'ISO-8859-9 (Turkish)', 845 'Windows-1251' => 'Windows-1251 (Cyrillic)', 846 'Windows-1252' => 'Windows-1252 (Western)', 847 'Windows-1255' => 'Windows-1255 (Hebrew)', 848 'Windows-1256' => 'Windows-1256 (Arabic)', 849 'Windows-1257' => 'Windows-1257 (Baltic)', 850 'UTF-8' => 'UTF-8' 851 ); 852 853 $select = new select($field_attrib); 854 $select->add(array_values($charsets), array_keys($charsets)); 855 856 $set = $_POST['_charset'] ? $_POST['_charset'] : $OUTPUT->get_charset(); 857 return $select->show($set); 858 } 859 860 861 /** 862 * GUI object 'searchform' 863 * Returns code for search function 864 * 865 * @param array Named parameters 866 * @return string HTML code for the gui object 867 */ 868 function rcmail_search_form($attrib) 869 { 870 global $OUTPUT; 871 872 // add some labels to client 873 rcube_add_label('searching'); 874 875 $attrib['name'] = '_q'; 876 877 if (empty($attrib['id'])) 878 $attrib['id'] = 'rcmqsearchbox'; 879 880 $input_q = new textfield($attrib); 881 $out = $input_q->show(); 882 883 $OUTPUT->add_gui_object('qsearchbox', $attrib['id']); 884 885 // add form tag around text field 886 if (empty($attrib['form'])) 887 $out = sprintf( 888 '<form name="rcmqsearchform" action="./" '. 889 'onsubmit="%s.command(\'search\');return false" style="display:inline;">%s</form>', 890 JS_OBJECT_NAME, 891 $out); 892 893 return $out; 894 } 895 630 896 631 897 ?>
Note: See TracChangeset
for help on using the changeset viewer.
