ILIAS  release_8 Revision v8.24
ilColorPickerInputGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 setValueByArray (array $a_values)
 
 setValue ($a_value)
 
 setDefaultColor (string $a_defaultcolor)
 
 getDefaultColor ()
 
 setAcceptNamedColors (bool $a_acceptnamedcolors)
 
 getAcceptNamedColors ()
 
 getHexcode ()
 
 insert (ilTemplate $a_tpl)
 
- Public Member Functions inherited from ilTextInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setValue ($a_value)
 
 getValue ()
 
 setValidationFailureMessage (string $a_msg)
 
 getValidationFailureMessage ()
 
 setValidationRegexp (string $a_value)
 
 getValidationRegexp ()
 
 setMaxLength (?int $a_maxlength)
 
 getMaxLength ()
 
 setSize (int $a_size)
 
 setInlineStyle (string $a_style)
 
 getInlineStyle ()
 
 setCssClass (string $a_class)
 
 getCssClass ()
 
 setValueByArray (array $a_values)
 
 getSize ()
 
 setSuffix (string $a_value)
 
 getSuffix ()
 
 setInputType (string $a_type)
 set input type More...
 
 getInputType ()
 
 setSubmitFormOnEnter (bool $a_val)
 
 getSubmitFormOnEnter ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 getDataSource ()
 
 setDataSource (string $href, string $a_delimiter=null)
 
 setDataSourceSubmitOnSelection (bool $a_stat)
 
 getDataSourceSubmitOnSelection ()
 
 setDataSourceSubmitUrl (string $a_url)
 
 getDataSourceSubmitUrl ()
 
 setMultiValues (array $a_values)
 
 render (string $a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 setDisableHtmlAutoComplete (bool $autocomplete)
 
 isHtmlAutoCompleteDisabled ()
 
 getPostValueForComparison ()
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $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...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. 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 (string $a_value)
 
- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 

Protected Attributes

string $hex = ""
 
bool $acceptnamedcolors = false
 
string $defaultcolor = ""
 
- Protected Attributes inherited from ilTextInputGUI
 $value = null
 
int $maxlength = 200
 
int $size = 40
 
string $validationRegexp = ""
 
string $validationFailureMessage = ''
 
string $suffix = ""
 
string $style_css = ""
 
string $css_class = ""
 
string $ajax_datasource = ""
 
string $ajax_datasource_delimiter = null
 
bool $ajax_datasource_commit = false
 
string $ajax_datasource_commit_url = ""
 
bool $submit_form_on_enter = false
 
bool $autocomplete_disabled = false
 
string $input_type = ""
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilTextInputGUI.

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

35 {
36 parent::__construct($a_title, $a_postvar);
37 $this->setType("color");
38 $this->setDefaultColor("04427e");
39 }
setDefaultColor(string $a_defaultcolor)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), setDefaultColor(), and ilFormPropertyGUI\setType().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilColorPickerInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilTextInputGUI.

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

41 : bool
42 {
43 if ($this->getRequired() && !strlen($this->getInput())
44 ) {
45 $this->setAlert($this->lng->txt("msg_input_is_required"));
46 return false;
47 }
48
49 return true;
50 }

References getInput(), ilFormPropertyGUI\getRequired(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setAlert().

+ Here is the call graph for this function:

◆ determineHexcode()

static ilColorPickerInputGUI::determineHexcode ( string  $a_value)
static

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

106 : string
107 {
108 $a_value = trim(strtolower($a_value));
109
110 // remove leading #
111 if (strpos($a_value, '#') === 0) {
112 $a_value = substr($a_value, 1);
113 }
114
115 // handle standard color names (no leading (!))
116 switch ($a_value) {
117 // html4 colors
118 case "black": $a_value = "000000"; break;
119 case "maroon": $a_value = "800000"; break;
120 case "green": $a_value = "008000"; break;
121 case "olive": $a_value = "808000"; break;
122 case "navy": $a_value = "000080"; break;
123 case "purple": $a_value = "800080"; break;
124 case "teal": $a_value = "008080"; break;
125 case "silver": $a_value = "C0C0C0"; break;
126 case "gray": $a_value = "808080"; break;
127 case "red": $a_value = "ff0000"; break;
128 case "lime": $a_value = "00ff00"; break;
129 case "yellow": $a_value = "ffff00"; break;
130 case "blue": $a_value = "0000ff"; break;
131 case "fuchsia": $a_value = "ff00ff"; break;
132 case "aqua": $a_value = "00ffff"; break;
133 case "white": $a_value = "ffffff"; break;
134
135 // other colors used by ILIAS, supported by modern browsers
136 case "brown": $a_value = "a52a2a"; break;
137 }
138
139 // handle rgb values
140 if (substr($a_value, 0, 3) == "rgb") {
141 $pos1 = strpos($a_value, "(");
142 $pos2 = strpos($a_value, ")");
143 $rgb = explode(",", substr($a_value, $pos1 + 1, $pos2 - $pos1 - 1));
144 $r = str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
145 $g = str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
146 $b = str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
147 $a_value = $r . $g . $b;
148 }
149
150 $a_value = trim(strtolower($a_value));
151
152 // expand three digit hex numbers
153 if (preg_match("/^[a-f0-9]{3}/", $a_value) && strlen($a_value) == 3) {
154 $a_value = "" . $a_value;
155 $a_value = $a_value[0] . $a_value[0] . $a_value[1] . $a_value[1] . $a_value[2] . $a_value[2];
156 }
157
158 if (!preg_match("/^[a-f0-9]{6}/", $a_value)) {
159 $a_value = "";
160 }
161
162 return strtoupper($a_value);
163 }

References Vendor\Package\$b.

Referenced by getInput(), 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 ( )

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

93 : bool
94 {
96 }

References $acceptnamedcolors.

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

+ Here is the caller graph for this function:

◆ getDefaultColor()

ilColorPickerInputGUI::getDefaultColor ( )

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

82 : string
83 {
85 }

References $defaultcolor.

Referenced by getHexcode().

+ Here is the caller graph for this function:

◆ getHexcode()

ilColorPickerInputGUI::getHexcode ( )

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

98 : string
99 {
100 if (strpos($this->hex, '#') === 0) {
101 return substr($this->hex, 1);
102 }
103 return $this->hex ?: $this->getDefaultColor();
104 }

References getDefaultColor().

Referenced by insert(), and setValue().

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

◆ getInput()

ilColorPickerInputGUI::getInput ( )
Returns
string|string[]

Reimplemented from ilTextInputGUI.

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

52 : string
53 {
54 $value = trim($this->str($this->getPostVar()));
55 if ($this->getAcceptNamedColors() && substr($value, 0, 1) == "!") {
56 return $value;
57 }
58 return $this->determineHexcode($value);
59 }
static determineHexcode(string $a_value)

References ilTextInputGUI\$value, determineHexcode(), getAcceptNamedColors(), ilFormPropertyGUI\getPostVar(), and ilFormPropertyGUI\str().

Referenced by checkInput().

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

◆ insert()

ilColorPickerInputGUI::insert ( ilTemplate  $a_tpl)

Reimplemented from ilTextInputGUI.

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

165 : void
166 {
167 $tpl = new ilTemplate('tpl.prop_color.html', true, true, 'Services/Form');
168 $tpl->setVariable('COLOR_ID', $this->getFieldId());
170 if ($ic == "") {
171 $ic = "FFFFFF";
172 }
173 $tpl->setVariable('INIT_COLOR_SHORT', $ic);
174 $tpl->setVariable('POST_VAR', $this->getPostVar());
175
176 if ($this->getDisabled()) {
177 $a_tpl->setVariable('COLOR_DISABLED', 'disabled="disabled"');
178 }
179
180 $tpl->setVariable("POST_VAR", $this->getPostVar());
181 $tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
182
183 if (substr(trim($this->getValue() ?? ""), 0, 1) == "!" && $this->getAcceptNamedColors()) {
184 $tpl->setVariable(
185 "PROPERTY_VALUE_COLOR",
187 );
188 } else {
189 $tpl->setVariable("PROPERTY_VALUE_COLOR", ilLegacyFormElementsUtil::prepareFormOutput($this->getHexcode()));
190 $tpl->setVariable('INIT_COLOR', '#' . $this->getHexcode());
191 }
192
193 $a_tpl->setCurrentBlock("prop_generic");
194 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
195 $a_tpl->parseCurrentBlock();
196 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $tpl, determineHexcode(), getAcceptNamedColors(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getHexcode(), ilFormPropertyGUI\getPostVar(), ilTextInputGUI\getValue(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ setAcceptNamedColors()

ilColorPickerInputGUI::setAcceptNamedColors ( bool  $a_acceptnamedcolors)

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

88 : void
89 {
90 $this->acceptnamedcolors = $a_acceptnamedcolors;
91 }

◆ setDefaultColor()

ilColorPickerInputGUI::setDefaultColor ( string  $a_defaultcolor)

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

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setValue()

ilColorPickerInputGUI::setValue (   $a_value)
Parameters
string | array$a_value

Reimplemented from ilTextInputGUI.

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

66 : void
67 {
68 $a_value = trim($a_value);
69 if ($this->getAcceptNamedColors() && substr($a_value, 0, 1) == "!") {
70 parent::setValue($a_value);
71 } else {
72 $this->hex = ilColorPickerInputGUI::determineHexcode($a_value);
73 parent::setValue($this->getHexcode());
74 }
75 }

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 ( array  $a_values)

Reimplemented from ilTextInputGUI.

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $acceptnamedcolors

bool ilColorPickerInputGUI::$acceptnamedcolors = false
protected

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

Referenced by getAcceptNamedColors().

◆ $defaultcolor

string ilColorPickerInputGUI::$defaultcolor = ""
protected

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

Referenced by getDefaultColor().

◆ $hex

string ilColorPickerInputGUI::$hex = ""
protected

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


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