summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/bugs.inc14
-rw-r--r--program/include/main.inc18
-rw-r--r--program/include/rcube_shared.inc81
3 files changed, 96 insertions, 17 deletions
diff --git a/program/include/bugs.inc b/program/include/bugs.inc
index 771f1aeda..bf4c572c8 100644
--- a/program/include/bugs.inc
+++ b/program/include/bugs.inc
@@ -115,5 +115,19 @@ function log_bug($arg_arr)
}
}
+function log_debug($filename, $text)
+{
+ global $CONFIG, $INSTALL_PATH;
+
+ if (empty($CONFIG['log_dir']))
+ $CONFIG['log_dir'] = $INSTALL_PATH.'logs';
+
+ // try to open specific log file for writing
+ if ($fp = @fopen($CONFIG['log_dir'].'/'.$filename, 'a'))
+ {
+ fwrite($fp, date("d-M-Y H:i:s", mktime()) . ' ' . $text . "\n");
+ fclose($fp);
+ }
+}
?> \ No newline at end of file
diff --git a/program/include/main.inc b/program/include/main.inc
index 02f5b5713..bbda83aa7 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -375,7 +375,7 @@ function load_gui()
// don't wait for page onload. Call init at the bottom of the page (delayed)
$javascript_foot = "if (window.call_init)\n call_init('$JS_OBJECT_NAME');";
-
+
if (!empty($GLOBALS['_framed']))
$javascript .= "$JS_OBJECT_NAME.set_env('framed', true);\n";
@@ -1197,6 +1197,7 @@ function rcube_xml_command($command, $str_attrib, $add_attrib=array())
'composeattachment' => 'rcmail_compose_attachment_field',
'priorityselector' => 'rcmail_priority_selector',
'charsetselector' => 'rcmail_charset_selector',
+ 'editorselector' => 'rcmail_editor_selector',
'searchform' => 'rcmail_search_form',
'receiptcheckbox' => 'rcmail_receipt_checkbox',
@@ -1279,8 +1280,7 @@ function rcube_button($attrib)
if ($attrib['type'])
$attrib['type'] = strtolower($attrib['type']);
else
- $attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $arg['imageact']) ? 'image' : 'link';
-
+ $attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $attrib['imageact']) ? 'image' : 'link';
$command = $attrib['command'];
@@ -1289,7 +1289,7 @@ function rcube_button($attrib)
$attrib = $sa_buttons[$attrib['name']];
// add button to button stack
- else if($attrib['image'] || $arg['imageact'] || $attrib['imagepas'] || $attrib['class'])
+ else if($attrib['image'] || $attrib['imageact'] || $attrib['imagepas'] || $attrib['class'])
{
if(!$attrib['name'])
$attrib['name'] = $command;
@@ -1487,7 +1487,15 @@ function rcube_table_output($attrib, $table_data, $a_show_cols, $id_col)
}
-
+/**
+ * Create an edit field for inclusion on a form
+ *
+ * @param string col field name
+ * @param string value field value
+ * @param array attrib HTML element attributes for field
+ * @param string type HTML element type (default 'text')
+ * @return string HTML field definition
+ */
function rcmail_get_edit_field($col, $value, $attrib, $type='text')
{
$fname = '_'.$col;
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index af4c295dd..11af48205 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -28,13 +28,15 @@ class rcube_html_page
var $scripts_path = '';
var $script_files = array();
+ var $external_scripts = array();
var $scripts = array();
var $charset = 'ISO-8859-1';
var $script_tag_file = "<script type=\"text/javascript\" src=\"%s%s\"></script>\n";
var $script_tag = "<script type=\"text/javascript\">\n<!--\n%s\n\n//-->\n</script>\n";
var $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>";
-
+ var $tag_format_external_script = "<script type=\"text/javascript\" src=\"%s\"></script>\n";
+
var $title = '';
var $header = '';
var $footer = '';
@@ -69,13 +71,22 @@ class rcube_html_page
$this->script_files[$position][] = $file;
}
-
+ function include_external_script($script_location, $position='head')
+ {
+ if (!is_array($this->external_scripts[$position]))
+ {
+ $this->external_scripts[$position] = array();
+ }
+
+ $this->external_scripts[$position][] = $script_location;
+ }
+
function add_script($script, $position='head')
{
if (!isset($this->scripts[$position]))
- $this->scripts[$position] = '';
-
- $this->scripts[$position] .= "\n$script";
+ $this->scripts[$position] = "\n$script";
+ else
+ $this->scripts[$position] .= "\n$script";
}
@@ -139,19 +150,27 @@ class rcube_html_page
foreach ($this->script_files['head'] as $file)
$__page_header .= sprintf($this->script_tag_file, $this->scripts_path, $file);
+ if (is_array($this->external_scripts['head']))
+ {
+ foreach ($this->external_scripts['head'] as $xscript)
+ {
+ $__page_header .= sprintf($this->tag_format_external_script, $xscript);
+ }
+ }
+
if (strlen($this->scripts['head']))
$__page_header .= sprintf($this->script_tag, $this->scripts['head']);
if (is_array($this->script_files['foot']))
+ {
foreach ($this->script_files['foot'] as $file)
$__page_footer .= sprintf($this->script_tag_file, $this->scripts_path, $file);
+ }
if (strlen($this->scripts['foot']))
$__page_footer .= sprintf($this->script_tag, $this->scripts['foot']);
-
$__page_header .= $this->css->show();
-
// find page header
if($hpos = strpos(strtolower($output), '</head>'))
@@ -192,8 +211,12 @@ class rcube_html_page
// find and add page footer
- if(($fpos = strpos(strtolower($output), '</body>')) || ($fpos = strpos(strtolower($output), '</html>')))
+ $output_lc = strtolower($output);
+ if(($fpos = strrpos($output_lc, '</body>')) ||
+ ($fpos = strrpos($output_lc, '</html>')))
+ {
$output = substr($output,0,$fpos) . "$__page_footer\n" . substr($output,$fpos,strlen($output));
+ }
else
$output .= "\n$__page_footer";
@@ -202,7 +225,7 @@ class rcube_html_page
$__page_header = $__page_footer = '';
- // correct absolute pathes in images and other tags
+ // correct absolute paths in images and other tags
$output = preg_replace('/(src|href|background)=(["\']?)(\/[a-z0-9_\-]+)/Ui', "\\1=\\2$base_path\\3", $output);
$output = str_replace('$__skin_path', $base_path, $output);
@@ -854,9 +877,9 @@ class textarea extends base_form_element
if (isset($this->attrib['value']))
unset($this->attrib['value']);
- if (strlen($value))
+ if (strlen($value) && !isset($this->attrib['mce_editable']))
$value = rep_specialchars_output($value, 'html', 'replace', FALSE);
-
+
// return final tag
return sprintf('<%s%s>%s</%s>%s',
$this->_conv_case('textarea', 'tag'),
@@ -1233,7 +1256,7 @@ function array2js($arr, $type='')
if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) /* || is_js_reserved_word($key) */)
$key = "'$key'";
- if (!is_array($value))
+ if (!is_array($value) && is_string($value))
{
$value = str_replace("\r\n", '\n', $value);
$value = str_replace("\n", '\n', $value);
@@ -1244,6 +1267,11 @@ function array2js($arr, $type='')
{
if ($type=='string')
$is_string = true;
+ else if (($type == 'mixed' && is_bool($value)) || $type == 'bool')
+ {
+ $is_string = false;
+ $value = $value ? "true" : "false";
+ }
else if ((($type=='mixed' && is_numeric($value)) || $type=='int') && strlen($value)<16) // js interprets numbers with digits >15 as ...e+...
$is_string = FALSE;
else
@@ -1270,7 +1298,9 @@ function array2js($arr, $type='')
}
}
else
+ {
return $arr;
+ }
}
@@ -1437,4 +1467,31 @@ function get_offset_time($offset_str, $factor=1)
}
+/**
+ * strrstr
+ *
+ * return the last occurence of a string in another string
+ * @param haystack string string in which to search
+ * @param needle string string for which to search
+ * @return index of needle within haystack, or false if not found
+ */
+function strrstr($haystack, $needle)
+ {
+ $pver = phpversion();
+ if ($pver[0] >= 5)
+ {
+ return strrpos($haystack, $needle);
+ }
+ else
+ {
+ $index = strpos(strrev($haystack), strrev($needle));
+ if($index === false) {
+ return false;
+ }
+ $index = strlen($haystack) - strlen($needle) - $index;
+ return $index;
+ }
+ }
+
+
?>