mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-24 22:21:34 +01:00
fixed colorpicker (as not using current color) and added colorpicker widget to etemplate
This commit is contained in:
parent
25c29211f5
commit
e73dcb2a27
@ -16,6 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
class boetemplate extends soetemplate
|
class boetemplate extends soetemplate
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Widget types implemented directly by etemplate (no extensions)
|
||||||
|
*
|
||||||
|
* @var array intern name => label
|
||||||
|
*/
|
||||||
static public $types = array(
|
static public $types = array(
|
||||||
'label' => 'Label', // Label $cell['label'] is (to be translated) textual content
|
'label' => 'Label', // Label $cell['label'] is (to be translated) textual content
|
||||||
'text' => 'Text', // Textfield 1 Line (size = [length][,maxlength])
|
'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)
|
'box' => 'Box', // just a container for widgets (html: div)
|
||||||
'grid' => 'Grid', // tabular widget containing rows with columns of widgets
|
'grid' => 'Grid', // tabular widget containing rows with columns of widgets
|
||||||
'deck' => 'Deck', // a container of elements where only one is visible, size = # of elem.
|
'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)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -638,7 +638,7 @@ class etemplate extends boetemplate
|
|||||||
{
|
{
|
||||||
return $cat2color[$cat];
|
return $cat2color[$cat];
|
||||||
}
|
}
|
||||||
$data = unserialize($GLOBALS['egw']->categories->id2name($cat,'data'));
|
$data = categories::id2name($cat,'data');
|
||||||
|
|
||||||
if (($color = $data['color']))
|
if (($color = $data['color']))
|
||||||
{
|
{
|
||||||
@ -1692,6 +1692,22 @@ class etemplate extends boetemplate
|
|||||||
),'style,id'));
|
),'style,id'));
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
if ($ext_type && $this->haveExtension($ext_type,'render'))
|
if ($ext_type && $this->haveExtension($ext_type,'render'))
|
||||||
{
|
{
|
||||||
@ -1913,7 +1929,7 @@ class etemplate extends boetemplate
|
|||||||
$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$on);
|
$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$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
|
$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);
|
$on = str_replace($matches[0],'confirm(\''.str_replace("'","\\'",$question).'\')',$on);
|
||||||
}
|
}
|
||||||
@ -2035,6 +2051,7 @@ class etemplate extends boetemplate
|
|||||||
case 'passwd':
|
case 'passwd':
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
|
case 'colorpicker':
|
||||||
if ($value === '' && $attr['needed'] && !$attr['blur'])
|
if ($value === '' && $attr['needed'] && !$attr['blur'])
|
||||||
{
|
{
|
||||||
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
||||||
|
@ -79,7 +79,7 @@ class html
|
|||||||
/**
|
/**
|
||||||
* Created an input-field with an attached color-picker
|
* 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 $name the name of the input-field
|
||||||
* @param string $value the actual value for the input-field, default ''
|
* @param string $value the actual value for the input-field, default ''
|
||||||
@ -89,8 +89,8 @@ class html
|
|||||||
static function inputColor($name,$value='',$title='')
|
static function inputColor($name,$value='',$title='')
|
||||||
{
|
{
|
||||||
$id = str_replace(array('[',']'),array('_',''),$name).'_colorpicker';
|
$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');";
|
$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 '<input type="text" name="'.$name.'" id="'.$id.'" value="'.self::htmlspecialchars($value).'" /> '.
|
return '<input type="text" name="'.$name.'" id="'.$id.'" value="'.self::htmlspecialchars($value).'" size="7" maxsize="7" /> '.
|
||||||
'<a href="#" onclick="'.$onclick.'">'.
|
'<a href="#" onclick="'.$onclick.'">'.
|
||||||
'<img src="'.self::$api_js_url.'/colorpicker/ed_color_bg.gif'.'"'.($title ? ' title="'.self::htmlspecialchars($title).'"' : '')." /></a>";
|
'<img src="'.self::$api_js_url.'/colorpicker/ed_color_bg.gif'.'"'.($title ? ' title="'.self::htmlspecialchars($title).'"' : '')." /></a>";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user