Changeset 4828 for trunk/expressoMail1_2


Ignore:
Timestamp:
07/19/11 16:54:27 (13 years ago)
Author:
airton
Message:

Ticket #2146 - Implementacao da funcionalidade de multiplas assinaturas

Location:
trunk/expressoMail1_2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/fckeditor.php

    r1059 r4828  
    7272                         
    7373                        if ( $this->ToolbarSet != '' ) 
    74                                 $Link .= "&Toolbar={$this->ToolbarSet}" ; 
     74                                $Link .= "&Toolbar={$this->ToolbarSet}" ; 
    7575 
    7676                        // Render the linked hidden field. 
     
    105105        function IsCompatible() 
    106106        { 
    107                 global $HTTP_USER_AGENT ; 
    108  
    109                 if ( isset( $HTTP_USER_AGENT ) ) 
    110                         $sAgent = $HTTP_USER_AGENT ; 
    111                 else 
    112                         $sAgent = $_SERVER['HTTP_USER_AGENT'] ; 
    113  
    114                 if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false ) 
    115                 { 
    116                         $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ; 
    117                         return ($iVersion >= 5.5) ; 
    118                 } 
    119                 else if ( strpos($sAgent, 'Gecko/') !== false ) 
    120                 { 
    121                         $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ; 
    122                         return ($iVersion >= 20030210) ; 
    123                 } 
    124                 else 
    125                         return false ; 
     107                //             global $HTTP_USER_AGENT ;  
     108                //   
     109                //              if ( isset( $HTTP_USER_AGENT ) )  
     110                //                      $sAgent = $HTTP_USER_AGENT ;  
     111                //              else  
     112                //                      $sAgent = $_SERVER['HTTP_USER_AGENT'] ;  
     113                //   
     114                //              if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )  
     115                //              {  
     116                //                      $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;  
     117                //                      return ($iVersion >= 5.5) ;  
     118                //              }  
     119                //              else if ( strpos($sAgent, 'Gecko/') !== false )  
     120                //              {  
     121                //                      $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;  
     122                //                      return ($iVersion >= 20030210) ;  
     123                //              }  
     124                //              else  
     125                //                      return false ;  
     126                            return( true );  
    126127        } 
    127128 
     
    149150        } 
    150151 
     152                //      function getConfigFieldString()  
     153                //      {  
     154                //          $sParams = array();  
     155                //        
     156                //          foreach( $this->Config as $sKey => $sValue )  
     157                //              $sParams[] = $this->EncodeConfig( $sKey ).'='.$this->EncodeConfig( $sValue );  
     158                //   
     159                //          return implode( '&', $sParams );  
     160                //      } 
     161         
     162         
    151163        function EncodeConfig( $valueToEncode ) 
    152164        { 
  • trunk/expressoMail1_2/inc/hook_settings.inc.php

    r4726 r4828  
    1919        *  option) any later version.                                              * 
    2020        \**************************************************************************/ 
    21 include_once("fckeditor.php"); 
    22 include_once("class.functions.inc.php"); 
    23 $type = isset($_GET['type']) ? $_GET['type']:$GLOBALS['type']; // FIX ME 
     21 
     22$type = isset($_GET['type']) ? $_GET['type']:$GLOBALS['type']; // FIX ME  
    2423 
    2524//if ($type == 'user' || $type == ''){ 
     
    2726{ 
    2827    var type = ("'.$type.'" == "") ? "user" : "'.$type.'"; 
    29     var use_signature_digital_cripto = null; 
    30  
    31     if (document.all) 
    32     { 
    33         // is_ie 
    34         use_signature_digital_cripto = document.getElementsByName(type+"[use_signature_digital_cripto]")[1]; 
    35     } 
    36     else 
    37     { 
    38         // not_ie 
    39         use_signature_digital_cripto = document.getElementsByName(type+"[use_signature_digital_cripto]")[0]; 
    40     } 
    41  
     28    var use_signature_digital_cripto = document.getElementsByName(type+"[use_signature_digital_cripto]")[0]; 
    4229    var default_signature_digital_cripto = "'.$GLOBALS['phpgw_info']['default']['preferences']['expressoMail']['use_signature_digital_cripto'].'"; 
    4330 
     
    7259    } 
    7360 
     61} 
     62function validateSignature() 
     63{ 
     64    var sigs_len = parseInt( document.getElementById("counter").value ); 
     65 
     66    var signatures = {}, types = {}, noSig = true; 
     67 
     68    var default_signature = "", errors = false; 
     69 
     70    for( var i = 0; i < sigs_len; i++ ) 
     71    { 
     72        if( !document.getElementById( "_signature" + i ) ) continue; 
     73 
     74        var key = document.getElementById( "title_signature" + i ).value; 
     75        var edit = !!document.getElementById( "edit_signature" + i ).checked; 
     76 
     77        var value =  edit ? tinyMCE.get( "user_signature" + i ).getContent() : 
     78                            document.getElementById( "user_signature" + i ).value; 
     79         
     80        if( !value ) 
     81            continue; 
     82 
     83        if( !key ) 
     84        { 
     85                alert( "Titulo da assinatura nao pode ser em branco." ); 
     86                return( false ); 
     87        } 
     88 
     89        var openTags = value.match(/<[a-z][^&>]*>/g); 
     90        var closedTags = value.match(/<[/][^&>]*>/g); 
     91        var oclosedTags = value.match(/[a-z]*[^&<>]* [/]>/g); 
     92 
     93        if( ( openTags || [] ).length !== (( closedTags || [] ).length + ( oclosedTags || [] ).length )) 
     94        { 
     95            errors = errors || []; 
     96            errors.push( key ); 
     97        } 
     98 
     99        if( errors ) 
     100            continue; 
     101 
     102        if( document.getElementById( "default_signature" + i ).checked ) 
     103            default_signature = key; 
     104 
     105        signatures[key] = value; 
     106 
     107        if( edit ) 
     108            types[key] = edit; 
     109 
     110        if( noSig ) 
     111            noSig = false; 
     112    } 
     113 
     114    if( errors ){ 
     115 
     116        alert( "Há erros de html na(s) assinatura(s) \'" + errors.join("\',\'") + "\'.\\nRevise a informação inserida (somente no modo Texto Simples ou visulização do Código-Fonte, no modo Texto Rico).\\nPossivelmente você copiou e colou sua assinatura de outro software. Para evitar erros, recomendamos utilizar apenas o editor Texto Rico do Expresso." ); 
     117        return( false ); 
     118    } 
     119 
     120    if( !default_signature ){ 
     121         
     122        if( !noSig ) 
     123        { 
     124            alert( "Favor selecionar uma assinatura padrao." ); 
     125            return( false ); 
     126        } 
     127 
     128        document.getElementById( "signature_default" ).value =  ""; 
     129        document.getElementById( "signature" ).value = ""; 
     130    } 
     131    else 
     132    { 
     133        document.getElementById( "signature_default" ).value =  default_signature; 
     134        document.getElementById( "signature" ).value = types[key] ? signatures[default_signature] : 
     135                                                                    signatures[default_signature].replace( /\\n/g, "<br>" ); 
     136    } 
     137 
     138    document.getElementById( "signatures" ).value = toJSON( signatures ); 
     139    document.getElementById( "signature_types" ).value = toJSON( types ); 
     140 
     141    return( true ); 
     142} 
     143function fromJSON( value ) 
     144{ 
     145    return (new Function( "return " + decode64( value )))(); 
     146} 
     147 
     148function toJSON( value ) 
     149{ 
     150    var json = []; 
     151 
     152    for( var key in value ) 
     153        json.push(  \'"\' + key + \'":"\' + escape( value[key] ) + \'"\' ); 
     154 
     155    return encode64( "{" + json.join( "," ) + "}" ); 
     156} 
     157 
     158// This code was written by Tyler Akins and has been placed in the 
     159// public domain.  It would be nice if you left this header intact. 
     160// Base64 code from Tyler Akins -- http://rumkin.com 
     161 
     162var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 
     163 
     164function encode64(input) { 
     165        var output = new StringMaker(); 
     166        var chr1, chr2, chr3; 
     167        var enc1, enc2, enc3, enc4; 
     168        var i = 0; 
     169 
     170        while (i < input.length) { 
     171                chr1 = input.charCodeAt(i++); 
     172                chr2 = input.charCodeAt(i++); 
     173                chr3 = input.charCodeAt(i++); 
     174 
     175                enc1 = chr1 >> 2; 
     176                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 
     177                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 
     178                enc4 = chr3 & 63; 
     179 
     180                if (isNaN(chr2)) { 
     181                        enc3 = enc4 = 64; 
     182                } else if (isNaN(chr3)) { 
     183                        enc4 = 64; 
     184                } 
     185 
     186                output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4)); 
     187   } 
     188    
     189   return output.toString(); 
     190} 
     191var ua = navigator.userAgent.toLowerCase(); 
     192if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(" gecko/") >= 0) { 
     193    var StringMaker = function () { 
     194        this.str = ""; 
     195        this.length = 0; 
     196        this.append = function (s) { 
     197            this.str += s; 
     198            this.length += s.length; 
     199        } 
     200        this.prepend = function (s) { 
     201            this.str = s + this.str; 
     202            this.length += s.length; 
     203        } 
     204        this.toString = function () { 
     205            return this.str; 
     206        } 
     207    } 
     208} else { 
     209    var StringMaker = function () { 
     210        this.parts = []; 
     211        this.length = 0; 
     212        this.append = function (s) { 
     213            this.parts.push(s); 
     214            this.length += s.length; 
     215        } 
     216        this.prepend = function (s) { 
     217            this.parts.unshift(s); 
     218            this.length += s.length; 
     219        } 
     220        this.toString = function () { 
     221            return this.parts.join(""); 
     222        } 
     223    } 
     224} 
     225function decode64(input) { 
     226        var output = new StringMaker(); 
     227        var chr1, chr2, chr3; 
     228        var enc1, enc2, enc3, enc4; 
     229        var i = 0; 
     230 
     231        // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 
     232        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 
     233 
     234        while (i < input.length) { 
     235                enc1 = keyStr.indexOf(input.charAt(i++)); 
     236                enc2 = keyStr.indexOf(input.charAt(i++)); 
     237                enc3 = keyStr.indexOf(input.charAt(i++)); 
     238                enc4 = keyStr.indexOf(input.charAt(i++)); 
     239 
     240                chr1 = (enc1 << 2) | (enc2 >> 4); 
     241                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 
     242                chr3 = ((enc3 & 3) << 6) | enc4; 
     243 
     244                output.append(String.fromCharCode(chr1)); 
     245 
     246                if (enc3 != 64) { 
     247                        output.append(String.fromCharCode(chr2)); 
     248                } 
     249                if (enc4 != 64) { 
     250                        output.append(String.fromCharCode(chr3)); 
     251                } 
     252        } 
     253 
     254        return output.toString(); 
     255} 
     256function loadSignature() 
     257{ 
     258    var types = fromJSON( document.getElementById( "signature_types" ).value ); 
     259    var signatures = fromJSON( document.getElementById( "signatures" ).value ); 
     260    var old_signature = document.getElementById( "signature" ).value;  
     261    var def = document.getElementById( "signature_default" ).value; 
     262 
     263    var counter = 0, ids = [], def_signature = "", noSig = true; 
     264 
     265    for( key in signatures ) 
     266    { 
     267        addSignature( !types || !types[key] ); 
     268 
     269        var value = unescape( signatures[key] ); 
     270 
     271        document.getElementById( "title_signature" + counter ).value = key; 
     272        document.getElementById( "user_signature" + counter ).value = value; 
     273 
     274        if( def === key ) 
     275            def_signature = counter; 
     276 
     277        if( noSig ) noSig = false; 
     278 
     279        counter++; 
     280    } 
     281 
     282    if( def_signature !== "" ) 
     283        document.getElementById( "default_signature" + def_signature ).checked = true; 
     284    else if( noSig && old_signature ) 
     285    { 
     286        addSignature( document.getElementById("type_signature").value !== "html" ); 
     287        document.getElementById( "user_signature" + counter ).value = old_signature; 
     288    } 
    74289}'); 
    75290//} 
    76 $default = false; 
    77 create_check_box('Do you want to show common name instead of UID?','uid2cn',$default, 
    78         'Do you want to show common name instead of UID?'); 
    79 create_check_box('Do you want to automatically display the message header?','show_head_msg_full',$default,''); 
     291 
    80292$default = array( 
    81293        '25'    => '25', 
     
    85297); 
    86298 
     299// Cria nova opção nas preferências do ExpressoMail  
     300create_check_box('View the user name in the header of the messages printed?', 'show_name_print_messages', 'Displays the user name in the header print email'); 
     301 
    87302create_select_box('What is the maximum number of messages per page?','max_email_per_page',$default,'This is the number of messages shown in your mailbox per page'); 
    88  
    89 create_check_box('View the user name in the header of the messages printed?', 'show_name_print_messages', 'Displays the user name in the header print email'); 
    90  
    91 //$default = 0; 
    92 create_check_box('Preview message text within subject column','preview_msg_subject','this exhibits a sample of message within the message subject column'); 
    93  
    94 //$default = 0; 
    95 create_check_box('Preview message text within a tool-tip box','preview_msg_tip','this exhibits a sample of message within a tool-tip box'); 
    96  
    97 create_check_box('View extended information about users','extended_info','This exhibits employeenumber and ou from LDAP in searchs'); 
    98  
    99303create_check_box('Save deleted messages in trash folder?','save_deleted_msg','When delete message, send it automatically to trash folder'); 
    100304$default = array( 
     
    106310); 
    107311 
    108 $arquived_messages = array(true => lang("Copy"), false => lang("Move")); 
    109  
    110312create_select_box('Delete trash messages after how many days?','delete_trash_messages_after_n_days',$default,'Delete automatically the messages in trash folder in how many days'); 
    111313create_check_box('Would you like to use local messages?','use_local_messages','Enabling this options you will be able to store messages in your local computer'); 
    112 create_select_box('Desired action to archive messages to local folders','keep_archived_messages',$arquived_messages,'After store email in your local computer delete it from server'); 
    113 create_check_box('Automaticaly create Default local folders?','auto_create_local','Enable this option if you want to automaticaly create the Inbox, Draft, Trash and Sent folders'); 
     314create_check_box('Would you like to keep archived messages?','keep_archived_messages','After store email in your local computer delete it from server'); 
    114315create_check_box('Show previous message, after delete actual message?','delete_and_show_previous_message','Enable this option if you want to read the next message everytime you delete a message'); 
    115316create_check_box('Do you wanna receive an alert for new messages?','alert_new_msg','Everytime you receive new messages you will be informed'); 
     
    117318create_check_box('Do you want to use remove attachments function?','remove_attachments_function','It allow you to remove attachments from messages'); 
    118319create_check_box('Do you want to use important flag in email editor?','use_important_flag','It allow you to send emails with important flag, but you can receive unwanted messages with important flag'); 
    119 create_check_box('Do you want to use SpellChecker in email editor?','use_SpellChecker','It allow you to check the spelling of your emails'); 
     320 
    120321//Use user folders from email 
    121  
     322if ($type != "" && $type != "user"){ 
     323        $trash = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 
     324        $drafts = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; 
     325        $spam = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']; 
     326        $sent = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; 
     327        $delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']; 
     328        $default = Array( 
     329                'INBOX' =>      lang('INBOX'),  
     330                'INBOX'.$delimiter.$trash => $trash,   
     331                'INBOX'.$delimiter.$drafts => $drafts, 
     332                'INBOX'.$delimiter.$spam => $spam, 
     333                'INBOX'.$delimiter.$sent => $sent 
     334        ); 
     335} 
     336else 
     337{ 
    122338require_once('class.imap_functions.inc.php'); 
    123339$boemailadmin = CreateObject('emailadmin.bo'); 
     
    127343$e_server = $_SESSION['phpgw_info']['expressomail']['email_server']; 
    128344$imap = CreateObject('expressoMail1_2.imap_functions'); 
    129  
    130 if ($type != "" && $type != "user"){ 
    131          
    132         $trash     = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 
    133         $drafts    = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; 
    134         $spam      = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']; 
    135         $sent      = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; 
    136         $delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']; 
    137         $default = Array( 
    138                 'INBOX' =>      lang('INBOX'),  
    139                 'INBOX' . $imap->imap_delimiter . $drafts => lang($drafts), 
    140                 'INBOX' . $imap->imap_delimiter . $spam => lang($spam), 
    141                 'INBOX' . $imap->imap_delimiter . $trash => lang($trash),   
    142                 'INBOX' . $imap->imap_delimiter . $sent => lang($sent) 
    143         ); 
    144 } 
    145 else 
    146 { 
    147345$save_in_folder_selected = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']; 
    148346 
     
    180378} 
    181379create_select_box('Save sent messages in folder','save_in_folder',$default,'Save automatically sent messages in selected folder'); 
    182 create_check_box('Show TO: in place of FROM: only in Automatic SEND folder','from_to_sent','Show TO: in place of FROM: only in Automatic SEND folder'); 
    183  
    184  
    185380create_check_box('Hide menu folders?','hide_folders','You can use it if your screen does not have good resolution'); 
    186381 
    187  
    188 $default =  array( 
    189     '50'    => '50', 
    190     '100'   => '100', 
    191     '150'   => '150', 
    192     '200'   => '200', 
    193     '300'   => '300', 
    194     '400'   => '400', 
    195     '65536' => lang('unlimited') 
     382$default = array( 
     383        '20' => lang('normal'), 
     384        '30' => lang('medium'), 
     385        '40' => lang('big') 
    196386); 
    197387 
    198 create_select_box('What is the maximum number of results in an e-mail search?','search_result_number',$default,''); 
    199  
    200 $default =  array( 
    201     '1' => lang('unlimited'), 
    202     '2'     => '2', 
    203     '3'     => '3', 
    204     '4'     => '4', 
    205     '5'     => '5' 
    206 ); 
    207  
    208 create_select_box('What is the minimum number of characters in searching contacts?','search_characters_number',$default,'what is the minimum number of characters in searching contacts'); 
    209  
    210         $default = array(  
    211                 '20' => lang('normal'),  
    212                 '30' => lang('medium'),  
    213                 '40' => lang('big')  
    214         ); 
    215  
    216  
    217388create_select_box('What is the height of the lines in the list of messages?','line_height',$default,''); 
    218 create_check_box('Increases th maximum size of show messages?','max_msg_size','Increases the maximum size of show emails from 100kb to 1mb'); 
    219389create_check_box('Use dynamic contacts?','use_dynamic_contacts','Store your\'s most used contacts'); 
    220 create_check_box('Use shortcuts?','use_shortcuts','n key (Open new message)<br>ESC key (Close tab)<br>i key (print)<br>e key (forward)<br>r key (reply)<br>DELETE key (delete the current message)<br>Ctrl + up (go to previous message)<br>Ctrl + down (go to next message)<br>Shift + up or down (select multiple messages)<br>F9  key (search at catalog)<br>'); 
     390create_check_box('Use shortcuts?','use_shortcuts',''); 
    221391create_check_box('Auto save draft','auto_save_draft','When you are away from computer it saves automatically the message you are writing'); 
    222 create_check_box('Send messages with return recipient option by default','return_recipient_deafault','With this option every new email will get the return recipient option marked'); 
    223  
    224 unset($default); 
    225 $functions = new functions(); 
    226 $zones = $functions->getTimezones(); 
    227 $default = array(sprintf("%s", array_search('America/Sao_Paulo', $zones)) => 'America/Sao_Paulo'); 
    228 create_select_box('What is your timezone?', 'timezone', $zones, 'The Timezone you\'re in.', $default); 
    229  
    230 $default =  array( 
    231     '1' => lang('contacts'), 
    232     '2' => lang('email') 
    233 ); 
    234  
    235 create_select_box('Where should the quick search be performed by default?','quick_search_default',$default,'It is where the keyword should be searched when the user executes a quick search.'); 
    236  
    237392$default = array( 
    238393        '65536' => lang('unlimited'), 
     
    265420        'html' => lang('rich text') 
    266421); 
    267 create_check_box('Auto close the first tab on reaching the maximum number of tabs?','auto_close_first_tab',''); 
    268422create_check_box('Insert signature automatically in new messages?','use_signature',''); 
    269 create_select_box('Signature Type','type_signature',$default,'','','','onchange="javascript:changeType(this.value);" onload="javascript:alert(this.value);"'); 
    270423 
    271424if ($type == 'user' || $type == ''){ 
    272         $oFCKeditor = new FCKeditor('html_signature'); 
    273         $oFCKeditor->BasePath   = '../expressoMail1_2/js/fckeditor/'; 
    274         $oFCKeditor->ToolbarSet = 'ExpressoLivre'; 
    275  
    276         $vars = $GLOBALS['phpgw']->preferences->user[$appname]; 
    277  
    278         create_html_code("signature","<div id='text_signature'> 
    279                 <textarea rows='5' cols='50' id='user_signature' name='user[signature]'>","</textarea></div> 
    280                 <div style='display:none;' id='html_signature'>".$oFCKeditor->Create()."</div> 
    281                 <script language='javascript'> 
    282 //document.getElementById('user_signature').value  = '".$vars['signature']."'; 
    283 function changeType(value){ 
    284         var html_signature = FCKeditorAPI.GetInstance(\"html_signature\"); 
    285         value=value.replace('d',''); 
    286         if(value == 'text'){ 
    287                 document.getElementById('user_signature').value = html_signature.GetHTML(); 
    288                 document.getElementById(\"text_signature\").style.display = ''; 
    289                 document.getElementById(\"html_signature\").style.display = 'none'; 
     425 
     426        global $prefs; 
     427//      create_select_box('Signature Type','type_signature',$default,'','','','onchange="javascript:changeType(this.value);"'); 
     428 
     429        $vars = $GLOBALS['phpgw']->preferences->user['expressoMail']; 
     430 
     431        create_html_code("signature","<script src='../library/jquery/jquery-1.6.1.min.js' language='javascript'></script><script src='../library/tiny_mce/jquery.tinymce.js' language='javascript'></script><script src='../library/tiny_mce/tiny_mce.js' language='javascript'></script> 
     432        <input type='hidden' id='counter' value='0'> 
     433        <input type='hidden' id='signatures' name='user[signatures]' value='". $vars['signatures']."'> 
     434        <input type='hidden' id='signature_default' name='user[signature_default]' value='".$vars['signature_default']."'> 
     435        <input type='hidden' id='type_signature' name='user[type_signature]' value='".$vars['type_signature']."'> 
     436        <input type='hidden' id='signature' name='user[signature]' value='","' > 
     437        <input type='hidden' id='signature_types' name='user[signature_types]' value='".$vars['signature_types']."'> 
     438 
     439        <div id='_signature' name='signature' style='display: none;'> 
     440        <div id='options_signature'> 
     441        <input id='edit_signature' type='checkbox' name='isEditor' onclick='changeType( \"\", this.id.replace( /[^0-9]*/gi, \"\" ) );' checked='checked'><label for='isEditor'>Editor de texto</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; titulo da assinatura&nbsp;<input type='text' id='title_signature'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' id='default_signature' name='signature_default'><label>Usar como padrao</label><a href='#' onclick='javascript: return removeSignature( this );' id='remove_signature'> remover</a> 
     442        </div><br/> 
     443        <div id='text_signature'> 
     444        <textarea rows='5' cols='50' id='user_signature' class='editor'></textarea></div> 
     445        </div> 
     446 
     447        <script language='javascript'> 
     448 
     449        $(document).ready(function(){ 
     450 
     451            loadSignature(); 
     452 
     453        }); 
     454 
     455        function changeType(value, target){ 
     456 
     457            tinyMCE.execCommand( 'mceToggleEditor', false, 'user_signature' + target ); 
    290458        } 
    291         else if(value == 'html'){ 
    292                 html_signature.SetHTML(document.getElementById('user_signature').value); 
    293                 document.getElementById(\"text_signature\").style.display = 'none'; 
    294                 document.getElementById(\"html_signature\").style.display  = ''; 
    295         } 
    296 } 
    297 function get_html_translation_table(table, quote_style) { 
    298     // http://kevin.vanzonneveld.net  
    299     var entities = {}, hash_map = {}, decimal = 0, symbol = ''; 
    300     var constMappingTable = {}, constMappingQuoteStyle = {}; 
    301     var useTable = {}, useQuoteStyle = {}; 
    302     // Translate arguments 
    303     constMappingTable[0]      = 'HTML_SPECIALCHARS'; 
    304     constMappingTable[1]      = 'HTML_ENTITIES'; 
    305     constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; 
    306     constMappingQuoteStyle[2] = 'ENT_COMPAT'; 
    307     constMappingQuoteStyle[3] = 'ENT_QUOTES'; 
    308   
    309     useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; 
    310     useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; 
    311   
    312     if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { 
    313         throw new Error(\"Table: \"+useTable+' not supported'); 
    314         // return false; 
    315     } 
    316   
    317     entities['38'] = '&amp;'; 
    318     if (useTable === 'HTML_ENTITIES') { 
    319         entities['160'] = '&nbsp;'; 
    320         entities['161'] = '&iexcl;'; 
    321         entities['162'] = '&cent;'; 
    322         entities['163'] = '&pound;'; 
    323         entities['164'] = '&curren;'; 
    324         entities['165'] = '&yen;'; 
    325         entities['166'] = '&brvbar;'; 
    326         entities['167'] = '&sect;'; 
    327         entities['168'] = '&uml;'; 
    328         entities['169'] = '&copy;'; 
    329         entities['170'] = '&ordf;'; 
    330         entities['171'] = '&laquo;'; 
    331         entities['172'] = '&not;'; 
    332         entities['173'] = '&shy;'; 
    333         entities['174'] = '&reg;'; 
    334         entities['175'] = '&macr;'; 
    335         entities['176'] = '&deg;'; 
    336         entities['177'] = '&plusmn;'; 
    337         entities['178'] = '&sup2;'; 
    338         entities['179'] = '&sup3;'; 
    339         entities['180'] = '&acute;'; 
    340         entities['181'] = '&micro;'; 
    341         entities['182'] = '&para;'; 
    342         entities['183'] = '&middot;'; 
    343         entities['184'] = '&cedil;'; 
    344         entities['185'] = '&sup1;'; 
    345         entities['186'] = '&ordm;'; 
    346         entities['187'] = '&raquo;'; 
    347         entities['188'] = '&frac14;'; 
    348         entities['189'] = '&frac12;'; 
    349         entities['190'] = '&frac34;'; 
    350         entities['191'] = '&iquest;'; 
    351         entities['192'] = '&Agrave;'; 
    352         entities['193'] = '&Aacute;'; 
    353         entities['194'] = '&Acirc;'; 
    354         entities['195'] = '&Atilde;'; 
    355         entities['196'] = '&Auml;'; 
    356         entities['197'] = '&Aring;'; 
    357         entities['198'] = '&AElig;'; 
    358         entities['199'] = '&Ccedil;'; 
    359         entities['200'] = '&Egrave;'; 
    360         entities['201'] = '&Eacute;'; 
    361         entities['202'] = '&Ecirc;'; 
    362         entities['203'] = '&Euml;'; 
    363         entities['204'] = '&Igrave;'; 
    364         entities['205'] = '&Iacute;'; 
    365         entities['206'] = '&Icirc;'; 
    366         entities['207'] = '&Iuml;'; 
    367         entities['208'] = '&ETH;'; 
    368         entities['209'] = '&Ntilde;'; 
    369         entities['210'] = '&Ograve;'; 
    370         entities['211'] = '&Oacute;'; 
    371         entities['212'] = '&Ocirc;'; 
    372         entities['213'] = '&Otilde;'; 
    373         entities['214'] = '&Ouml;'; 
    374         entities['215'] = '&times;'; 
    375         entities['216'] = '&Oslash;'; 
    376         entities['217'] = '&Ugrave;'; 
    377         entities['218'] = '&Uacute;'; 
    378         entities['219'] = '&Ucirc;'; 
    379         entities['220'] = '&Uuml;'; 
    380         entities['221'] = '&Yacute;'; 
    381         entities['222'] = '&THORN;'; 
    382         entities['223'] = '&szlig;'; 
    383         entities['224'] = '&agrave;'; 
    384         entities['225'] = '&aacute;'; 
    385         entities['226'] = '&acirc;'; 
    386         entities['227'] = '&atilde;'; 
    387         entities['228'] = '&auml;'; 
    388         entities['229'] = '&aring;'; 
    389         entities['230'] = '&aelig;'; 
    390         entities['231'] = '&ccedil;'; 
    391         entities['232'] = '&egrave;'; 
    392         entities['233'] = '&eacute;'; 
    393         entities['234'] = '&ecirc;'; 
    394         entities['235'] = '&euml;'; 
    395         entities['236'] = '&igrave;'; 
    396         entities['237'] = '&iacute;'; 
    397         entities['238'] = '&icirc;'; 
    398         entities['239'] = '&iuml;'; 
    399         entities['240'] = '&eth;'; 
    400         entities['241'] = '&ntilde;'; 
    401         entities['242'] = '&ograve;'; 
    402         entities['243'] = '&oacute;'; 
    403         entities['244'] = '&ocirc;'; 
    404         entities['245'] = '&otilde;'; 
    405         entities['246'] = '&ouml;'; 
    406         entities['247'] = '&divide;'; 
    407         entities['248'] = '&oslash;'; 
    408         entities['249'] = '&ugrave;'; 
    409         entities['250'] = '&uacute;'; 
    410         entities['251'] = '&ucirc;'; 
    411         entities['252'] = '&uuml;'; 
    412         entities['253'] = '&yacute;'; 
    413         entities['254'] = '&thorn;'; 
    414         entities['255'] = '&yuml;'; 
    415     } 
    416     if (useQuoteStyle !== 'ENT_NOQUOTES') { 
    417         entities['34'] = '&quot;'; 
    418     } 
    419     if (useQuoteStyle === 'ENT_QUOTES') { 
    420         entities['39'] = '&#39;'; 
    421     } 
    422     entities['60'] = '&lt;'; 
    423     entities['62'] = '&gt;'; 
    424    
    425     // ascii decimals to real symbols 
    426     for (decimal in entities) { 
    427         symbol = String.fromCharCode(decimal); 
    428         hash_map[symbol] = entities[decimal]; 
    429     } 
    430     return hash_map; 
    431 } 
    432 function html_entity_decode( string, quote_style ) { 
    433     // http://kevin.vanzonneveld.net 
    434     var hash_map = {}, symbol = '', tmp_str = '', entity = ''; 
    435     tmp_str = string.toString(); 
    436     if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { 
    437         return false; 
    438     } 
    439     for (symbol in hash_map) { 
    440         entity = hash_map[symbol]; 
    441         tmp_str = tmp_str.split(entity).join(symbol); 
    442     } 
    443     tmp_str = tmp_str.split('&#039;').join(\"'\"); 
    444     return tmp_str; 
    445 } 
    446  
    447 function getTypeSignature() { 
    448    var elementoSelects  = document.getElementsByTagName('select'); 
    449  
    450    if ( elementoSelects[18].name == \"user[type_signature]\" ) { 
    451         return elementoSelects[18]; 
    452    } 
    453     
    454    for(i=0;i<elementoSelects.length;i++){ 
    455         if( elementoSelects[i].name == \"user[type_signature]\" ){ 
    456                  return elementoSelects[i]; 
    457         } 
    458     } 
    459     return null; 
    460 } 
    461  
    462 function config_form(pObj,pHandler) 
    463 { 
    464         pObj.onclick=function () { 
    465                 if (getTypeSignature().value == \"html\" || getTypeSignature().value == \"htmld\") { 
    466                         return pHandler(\"text\"); 
    467                 } 
    468         }; 
    469  
    470 } 
    471 document.getElementById('user_signature').value=html_entity_decode(document.getElementById('user_signature').innerHTML); 
    472  
    473 function setDefaultTypeSignature() { 
    474         if(getTypeSignature()){ 
    475                 getTypeSignature().options[0].value = '".$GLOBALS['phpgw']->preferences->default['expressoMail']['type_signature']."d'; 
    476                 if(getTypeSignature().value.indexOf('html')!=-1){ 
    477                    changeType(getTypeSignature().value); 
    478             } 
    479         }else{ 
    480                  changeType('".$GLOBALS['phpgw']->preferences->forced['expressoMail']['type_signature']."'); 
    481         } 
    482 } 
    483  
    484 setTimeout('setDefaultTypeSignature();config_form(document.getElementsByName(\'submit\')[0],changeType);',2000); 
    485 </script>"); 
     459 
     460// var counter = 0; 
     461 
     462function addSignature( simple ) 
     463{ 
     464        var sig = document.getElementById('_signature').cloneNode( true ); 
     465        var counter = document.getElementById( 'counter' ).value; 
     466 
     467        sig.innerHTML = sig.innerHTML.replace( /_signature/g, '_signature' + counter ); 
     468 
     469        sig.id = '_signature' + counter; 
     470        sig.style.display = ''; 
     471 
     472        $( '#add_signature' ).before( sig ); 
     473 
     474        if( !simple ) 
     475            $( '#user_signature' + counter ).tinymce({ 
     476                plugins : 'paste', 
     477                theme_advanced_toolbar_location : 'top', 
     478                theme_advanced_toolbar_align : 'center', 
     479                entities: '', 
     480                entity_encoding: 'raw', 
     481                theme: 'advanced', 
     482                add_form_submit_trigger : false 
     483            }); 
     484        else 
     485            document.getElementById('edit_signature' + counter ).checked = ''; 
     486 
     487        document.getElementById( 'counter' ).value = ++counter; 
     488} 
     489 
     490function removeSignature( el ) 
     491{ 
     492    counter = el.id.replace( /[^0-9]*/gi, \"\" ); 
     493 
     494    el = document.getElementById( '_signature' + counter ); 
     495    el.parentNode.removeChild( el ); 
     496 
     497    return( false ); 
     498} 
     499</script> 
     500<input id='add_signature' type='button' onclick='addSignature();' value='Adicionar Assinatura'> 
     501"); 
     502}else{ 
     503        create_select_box('Signature Type','type_signature',$default,'','','',''); 
     504 
    486505} 
    487506?> 
  • trunk/expressoMail1_2/js/rich_text_editor.js

    r4801 r4828  
    66        this.buildEditor(); 
    77        this.saveFlag = 0; 
     8        }  
     9                  
     10                // This code was written by Tyler Akins and has been placed in the  
     11                // public domain.  It would be nice if you left this header intact.  
     12                // Base64 code from Tyler Akins -- http://rumkin.com  
     13                  
     14                var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";  
     15          
     16                var ua = navigator.userAgent.toLowerCase();  
     17                if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) {  
     18                    var StringMaker = function () {  
     19                        this.str = "";  
     20                        this.length = 0;  
     21                        this.append = function (s) {  
     22                            this.str += s;  
     23                            this.length += s.length;  
     24                        }  
     25                        this.prepend = function (s) {  
     26                            this.str = s + this.str;  
     27                            this.length += s.length;  
     28                        }  
     29                        this.toString = function () {  
     30                            return this.str;  
     31                        }  
     32                    }  
     33                } else {  
     34                    var StringMaker = function () {  
     35                                this.parts = [];  
     36                        this.length = 0;  
     37                        this.append = function (s) {  
     38                            this.parts.push(s);  
     39                            this.length += s.length;  
     40                        }  
     41                        this.prepend = function (s) {  
     42                            this.parts.unshift(s);  
     43                            this.length += s.length;  
     44                        }  
     45                        this.toString = function () {  
     46                            return this.parts.join('');  
     47                        }  
     48                    }  
     49                }  
     50                 
     51                function fromJSON( value )  
     52                {  
     53                    return (new Function( "return " + decode64( value )))();  
     54                } 
     55 
     56                 
     57                function decode64(input) {  
     58                  
     59                        if( typeof input === "undefined" ) return;  
     60                  
     61                        var output = new StringMaker();  
     62                        var chr1, chr2, chr3;  
     63                        var enc1, enc2, enc3, enc4;  
     64                                var i = 0;  
     65                  
     66                        // remove all characters that are not A-Z, a-z, 0-9, +, /, or =  
     67                        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");  
     68                  
     69                        while (i < input.length) {  
     70                                enc1 = keyStr.indexOf(input.charAt(i++));  
     71                                enc2 = keyStr.indexOf(input.charAt(i++));  
     72                                enc3 = keyStr.indexOf(input.charAt(i++));  
     73                                enc4 = keyStr.indexOf(input.charAt(i++));  
     74                  
     75                                                chr1 = (enc1 << 2) | (enc2 >> 4);  
     76                                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);  
     77                                chr3 = ((enc3 & 3) << 6) | enc4;  
     78                  
     79                                output.append(String.fromCharCode(chr1));  
     80                  
     81                                if (enc3 != 64) {  
     82                                        output.append(String.fromCharCode(chr2));  
     83                                }  
     84                                if (enc4 != 64) {  
     85                                        output.append(String.fromCharCode(chr3));  
     86                                }  
     87                        }  
     88                  
     89                        return output.toString(); 
     90         
     91         
    892} 
    993 
     
    220304 
    221305 
    222  
     306cRichTextEditor.prototype.buildSelect = function( selectId, label, options, decode ) {   
     307                  
     308                    var selectBox = document.createElement("SELECT");  
     309                    selectBox.id = selectId;  
     310                    selectBox.setAttribute("tabIndex","-1");  
     311                    selectBox.onchange = function () {RichTextEditor.Select( selectId );};  
     312                    selectBox.className = 'select_richtext';  
     313                    selectBox.length = 0;  
     314                  
     315                    selectBox.options[0] = new Option( get_lang(label), label );  
     316                  
     317                    for( var key in options )  
     318                        selectBox.options[ selectBox.length ] = new Option( key, unescape( options[key] ) );  
     319                  
     320                    return selectBox;  
     321                } 
    223322 
    224323cRichTextEditor.prototype.buildEditor = function() { 
     
    232331        var div_button_rt = document.createElement("DIV"); 
    233332         
    234         selectBox=document.createElement("SELECT"); 
    235         selectBox.id="fontname"; 
    236         selectBox.setAttribute("tabIndex","-1"); 
    237         selectBox.onchange = function () {RichTextEditor.Select("fontname");}; 
    238         selectBox.className = 'select_richtext'; 
    239         var option1 = new Option(get_lang('Font'), 'Font'); 
    240         var option2 = new Option('Arial', 'Arial'); 
    241         var option3 = new Option('Courier', 'Courier'); 
    242         var option4 = new Option('Times New Roman', 'Times'); 
    243         if (is_ie){ 
    244                 selectBox.add(option1); 
    245                 selectBox.add(option2); 
    246                 selectBox.add(option3); 
    247                 selectBox.add(option4); 
    248         } 
    249         else{ 
    250                 selectBox.add(option1, null); 
    251                 selectBox.add(option2, null); 
    252                 selectBox.add(option3, null); 
    253                 selectBox.add(option4, null); 
    254         } 
    255         div_button_rt.appendChild(selectBox); 
    256  
    257         selectBox=document.createElement("SELECT"); 
    258         selectBox.id="fontsize"; 
    259         selectBox.setAttribute("tabIndex","-1"); 
    260         selectBox.setAttribute("unselectable","on"); 
    261         selectBox.className = 'select_richtext'; 
    262         selectBox.onchange = function () {RichTextEditor.Select("fontsize");}; 
    263         var option1 = new Option(get_lang('Size'), 'Size'); 
    264         var option2 = new Option('1 (8 pt)','1' ); 
    265         var option3 = new Option('2 (10 pt)','2'); 
    266         var option4 = new Option('3 (12 pt)','3'); 
    267         var option5 = new Option('4 (14 pt)','4'); 
    268         var option6 = new Option('5 (18 pt)','5'); 
    269         var option7 = new Option('6 (24 pt)','6'); 
    270         var option8 = new Option('7 (36 pt)','7'); 
    271         if (is_ie){ 
    272                 selectBox.add(option1); 
    273                 selectBox.add(option2); 
    274                 selectBox.add(option3); 
    275                 selectBox.add(option4); 
    276                 selectBox.add(option5); 
    277                 selectBox.add(option6); 
    278                 selectBox.add(option7); 
    279                 selectBox.add(option8); 
    280         } 
    281         else{ 
    282                 selectBox.add(option1, null); 
    283                 selectBox.add(option2, null); 
    284                 selectBox.add(option3, null); 
    285                 selectBox.add(option4, null); 
    286                 selectBox.add(option5, null); 
    287                 selectBox.add(option6, null); 
    288                 selectBox.add(option7, null); 
    289                 selectBox.add(option8, null);    
    290         } 
    291         div_button_rt.appendChild(selectBox); 
     333         
     334        selectBox = this.buildSelect( "fontname", 'Font', { 'Arial' : 'Arial',  
     335                                                                            'Courier' : 'Courier',  
     336                                                                            'Times New Roman' : 'Times' });  
     337                  
     338                        div_button_rt.appendChild( selectBox );  
     339                  
     340                        selectBox = this.buildSelect( "fontsize", 'Size', { '1 (8 pt)': '1',  
     341                                                                            '2 (10 pt)': '2',  
     342                                                                            '3 (12 pt)': '3',  
     343                                                                            '4 (14 pt)': '4',  
     344                                                                            '5 (18 pt)': '5',  
     345                                                                            '6 (24 pt)': '6',  
     346                                                                            '7 (36 pt)': '7' });  
     347                  
     348                        div_button_rt.appendChild( selectBox ); 
    292349         
    293350        var buttons = ['bold', 'italic', 'underline', 'forecolor', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 
     
    355412        } 
    356413 
     414        preferences.signatures = fromJSON( preferences.signatures );  
     415                        preferences.signature_types = fromJSON( preferences.signature_types );  
     416                  
     417                        for( key in preferences.signatures )  
     418                            if( !preferences.signature_types[key] )  
     419                                                preferences.signatures[key] = preferences.signatures[key].replace( /\n/g, "<br>" ); 
     420                  
     421                selectBox = this.buildSelect( "inserthtml", 'Signature', preferences.signatures );  
     422                div_button_rt.appendChild( selectBox ); 
    357423 
    358424        td.appendChild(div_button_rt); 
     
    366432                var mainField = document.getElementById(this.editor).contentWindow; 
    367433                mainField.focus(); 
    368                 var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 
     434                var signature = preferences.signature;  
     435            if( !preferences.signatures )  
     436                        signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 
    369437                if (command == 'signature'){ 
    370438                        if (is_ie){ 
Note: See TracChangeset for help on using the changeset viewer.