ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 (string $a_title="", string $a_postvar="")
 
 checkInput ()
 
 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 ()
 
 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)
 
- 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
 getTableFilterLabelFor ()
 Get label "for" attribute value. 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
 symbol ()
 
 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

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
Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

36  {
37  parent::__construct($a_title, $a_postvar);
38  $this->setType("color");
39  $this->setDefaultColor("04427e");
40  }
setDefaultColor(string $a_defaultcolor)
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilColorPickerInputGUI::checkInput ( )

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

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

42  : bool
43  {
44  if ($this->getRequired() && !strlen($this->getInput())
45  ) {
46  $this->setAlert($this->lng->txt("msg_input_is_required"));
47  return false;
48  }
49 
50  return true;
51  }
+ Here is the call graph for this function:

◆ determineHexcode()

static ilColorPickerInputGUI::determineHexcode ( string  $a_value)
static

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

References Vendor\Package\$b, and $r.

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

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

◆ getAcceptNamedColors()

ilColorPickerInputGUI::getAcceptNamedColors ( )

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

References $acceptnamedcolors.

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

94  : bool
95  {
97  }
+ Here is the caller graph for this function:

◆ getDefaultColor()

ilColorPickerInputGUI::getDefaultColor ( )

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

References $defaultcolor.

Referenced by getHexcode().

83  : string
84  {
85  return $this->defaultcolor;
86  }
+ Here is the caller graph for this function:

◆ getHexcode()

ilColorPickerInputGUI::getHexcode ( )

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

References getDefaultColor().

Referenced by insert(), and setValue().

99  : string
100  {
101  if (strpos($this->hex, '#') === 0) {
102  return substr($this->hex, 1);
103  }
104  return $this->hex ?: $this->getDefaultColor();
105  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInput()

ilColorPickerInputGUI::getInput ( )

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

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

Referenced by checkInput().

53  : string
54  {
55  $value = trim($this->str($this->getPostVar()));
56  if ($this->getAcceptNamedColors() && substr($value, 0, 1) == "!") {
57  return $value;
58  }
59  return $this->determineHexcode($value);
60  }
static determineHexcode(string $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilColorPickerInputGUI::insert ( ilTemplate  $a_tpl)

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

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

183  : void
184  {
185  $tpl = new ilTemplate('tpl.prop_color.html', true, true, 'components/ILIAS/Form');
186  $tpl->setVariable('COLOR_ID', $this->getFieldId());
188  if ($ic == "") {
189  $ic = "FFFFFF";
190  }
191  $tpl->setVariable('INIT_COLOR_SHORT', $ic);
192  $tpl->setVariable('POST_VAR', $this->getPostVar());
193 
194  if ($this->getDisabled()) {
195  $a_tpl->setVariable('COLOR_DISABLED', 'disabled="disabled"');
196  }
197 
198  $tpl->setVariable("POST_VAR", $this->getPostVar());
199  $tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
200 
201  if (substr(trim($this->getValue() ?? ""), 0, 1) == "!" && $this->getAcceptNamedColors()) {
202  $tpl->setVariable(
203  "PROPERTY_VALUE_COLOR",
205  );
206  } else {
207  $tpl->setVariable("PROPERTY_VALUE_COLOR", ilLegacyFormElementsUtil::prepareFormOutput($this->getHexcode()));
208  $tpl->setVariable('INIT_COLOR', '#' . $this->getHexcode());
209  }
210 
211  $a_tpl->setCurrentBlock("prop_generic");
212  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
213  $a_tpl->parseCurrentBlock();
214  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static determineHexcode(string $a_value)
+ Here is the call graph for this function:

◆ setAcceptNamedColors()

ilColorPickerInputGUI::setAcceptNamedColors ( bool  $a_acceptnamedcolors)

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

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

◆ setDefaultColor()

ilColorPickerInputGUI::setDefaultColor ( string  $a_defaultcolor)

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

Referenced by __construct(), and ilStyleCharacteristicGUI\initTagStyleForm().

78  : void
79  {
80  $this->defaultcolor = $a_defaultcolor;
81  }
+ Here is the caller graph for this function:

◆ setValue()

ilColorPickerInputGUI::setValue (   $a_value)

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

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

Referenced by ilCalendarCategoryGUI\initFormCategory(), and setValueByArray().

67  : void
68  {
69  $a_value = trim($a_value);
70  if ($this->getAcceptNamedColors() && substr($a_value, 0, 1) == "!") {
71  parent::setValue($a_value);
72  } else {
73  $this->hex = ilColorPickerInputGUI::determineHexcode($a_value);
74  parent::setValue($this->getHexcode());
75  }
76  }
static determineHexcode(string $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueByArray()

ilColorPickerInputGUI::setValueByArray ( array  $a_values)

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

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

62  : void
63  {
64  $this->setValue($a_values[$this->getPostVar()]);
65  }
+ Here is the call graph for this function:

Field Documentation

◆ $acceptnamedcolors

bool ilColorPickerInputGUI::$acceptnamedcolors = false
protected

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

Referenced by getAcceptNamedColors().

◆ $defaultcolor

string ilColorPickerInputGUI::$defaultcolor = ""
protected

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

Referenced by getDefaultColor().

◆ $hex

string ilColorPickerInputGUI::$hex = ""
protected

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


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