Changeset 284 in subversion


Ignore:
Timestamp:
Jul 30, 2006 6:14:19 AM (7 years ago)
Author:
thomasb
Message:

Alter links in HTML messages; highlight droptargets

Location:
trunk/roundcubemail
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r282 r284  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42006/07/30 (thomasb) 
     5---------- 
     6- Alter links in HTML messages (Bug #1326402) 
     7- Added fallback if host not found in 'mail_domain' array 
     8- Applied patch of Charles to highlight droptargets (Ticket #1473034) 
     9 
    310 
    4112006/07/25 (thomasb) 
  • trunk/roundcubemail/program/include/main.inc

    r277 r284  
    542542  if ($user_id = $DB->insert_id(get_sequence_name('users'))) 
    543543    { 
    544     if (is_array($CONFIG['mail_domain']) && isset($CONFIG['mail_domain'][$host])) 
    545       $mail_domain = $CONFIG['mail_domain'][$host]; 
     544    $mail_domain = $host; 
     545    if (is_array($CONFIG['mail_domain'])) 
     546      { 
     547      if (isset($CONFIG['mail_domain'][$host])) 
     548        $mail_domain = $CONFIG['mail_domain'][$host]; 
     549      } 
    546550    else if (!empty($CONFIG['mail_domain'])) 
    547551      $mail_domain = $CONFIG['mail_domain']; 
    548     else 
    549       $mail_domain = $host; 
    550552    
    551553    if ($user_email=='') 
     
    11261128 
    11271129 
    1128 function rcube_xml_command($command, $str_attrib, $a_attrib=NULL) 
     1130function rcube_xml_command($command, $str_attrib, $add_attrib=array()) 
    11291131  { 
    11301132  global $IMAP, $CONFIG, $OUTPUT; 
    11311133   
    1132   $attrib = array(); 
    11331134  $command = strtolower($command); 
    1134  
    1135   preg_match_all('/\s*([-_a-z]+)=["]([^"]+)["]?/i', stripslashes($str_attrib), $regs, PREG_SET_ORDER); 
    1136  
    1137   // convert attributes to an associative array (name => value) 
    1138   if ($regs) 
    1139     foreach ($regs as $attr) 
    1140       $attrib[strtolower($attr[1])] = $attr[2]; 
    1141   else if ($a_attrib) 
    1142     $attrib = $a_attrib; 
     1135  $attrib = parse_attrib_string($str_attrib) + $add_attrib; 
    11431136 
    11441137  // execute command 
     
    12241217        'foldersubscription' => 'rcube_subscription_form', 
    12251218        'createfolder' => 'rcube_create_folder_form', 
    1226         'renamefolder' => 'rcube_rename_folder_form', 
     1219        'renamefolder' => 'rcube_rename_folder_form', 
    12271220        'composebody' => 'rcmail_compose_body' 
    12281221      ); 
     
    15241517 
    15251518 
     1519// compose a valid attribute string for HTML tags 
    15261520function create_attrib_string($attrib, $allowed_attribs=array('id', 'class', 'style')) 
    15271521  { 
     
    15301524  foreach ($allowed_attribs as $a) 
    15311525    if (isset($attrib[$a])) 
    1532       $attrib_str .= sprintf(' %s="%s"', $a, $attrib[$a]); 
     1526      $attrib_str .= sprintf(' %s="%s"', $a, str_replace('"', '"', $attrib[$a])); 
    15331527 
    15341528  return $attrib_str; 
    15351529  } 
    15361530 
     1531 
     1532// convert a HTML attribute string attributes to an associative array (name => value) 
     1533function parse_attrib_string($str) 
     1534  { 
     1535  $attrib = array(); 
     1536  preg_match_all('/\s*([-_a-z]+)=["]([^"]+)["]?/i', stripslashes($str), $regs, PREG_SET_ORDER); 
     1537 
     1538  // convert attributes to an associative array (name => value) 
     1539  if ($regs) 
     1540    foreach ($regs as $attr) 
     1541      $attrib[strtolower($attr[1])] = $attr[2]; 
     1542 
     1543  return $attrib; 
     1544  } 
    15371545 
    15381546 
  • trunk/roundcubemail/program/js/app.js

    r282 r284  
    288288      e = window.event; 
    289289 
    290     for (var n=0; n<this.selection.length; n++) { 
     290    for (var n=0; n<this.selection.length; n++) 
     291      { 
    291292      id = this.selection[n]; 
    292       if (this.list_rows[id].obj) { 
     293      if (this.list_rows[id].obj) 
     294        { 
    293295        this.set_classname(this.list_rows[id].obj, 'selected', true); 
    294296                this.set_classname(this.list_rows[id].obj, 'unfocused', false); 
    295           } 
    296     } 
    297  
     297        } 
     298      } 
     299 
     300    var mbox_li; 
     301    if (mbox_li = this.get_mailbox_li())  
     302      this.set_classname(mbox_li, 'unfocused', true); 
     303     
    298304    this.in_message_list = true; 
    299305    e.cancelBubble = true; 
     
    11841190    { 
    11851191    if (this.drag_active) 
     1192      { 
     1193      this.unfocus_mailbox(mbox); 
    11861194      this.command('moveto', mbox); 
     1195      } 
    11871196    else 
    11881197      this.command('list', mbox); 
    1189        
     1198   
    11901199    return false; 
    11911200    }; 
     
    15571566      add_url += '&_search='+this.env.search_request; 
    15581567       
    1559     if (this.env.mailbox!=mbox) 
    1560       this.select_mailbox(mbox); 
     1568    this.select_mailbox(mbox); 
    15611569 
    15621570    // load message list remotely 
     
    16681676    }; 
    16691677     
    1670  
     1678  this.focus_mailbox = function(mbox) 
     1679    { 
     1680    var mbox_li; 
     1681        if (this.drag_active && mbox != this.env.mailbox && (mbox_li = this.get_mailbox_li(mbox))) 
     1682      this.set_classname(mbox_li, 'droptarget', true); 
     1683    } 
     1684     
     1685  this.unfocus_mailbox = function(mbox) 
     1686    { 
     1687    var mbox_li; 
     1688        if (this.drag_active && (mbox_li = this.get_mailbox_li(mbox))) 
     1689      this.set_classname(mbox_li, 'droptarget', false); 
     1690    } 
     1691   
    16711692  // move selected messages to the specified mailbox 
    16721693  this.move_messages = function(mbox) 
     
    19311952  } 
    19321953 
     1954 
     1955  this.get_mailbox_li = function(mbox) 
     1956    { 
     1957    if (this.gui_objects.mailboxlist) 
     1958      { 
     1959      mbox = String((mbox ? mbox : this.env.mailbox)).toLowerCase().replace(this.mbox_expression, ''); 
     1960      return document.getElementById('rcmbx'+mbox); 
     1961      } 
     1962     
     1963    return null; 
     1964    }; 
     1965     
     1966 
    19331967  /*********************************************************/ 
    19341968  /*********        message compose methods        *********/ 
     
    22382272          //highlight.removeAttribute('class'); 
    22392273          this.set_classname(highlight, 'selected', false); 
    2240           this.set_classname(highlight, 'unfocused', false); 
    22412274          } 
    22422275 
     
    31533186  this.select_mailbox = function(mbox) 
    31543187    { 
    3155     if (this.gui_objects.mailboxlist) 
    3156       { 
    3157       var item, reg, text_obj; 
    3158       var s_current = this.env.mailbox.toLowerCase().replace(this.mbox_expression, ''); 
    3159       var s_mbox = String(mbox).toLowerCase().replace(this.mbox_expression, ''); 
    3160       var s_current = this.env.mailbox.toLowerCase().replace(this.mbox_expression, ''); 
    3161        
    3162       var current_li = document.getElementById('rcmbx'+s_current); 
    3163       var mbox_li = document.getElementById('rcmbx'+s_mbox); 
    3164        
    3165       if (current_li) { 
     3188    if (this.gui_objects.mailboxlist ) 
     3189      { 
     3190      var item, reg, text_obj;       
     3191      var current_li = this.get_mailbox_li(); 
     3192      var mbox_li = this.get_mailbox_li(mbox); 
     3193       
     3194      if (current_li) 
     3195        { 
    31663196        this.set_classname(current_li, 'selected', false); 
    31673197        this.set_classname(current_li, 'unfocused', false); 
    31683198        } 
    3169       if (mbox_li) 
     3199 
     3200      if (mbox_li || this.env.mailbox == mbox) 
     3201        { 
     3202        this.set_classname(mbox_li, 'unfocused', false); 
    31703203        this.set_classname(mbox_li, 'selected', true); 
     3204        } 
    31713205      } 
    31723206     
     
    32853319      set_title = true; 
    32863320 
    3287     var item, reg, text_obj; 
     3321    var reg, text_obj; 
     3322    var item = this.get_mailbox_li(mbox); 
    32883323    mbox = String(mbox).toLowerCase().replace(this.mbox_expression, ''); 
    3289     item = document.getElementById('rcmbx'+mbox); 
    32903324 
    32913325    if (item && item.className && item.className.indexOf('mailbox '+mbox)>=0) 
  • trunk/roundcubemail/program/steps/mail/func.inc

    r282 r284  
    217217    $out .= sprintf('<li id="rcmbx%s" class="mailbox %s %s%s%s"><a href="%s&amp;_mbox=%s"'. 
    218218                    ' onclick="return %s.command(\'list\',\'%s\')"'. 
     219                    ' onmouseover="return %s.focus_mailbox(\'%s\')"' .             
     220                    ' onmouseout="return %s.unfocus_mailbox(\'%s\')"' . 
    219221                    ' onmouseup="return %s.mbox_mouse_up(\'%s\')"%s>%s</a>', 
    220222                    $folder_css, 
     
    225227                    $COMM_PATH, 
    226228                    urlencode($folder['id']), 
     229                    $JS_OBJECT_NAME, 
     230                    addslashes($folder['id']), 
     231                    $JS_OBJECT_NAME, 
     232                    addslashes($folder['id']), 
    227233                    $JS_OBJECT_NAME, 
    228234                    addslashes($folder['id']), 
     
    11711177    $body = preg_replace($base_reg, '', $body); 
    11721178    } 
     1179     
     1180  // modify HTML links to open a new window if clicked 
     1181  $body = preg_replace('/<a\s+([^>]+)>/Uie', "rcmail_alter_html_link('\\1');", $body); 
    11731182 
    11741183  // add comments arround html and other tags 
    11751184  $out = preg_replace(array('/(<\/?html[^>]*>)/i', 
    11761185                            '/(<\/?head[^>]*>)/i', 
    1177                             '/(<title[^>]*>.+<\/title>)/ui', 
     1186                            '/(<title[^>]*>.*<\/title>)/Ui', 
    11781187                            '/(<\/?meta[^>]*>)/i'), 
    11791188                      '<!--\\1-->', 
     
    11851194                            '</div>'), 
    11861195                      $out); 
    1187  
    11881196   
    11891197  return $out; 
    11901198  } 
    11911199 
     1200 
     1201// parse link attributes and set correct target 
     1202function rcmail_alter_html_link($in) 
     1203  { 
     1204  $attrib = parse_attrib_string($in); 
     1205 
     1206  if (stristr((string)$attrib['href'], 'mailto:')) 
     1207    $attrib['onclick'] = sprintf("return %s.command('compose','%s',this)", 
     1208                                 $GLOBALS['JS_OBJECT_NAME'], 
     1209                                 substr($attrib['href'], 7)); 
     1210  else if (!empty($attrib['href']) && $attrib['href']{0}!='#') 
     1211    $attrib['target'] = '_blank'; 
     1212   
     1213  return '<a' . create_attrib_string($attrib, array('href', 'name', 'target', 'onclick', 'id', 'class', 'style', 'title')) . '>'; 
     1214  } 
    11921215 
    11931216 
  • trunk/roundcubemail/skins/default/mail.css

    r280 r284  
    277277} 
    278278 
     279#mailboxlist li.droptarget 
     280{ 
     281  background-color: #FFFFA6; 
     282} 
    279283 
    280284/* styles for nested folders */ 
Note: See TracChangeset for help on using the changeset viewer.