| | |
| | | protected $footer = ''; |
| | | protected $body = ''; |
| | | protected $base_path = ''; |
| | | protected $devel_mode = false; |
| | | |
| | | // deprecated names of templates used before 0.5 |
| | | protected $deprecated_templates = array( |
| | |
| | | public function __construct($task = null, $framed = false) |
| | | { |
| | | parent::__construct(); |
| | | |
| | | $this->devel_mode = $this->config->get('devel_mode'); |
| | | |
| | | //$this->framed = $framed; |
| | | $this->set_env('task', $task); |
| | |
| | | */ |
| | | public function reset($all = false) |
| | | { |
| | | $framed = $this->framed; |
| | | $env = $all ? null : array_intersect_key($this->env, array('extwin'=>1, 'framed'=>1)); |
| | | |
| | | parent::reset(); |
| | | |
| | | // let some env variables survive |
| | | $this->env = $this->js_env = $env; |
| | | $this->framed = $framed || $this->env['framed']; |
| | | $this->js_labels = array(); |
| | | $this->js_commands = array(); |
| | | $this->script_files = array(); |
| | |
| | | $this->header = ''; |
| | | $this->footer = ''; |
| | | $this->body = ''; |
| | | |
| | | // load defaults |
| | | if (!$all) { |
| | | $this->__construct(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // add file modification timestamp |
| | | if (preg_match('/\.(js|css)$/', $file)) { |
| | | if ($fs = @filemtime($file)) { |
| | | if (preg_match('/\.(js|css)$/', $file, $m)) { |
| | | $fs = false; |
| | | $ext = $m[1]; |
| | | |
| | | // use minified file if exists (not in development mode) |
| | | if (!$this->devel_mode && !preg_match('/\.min\.' . $ext . '$/', $file)) { |
| | | $minified_file = substr($file, 0, strlen($ext) * -1) . 'min.' . $ext; |
| | | if ($fs = @filemtime($minified_file)) { |
| | | $file = $minified_file . '?s=' . $fs; |
| | | } |
| | | } |
| | | |
| | | if (!$fs && ($fs = @filemtime($file))) { |
| | | $file .= '?s=' . $fs; |
| | | } |
| | | } |
| | |
| | | } |
| | | else if ($object == 'logo') { |
| | | $attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"'))); |
| | | if ($logo = $this->config->get('skin_logo')) |
| | | $attrib['src'] = $logo; |
| | | |
| | | if ($logo = $this->config->get('skin_logo')) { |
| | | if (is_array($logo)) { |
| | | if ($template_logo = $logo[$this->template_name]) { |
| | | $attrib['src'] = $template_logo; |
| | | } |
| | | elseif ($template_logo = $logo['*']) { |
| | | $attrib['src'] = $template_logo; |
| | | } |
| | | } |
| | | else { |
| | | $attrib['src'] = $logo; |
| | | } |
| | | } |
| | | |
| | | $content = html::img($attrib); |
| | | } |
| | | else if ($object == 'productname') { |
| | |
| | | $content = html::quote($this->get_pagetitle()); |
| | | } |
| | | else if ($object == 'pagetitle') { |
| | | if ($this->config->get('devel_mode') && !empty($_SESSION['username'])) |
| | | if ($this->devel_mode && !empty($_SESSION['username'])) |
| | | $title = $_SESSION['username'].' :: '; |
| | | else if ($prod_name = $this->config->get('product_name')) |
| | | $title = $prod_name . ' :: '; |
| | |
| | | } |
| | | |
| | | return html::quote($value); |
| | | break; |
| | | |
| | | case 'form': |
| | | return $this->form_tag($attrib); |
| | | } |
| | | return ''; |
| | | } |
| | |
| | | // these commands can be called directly via url |
| | | $a_static_commands = array('compose', 'list', 'preferences', 'folders', 'identities'); |
| | | |
| | | if (!($attrib['command'] || $attrib['name'])) { |
| | | if (!($attrib['command'] || $attrib['name'] || $attrib['href'])) { |
| | | return ''; |
| | | } |
| | | |
| | |
| | | } |
| | | else if ($attrib['type'] == 'link') { |
| | | $btn_content = isset($attrib['content']) ? $attrib['content'] : ($attrib['label'] ? $attrib['label'] : $attrib['command']); |
| | | $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex', 'target'); |
| | | $link_attrib = array_merge(html::$common_attrib, array('href', 'onclick', 'tabindex', 'target')); |
| | | if ($attrib['innerclass']) |
| | | $btn_content = html::span($attrib['innerclass'], $btn_content); |
| | | } |
| | |
| | | */ |
| | | public function include_script($file, $position='head') |
| | | { |
| | | static $sa_files = array(); |
| | | |
| | | if (!preg_match('|^https?://|i', $file) && $file[0] != '/') { |
| | | $file = $this->scripts_path . $file; |
| | | if ($fs = @filemtime($file)) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (in_array($file, $sa_files)) { |
| | | return; |
| | | } |
| | | |
| | | $sa_files[] = $file; |
| | | |
| | | if (!is_array($this->script_files[$position])) { |
| | | $this->script_files[$position] = array(); |
| | | } |
| | | |
| | | $this->script_files[$position][] = $file; |
| | | if (!in_array($file, $this->script_files[$position])) { |
| | | $this->script_files[$position][] = $file; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public function _write($templ = '', $base_path = '') |
| | | { |
| | | $output = empty($templ) ? $this->default_template : trim($templ); |
| | | $output = trim($templ); |
| | | |
| | | if (empty($output)) { |
| | | $output = $this->default_template; |
| | | $is_empty = true; |
| | | } |
| | | |
| | | // set default page title |
| | | if (empty($this->pagetitle)) { |
| | |
| | | } |
| | | |
| | | // add css files in head, before scripts, for speed up with parallel downloads |
| | | if (!empty($this->css_files) && |
| | | (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>'))) |
| | | if (!empty($this->css_files) && !$is_empty |
| | | && (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>'))) |
| | | ) { |
| | | $css = ''; |
| | | foreach ($this->css_files as $file) { |
| | |
| | | $attrib['noclose'] = true; |
| | | |
| | | return html::tag('form', |
| | | $attrib + array('action' => "./", 'method' => "get"), |
| | | $attrib + array('action' => $this->app->comm_path, 'method' => "get"), |
| | | $hidden . $content, |
| | | array('id','class','style','name','method','action','enctype','onsubmit')); |
| | | } |
| | |
| | | $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login')); |
| | | $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_')); |
| | | $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url)); |
| | | $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') |
| | | $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'required' => 'required') |
| | | + $attrib + $user_attrib); |
| | | $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') |
| | | $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'required' => 'required') |
| | | + $attrib + $pass_attrib); |
| | | $input_host = null; |
| | | |