- Timestamp:
- Sep 28, 2009, 10:54:06 PM (15 years ago)
- Location:
- trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/config_default.inc.php
r3935 r3938 287 287 // Value could be text/plain or text/html 288 288 $conf['default_email_format'] = 'text/html'; 289 290 // alternative_email_format: 291 // Define the alternative email format use to send email 292 // Value could be text/plain or text/html 293 $conf['alternative_email_format'] = 'text/plain'; 289 294 290 295 // define the name of sender mail: -
trunk/include/functions_mail.inc.php
r3926 r3938 80 80 'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'], 81 81 'default_email_format' => $conf['default_email_format'], 82 'alternative_email_format' => $conf['alternative_email_format'], 82 83 'use_smtp' => !empty($conf['smtp_host']), 83 84 'smtp_host' => $conf['smtp_host'], … … 559 560 560 561 // Compute root_path in order have complete path 561 if ($args['email_format'] == 'text/html') 562 { 563 set_make_full_url(); 564 } 562 set_make_full_url(); 565 563 566 564 if (empty($args['from'])) … … 595 593 { 596 594 $args['Bcc'][] = $conf_mail['formated_email_webmaster']; 597 }598 599 if (($args['content_format'] == 'text/html') and ($args['email_format'] == 'text/plain'))600 {601 // Todo find function to convert html text to plain text602 return false;603 595 } 604 596 … … 624 616 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 625 617 618 // List on content-type 619 $content_type_list[] = $args['email_format']; 620 if (!empty($conf_mail['alternative_email_format'])) 621 { 622 $content_type_list[] = $conf_mail['alternative_email_format']; 623 } 624 626 625 $content = ''; 627 626 628 // key compose of indexes witch allow ti cache mail data 629 $cache_key = $args['email_format'].'-'.$lang_info['code'].'-'.$args['template'].'-'.$args['theme']; 630 631 if (!isset($conf_mail[$cache_key])) 632 { 633 if (!isset($mail_template)) 634 { 635 $mail_template = get_mail_template($args['email_format']); 636 } 637 638 $mail_template->set_filename('mail_header', 'header.tpl'); 639 $mail_template->set_filename('mail_footer', 'footer.tpl'); 640 641 $mail_template->assign( 642 array( 643 //Header 644 'BOUNDARY_KEY' => $conf_mail['boundary_key'], 645 'CONTENT_TYPE' => $args['email_format'], 646 'CONTENT_ENCODING' => get_pwg_charset(), 647 648 // Footer 649 'GALLERY_URL' => 650 isset($page['gallery_url']) ? 651 $page['gallery_url'] : $conf['gallery_url'], 652 'GALLERY_TITLE' => 653 isset($page['gallery_title']) ? 654 $page['gallery_title'] : $conf['gallery_title'], 655 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 656 'PHPWG_URL' => PHPWG_URL, 657 658 'TITLE_MAIL' => urlencode(l10n('title_send_mail')), 659 'MAIL' => get_webmaster_mail_address() 660 )); 661 662 if ($args['email_format'] == 'text/html') 663 { 664 if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl')) 627 foreach (array_unique($content_type_list) as $content_type) 628 { 629 // key compose of indexes witch allow ti cache mail data 630 $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['template'].'-'.$args['theme']; 631 632 if (!isset($conf_mail[$cache_key])) 633 { 634 if (!isset($conf_mail[$cache_key]['template'])) 665 635 { 666 $mail_template->set_filename('css', 'global-mail-css.tpl'); 667 $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); 636 $conf_mail[$cache_key]['template'] = get_mail_template($content_type); 668 637 } 669 638 670 $root_abs_path = dirname(dirname(__FILE__)); 671 672 $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl'; 673 if (is_file($file)) 639 $conf_mail[$cache_key]['template']->set_filename('mail_header', 'header.tpl'); 640 $conf_mail[$cache_key]['template']->set_filename('mail_footer', 'footer.tpl'); 641 642 $conf_mail[$cache_key]['template']->assign( 643 array( 644 //Header 645 'BOUNDARY_KEY' => $conf_mail['boundary_key'], 646 'CONTENT_TYPE' => $content_type, 647 'CONTENT_ENCODING' => get_pwg_charset(), 648 649 // Footer 650 'GALLERY_URL' => 651 isset($page['gallery_url']) ? 652 $page['gallery_url'] : $conf['gallery_url'], 653 'GALLERY_TITLE' => 654 isset($page['gallery_title']) ? 655 $page['gallery_title'] : $conf['gallery_title'], 656 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 657 'PHPWG_URL' => PHPWG_URL, 658 659 'TITLE_MAIL' => urlencode(l10n('title_send_mail')), 660 'MAIL' => get_webmaster_mail_address() 661 )); 662 663 if ($content_type == 'text/html') 674 664 { 675 $mail_template->set_filename('css', $file); 676 $mail_template->assign_var_from_handle('MAIL_CSS', 'css'); 665 if (is_file($conf_mail[$cache_key]['template']->get_template_dir().'/global-mail-css.tpl')) 666 { 667 $conf_mail[$cache_key]['template']->set_filename('css', 'global-mail-css.tpl'); 668 $conf_mail[$cache_key]['template']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); 669 } 670 671 $root_abs_path = dirname(dirname(__FILE__)); 672 673 $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl'; 674 if (is_file($file)) 675 { 676 $conf_mail[$cache_key]['template']->set_filename('css', $file); 677 $conf_mail[$cache_key]['template']->assign_var_from_handle('MAIL_CSS', 'css'); 678 } 679 680 $file = $root_abs_path.'/template-common/local-mail-css.tpl'; 681 if (is_file($file)) 682 { 683 $conf_mail[$cache_key]['template']->set_filename('css', $file); 684 $conf_mail[$cache_key]['template']->assign_var_from_handle('LOCAL_MAIL_CSS', 'css'); 685 } 677 686 } 678 687 679 $file = $root_abs_path.'/template-common/local-mail-css.tpl'; 680 if (is_file($file)) 681 { 682 $mail_template->set_filename('css', $file); 683 $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css'); 684 } 685 } 686 687 // what are displayed on the header of each mail ? 688 $conf_mail[$cache_key]['header'] = 689 $mail_template->parse('mail_header', true); 690 691 // what are displayed on the footer of each mail ? 692 $conf_mail[$cache_key]['footer'] = 693 $mail_template->parse('mail_footer', true); 694 } 695 696 // Header 697 $content.= $conf_mail[$cache_key]['header']; 698 699 // Content 700 if (($args['content_format'] == 'text/plain') and ($args['email_format'] == 'text/html')) 701 { 702 $content.= '<p>'. 703 nl2br( 704 preg_replace("/(http:\/\/)([^\s,]*)/i", 705 "<a href='$1$2' class='thumblnk'>$1$2</a>", 706 htmlspecialchars($args['content']))). 707 '</p>'; 708 } 709 else 710 { 711 $content.= $args['content']; 712 } 713 714 // Footer 715 $content.= $conf_mail[$cache_key]['footer']; 688 // what are displayed on the header of each mail ? 689 $conf_mail[$cache_key]['header'] = 690 $conf_mail[$cache_key]['template']->parse('mail_header', true); 691 692 // what are displayed on the footer of each mail ? 693 $conf_mail[$cache_key]['footer'] = 694 $conf_mail[$cache_key]['template']->parse('mail_footer', true); 695 } 696 697 // Header 698 $content.= $conf_mail[$cache_key]['header']; 699 700 // Content 701 if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html')) 702 { 703 $content.= '<p>'. 704 nl2br( 705 preg_replace("/(http:\/\/)([^\s,]*)/i", 706 "<a href='$1$2' class='thumblnk'>$1$2</a>", 707 htmlspecialchars($args['content']))). 708 '</p>'; 709 } 710 else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain')) 711 { 712 // convert html text to plain text 713 $content.= strip_tags($args['content']); 714 } 715 else 716 { 717 $content.= $args['content']; 718 } 719 720 // Footer 721 $content.= $conf_mail[$cache_key]['footer']; 716 722 717 723 // Close boundary 718 724 $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 725 } 726 727 728 //~ // Close boundary 729 //~ $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 719 730 720 731 // Undo Compute root_path in order have complete path 721 if ($args['email_format'] == 'text/html') 722 { 723 unset_make_full_url(); 724 } 732 unset_make_full_url(); 725 733 726 734 return
Note: See TracChangeset
for help on using the changeset viewer.