Skip to content

Commit

Permalink
Merge branch 'master' into feature/studio-create-if-deferred
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Oct 9, 2020
2 parents 6f0b976 + 96b9d4d commit 412ce3e
Show file tree
Hide file tree
Showing 206 changed files with 2,244 additions and 1,094 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -60,9 +60,9 @@ jobs:

- name: Check the coding style
run: |
vendor/bin/ecs check *-bundle/bin *-bundle/src *-bundle/tests --config vendor/contao/easy-coding-standard/config/default.yaml --no-progress-bar --ansi
vendor/bin/ecs check *-bundle/src/Resources/contao --config vendor/contao/easy-coding-standard/config/legacy.yaml --no-progress-bar --ansi
vendor/bin/ecs check *-bundle/src/Resources/contao/templates --config vendor/contao/easy-coding-standard/config/template.yaml --no-progress-bar --ansi
vendor/bin/ecs check *-bundle/bin *-bundle/src *-bundle/tests --config vendor/contao/easy-coding-standard/config/default.php --no-progress-bar --ansi
vendor/bin/ecs check *-bundle/src/Resources/contao --config vendor/contao/easy-coding-standard/config/legacy.php --no-progress-bar --ansi
vendor/bin/ecs check *-bundle/src/Resources/contao/templates --config vendor/contao/easy-coding-standard/config/template.php --no-progress-bar --ansi
- name: Analyze the code
run: |
Expand Down
4 changes: 2 additions & 2 deletions calendar-bundle/src/Resources/contao/classes/Calendar.php
Expand Up @@ -353,7 +353,7 @@ public function getSearchablePages($arrPages, $intRoot=0, $blnIsSitemap=false)
}

// The target page has not been published (see #5520)
if (!$objParent->published || ($objParent->start != '' && $objParent->start > $time) || ($objParent->stop != '' && $objParent->stop <= $time))
if (!$objParent->published || ($objParent->start && $objParent->start > $time) || ($objParent->stop && $objParent->stop <= $time))
{
continue;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ protected function addEvent($objEvent, $intStart, $intEnd, $strUrl, $strBase='')
$title .= ' ' . $objEvent->title;

// Backwards compatibility (see #8329)
if ($strBase != '' && !preg_match('#^https?://#', $strUrl))
if ($strBase && !preg_match('#^https?://#', $strUrl))
{
$strUrl = $strBase . $strUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion calendar-bundle/src/Resources/contao/classes/Events.php
Expand Up @@ -324,7 +324,7 @@ protected function addEvent($objEvents, $intStart, $intEnd, $intBegin, $intLimit
}

// Clean the RTE output
if ($arrEvent['teaser'] != '')
if ($arrEvent['teaser'])
{
$arrEvent['hasTeaser'] = true;
$arrEvent['teaser'] = StringUtil::toHtml5($arrEvent['teaser']);
Expand Down
49 changes: 46 additions & 3 deletions calendar-bundle/src/Resources/contao/dca/tl_calendar_events.php
Expand Up @@ -21,6 +21,8 @@
use Contao\Events;
use Contao\Image;
use Contao\Input;
use Contao\LayoutModel;
use Contao\PageModel;
use Contao\StringUtil;
use Contao\System;
use Contao\Versions;
Expand Down Expand Up @@ -292,7 +294,7 @@
'label' => &$GLOBALS['TL_LANG']['MSC']['serpPreview'],
'exclude' => true,
'inputType' => 'serpPreview',
'eval' => array('url_callback'=>array('tl_calendar_events', 'getSerpUrl'), 'titleFields'=>array('pageTitle', 'title'), 'descriptionFields'=>array('description', 'teaser')),
'eval' => array('url_callback'=>array('tl_calendar_events', 'getSerpUrl'), 'title_tag_callback'=>array('tl_calendar_events', 'getTitleTag'), 'titleFields'=>array('pageTitle', 'title'), 'descriptionFields'=>array('description', 'teaser')),
'sql' => null
),
'location' => array
Expand Down Expand Up @@ -704,10 +706,14 @@ public function generateAlias($varValue, DataContainer $dc)
};

// Generate the alias if there is none
if ($varValue == '')
if (!$varValue)
{
$varValue = System::getContainer()->get('contao.slug')->generate($dc->activeRecord->title, CalendarModel::findByPk($dc->activeRecord->pid)->jumpTo, $aliasExists);
}
elseif (preg_match('/^[1-9]\d*$/', $varValue))
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasNumeric'], $varValue));
}
elseif ($aliasExists($varValue))
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
Expand Down Expand Up @@ -785,6 +791,43 @@ public function getSerpUrl(CalendarEventsModel $model)
return Events::generateEventUrl($model, true);
}

/**
* Return the title tag from the associated page layout
*
* @param CalendarEventsModel $model
*
* @return string
*/
public function getTitleTag(CalendarEventsModel $model)
{
/** @var CalendarModel $calendar */
if (!$calendar = $model->getRelated('pid'))
{
return '';
}

/** @var PageModel $page */
if (!$page = $calendar->getRelated('jumpTo'))
{
return '';
}

$page->loadDetails();

/** @var LayoutModel $layout */
if (!$layout = $page->getRelated('layout'))
{
return '';
}

global $objPage;

// Set the global page object so we can replace the insert tags
$objPage = $page;

return self::replaceInsertTags(str_replace('{{page::pageTitle}}', '%s', $layout->titleTag ?: '{{page::pageTitle}} - {{page::rootPageTitle}}'));
}

/**
* Add the type of input field
*
Expand Down Expand Up @@ -898,7 +941,7 @@ public function getSourceOptions(DataContainer $dc)
}

// Add the option currently set
if ($dc->activeRecord && $dc->activeRecord->source != '')
if ($dc->activeRecord && $dc->activeRecord->source)
{
$arrOptions[] = $dc->activeRecord->source;
$arrOptions = array_unique($arrOptions);
Expand Down
Expand Up @@ -548,7 +548,7 @@ public function getAllowedCalendars()
public function checkFeedAlias($varValue, DataContainer $dc)
{
// No change or empty value
if ($varValue == $dc->value || $varValue == '')
if (!$varValue || $varValue == $dc->value)
{
return $varValue;
}
Expand Down
Expand Up @@ -253,7 +253,7 @@ protected function compile()
}

// Clean the RTE output
if ($objEvent->teaser != '')
if ($objEvent->teaser)
{
$objTemplate->hasTeaser = true;
$objTemplate->teaser = StringUtil::toHtml5($objEvent->teaser);
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function compile()
$objTemplate->addImage = false;

// Add an image
if ($objEvent->addImage && $objEvent->singleSRC != '')
if ($objEvent->addImage && $objEvent->singleSRC)
{
$objModel = FilesModel::findByUuid($objEvent->singleSRC);

Expand All @@ -306,7 +306,7 @@ protected function compile()
$arrEvent = $objEvent->row();

// Override the default image size
if ($this->imgSize != '')
if ($this->imgSize)
{
$size = StringUtil::deserialize($this->imgSize);

Expand Down Expand Up @@ -441,7 +441,7 @@ protected function compile()
}

/** @var UserModel $objAuthor */
if ($objCalendar->notify != 'notify_admin' && ($objAuthor = $objEvent->getRelated('author')) instanceof UserModel && $objAuthor->email != '')
if ($objCalendar->notify != 'notify_admin' && ($objAuthor = $objEvent->getRelated('author')) instanceof UserModel && $objAuthor->email)
{
$arrNotifies[] = $objAuthor->email;
}
Expand Down
Expand Up @@ -265,7 +265,7 @@ protected function compile()
$imgSize = false;

// Override the default image size
if ($this->imgSize != '')
if ($this->imgSize)
{
$size = StringUtil::deserialize($this->imgSize);

Expand All @@ -280,7 +280,7 @@ protected function compile()

for ($i=$offset; $i<$limit; $i++)
{
if ($arrEvents[$i]['addImage'] && $arrEvents[$i]['singleSRC'] != '')
if ($arrEvents[$i]['addImage'] && $arrEvents[$i]['singleSRC'])
{
$uuids[] = $arrEvents[$i]['singleSRC'];
}
Expand Down Expand Up @@ -350,7 +350,7 @@ protected function compile()
$objTemplate->addImage = false;

// Add an image
if ($event['addImage'] && $event['singleSRC'] != '')
if ($event['addImage'] && $event['singleSRC'])
{
$objModel = FilesModel::findByUuid($event['singleSRC']);

Expand Down Expand Up @@ -393,7 +393,7 @@ protected function compile()
}

// No events found
if ($strEvents == '')
if (!$strEvents)
{
$strEvents = "\n" . '<div class="empty">' . $strEmpty . '</div>' . "\n";
}
Expand Down
6 changes: 3 additions & 3 deletions comments-bundle/src/Resources/contao/classes/Comments.php
Expand Up @@ -122,7 +122,7 @@ public function addCommentsToTemplate(FrontendTemplate $objTemplate, \stdClass $
$objPartial->addReply = false;

// Reply
if ($objComments->addReply && $objComments->reply != '' && ($objAuthor = $objComments->getRelated('author')) instanceof UserModel)
if ($objComments->addReply && $objComments->reply && ($objAuthor = $objComments->getRelated('author')) instanceof UserModel)
{
$objPartial->addReply = true;
$objPartial->rby = $GLOBALS['TL_LANG']['MSC']['com_reply'];
Expand Down Expand Up @@ -307,7 +307,7 @@ protected function renderCommentForm(FrontendTemplate $objTemplate, \stdClass $o
$strWebsite = $arrWidgets['website']->value;

// Add http:// to the website
if (($strWebsite != '') && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite))
if ($strWebsite && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite))
{
$strWebsite = 'http://' . $strWebsite;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ protected function renderCommentForm(FrontendTemplate $objTemplate, \stdClass $o
{
$objEmail->sendTo(array_unique($varNotifies));
}
elseif ($varNotifies != '')
elseif ($varNotifies)
{
$objEmail->sendTo($varNotifies); // see #5443
}
Expand Down
2 changes: 1 addition & 1 deletion comments-bundle/src/Resources/contao/dca/tl_comments.php
Expand Up @@ -574,7 +574,7 @@ public function listComments($arrRow)

return '
<div class="comment_wrap">
<div class="cte_type ' . $key . '"><a href="mailto:' . Idna::decodeEmail($arrRow['email']) . '" title="' . StringUtil::specialchars(Idna::decodeEmail($arrRow['email'])) . '">' . $arrRow['name'] . '</a>' . (($arrRow['website'] != '') ? ' (<a href="' . $arrRow['website'] . '" title="' . StringUtil::specialchars($arrRow['website']) . '" target="_blank" rel="noreferrer noopener">' . $GLOBALS['TL_LANG']['MSC']['com_website'] . '</a>)' : '') . ' – ' . Date::parse(Config::get('datimFormat'), $arrRow['date']) . ' – IP ' . StringUtil::specialchars($arrRow['ip']) . '<br>' . $title . '</div>
<div class="cte_type ' . $key . '"><a href="mailto:' . Idna::decodeEmail($arrRow['email']) . '" title="' . StringUtil::specialchars(Idna::decodeEmail($arrRow['email'])) . '">' . $arrRow['name'] . '</a>' . ($arrRow['website'] ? ' (<a href="' . $arrRow['website'] . '" title="' . StringUtil::specialchars($arrRow['website']) . '" target="_blank" rel="noreferrer noopener">' . $GLOBALS['TL_LANG']['MSC']['com_website'] . '</a>)' : '') . ' – ' . Date::parse(Config::get('datimFormat'), $arrRow['date']) . ' – IP ' . StringUtil::specialchars($arrRow['ip']) . '<br>' . $title . '</div>
<div class="limit_height mark_links' . (!Config::get('doNotCollapse') ? ' h40' : '') . '">
' . $arrRow['comment'] . '
</div>
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Expand Up @@ -65,18 +65,18 @@
"michelf/php-markdown": "^1.4",
"nelmio/cors-bundle": "^1.5.3 || ^2.0.1",
"nelmio/security-bundle": "^2.2",
"nikic/php-parser": "^4.9",
"nyholm/psr7": "^1.2",
"ocramius/proxy-manager": "^2.1",
"paragonie/constant_time_encoding": "^2.2",
"patchwork/utf8": "^1.2",
"phpspec/php-diff": "^1.0",
"phpunit/php-token-stream": "^1.4 || ^2.0 || ^3.0",
"psr/log": "^1.0",
"ramsey/uuid": "^3.8",
"scheb/two-factor-bundle": "^4.11",
"scssphp/scssphp": "^1.0",
"simplepie/simplepie": "^1.3",
"spomky-labs/otphp": "^9.1",
"spomky-labs/otphp": "^9.1 || ^10.0",
"symfony-cmf/routing-bundle": "^2.4",
"symfony/asset": "4.4.*",
"symfony/cache": "4.4.*",
Expand Down Expand Up @@ -147,14 +147,14 @@
"require-dev": {
"ext-fileinfo": "*",
"composer/composer": "^1.0",
"contao/easy-coding-standard": "^2.0",
"contao/easy-coding-standard": "^3.0",
"contao/monorepo-tools": "dev-master",
"contao/test-case": "^4.2",
"doctrine/event-manager": "^1.0",
"monolog/monolog": "^1.24",
"phpunit/phpunit": "^8.4",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"phpunit/phpunit": "^8.4",
"psalm/plugin-phpunit": "^0.10",
"psalm/plugin-symfony": "^1.0",
"psr/event-dispatcher": "^1.0",
Expand Down Expand Up @@ -265,9 +265,9 @@
"@monorepo-tools"
],
"cs-fixer": [
"vendor/bin/ecs check *-bundle/bin *-bundle/src *-bundle/tests --config vendor/contao/easy-coding-standard/config/default.yaml --fix --ansi",
"vendor/bin/ecs check *-bundle/src/Resources/contao --config vendor/contao/easy-coding-standard/config/legacy.yaml --fix --ansi",
"vendor/bin/ecs check *-bundle/src/Resources/contao/templates --config vendor/contao/easy-coding-standard/config/template.yaml --fix --ansi"
"vendor/bin/ecs check *-bundle/bin *-bundle/src *-bundle/tests --config vendor/contao/easy-coding-standard/config/default.php --fix --ansi",
"vendor/bin/ecs check *-bundle/src/Resources/contao --config vendor/contao/easy-coding-standard/config/legacy.php --fix --ansi",
"vendor/bin/ecs check *-bundle/src/Resources/contao/templates --config vendor/contao/easy-coding-standard/config/template.php --fix --ansi"
],
"functional-tests": [
"vendor/bin/phpunit --testsuite=functional --colors=always"
Expand All @@ -279,7 +279,7 @@
"vendor/bin/phpstan analyze core-bundle/src core-bundle/tests --level=5 --memory-limit=1G --ansi"
],
"psalm": [
"vendor/bin/psalm --no-suggestions --threads=4"
"vendor/bin/psalm --no-suggestions"
],
"unit-tests": [
"vendor/bin/phpunit --colors=always"
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/composer.json
Expand Up @@ -62,17 +62,17 @@
"matthiasmullie/minify": "^1.3",
"michelf/php-markdown": "^1.4",
"nelmio/cors-bundle": "^1.5.3 || ^2.0.1",
"nikic/php-parser": "^4.9",
"nyholm/psr7": "^1.2",
"paragonie/constant_time_encoding": "^2.2",
"patchwork/utf8": "^1.2",
"phpspec/php-diff": "^1.0",
"phpunit/php-token-stream": "^1.4 || ^2.0 || ^3.0",
"psr/log": "^1.0",
"ramsey/uuid": "^3.8",
"scheb/two-factor-bundle": "^4.11",
"scssphp/scssphp": "^1.0",
"simplepie/simplepie": "^1.3",
"spomky-labs/otphp": "^9.1",
"spomky-labs/otphp": "^9.1 || ^10.0",
"symfony-cmf/routing-bundle": "^2.4",
"symfony/asset": "4.4.*",
"symfony/cache": "4.4.*",
Expand Down

0 comments on commit 412ce3e

Please sign in to comment.