Skip to content

Commit

Permalink
Correctly transfer the image size to the template (for #35 )
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffparnitzky committed Aug 19, 2021
1 parent f466b02 commit b34e355
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/Resources/contao/forms/FormCalendarField.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function parse($arrAttributes=null)
break;
case 'gtToday' : $this->minDate = "new Date().fp_incr(1)";
break;
case 'ownMinMax': $arrMinMax = deserialize($this->dateDirectionMinMax, true);
case 'ownMinMax': $arrMinMax = \StringUtil::deserialize($this->dateDirectionMinMax, true);
if (!empty($arrMinMax[0]))
{
$this->minDate = sprintf("new Date().fp_incr(%s)", $arrMinMax[0]);
Expand All @@ -88,10 +88,18 @@ public function parse($arrAttributes=null)

if ($this->dateImage) {
if (\Validator::isUuid($this->dateImageSRC)) {
$objFile = \FilesModel::findByPk($this->dateImageSRC);
$objModel = \FilesModel::findByUuid($this->dateImageSRC);

if ($objFile !== null && is_file(TL_ROOT . '/' . $objFile->path)) {
$strIcon = $objFile->path;
if ($objModel !== null && is_file(System::getContainer()->getParameter('kernel.project_dir') . '/' . $objModel->path))
{
$strIcon = $objModel->path;
$arrData = array(
'singleSRC' => $objModel->path,
'size' => $this->dateImageSize,
'alt' => $GLOBALS['TL_LANG']['MSC']['calendarfield_tooltip'],
'imageTitle' => $GLOBALS['TL_LANG']['MSC']['calendarfield_tooltip']
);
$this->addImageToTemplate($this, $arrData, null, null, $objModel);
}
}

Expand All @@ -100,7 +108,7 @@ public function parse($arrAttributes=null)
}

// add the disallowed weekdays to the template
$this->disabledWeekdays = deserialize($this->dateDisabledWeekdays, true);
$this->disabledWeekdays = \StringUtil::deserialize($this->dateDisabledWeekdays, true);

// add the disallowed days to the template
$this->disabledDays = $this->getActiveDisabledDays($dateFormat);
Expand Down Expand Up @@ -179,7 +187,7 @@ public function validator($varInput)
}

//validate disallowed weekdays
$disabledWeekdays = deserialize($this->dateDisabledWeekdays, true);
$disabledWeekdays = \StringUtil::deserialize($this->dateDisabledWeekdays, true);
if (in_array(date("w", $intTstamp), $disabledWeekdays))
{
$this->addError($GLOBALS['TL_LANG']['ERR']['calendarfield_disabled_weekday']);
Expand Down Expand Up @@ -342,7 +350,7 @@ private function dateformat_PHP_to_jQueryUI($php_format)

private function getActiveDisabledDays($dateFormat)
{
$arrDateDisabledDays = deserialize($this->dateDisabledDays, true);
$arrDateDisabledDays = \StringUtil::deserialize($this->dateDisabledDays, true);
$arrDateDisabledDaysActive = array();
foreach ($arrDateDisabledDays as $config)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (!empty($this->dateCssTheme)) {
<?php if($this->dateImage): ?>
<a class="input-button" style="cursor: pointer;" title="<?= $this->buttonText ?>" data-toggle="">
<?php if(!empty($this->buttonImage)): ?>
<img src="<?= $this->buttonImage ?>" alt="<?= $this->buttonText ?>">
<?php $this->insert('picture_default', $this->picture); ?>
<?php else: ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 17 17" style="width: 16px; height: 16px;"><g></g><path d="M14 2V1h-3v1H6V1H3v1H0v15h17V2h-3zM12 2h1v2h-1V2zM4 2h1v2H4V2zM16 16H1v-8.921h15V16zM1 6.079v-3.079h2v2h3V3h5v2h3V3h2v3.079H1z" fill="#000"></path></svg>
<?php endif; ?>
Expand Down

0 comments on commit b34e355

Please sign in to comment.