Skip to content

Commit 6618a1e

Browse files
committed
Add colorpicker support
1 parent 402d449 commit 6618a1e

1 file changed

Lines changed: 51 additions & 23 deletions

File tree

system/modules/multicolumnwizard/MultiColumnWizard.php

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ public function generate()
403403

404404
$arrUnique = array();
405405
$arrDatepicker = array();
406+
$arrColorpicker = array();
406407
$arrTinyMCE = array();
407408
$arrHeaderItems = array();
408409

@@ -420,6 +421,12 @@ public function generate()
420421
$arrDatepicker[] = $strKey;
421422
}
422423

424+
// Store color picker fields
425+
if ($arrField['eval']['colorpicker'])
426+
{
427+
$arrColorpicker[] = $strKey;
428+
}
429+
423430
// Store tiny mce fields
424431
if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0)
425432
{
@@ -512,6 +519,7 @@ public function generate()
512519
else
513520
{
514521
$datepicker = '';
522+
$colorpicker = '';
515523
$tinyMce = '';
516524

517525
// Datepicker
@@ -537,21 +545,19 @@ public function generate()
537545

538546
$datepicker = ' <img src="system/modules/multicolumnwizard/html/img/datepicker.gif" width="20" height="20" alt="" id="toggle_' . $objWidget->id . '" style="vertical-align:-6px;">
539547
<script>
540-
541-
window.datepicker_' . $this->strName . '_' . $strKey . ' = new DatePicker(\'#ctrl_' . $objWidget->id . '\', {
542-
allowEmpty:true,
543-
toggleElements:\'#toggle_' . $objWidget->id . '\',
544-
pickerClass:\'datepicker_dashboard\',
545-
format:\'' . $format . '\',
546-
inputOutputFormat:\'' . $format . '\',
547-
positionOffset:{x:130,y:-185}' . $time . ',
548-
startDay:' . $GLOBALS['TL_LANG']['MSC']['weekOffset'] . ',
549-
days:[\'' . implode("','", $GLOBALS['TL_LANG']['DAYS']) . '\'],
550-
dayShort:' . $GLOBALS['TL_LANG']['MSC']['dayShortLength'] . ',
551-
months:[\'' . implode("','", $GLOBALS['TL_LANG']['MONTHS']) . '\'],
552-
monthShort:' . $GLOBALS['TL_LANG']['MSC']['monthShortLength'] . '
548+
window.datepicker_' . $this->strName . '_' . $strKey . ' = new DatePicker(\'#ctrl_' . $objWidget->id . '\', {
549+
allowEmpty:true,
550+
toggleElements:\'#toggle_' . $objWidget->id . '\',
551+
pickerClass:\'datepicker_dashboard\',
552+
format:\'' . $format . '\',
553+
inputOutputFormat:\'' . $format . '\',
554+
positionOffset:{x:130,y:-185}' . $time . ',
555+
startDay:' . $GLOBALS['TL_LANG']['MSC']['weekOffset'] . ',
556+
days:[\'' . implode("','", $GLOBALS['TL_LANG']['DAYS']) . '\'],
557+
dayShort:' . $GLOBALS['TL_LANG']['MSC']['dayShortLength'] . ',
558+
months:[\'' . implode("','", $GLOBALS['TL_LANG']['MONTHS']) . '\'],
559+
monthShort:' . $GLOBALS['TL_LANG']['MSC']['monthShortLength'] . '
553560
});
554-
555561
</script>';
556562

557563
$datepicker = $this->getMcWDatePickerString($objWidget->id, $strKey, $rgxp);
@@ -562,6 +568,28 @@ public function generate()
562568
});
563569
</script>'; */
564570
}
571+
572+
// Color picker
573+
if ($arrField['eval']['colorpicker'])
574+
{
575+
// Support single fields as well (see #5240)
576+
//$strKey = $arrData['eval']['multiple'] ? $this->strField . '_0' : $this->strField;
577+
578+
$colorpicker = ' ' . \Image::getHtml('pickcolor.gif', $GLOBALS['TL_LANG']['MSC']['colorpicker'], 'style="vertical-align:top;cursor:pointer" title="'.specialchars($GLOBALS['TL_LANG']['MSC']['colorpicker']).'" id="moo_' . $objWidget->id . '"') . '
579+
<script>
580+
window.addEvent("domready", function() {
581+
new MooRainbow("moo_' . $objWidget->id . '", {
582+
id: "ctrl_' . $objWidget->id . '",
583+
startColor: ((cl = $("ctrl_' . $objWidget->id . '").value.hexToRgb(true)) ? cl : [255, 0, 0]),
584+
imgPath: "assets/mootools/colorpicker/' . $GLOBALS['TL_ASSETS']['COLORPICKER'] . '/images/",
585+
onComplete: function(color) {
586+
$("ctrl_' . $objWidget->id . '").value = color.hex.replace("#", "");
587+
}
588+
});
589+
});
590+
</script>';
591+
}
592+
565593

566594
// Tiny MCE
567595
if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0)
@@ -596,7 +624,7 @@ public function generate()
596624
$objWidget->wizard = $wizard;
597625
}
598626

599-
$strWidget = $objWidget->parse() . $datepicker . $tinyMce;
627+
$strWidget = $objWidget->parse() . $datepicker . $colorpicker . $tinyMce;
600628
}
601629

602630
// Build array of items
@@ -624,17 +652,17 @@ public function generate()
624652

625653
if ($this->blnTableless)
626654
{
627-
$strOutput = $this->generateDiv($arrUnique, $arrDatepicker, $strHidden, $arrItems, $arrHiddenHeader);
655+
$strOutput = $this->generateDiv($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
628656
}
629657
else
630658
{
631659
if ($this->columnTemplate != '')
632660
{
633-
$strOutput = $this->generateTemplateOutput($arrUnique, $arrDatepicker, $strHidden, $arrItems, $arrHiddenHeader);
661+
$strOutput = $this->generateTemplateOutput($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
634662
}
635663
else
636664
{
637-
$strOutput = $this->generateTable($arrUnique, $arrDatepicker, $strHidden, $arrItems, $arrHiddenHeader);
665+
$strOutput = $this->generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
638666
}
639667
}
640668

@@ -1039,7 +1067,7 @@ public function addDataToFieldAtIndex($intIndex, $strField, $arrData)
10391067
* @param array
10401068
* @return string
10411069
*/
1042-
protected function generateTable($arrUnique, $arrDatepicker, $strHidden, $arrItems, $arrHiddenHeader = array())
1070+
protected function generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader = array())
10431071
{
10441072

10451073
// generate header fields
@@ -1065,7 +1093,7 @@ protected function generateTable($arrUnique, $arrDatepicker, $strHidden, $arrIte
10651093

10661094

10671095
$return = '
1068-
<table cellspacing="0" ' . (($this->style) ? ('style="' . $this->style . '"') : ('')) . 'rel="maxCount[' . ($this->maxCount ? $this->maxCount : '0') . '] minCount[' . ($this->minCount ? $this->minCount : '0') . '] unique[' . implode(',', $arrUnique) . '] datepicker[' . implode(',', $arrDatepicker) . ']" cellpadding="0" id="ctrl_' . $this->strId . '" class="tl_modulewizard multicolumnwizard" summary="MultiColumnWizard">';
1096+
<table cellspacing="0" ' . (($this->style) ? ('style="' . $this->style . '"') : ('')) . 'rel="maxCount[' . ($this->maxCount ? $this->maxCount : '0') . '] minCount[' . ($this->minCount ? $this->minCount : '0') . '] unique[' . implode(',', $arrUnique) . '] datepicker[' . implode(',', $arrDatepicker) . ']" colorpicker[' . implode(',', $arrColorpicker) . ']" cellpadding="0" id="ctrl_' . $this->strId . '" class="tl_modulewizard multicolumnwizard" summary="MultiColumnWizard">';
10691097

10701098
if ($this->columnTemplate == '')
10711099
{
@@ -1117,7 +1145,7 @@ protected function generateTable($arrUnique, $arrDatepicker, $strHidden, $arrIte
11171145
return $return;
11181146
}
11191147

1120-
protected function generateTemplateOutput($arrUnique, $arrDatepicker, $strHidden, $arrItems)
1148+
protected function generateTemplateOutput($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems)
11211149
{
11221150
$objTemplate = new BackendTemplate($this->columnTemplate);
11231151
$objTemplate->items = $arrItems;
@@ -1140,7 +1168,7 @@ protected function generateTemplateOutput($arrUnique, $arrDatepicker, $strHidden
11401168
* @param array
11411169
* @return string
11421170
*/
1143-
protected function generateDiv($arrUnique, $arrDatepicker, $strHidden, $arrItems, $arrHiddenHeader = array())
1171+
protected function generateDiv($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader = array())
11441172
{
11451173
// generate header fields
11461174
foreach ($this->columnFields as $strKey => $arrField)
@@ -1154,7 +1182,7 @@ protected function generateDiv($arrUnique, $arrDatepicker, $strHidden, $arrItems
11541182
}
11551183

11561184

1157-
$return = '<div' . (($this->style) ? (' style="' . $this->style . '"') : '') . ' rel="maxCount[' . ($this->maxCount ? $this->maxCount : '0') . '] minCount[' . ($this->minCount ? $this->minCount : '0') . '] unique[' . implode(',', $arrUnique) . '] datepicker[' . implode(',', $arrDatepicker) . ']" id="ctrl_' . $this->strId . '" class="tl_modulewizard multicolumnwizard">';
1185+
$return = '<div' . (($this->style) ? (' style="' . $this->style . '"') : '') . ' rel="maxCount[' . ($this->maxCount ? $this->maxCount : '0') . '] minCount[' . ($this->minCount ? $this->minCount : '0') . '] unique[' . implode(',', $arrUnique) . '] datepicker[' . implode(',', $arrDatepicker) . '] colorpicker[' . implode(',', $arrColorpicker) . ']" id="ctrl_' . $this->strId . '" class="tl_modulewizard multicolumnwizard">';
11581186
$return .= '<div class="header_fields">' . implode('', $arrHeaderItems) . '</div>';
11591187

11601188

0 commit comments

Comments
 (0)