Aleksander Machniak
2012-10-20 0768134de16b1c75a1908da09f58cd627f2330b0
program/include/rcube_output_html.php
@@ -67,8 +67,15 @@
        $this->set_env('task', $task);
        $this->set_env('x_frame_options', $this->config->get('x_frame_options', 'sameorigin'));
        // add cookie info
        $this->set_env('cookie_domain', ini_get('session.cookie_domain'));
        $this->set_env('cookie_path', ini_get('session.cookie_path'));
        $this->set_env('cookie_secure', ini_get('session.cookie_secure'));
        // load the correct skin (in case user-defined)
        $this->set_skin($this->config->get('skin'));
        $skin = $this->config->get('skin');
        $this->set_skin($skin);
        $this->set_env('skin', $skin);
        // add common javascripts
        $this->add_script('var '.rcmail::JS_OBJECT_NAME.' = new rcube_webmail();', 'head_top');
@@ -147,7 +154,7 @@
        else {
            $skin_path = $this->config->get('skin_path');
            if (!$skin_path) {
                $skin_path = 'skins/default';
                $skin_path = 'skins/' . rcube_config::DEFAULT_SKIN;
            }
            $valid = !$skin;
        }
@@ -393,7 +400,7 @@
                'line' => __LINE__,
                'file' => __FILE__,
                'message' => 'Error loading template for '.$realname
                ), true, true);
                ), true, $write);
            return false;
        }
@@ -520,7 +527,7 @@
    {
        $GLOBALS['__version']   = html::quote(RCMAIL_VERSION);
        $GLOBALS['__comm_path'] = html::quote($this->app->comm_path);
        $GLOBALS['__skin_path'] = Q($this->config->get('skin_path'));
        $GLOBALS['__skin_path'] = html::quote($this->config->get('skin_path'));
        return preg_replace_callback('/\$(__[a-z0-9_\-]+)/',
            array($this, 'globals_callback'), $input);
@@ -691,13 +698,39 @@
                }
                break;
            // frame
            case 'frame':
                return $this->frame($attrib);
                break;
            // show a label
            case 'label':
                if ($attrib['name'] || $attrib['command']) {
                    // @FIXME: 'noshow' is useless, remove?
                    if ($attrib['noshow']) {
                        return '';
                    }
                    $vars = $attrib + array('product' => $this->config->get('product_name'));
                    unset($vars['name'], $vars['command']);
                    $label = $this->app->gettext($attrib + array('vars' => $vars));
                    return !$attrib['noshow'] ? (get_boolean((string)$attrib['html']) ? $label : html::quote($label)) : '';
                    $label   = $this->app->gettext($attrib + array('vars' => $vars));
                    $quoting = !empty($attrib['quoting']) ? strtolower($attrib['quoting']) : (get_boolean((string)$attrib['html']) ? 'no' : '');
                    switch ($quoting) {
                        case 'no':
                        case 'raw':
                            break;
                        case 'javascript':
                        case 'js':
                            $label = rcmail::JQ($label);
                            break;
                        default:
                            $label = html::quote($label);
                            break;
                    }
                    return $label;
                }
                break;
@@ -933,7 +966,7 @@
            // make valid href to specific buttons
            if (in_array($attrib['command'], rcmail::$main_tasks)) {
                $attrib['href']    = $this->app->url(array('task' => $attrib['command']));
                $attrib['onclick'] = sprintf("%s.command('switch-task','%s');return false", rcmail::JS_OBJECT_NAME, $attrib['command']);
                $attrib['onclick'] = sprintf("%s.command('switch-task','%s',null,event); return false", rcmail::JS_OBJECT_NAME, $attrib['command']);
            }
            else if ($attrib['task'] && in_array($attrib['task'], rcmail::$main_tasks)) {
                $attrib['href'] = $this->app->url(array('action' => $attrib['command'], 'task' => $attrib['task']));
@@ -956,7 +989,7 @@
        }
        else if ($command && !$attrib['onclick']) {
            $attrib['onclick'] = sprintf(
                "return %s.command('%s','%s',this)",
                "return %s.command('%s','%s',this,event)",
                rcmail::JS_OBJECT_NAME,
                $command,
                $attrib['prop']
@@ -1229,21 +1262,45 @@
     */
    protected function file_callback($matches)
    {
       $file = $matches[3];
        $file = $matches[3];
        // correct absolute paths
       if ($file[0] == '/') {
           $file = $this->base_path . $file;
        if ($file[0] == '/') {
            $file = $this->base_path . $file;
        }
        // add file modification timestamp
       if (preg_match('/\.(js|css)$/', $file)) {
        if (preg_match('/\.(js|css)$/', $file)) {
            if ($fs = @filemtime($file)) {
                $file .= '?s=' . $fs;
            }
        }
       return $matches[1] . '=' . $matches[2] . $file . $matches[4];
        return $matches[1] . '=' . $matches[2] . $file . $matches[4];
    }
    /**
     * Returns iframe object, registers some related env variables
     *
     * @param array $attrib HTML attributes
     *
     * @return string IFRAME element
     */
    public function frame($attrib)
    {
        if (!$attrib['id']) {
            $attrib['id'] = 'rcmframe';
        }
        if (!$attrib['name']) {
            $attrib['name'] = $attrib['id'];
        }
        $this->set_env('contentframe', $attrib['id']);
        $this->set_env('blankpage', $attrib['src'] ? $this->abs_url($attrib['src']) : 'program/resources/blank.gif');
        return html::iframe($attrib);
    }
@@ -1354,6 +1411,9 @@
        $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
        if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING']))
            $url = $_SERVER['QUERY_STRING'];
        // Disable autocapitalization on iPad/iPhone (#1488609)
        $attrib['autocapitalize'] = 'off';
        // set atocomplete attribute
        $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
@@ -1485,7 +1545,7 @@
        if (empty($attrib['form'])) {
            $out = $this->form_tag(array(
                'name' => "rcmqsearchform",
                'onsubmit' => rcmail::JS_OBJECT_NAME . ".command('search');return false;",
                'onsubmit' => rcmail::JS_OBJECT_NAME . ".command('search'); return false",
                'style' => "display:inline"),
                $out);
        }
@@ -1564,16 +1624,20 @@
            'GB2312'       => 'GB2312 ('.$this->app->gettext('chinese').')',
        );
        if (!empty($_POST['_charset']))
           $set = $_POST['_charset'];
       else if (!empty($attrib['selected']))
           $set = $attrib['selected'];
       else
           $set = $this->get_charset();
        if (!empty($_POST['_charset'])) {
            $set = $_POST['_charset'];
        }
        else if (!empty($attrib['selected'])) {
            $set = $attrib['selected'];
        }
        else {
            $set = $this->get_charset();
        }
       $set = strtoupper($set);
       if (!isset($charsets[$set]))
           $charsets[$set] = $set;
        $set = strtoupper($set);
        if (!isset($charsets[$set])) {
            $charsets[$set] = $set;
        }
        $select = new html_select($field_attrib);
        $select->add(array_values($charsets), array_keys($charsets));