ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 checkInput ()
 check input
 setValue ($a_value)
 set value
 setDefaultColor ($a_defaultcolor)
 Set Default Color.
 getDefaultColor ()
 Get Default Color.
 setAcceptNamedColors ($a_acceptnamedcolors)
 Set Accept Named Colors (Leading '!').
 getAcceptNamedColors ()
 Get Accept Named Colors (Leading '!').
 getHexcode ()
 get hexcode
 insert ($a_tpl)
 Insert property html.
- Public Member Functions inherited from ilTextInputGUI
 getValue ()
 Get Value.
 setMulti ($a_multi, $a_sortable=false)
 setValidationFailureMessage ($a_msg)
 Set message string for validation failure.
 getValidationFailureMessage ()
 setValidationRegexp ($a_value)
 Set validation regexp.
 getValidationRegexp ()
 Get validation regexp.
 setMaxLength ($a_maxlength)
 Set Max Length.
 getMaxLength ()
 Get Max Length.
 setSize ($a_size)
 Set Size.
 setInlineStyle ($a_style)
 Set inline style.
 getInlineStyle ()
 Get inline style.
 setCssClass ($a_class)
 getCssClass ()
 setValueByArray ($a_values)
 Set value by array.
 getSize ()
 Get Size.
 setSuffix ($a_value)
 Set suffix.
 getSuffix ()
 Get suffix.
 setInputType ($a_type)
 set input type
 getInputType ()
 get input type
 setSubmitFormOnEnter ($a_val)
 Set submit form on enter.
 getSubmitFormOnEnter ()
 Get submit form on enter.
 getDataSource ()
 get datasource link for js autocomplete
 setDataSource ($href)
 set datasource link for js autocomplete
 setMultiValues (array $a_values)
 Set multi values.
 insert (&$a_tpl)
 Insert property html.
 getTableFilterHTML ()
 Get HTML for table filter.
 getToolbarHTML ()
 Get HTML for toolbar.
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 checkSubItemsInput ()
 Check SubItems.
 getSubForm ()
 Get sub form html.
 getItemByPostVar ($a_post_var)
 Get item by post var.
- Public Member Functions inherited from ilFormPropertyGUI
executeCommand ()
 Execute command.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setPostVar ($a_postvar)
 Set Post Variable.
 getPostVar ()
 Get Post Variable.
 getFieldId ()
 Get Post Variable.
 setInfo ($a_info)
 Set Information Text.
 getInfo ()
 Get Information Text.
 setAlert ($a_alert)
 Set Alert Text.
 getAlert ()
 Get Alert Text.
 setRequired ($a_required)
 Set Required.
 getRequired ()
 Get Required.
 setDisabled ($a_disabled)
 Set Disabled.
 getDisabled ()
 Get Disabled.
 setParentForm ($a_parentform)
 Set Parent Form.
 getParentForm ()
 Get Parent Form.
 setParent ($a_val)
 Set Parent GUI object.
 getParent ()
 Get Parent GUI object.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 serializeData ()
 serialize data
 unserializeData ($a_data)
 unserialize data
 writeToSession ()
 Write to session.
 clearFromSession ()
 Clear session value.
 readFromSession ()
 Read from session.
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties)
 setMulti ($a_multi)
 Set Multi.
 getMulti ()
 Get Multi.
 getMultiValues ()
 Get multi values.

Static Public Member Functions

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

Protected Attributes

 $hex
- Protected Attributes inherited from ilTextInputGUI
 $value
 $maxlength = 200
 $size = 40
 $validationRegexp
 $validationFailureMessage = ''
 $suffix
 $style_css
 $css_class
 $ajax_datasource
 $submit_form_on_enter = 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
 $multi_values

Additional Inherited Members

- Protected Member Functions inherited from ilTextInputGUI
 render ($a_mode="")
 Render item.

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

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.

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

{
parent::__construct($a_title, $a_postvar);
$this->setType("color");
$this->setDefaultColor("04427e");
}

+ Here is the call graph for this function:

Member Function Documentation

ilColorPickerInputGUI::checkInput ( )

check input

public

Returns

Reimplemented from ilTextInputGUI.

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

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

{
if ($this->getAcceptNamedColors() && substr($_POST[$this->getPostVar()], 0, 1) == "!")
{
$_POST[$this->getPostVar()] =
ilUtil::stripslashes(trim($_POST[$this->getPostVar()]));
}
else
{
$_POST[$this->getPostVar()] =
$this->determineHexcode(ilUtil::stripslashes(trim($_POST[$this->getPostVar()])));
}
return true;
}

+ Here is the call graph for this function:

static ilColorPickerInputGUI::determineHexcode (   $a_value)
static

Determine hex code for a given value.

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

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

{
$a_value = trim(strtolower($a_value));
// remove leading #
if(strpos($a_value,'#') === 0)
{
$a_value = substr($a_value,1);
}
// handle standard color names (no leading (!))
switch ($a_value)
{
// html4 colors
case "black": $a_value = "000000"; break;
case "maroon": $a_value = "800000"; break;
case "green": $a_value = "008000"; break;
case "olive": $a_value = "808000"; break;
case "navy": $a_value = "000080"; break;
case "purple": $a_value = "800080"; break;
case "teal": $a_value = "008080"; break;
case "silver": $a_value = "C0C0C0"; break;
case "gray": $a_value = "808080"; break;
case "red": $a_value = "ff0000"; break;
case "lime": $a_value = "00ff00"; break;
case "yellow": $a_value = "ffff00"; break;
case "blue": $a_value = "0000ff"; break;
case "fuchsia": $a_value = "ff00ff"; break;
case "aqua": $a_value = "00ffff"; break;
case "white": $a_value = "ffffff"; break;
// other colors used by ILIAS, supported by modern browsers
case "brown": $a_value = "a52a2a"; break;
}
// handle rgb values
if (substr($a_value, 0, 3) == "rgb")
{
$pos1 = strpos($a_value, "(");
$pos2 = strpos($a_value, ")");
$rgb = explode(",", substr($a_value, $pos1 + 1, $pos2 - $pos1 - 1));
$r = str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
$g = str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
$b = str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
$a_value = $r.$g.$b;
}
$a_value = trim(strtolower($a_value));
// expand three digit hex numbers
if (preg_match("/^[0-9a-f]3/", $a_value) && strlen($a_value == 3))
{
$a_value = "".$a_value;
$a_value = "0".$a_value[0]."0".$a_value[1]."0".$a_value[2];
}
if (!preg_match("/^[a-f0-9]{6}/", $a_value))
{
$a_value = "";
}
return strtoupper($a_value);
}

+ Here is the caller graph for this function:

ilColorPickerInputGUI::getAcceptNamedColors ( )

Get Accept Named Colors (Leading '!').

Returns
boolean Accept Named Colors (Leading '!')

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

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

{
return $this->acceptnamedcolors;
}

+ Here is the caller graph for this function:

ilColorPickerInputGUI::getDefaultColor ( )

Get Default Color.

Returns
mixed Default Color

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

Referenced by getHexcode().

{
return $this->defaultcolor;
}

+ Here is the caller graph for this function:

ilColorPickerInputGUI::getHexcode ( )

get hexcode

public

Returns

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

References getDefaultColor().

Referenced by insert(), and setValue().

{
if(strpos($this->hex,'#') === 0)
{
return substr($this->hex,1);
}
return $this->hex ? $this->hex : $this->getDefaultColor();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilColorPickerInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

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

{
global $tpl;
include_once('./Services/YUI/classes/class.ilYuiUtil.php');
$a_tpl->setCurrentBlock("prop_color");
$js_tpl = new ilTemplate('tpl.color_picker.js',true,true,'Services/Form');
$js_tpl->setVariable('THUMB_PATH',ilUtil::getImagePath('color_picker_thumb.png','Services/Form'));
$js_tpl->setVariable('HUE_THUMB_PATH',ilUtil::getImagePath('color_picker_hue_thumb.png','Services/Form'));
$js_tpl->setVariable('COLOR_ID',$this->getFieldId());
if ($ic == "")
{
$ic = "FFFFFF";
}
$js_tpl->setVariable('INIT_COLOR_SHORT',$ic);
$js_tpl->setVariable('INIT_COLOR','#'.$this->getHexcode());
$js_tpl->setVariable('POST_VAR', $this->getPostVar());
if($this->getDisabled())
{
$a_tpl->setVariable('COLOR_DISABLED','disabled="disabled"');
}
else
{
$a_tpl->setVariable('PROP_COLOR_JS',$js_tpl->get());
}
$a_tpl->setVariable("POST_VAR", $this->getPostVar());
$a_tpl->setVariable("PROP_COLOR_ID", $this->getFieldId());
if (substr(trim($this->getValue()), 0, 1) == "!" && $this->getAcceptNamedColors())
{
$a_tpl->setVariable("PROPERTY_VALUE_COLOR",ilUtil::prepareFormOutput(trim($this->getValue())));
}
else
{
$a_tpl->setVariable("PROPERTY_VALUE_COLOR",ilUtil::prepareFormOutput($this->getHexcode()));
}
$a_tpl->parseCurrentBlock();
}

+ Here is the call graph for this function:

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.

{
$this->acceptnamedcolors = $a_acceptnamedcolors;
}
ilColorPickerInputGUI::setDefaultColor (   $a_defaultcolor)

Set Default Color.

Parameters
mixed$a_defaultcolorDefault Color

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

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

{
$this->defaultcolor = $a_defaultcolor;
}

+ Here is the caller graph for this function:

ilColorPickerInputGUI::setValue (   $a_value)

set value

public

Parameters
string$a_valuecolor hexcode
Returns

Reimplemented from ilTextInputGUI.

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

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

Referenced by ilObjAssessmentFolderGUI\defaultsObject(), ilObjPortfolioGUI\initForm(), and ilCalendarCategoryGUI\initFormCategory().

{
$a_value = trim($a_value);
if ($this->getAcceptNamedColors() && substr($a_value, 0, 1) == "!")
{
parent::setValue($a_value);
}
else
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilColorPickerInputGUI::$hex
protected

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


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