diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php
index 7099ac5cc7..9aefb13b8f 100644
--- a/etemplate/inc/class.boetemplate.inc.php
+++ b/etemplate/inc/class.boetemplate.inc.php
@@ -16,6 +16,11 @@
*/
class boetemplate extends soetemplate
{
+ /**
+ * Widget types implemented directly by etemplate (no extensions)
+ *
+ * @var array intern name => label
+ */
static public $types = array(
'label' => 'Label', // Label $cell['label'] is (to be translated) textual content
'text' => 'Text', // Textfield 1 Line (size = [length][,maxlength])
@@ -41,7 +46,8 @@ class boetemplate extends soetemplate
'box' => 'Box', // just a container for widgets (html: div)
'grid' => 'Grid', // tabular widget containing rows with columns of widgets
'deck' => 'Deck', // a container of elements where only one is visible, size = # of elem.
- 'passwd' => 'Password' // a text of type password
+ 'passwd' => 'Password', // a text of type password
+ 'colorpicker' => 'Colorpicker', // input for a color (eg. #123456)
);
/**
diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php
index ab6e254abb..c68599de5a 100644
--- a/etemplate/inc/class.etemplate.inc.php
+++ b/etemplate/inc/class.etemplate.inc.php
@@ -638,7 +638,7 @@ class etemplate extends boetemplate
{
return $cat2color[$cat];
}
- $data = unserialize($GLOBALS['egw']->categories->id2name($cat,'data'));
+ $data = categories::id2name($cat,'data');
if (($color = $data['color']))
{
@@ -1692,6 +1692,22 @@ class etemplate extends boetemplate
),'style,id'));
}
break;
+ case 'colorpicker':
+ if ($readonly)
+ {
+ $html = $value;
+ }
+ else
+ {
+ $html = html::inputColor($form_name,$value,$cell['help']);
+
+ self::$request->set_to_process($form_name,$cell['type'],array(
+ 'maxlength' => 7,
+ 'needed' => $cell['needed'],
+ 'preg' => '/^(#[0-9a-f]{6}|)$/i',
+ ));
+ }
+ break;
default:
if ($ext_type && $this->haveExtension($ext_type,'render'))
{
@@ -1913,7 +1929,7 @@ class etemplate extends boetemplate
$on = str_replace($matches[0],"''",$on);
}
}
- if (strpos($on,'confirm(') !== false && preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) {
+ if (strpos($on,'confirm(') !== false && preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/U',$on,$matches)) {
$question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase
$on = str_replace($matches[0],'confirm(\''.str_replace("'","\\'",$question).'\')',$on);
}
@@ -2035,6 +2051,7 @@ class etemplate extends boetemplate
case 'passwd':
case 'text':
case 'textarea':
+ case 'colorpicker':
if ($value === '' && $attr['needed'] && !$attr['blur'])
{
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php
index 7fdd73aa0c..87767bf367 100644
--- a/phpgwapi/inc/class.html.inc.php
+++ b/phpgwapi/inc/class.html.inc.php
@@ -79,7 +79,7 @@ class html
/**
* Created an input-field with an attached color-picker
*
- * Please note: it need to be called before the call to phpgw_header() !!!
+ * Please note: it need to be called before the call to egw_header() !!!
*
* @param string $name the name of the input-field
* @param string $value the actual value for the input-field, default ''
@@ -89,8 +89,8 @@ class html
static function inputColor($name,$value='',$title='')
{
$id = str_replace(array('[',']'),array('_',''),$name).'_colorpicker';
- $onclick = "javascript:window.open('".self::$api_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+document.getElementById('$id').value,'colorPicker','width=240,height=187,scrollbars=no,resizable=no,toolbar=no');";
- return ' '.
+ $onclick = "javascript:window.open('".self::$api_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+encodeURIComponent(document.getElementById('$id').value),'colorPicker','width=240,height=187,scrollbars=no,resizable=no,toolbar=no');";
+ return ' '.
''.
'";
}