From 99cdca46b7bcc46fe6affd9e9f9f60a546b2e5b8 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 05 Jun 2014 03:18:07 -0400
Subject: [PATCH] Merge branch 'dev-accessibility'

---
 program/include/rcmail.php |  141 ++++++++++++++++++++++++++++------------------
 1 files changed, 86 insertions(+), 55 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 8e66e85..1a22792 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -428,7 +428,8 @@
         }
 
         // add some basic labels to client
-        $this->output->add_label('loading', 'servererror', 'connerror', 'requesttimedout', 'refreshing');
+        $this->output->add_label('loading', 'servererror', 'connerror', 'requesttimedout',
+            'refreshing', 'windowopenerror');
 
         return $this->output;
     }
@@ -494,30 +495,18 @@
         $username_domain = $this->config->get('username_domain');
         $login_lc        = $this->config->get('login_lc', 2);
 
-        if (!$host) {
-            $host = $default_host;
-        }
-
-        // Validate that selected host is in the list of configured hosts
-        if (is_array($default_host)) {
-            $allowed = false;
-
-            foreach ($default_host as $key => $host_allowed) {
-                if (!is_numeric($key)) {
-                    $host_allowed = $key;
-                }
-                if ($host == $host_allowed) {
-                    $allowed = true;
-                    break;
-                }
+        // host is validated in rcmail::autoselect_host(), so here
+        // we'll only handle unset host (if possible)
+        if (!$host && !empty($default_host)) {
+            if (is_array($default_host)) {
+                list($key, $val) = each($default_host);
+                $host = is_numeric($key) ? $val : $key;
+            }
+            else {
+                $host = $default_host;
             }
 
-            if (!$allowed) {
-                $host = null;
-            }
-        }
-        else if (!empty($default_host) && $host != rcube_utils::parse_host($default_host)) {
-            $host = null;
+            $host = rcube_utils::parse_host($host);
         }
 
         if (!$host) {
@@ -840,7 +829,7 @@
         }
 
         // write performance stats to logs/console
-        if ($this->config->get('devel_mode')) {
+        if ($this->config->get('devel_mode') || $this->config->get('performance_stats')) {
             // make sure logged numbers use unified format
             setlocale(LC_NUMERIC, 'en_US.utf8', 'en_US.UTF-8', 'en_US', 'C');
 
@@ -1088,14 +1077,17 @@
         }
         else {
             foreach ($table_data as $row_data) {
-                $class = !empty($row_data['class']) ? $row_data['class'] : '';
+                $class = !empty($row_data['class']) ? $row_data['class'] : null;
+                if (!empty($attrib['rowclass']))
+                    $class = trim($class . ' ' . $attrib['rowclass']);
                 $rowid = 'rcmrow' . rcube_utils::html_identifier($row_data[$id_col]);
 
                 $table->add_row(array('id' => $rowid, 'class' => $class));
 
                 // format each col
                 foreach ($a_show_cols as $col) {
-                    $table->add($col, $this->Q(is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col]));
+                    $val = is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col];
+                    $table->add($col, empty($attrib['ishtml']) ? $this->Q($val) : $val);
                 }
             }
         }
@@ -1781,31 +1773,36 @@
             return;
         }
 
-        $lang = strtolower($_SESSION['language']);
+        $lang_codes = array($_SESSION['language']);
 
-        // TinyMCE uses two-letter lang codes, with exception of Chinese
-        if (strpos($lang, 'zh_') === 0) {
-            $lang = str_replace('_', '-', $lang);
-        }
-        else {
-            $lang = substr($lang, 0, 2);
+        if ($pos = strpos($_SESSION['language'], '_')) {
+            $lang_codes[] = substr($_SESSION['language'], 0, $pos);
         }
 
-        if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$lang.'.js')) {
+        foreach ($lang_codes as $code) {
+            if (file_exists(INSTALL_PATH . 'program/js/tinymce/langs/'.$code.'.js')) {
+                $lang = $code;
+                break;
+            }
+        }
+
+        if (empty($lang)) {
             $lang = 'en';
         }
 
-        $script = json_encode(array(
+        $config = array(
             'mode'       => $mode,
             'lang'       => $lang,
             'skin_path'  => $this->output->get_skin_path(),
             'spellcheck' => intval($this->config->get('enable_spellcheck')),
             'spelldict'  => intval($this->config->get('spellcheck_dictionary'))
-        ));
+        );
 
-        $this->output->include_script('tiny_mce/tiny_mce.js');
+        $this->output->add_label('selectimage', 'addimage', 'selectmedia', 'addmedia');
+        $this->output->set_env('editor_config', $config);
+        $this->output->include_css('program/js/tinymce/roundcube/browser.css');
+        $this->output->include_script('tinymce/tinymce.min.js');
         $this->output->include_script('editor.js');
-        $this->output->add_script("rcmail_editor_init($script)", 'docready');
     }
 
     /**
@@ -1837,8 +1834,8 @@
         );
 
         foreach ($emoticons as $idx => $file) {
-            // <img title="Cry" src="http://.../program/js/tiny_mce/plugins/emotions/img/smiley-cry.gif" border="0" alt="Cry" />
-            $search[]  = '/<img title="[a-z ]+" src="https?:\/\/[a-z0-9_.\/-]+\/tiny_mce\/plugins\/emotions\/img\/'.$file.'.gif"[^>]+\/>/i';
+            // <img title="Cry" src="http://.../program/js/tinymce/plugins/emoticons/img/smiley-cry.gif" border="0" alt="Cry" />
+            $search[]  = '/<img title="[a-z ]+" src="https?:\/\/[a-z0-9_.\/-]+\/tinymce\/plugins\/emoticons\/img\/'.$file.'.gif"[^>]+\/>/i';
             $replace[] = $idx;
         }
 
@@ -1850,27 +1847,52 @@
      */
     public function upload_progress()
     {
-        $prefix = ini_get('apc.rfc1867_prefix');
         $params = array(
             'action' => $this->action,
-            'name' => rcube_utils::get_input_value('_progress', rcube_utils::INPUT_GET),
+            'name'   => rcube_utils::get_input_value('_progress', rcube_utils::INPUT_GET),
         );
 
-        if (function_exists('apc_fetch')) {
-            $status = apc_fetch($prefix . $params['name']);
+        if (function_exists('uploadprogress_get_info')) {
+            $status = uploadprogress_get_info($params['name']);
 
             if (!empty($status)) {
-                $status['percent'] = round($status['current']/$status['total']*100);
-                $params = array_merge($status, $params);
+                $params['current'] = $status['bytes_uploaded'];
+                $params['total']   = $status['bytes_total'];
             }
         }
 
-        if (isset($params['percent']))
-            $params['text'] = $this->gettext(array('name' => 'uploadprogress', 'vars' => array(
-                'percent' => $params['percent'] . '%',
-                'current' => $this->show_bytes($params['current']),
-                'total'   => $this->show_bytes($params['total'])
-        )));
+        if (!isset($status) && filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN)
+            && ini_get('apc.rfc1867_name')
+        ) {
+            $prefix = ini_get('apc.rfc1867_prefix');
+            $status = apc_fetch($prefix . $params['name']);
+
+            if (!empty($status)) {
+                $params['current'] = $status['current'];
+                $params['total']   = $status['total'];
+            }
+        }
+
+        if (!isset($status) && filter_var(ini_get('session.upload_progress.enabled'), FILTER_VALIDATE_BOOLEAN)
+            && ini_get('session.upload_progress.name')
+        ) {
+            $key = ini_get('session.upload_progress.prefix') . $params['name'];
+
+            $params['total']   = $_SESSION[$key]['content_length'];
+            $params['current'] = $_SESSION[$key]['bytes_processed'];
+        }
+
+        if (!empty($params['total'])) {
+            $params['percent'] = round($status['current']/$status['total']*100);
+            $params['text']    = $this->gettext(array(
+                'name' => 'uploadprogress',
+                'vars' => array(
+                    'percent' => $params['percent'] . '%',
+                    'current' => $this->show_bytes($params['current']),
+                    'total'   => $this->show_bytes($params['total'])
+                )
+            ));
+        }
 
         $this->output->command('upload_progress_update', $params);
         $this->output->send();
@@ -1882,9 +1904,18 @@
     public function upload_init()
     {
         // Enable upload progress bar
-        $rfc1867 = filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN);
-        if ($rfc1867 && ($seconds = $this->config->get('upload_progress'))) {
-            if ($field_name = ini_get('apc.rfc1867_name')) {
+        if ($seconds = $this->config->get('upload_progress')) {
+            if (function_exists('uploadprogress_get_info')) {
+                $field_name = 'UPLOAD_IDENTIFIER';
+            }
+            if (!$field_name && filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN)) {
+                $field_name = ini_get('apc.rfc1867_name');
+            }
+            if (!$field_name && filter_var(ini_get('session.upload_progress.enabled'), FILTER_VALIDATE_BOOLEAN)) {
+                $field_name = ini_get('session.upload_progress.name');
+            }
+
+            if ($field_name) {
                 $this->output->set_env('upload_progress_name', $field_name);
                 $this->output->set_env('upload_progress_time', (int) $seconds);
             }

--
Gitblit v1.9.1