Changeset e349a8c in github


Ignore:
Timestamp:
May 28, 2012 8:17:57 AM (12 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
master, HEAD, dev-browser-capabilities, pdo
Children:
7c1231a
Parents:
2d7b4ff
Message:

Added browser capabilities detection, i.e. PDF and TIFF support

Location:
program
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • program/js/app.js

    r041c93c re349a8c  
    307307          this.http_post(postact, postdata); 
    308308        } 
     309 
     310        // detect browser capabilities 
     311        if (!this.is_framed()) 
     312          this.browser_capabilities_check(); 
    309313 
    310314        break; 
     
    19441948      url += '&_search='+this.env.search_request; 
    19451949 
    1946     if (action == 'preview' && String(target.location.href).indexOf(url) >= 0) 
     1950    // add browser capabilities, so we can properly handle attachments 
     1951    url += '&_caps='+urlencode(this.browser_capabilities()); 
     1952 
     1953    if (preview && String(target.location.href).indexOf(url) >= 0) 
    19471954      this.show_contentframe(true); 
    19481955    else { 
     
    19501957 
    19511958      // mark as read and change mbox unread counter 
    1952       if (action == 'preview' && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { 
     1959      if (preview && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { 
    19531960        this.preview_read_timer = setTimeout(function() { 
    19541961          ref.set_message(id, 'unread', false); 
     
    63696376  }; 
    63706377 
     6378  // Checks browser capabilities eg. PDF support, TIF support 
     6379  this.browser_capabilities_check = function() 
     6380  { 
     6381    if (!this.env.browser_capabilities) 
     6382      this.env.browser_capabilities = {}; 
     6383 
     6384    if (this.env.browser_capabilities.pdf === undefined) 
     6385      this.env.browser_capabilities.pdf = this.pdf_support_check(); 
     6386 
     6387    if (this.env.browser_capabilities.tif === undefined) 
     6388      this.tif_support_check(); 
     6389  }; 
     6390 
     6391  // Returns browser capabilities string 
     6392  this.browser_capabilities = function() 
     6393  { 
     6394    if (!this.env.browser_capabilities) 
     6395      return ''; 
     6396 
     6397    var n, ret = []; 
     6398 
     6399    for (n in this.env.browser_capabilities) 
     6400      ret.push(n + '=' + this.env.browser_capabilities[n]); 
     6401 
     6402    return ret.join(); 
     6403  }; 
     6404 
     6405  this.tif_support_check = function() 
     6406  { 
     6407    var img = new Image(); 
     6408 
     6409    img.onload = function() { rcmail.env.browser_capabilities.tif = 1; }; 
     6410    img.onerror = function() { rcmail.env.browser_capabilities.tif = 0; }; 
     6411    img.src = 'program/blank.tif'; 
     6412  }; 
     6413 
     6414  this.pdf_support_check = function() 
     6415  { 
     6416    var plugin = navigator.mimeTypes ? navigator.mimeTypes["application/pdf"] : {}, 
     6417      plugins = navigator.plugins, 
     6418      len = plugins.length, 
     6419      regex = /Adobe Reader|PDF|Acrobat/i; 
     6420 
     6421    if (plugin && plugin.enabledPlugin) 
     6422        return 1; 
     6423 
     6424    if (window.ActiveXObject) { 
     6425      try { 
     6426        if (axObj = new ActiveXObject("AcroPDF.PDF")) 
     6427          return 1; 
     6428      } 
     6429      catch (e) {} 
     6430      try { 
     6431        if (axObj = new ActiveXObject("PDF.PdfCtrl")) 
     6432          return 1; 
     6433      } 
     6434      catch (e) {} 
     6435    } 
     6436 
     6437    for (i=0; i<len; i++) { 
     6438      plugin = plugins[i]; 
     6439      if (typeof plugin === 'String') { 
     6440        if (regex.test(plugin)) 
     6441          return 1; 
     6442      } 
     6443      else if (plugin.name && regex.test(plugin.name)) 
     6444        return 1; 
     6445    } 
     6446 
     6447    return 0; 
     6448  }; 
     6449 
    63716450}  // end object rcube_webmail 
    63726451 
  • program/steps/mail/func.inc

    r041c93c re349a8c  
    8282    } 
    8383 
    84       $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT); 
    85       $OUTPUT->set_env('search_mods', $search_mods); 
     84    $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT); 
     85    $OUTPUT->set_env('search_mods', $search_mods); 
    8686  } 
    8787 
     
    115115  if ($CONFIG['junk_mbox']) 
    116116    $OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']); 
     117 
     118  if (!empty($_SESSION['browser_caps'])) 
     119    $OUTPUT->set_env('browser_capabilities', $_SESSION['browser_caps']); 
    117120 
    118121  if (!$OUTPUT->ajax_call) 
  • program/steps/mail/show.inc

    r041c93c re349a8c  
    2121 
    2222$PRINT_MODE = $RCMAIL->action=='print' ? TRUE : FALSE; 
     23 
     24// Read browser capabilities and store them in session 
     25if ($caps = get_input_value('_caps', RCUBE_INPUT_GET)) { 
     26  $browser_caps = array(); 
     27  foreach (explode(',', $caps) as $cap) { 
     28    $cap = explode('=', $cap); 
     29    $browser_caps[$cap[0]] = $cap[1]; 
     30  } 
     31  $_SESSION['browser_caps'] = $browser_caps; 
     32} 
    2333 
    2434// similar code as in program/steps/mail/get.inc 
Note: See TracChangeset for help on using the changeset viewer.