ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 setValueByArray ($a_values)
 Set values by array. 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...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. 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...
 
- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. 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
 $ctrl
 
 $lng
 
 $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 (
39 $this->getRequired() &&
40 !strlen($_POST[$this->getPostVar()])
41 ) {
42 $this->setAlert($this->lng->txt("msg_input_is_required"));
43 return false;
44 }
45
46 if ($this->getAcceptNamedColors() && substr($_POST[$this->getPostVar()], 0, 1) == "!") {
47 $_POST[$this->getPostVar()] =
48 ilUtil::stripslashes(trim($_POST[$this->getPostVar()]));
49 } else {
50 $_POST[$this->getPostVar()] =
51 $this->determineHexcode(ilUtil::stripslashes(trim($_POST[$this->getPostVar()])));
52 }
53 return true;
54 }
$_POST["username"]
static determineHexcode($a_value)
Determine hex code for a given value.
getAcceptNamedColors()
Get Accept Named Colors (Leading '!').
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.

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

+ 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 140 of file class.ilColorPickerInputGUI.php.

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

119 {
120 return $this->acceptnamedcolors;
121 }

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 98 of file class.ilColorPickerInputGUI.php.

99 {
100 return $this->defaultcolor;
101 }

Referenced by getHexcode().

+ Here is the caller graph for this function:

◆ getHexcode()

ilColorPickerInputGUI::getHexcode ( )

get hexcode

@access public

Returns

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

130 {
131 if (strpos($this->hex, '#') === 0) {
132 return substr($this->hex, 1);
133 }
134 return $this->hex ? $this->hex : $this->getDefaultColor();
135 }

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

Reimplemented from ilTextInputGUI.

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

205 {
206 include_once('./Services/YUI/classes/class.ilYuiUtil.php');
207
209
210
211 $a_tpl->setCurrentBlock("prop_color");
212
213 $js_tpl = new ilTemplate('tpl.color_picker.js', true, true, 'Services/Form');
214 $js_tpl->setVariable('THUMB_PATH', ilUtil::getImagePath('color_picker_thumb.png', 'Services/Form'));
215 $js_tpl->setVariable('HUE_THUMB_PATH', ilUtil::getImagePath('color_picker_hue_thumb.png', 'Services/Form'));
216 $js_tpl->setVariable('COLOR_ID', $this->getFieldId());
218 if ($ic == "") {
219 $ic = "FFFFFF";
220 }
221 $js_tpl->setVariable('INIT_COLOR_SHORT', $ic);
222 $js_tpl->setVariable('INIT_COLOR', '#' . $this->getHexcode());
223 $js_tpl->setVariable('POST_VAR', $this->getPostVar());
224
225
226 if ($this->getDisabled()) {
227 $a_tpl->setVariable('COLOR_DISABLED', 'disabled="disabled"');
228 } else {
229 $a_tpl->setVariable('PROP_COLOR_JS', $js_tpl->get());
230 }
231 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
232 $a_tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
233
234 if (substr(trim($this->getValue()), 0, 1) == "!" && $this->getAcceptNamedColors()) {
235 $a_tpl->setVariable("PROPERTY_VALUE_COLOR", ilUtil::prepareFormOutput(trim($this->getValue())));
236 } else {
237 $a_tpl->setVariable("PROPERTY_VALUE_COLOR", ilUtil::prepareFormOutput($this->getHexcode()));
238 }
239 $a_tpl->parseCurrentBlock();
240 }
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 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 108 of file class.ilColorPickerInputGUI.php.

109 {
110 $this->acceptnamedcolors = $a_acceptnamedcolors;
111 }

◆ setDefaultColor()

ilColorPickerInputGUI::setDefaultColor (   $a_defaultcolor)

Set Default Color.

Parameters
mixed$a_defaultcolorDefault Color

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

89 {
90 $this->defaultcolor = $a_defaultcolor;
91 }

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 72 of file class.ilColorPickerInputGUI.php.

73 {
74 $a_value = trim($a_value);
75 if ($this->getAcceptNamedColors() && substr($a_value, 0, 1) == "!") {
76 parent::setValue($a_value);
77 } else {
78 $this->hex = ilColorPickerInputGUI::determineHexcode($a_value);
79 parent::setValue($this->getHexcode());
80 }
81 }

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

Referenced by setValueByArray().

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

◆ setValueByArray()

ilColorPickerInputGUI::setValueByArray (   $a_values)

Set values by array.

Parameters
type$a_values

Reimplemented from ilTextInputGUI.

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

61 {
62 $this->setValue($a_values[$this->getPostVar()]);
63 }

References ilFormPropertyGUI\getPostVar(), and setValue().

+ 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: