ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilColorPickerInputGUI Class Reference

Color picker form for selecting color hexcodes using yui library. More...

+ Inheritance diagram for ilColorPickerInputGUI:
+ Collaboration diagram for ilColorPickerInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 checkInput ()
 check input More...
 
 setValue ($a_value)
 set value More...
 
 setDefaultColor ($a_defaultcolor)
 Set Default Color. More...
 
 getDefaultColor ()
 Get Default Color. More...
 
 setAcceptNamedColors ($a_acceptnamedcolors)
 Set Accept Named Colors (Leading '!'). More...
 
 getAcceptNamedColors ()
 Get Accept Named Colors (Leading '!'). More...
 
 getHexcode ()
 get hexcode More...
 
 insert ($a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilTextInputGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValidationFailureMessage ($a_msg)
 Set message string for validation failure. More...
 
 getValidationFailureMessage ()
 
 setValidationRegexp ($a_value)
 Set validation regexp. More...
 
 getValidationRegexp ()
 Get validation regexp. More...
 
 setMaxLength ($a_maxlength)
 Set Max Length. More...
 
 getMaxLength ()
 Get Max Length. More...
 
 setSize ($a_size)
 Set Size. More...
 
 setInlineStyle ($a_style)
 Set inline style. More...
 
 getInlineStyle ()
 Get inline style. More...
 
 setCssClass ($a_class)
 
 getCssClass ()
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 getSize ()
 Get Size. More...
 
 setSuffix ($a_value)
 Set suffix. More...
 
 getSuffix ()
 Get suffix. More...
 
 setInputType ($a_type)
 set input type More...
 
 getInputType ()
 get input type More...
 
 setSubmitFormOnEnter ($a_val)
 Set submit form on enter. More...
 
 getSubmitFormOnEnter ()
 Get submit form on enter. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getDataSource ()
 get datasource link for js autocomplete More...
 
 setDataSource ($href, $a_delimiter=null)
 set datasource link for js autocomplete More...
 
 setDataSourceSubmitOnSelection ($a_stat)
 
 getDataSourceSubmitOnSelection ()
 
 setDataSourceSubmitUrl ($a_url)
 
 getDataSourceSubmitUrl ()
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 insert (&$a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
 getToolbarHTML ()
 Get HTML for toolbar. More...
 
 setDisableHtmlAutoComplete ($autocomplete)
 
 isHtmlAutoCompleteDisabled ()
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Static Public Member Functions

static determineHexcode ($a_value)
 Determine hex code for a given value. More...
 

Protected Attributes

 $hex
 
- Protected Attributes inherited from ilTextInputGUI
 $value
 
 $maxlength = 200
 
 $size = 40
 
 $validationRegexp
 
 $validationFailureMessage = ''
 
 $suffix
 
 $style_css
 
 $css_class
 
 $ajax_datasource
 
 $ajax_datasource_delimiter
 
 $ajax_datasource_commit = FALSE
 
 $ajax_datasource_commit_url
 
 $submit_form_on_enter = false
 
 $autocomplete_disabled = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Detailed Description

Color picker form for selecting color hexcodes using yui library.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilColorPickerInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilColorPickerInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilTextInputGUI.

Definition at line 23 of file class.ilColorPickerInputGUI.php.

24 {
25 parent::__construct($a_title, $a_postvar);
26 $this->setType("color");
27 $this->setDefaultColor("04427e");
28 }
setDefaultColor($a_defaultcolor)
Set Default Color.
setType($a_type)
Set Type.

References setDefaultColor(), and ilFormPropertyGUI\setType().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilColorPickerInputGUI::checkInput ( )

check input

@access public

Returns

Reimplemented from ilTextInputGUI.

Definition at line 36 of file class.ilColorPickerInputGUI.php.

37 {
38 if ($this->getAcceptNamedColors() && substr($_POST[$this->getPostVar()], 0, 1) == "!")
39 {
40 $_POST[$this->getPostVar()] =
41 ilUtil::stripslashes(trim($_POST[$this->getPostVar()]));
42 }
43 else
44 {
45 $_POST[$this->getPostVar()] =
46 $this->determineHexcode(ilUtil::stripslashes(trim($_POST[$this->getPostVar()])));
47 }
48 return true;
49 }
static determineHexcode($a_value)
Determine hex code for a given value.
getAcceptNamedColors()
Get Accept Named Colors (Leading '!').
getPostVar()
Get Post Variable.
$_POST['username']
Definition: cron.php:12

References $_POST, determineHexcode(), getAcceptNamedColors(), and ilFormPropertyGUI\getPostVar().

+ Here is the call graph for this function:

◆ determineHexcode()

static ilColorPickerInputGUI::determineHexcode (   $a_value)
static

Determine hex code for a given value.

Definition at line 130 of file class.ilColorPickerInputGUI.php.

131 {
132 $a_value = trim(strtolower($a_value));
133
134 // remove leading #
135 if(strpos($a_value,'#') === 0)
136 {
137 $a_value = substr($a_value,1);
138 }
139
140 // handle standard color names (no leading (!))
141 switch ($a_value)
142 {
143 // html4 colors
144 case "black": $a_value = "000000"; break;
145 case "maroon": $a_value = "800000"; break;
146 case "green": $a_value = "008000"; break;
147 case "olive": $a_value = "808000"; break;
148 case "navy": $a_value = "000080"; break;
149 case "purple": $a_value = "800080"; break;
150 case "teal": $a_value = "008080"; break;
151 case "silver": $a_value = "C0C0C0"; break;
152 case "gray": $a_value = "808080"; break;
153 case "red": $a_value = "ff0000"; break;
154 case "lime": $a_value = "00ff00"; break;
155 case "yellow": $a_value = "ffff00"; break;
156 case "blue": $a_value = "0000ff"; break;
157 case "fuchsia": $a_value = "ff00ff"; break;
158 case "aqua": $a_value = "00ffff"; break;
159 case "white": $a_value = "ffffff"; break;
160
161 // other colors used by ILIAS, supported by modern browsers
162 case "brown": $a_value = "a52a2a"; break;
163 }
164
165 // handle rgb values
166 if (substr($a_value, 0, 3) == "rgb")
167 {
168 $pos1 = strpos($a_value, "(");
169 $pos2 = strpos($a_value, ")");
170 $rgb = explode(",", substr($a_value, $pos1 + 1, $pos2 - $pos1 - 1));
171 $r = str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
172 $g = str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
173 $b = str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
174 $a_value = $r.$g.$b;
175 }
176
177 $a_value = trim(strtolower($a_value));
178
179 // expand three digit hex numbers
180 if (preg_match("/^[0-9a-f]3/", $a_value) && strlen($a_value == 3))
181 {
182 $a_value = "".$a_value;
183 $a_value = "0".$a_value[0]."0".$a_value[1]."0".$a_value[2];
184 }
185
186 if (!preg_match("/^[a-f0-9]{6}/", $a_value))
187 {
188 $a_value = "";
189 }
190
191 return strtoupper($a_value);
192 }
$r
Definition: example_031.php:79

References $r.

Referenced by checkInput(), insert(), ilTRBLColorPickerInputGUI\insert(), ilTRBLColorPickerInputGUI\setAllValue(), ilTRBLColorPickerInputGUI\setBottomValue(), ilTRBLColorPickerInputGUI\setLeftValue(), ilTRBLColorPickerInputGUI\setRightValue(), ilTRBLColorPickerInputGUI\setTopValue(), and setValue().

+ Here is the caller graph for this function:

◆ getAcceptNamedColors()

ilColorPickerInputGUI::getAcceptNamedColors ( )

Get Accept Named Colors (Leading '!').

Returns
boolean Accept Named Colors (Leading '!')

Definition at line 107 of file class.ilColorPickerInputGUI.php.

108 {
109 return $this->acceptnamedcolors;
110 }

Referenced by checkInput(), insert(), and setValue().

+ Here is the caller graph for this function:

◆ getDefaultColor()

ilColorPickerInputGUI::getDefaultColor ( )

Get Default Color.

Returns
mixed Default Color

Definition at line 87 of file class.ilColorPickerInputGUI.php.

88 {
89 return $this->defaultcolor;
90 }

Referenced by getHexcode().

+ Here is the caller graph for this function:

◆ getHexcode()

ilColorPickerInputGUI::getHexcode ( )

get hexcode

@access public

Returns

Definition at line 118 of file class.ilColorPickerInputGUI.php.

119 {
120 if(strpos($this->hex,'#') === 0)
121 {
122 return substr($this->hex,1);
123 }
124 return $this->hex ? $this->hex : $this->getDefaultColor();
125 }

References getDefaultColor().

Referenced by insert(), and setValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilColorPickerInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

Definition at line 199 of file class.ilColorPickerInputGUI.php.

200 {
201 global $tpl;
202
203 include_once('./Services/YUI/classes/class.ilYuiUtil.php');
204
206
207
208 $a_tpl->setCurrentBlock("prop_color");
209
210 $js_tpl = new ilTemplate('tpl.color_picker.js',true,true,'Services/Form');
211 $js_tpl->setVariable('THUMB_PATH',ilUtil::getImagePath('color_picker_thumb.png','Services/Form'));
212 $js_tpl->setVariable('HUE_THUMB_PATH',ilUtil::getImagePath('color_picker_hue_thumb.png','Services/Form'));
213 $js_tpl->setVariable('COLOR_ID',$this->getFieldId());
215 if ($ic == "")
216 {
217 $ic = "FFFFFF";
218 }
219 $js_tpl->setVariable('INIT_COLOR_SHORT',$ic);
220 $js_tpl->setVariable('INIT_COLOR','#'.$this->getHexcode());
221 $js_tpl->setVariable('POST_VAR', $this->getPostVar());
222
223
224 if($this->getDisabled())
225 {
226 $a_tpl->setVariable('COLOR_DISABLED','disabled="disabled"');
227 }
228 else
229 {
230 $a_tpl->setVariable('PROP_COLOR_JS',$js_tpl->get());
231 }
232 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
233 $a_tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
234
235 if (substr(trim($this->getValue()), 0, 1) == "!" && $this->getAcceptNamedColors())
236 {
237 $a_tpl->setVariable("PROPERTY_VALUE_COLOR",ilUtil::prepareFormOutput(trim($this->getValue())));
238 }
239 else
240 {
241 $a_tpl->setVariable("PROPERTY_VALUE_COLOR",ilUtil::prepareFormOutput($this->getHexcode()));
242 }
243 $a_tpl->parseCurrentBlock();
244 }
global $tpl
Definition: ilias.php:8
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initColorPicker()
init color picker button

References $tpl, determineHexcode(), getAcceptNamedColors(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getHexcode(), ilUtil\getImagePath(), ilFormPropertyGUI\getPostVar(), ilTextInputGUI\getValue(), ilYuiUtil\initColorPicker(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ setAcceptNamedColors()

ilColorPickerInputGUI::setAcceptNamedColors (   $a_acceptnamedcolors)

Set Accept Named Colors (Leading '!').

Parameters
boolean$a_acceptnamedcolorsAccept Named Colors (Leading '!')

Definition at line 97 of file class.ilColorPickerInputGUI.php.

98 {
99 $this->acceptnamedcolors = $a_acceptnamedcolors;
100 }

◆ setDefaultColor()

ilColorPickerInputGUI::setDefaultColor (   $a_defaultcolor)

Set Default Color.

Parameters
mixed$a_defaultcolorDefault Color

Definition at line 77 of file class.ilColorPickerInputGUI.php.

78 {
79 $this->defaultcolor = $a_defaultcolor;
80 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setValue()

ilColorPickerInputGUI::setValue (   $a_value)

set value

@access public

Parameters
string$a_valuecolor hexcode
Returns

Reimplemented from ilTextInputGUI.

Definition at line 58 of file class.ilColorPickerInputGUI.php.

59 {
60 $a_value = trim($a_value);
61 if ($this->getAcceptNamedColors() && substr($a_value, 0, 1) == "!")
62 {
63 parent::setValue($a_value);
64 }
65 else
66 {
67 $this->hex = ilColorPickerInputGUI::determineHexcode($a_value);
68 parent::setValue($this->getHexcode());
69 }
70 }

References determineHexcode(), getAcceptNamedColors(), and getHexcode().

+ Here is the call graph for this function:

Field Documentation

◆ $hex

ilColorPickerInputGUI::$hex
protected

Definition at line 15 of file class.ilColorPickerInputGUI.php.


The documentation for this class was generated from the following file: