| | |
| | | )); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Set environment variable |
| | | * |
| | |
| | | $this->js_env[$name] = $value; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Getter for the current page title |
| | |
| | | return $title; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Set skin |
| | | */ |
| | | public function set_skin($skin) |
| | | { |
| | | $valid = false; |
| | | $path = RCUBE_INSTALL_PATH . 'skins/'; |
| | | |
| | | if (!empty($skin) && is_dir('skins/'.$skin) && is_readable('skins/'.$skin)) { |
| | | $skin_path = 'skins/'.$skin; |
| | | $valid = true; |
| | | if (!empty($skin) && is_dir($path . $skin) && is_readable($path . $skin)) { |
| | | $skin_path = 'skins/' . $skin; |
| | | $valid = true; |
| | | } |
| | | else { |
| | | $skin_path = $this->config->get('skin_path'); |
| | |
| | | $this->skin_paths[] = $skin_path; |
| | | |
| | | // read meta file and check for dependecies |
| | | $meta = @json_decode(@file_get_contents($skin_path.'/meta.json'), true); |
| | | if ($meta['extends'] && is_dir('skins/' . $meta['extends'])) { |
| | | $this->load_skin('skins/' . $meta['extends']); |
| | | $meta = @file_get_contents(RCUBE_INSTALL_PATH . $skin_path . '/meta.json'); |
| | | $meta = @json_decode($meta, true); |
| | | if ($meta['extends']) { |
| | | $path = RCUBE_INSTALL_PATH . 'skins/'; |
| | | if (is_dir($path . $meta['extends']) && is_readable($path . $meta['extends'])) { |
| | | $this->load_skin('skins/' . $meta['extends']); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Check if a specific template exists |
| | |
| | | */ |
| | | public function template_exists($name) |
| | | { |
| | | $found = false; |
| | | foreach ($this->skin_paths as $skin_path) { |
| | | $filename = $skin_path . '/templates/' . $name . '.html'; |
| | | $found = (is_file($filename) && is_readable($filename)) || ($this->deprecated_templates[$name] && $this->template_exists($this->deprecated_templates[$name])); |
| | | if ($found) |
| | | break; |
| | | $filename = RCUBE_INSTALL_PATH . $skin_path . '/templates/' . $name . '.html'; |
| | | if ((is_file($filename) && is_readable($filename)) |
| | | || ($this->deprecated_templates[$name] && $this->template_exists($this->deprecated_templates[$name])) |
| | | ) { |
| | | return true; |
| | | } |
| | | } |
| | | return $found; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Find the given file in the current skin path stack |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Register a GUI object to the client script |
| | | * |
| | |
| | | { |
| | | $this->add_script(self::JS_OBJECT_NAME.".gui_object('$obj', '$id');"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Call a client method |
| | |
| | | $this->js_commands[] = $cmd; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add a localized label to the client environment |
| | | */ |
| | |
| | | $this->js_labels[$name] = $this->app->gettext($name); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Invoke display_message command |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Delete all stored env variables and commands |
| | | * |
| | |
| | | $this->body = ''; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Redirect to a certain url |
| | | * |
| | |
| | | header('Location: ' . $location); |
| | | exit; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Send the request output to the client. |
| | |
| | | exit; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Process template and write to stdOut |
| | |
| | | // call super method |
| | | $this->_write($template, $this->config->get('skin_path')); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parse a specific skin template and deliver to stdout (or return) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return executable javascript code for all registered commands |
| | | * |
| | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Make URLs starting with a slash point to skin directory |
| | | * |
| | |
| | | else |
| | | return $str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Show error page and terminate script execution |
| | |
| | | array($this, 'globals_callback'), $input); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Callback funtion for preg_replace_callback() in parse_with_globals() |
| | | */ |
| | |
| | | { |
| | | return $GLOBALS[$matches[1]]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Correct absolute paths in images and other tags |
| | |
| | | '!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i', |
| | | array($this, 'file_callback'), $output); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Callback function for preg_replace_callback in write() |
| | |
| | | return $matches[1] . '=' . $matches[2] . $file . $matches[4]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Public wrapper to dipp into template parsing. |
| | | * |
| | |
| | | |
| | | return $input; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parse for conditional tags |
| | |
| | | return $input; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Determines if a given condition is met |
| | | * |
| | |
| | | { |
| | | return $this->eval_expression($condition); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Inserts hidden field with CSRF-prevention-token into POST forms |
| | |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parse & evaluate a given expression and return its result. |
| | |
| | | return $fn($this->app, $this->browser, $this->env); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Search for special tags in input and replace them |
| | | * with the appropriate content |
| | |
| | | { |
| | | return preg_replace_callback('/<roundcube:([-_a-z]+)\s+((?:[^>]|\\\\>)+)(?<!\\\\)>/Ui', array($this, 'xml_command'), $input); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Callback function for parsing an xml command tag |
| | |
| | | return ''; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Include a specific file and return it's contents |
| | | * |
| | |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create and register a button |
| | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Link an external script file |
| | | * |
| | |
| | | $this->script_files[$position][] = $file; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add inline javascript code |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Link an external css file |
| | | * |
| | |
| | | { |
| | | $this->css_files[] = $file; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add HTML code to the page header |
| | |
| | | $this->header .= "\n" . $str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add HTML code to the page footer |
| | | * To be added right befor </body> |
| | |
| | | { |
| | | $this->footer .= "\n" . $str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Process template and write to stdOut |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns iframe object, registers some related env variables |
| | | * |
| | |
| | | |
| | | /* ************* common functions delivering gui objects ************** */ |
| | | |
| | | |
| | | /** |
| | | * Create a form tag with the necessary hidden fields |
| | | * |
| | |
| | | $hidden . $content, |
| | | array('id','class','style','name','method','action','enctype','onsubmit')); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Build a form tag with a unique request token |
| | |
| | | return $this->form_tag($attrib, $hidden->show() . $content); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GUI object 'username' |
| | | * Showing IMAP username of the current session |
| | |
| | | |
| | | return rcube_utils::idn_to_utf8($username); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GUI object 'loginform' |
| | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GUI object 'preloader' |
| | | * Loads javascript code for images preloading |
| | |
| | | img.src = images[i]; |
| | | }', 'docready'); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GUI object 'searchform' |
| | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Builder for GUI object 'message' |
| | | * |
| | |
| | | |
| | | return html::div($attrib, ''); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GUI object 'charsetselector' |