-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Contao to version 4.13 and 5.0
- Loading branch information
Showing
16 changed files
with
158 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,16 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Model; | ||
|
||
use Contao\ContentModel as ContaoContentModel; | ||
use Contao\Model\Collection; | ||
use Contao\System; | ||
|
||
/** | ||
* Content Model Extension | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class ContentModel extends \ContentModel | ||
class ContentModel extends ContaoContentModel | ||
{ | ||
/** | ||
* Find all published content elements by their parent IDs and parent table | ||
|
@@ -22,15 +26,15 @@ class ContentModel extends \ContentModel | |
* @param string $parentTable The parent table name | ||
* @param array $options An optional options array | ||
* | ||
* @return \Model\Collection|null A collection of models or null if there are no content elements | ||
* @return Collection|null A collection of models or null if there are no content elements | ||
*/ | ||
public static function findPublishedByPidsAndTable(array $parentIds, $parentTable, array $options = array()) | ||
{ | ||
$table = static::$strTable; | ||
|
||
$columns = array("$table.pid IN(" . implode(',', array_map('intval', $parentIds)) . ") AND ptable=?"); | ||
|
||
if (!BE_USER_LOGGED_IN) { | ||
if (!System::getContainer()->get('contao.security.token_checker')->isPreviewMode()) { | ||
$columns[] = "$table.invisible=''"; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,16 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Model; | ||
|
||
use Contao\Date; | ||
use Contao\Model; | ||
use Contao\System; | ||
|
||
/** | ||
* Slider Model | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class SlideModel extends \Model | ||
class SlideModel extends Model | ||
{ | ||
/** | ||
* @var string Table name | ||
|
@@ -34,8 +38,8 @@ public static function findPublishedByPid($id, $limit = 0, array $options = arra | |
$table = static::$strTable; | ||
$columns = array("$table.pid=?"); | ||
|
||
if (!empty($options['ignoreFePreview']) || !BE_USER_LOGGED_IN) { | ||
$time = \Date::floorToMinute(); | ||
if (!empty($options['ignoreFePreview']) || !System::getContainer()->get('contao.security.token_checker')->isPreviewMode()) { | ||
$time = Date::floorToMinute(); | ||
$columns[] = "($table.start='' OR $table.start<$time) AND ($table.stop='' OR $table.stop>$time) AND $table.published=1"; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,14 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Model; | ||
|
||
use Contao\Model; | ||
|
||
/** | ||
* Slider Model | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class SliderModel extends \Model | ||
class SliderModel extends Model | ||
{ | ||
/** | ||
* @var string Table name | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,25 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Module; | ||
|
||
use Contao\BackendTemplate; | ||
use Contao\File; | ||
use Contao\FilesModel; | ||
use Contao\Model\Collection; | ||
use Contao\Module; | ||
use Contao\ModuleModel; | ||
use Contao\StringUtil; | ||
use Contao\System; | ||
use MadeYourDay\RockSolidSlider\Model\SlideModel; | ||
use MadeYourDay\RockSolidSlider\Model\SliderModel; | ||
use MadeYourDay\RockSolidSlider\Model\ContentModel; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Slider Frontend Module | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class Slider extends \Module | ||
class Slider extends Module | ||
{ | ||
/** | ||
* @var string Template | ||
|
@@ -30,19 +39,19 @@ class Slider extends \Module | |
public function generate() | ||
{ | ||
// Display a wildcard in the back end | ||
if (TL_MODE === 'BE') { | ||
$template = new \BackendTemplate('be_wildcard'); | ||
if (System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest(System::getContainer()->get('request_stack')->getCurrentRequest() ?? Request::create(''))) { | ||
$template = new BackendTemplate('be_wildcard'); | ||
|
||
$template->wildcard = '### ROCKSOLID SLIDER ###'; | ||
$template->title = $this->name; | ||
$template->id = $this->id; | ||
$template->link = $this->name; | ||
$template->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; | ||
$template->href = 'contao?do=themes&table=tl_module&act=edit&id=' . $this->id; | ||
|
||
if ($this->objModel->rsts_id && ($slider = SliderModel::findByPk($this->objModel->rsts_id)) !== null) { | ||
$template->id = $slider->id; | ||
$template->link = $slider->name; | ||
$template->href = 'contao/main.php?do=rocksolid_slider&table=tl_rocksolid_slide&id=' . $slider->id; | ||
$template->href = 'contao?do=rocksolid_slider&table=tl_rocksolid_slide&id=' . $slider->id; | ||
} | ||
|
||
return $template->parse(); | ||
|
@@ -51,7 +60,7 @@ public function generate() | |
if ( | ||
$this->rsts_import_settings | ||
&& $this->rsts_import_settings_from | ||
&& ($settingsModule = \ModuleModel::findByPk($this->rsts_import_settings_from)) | ||
&& ($settingsModule = ModuleModel::findByPk($this->rsts_import_settings_from)) | ||
) { | ||
$this->objModel->imgSize = $settingsModule->imgSize; | ||
$this->objModel->fullsize = $settingsModule->fullsize; | ||
|
@@ -78,7 +87,7 @@ public function generate() | |
} | ||
else if ($this->rsts_content_type === 'rsts_images' || !$this->rsts_id) { | ||
|
||
$this->multiSRC = deserialize($this->multiSRC); | ||
$this->multiSRC = StringUtil::deserialize($this->multiSRC); | ||
if (!is_array($this->multiSRC) || !count($this->multiSRC)) { | ||
// Return if there are no images | ||
return ''; | ||
|
@@ -95,18 +104,17 @@ public function generate() | |
} | ||
|
||
if ($this->slider->type === 'image') { | ||
$this->multiSRC = deserialize($this->slider->multiSRC); | ||
$this->orderSRC = $this->slider->orderSRC; | ||
$this->multiSRC = StringUtil::deserialize($this->slider->multiSRC); | ||
} | ||
|
||
} | ||
|
||
$this->files = \FilesModel::findMultipleByUuids($this->multiSRC); | ||
$this->files = FilesModel::findMultipleByUuids($this->multiSRC); | ||
|
||
if ( | ||
$this->rsts_import_settings | ||
&& $this->rsts_import_settings_from | ||
&& ($settingsModule = \ModuleModel::findByPk($this->rsts_import_settings_from)) | ||
&& ($settingsModule = ModuleModel::findByPk($this->rsts_import_settings_from)) | ||
) { | ||
$exclude = array('rsts_import_settings', 'rsts_import_settings_from', 'rsts_content_type', 'rsts_id'); | ||
$include = array('imgSize', 'fullsize'); | ||
|
@@ -118,7 +126,7 @@ public function generate() | |
$this->arrData[$key] = $value; | ||
} | ||
} | ||
$settingsCssId = \StringUtil::deserialize($settingsModule->cssID, true); | ||
$settingsCssId = StringUtil::deserialize($settingsModule->cssID, true); | ||
if (!empty($settingsCssId[1])) { | ||
$this->arrData['cssID'][1] = ( | ||
empty($this->arrData['cssID'][1]) ? '' : $this->arrData['cssID'][1] . ' ' | ||
|
@@ -153,7 +161,7 @@ protected function compile() | |
$filesExpaned[] = $files->current(); | ||
} | ||
else { | ||
$subFiles = \FilesModel::findByPid($files->uuid); | ||
$subFiles = FilesModel::findByPid($files->uuid); | ||
while ($subFiles && $subFiles->next()) { | ||
if ($subFiles->type === 'file'){ | ||
$filesExpaned[] = $subFiles->current(); | ||
|
@@ -165,11 +173,11 @@ protected function compile() | |
foreach ($filesExpaned as $files) { | ||
|
||
// Continue if the files has been processed or does not exist | ||
if (isset($images[$files->path]) || ! file_exists(TL_ROOT . '/' . $files->path)) { | ||
if (isset($images[$files->path]) || ! file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $files->path)) { | ||
continue; | ||
} | ||
|
||
$file = new \File($files->path, true); | ||
$file = new File($files->path, true); | ||
|
||
if (!$file->isGdImage && !$file->isImage) { | ||
continue; | ||
|
@@ -193,36 +201,12 @@ protected function compile() | |
|
||
} | ||
|
||
if ($this->orderSRC) { | ||
// Turn the order string into an array and remove all values | ||
$order = deserialize($this->orderSRC); | ||
if (!$order || !is_array($order)) { | ||
$order = array(); | ||
} | ||
$order = array_flip($order); | ||
$order = array_map(function(){}, $order); | ||
|
||
// Move the matching elements to their position in $order | ||
foreach ($images as $k => $v) { | ||
if (array_key_exists($v['uuid'], $order)) { | ||
$order[$v['uuid']] = $v; | ||
unset($images[$k]); | ||
} | ||
} | ||
|
||
$order = array_merge($order, array_values($images)); | ||
|
||
// Remove empty (unreplaced) entries | ||
$images = array_filter($order); | ||
unset($order); | ||
} | ||
|
||
$images = array_values($images); | ||
|
||
foreach ($images as $key => $image) { | ||
$newImage = new \stdClass(); | ||
$image['size'] = isset($this->imgSize) ? $this->imgSize : $this->size; | ||
$this->addImageToTemplate($newImage, $image, null, substr(md5('mod_rocksolid_slider_' . $this->id), 0, 6), \FilesModel::findByPk($image['id'])); | ||
$this->addImageToTemplate($newImage, $image, null, substr(md5('mod_rocksolid_slider_' . $this->id), 0, 6), FilesModel::findByPk($image['id'])); | ||
if ($this->rsts_navType === 'thumbs') { | ||
$newImage->thumb = new \stdClass; | ||
$image['size'] = $this->rsts_thumbs_imgSize; | ||
|
@@ -402,15 +386,15 @@ protected function compile() | |
$GLOBALS['TL_JAVASCRIPT'][] = $assetsDir . '/js/rocksolid-slider.min.js|static'; | ||
$GLOBALS['TL_CSS'][] = $assetsDir . '/css/rocksolid-slider.min.css||static'; | ||
$skinPath = $assetsDir . '/css/' . (empty($this->arrData['rsts_skin']) ? 'default' : $this->arrData['rsts_skin']) . '-skin.min.css'; | ||
if (file_exists(\System::getContainer()->getParameter('contao.web_dir') . '/' . $skinPath)) { | ||
if (file_exists(System::getContainer()->getParameter('contao.web_dir') . '/' . $skinPath)) { | ||
$GLOBALS['TL_CSS'][] = $skinPath . '||static'; | ||
} | ||
} | ||
|
||
/** | ||
* Parse slides | ||
* | ||
* @param \Model\Collection $objSlides slides retrieved from the database | ||
* @param Collection $objSlides slides retrieved from the database | ||
* @return array parsed slides | ||
*/ | ||
protected function parseSlides($objSlides) | ||
|
@@ -437,8 +421,8 @@ protected function parseSlides($objSlides) | |
if ( | ||
in_array($slide['type'], array('image', 'video')) && | ||
trim($slide['singleSRC']) && | ||
($file = \FilesModel::findByUuid($slide['singleSRC'])) && | ||
($fileObject = new \File($file->path, true)) && | ||
($file = FilesModel::findByUuid($slide['singleSRC'])) && | ||
($fileObject = new File($file->path, true)) && | ||
($fileObject->isGdImage || $fileObject->isImage) | ||
) { | ||
$meta = $this->getMetaData($file->meta, $objPage->language); | ||
|
@@ -491,8 +475,8 @@ protected function parseSlides($objSlides) | |
} | ||
|
||
if ($slide['type'] === 'video' && $slide['videos']) { | ||
$videoFiles = deserialize($slide['videos'], true); | ||
$videoFiles = \FilesModel::findMultipleByUuids($videoFiles); | ||
$videoFiles = StringUtil::deserialize($slide['videos'], true); | ||
$videoFiles = FilesModel::findMultipleByUuids($videoFiles); | ||
$videos = array(); | ||
foreach ($videoFiles as $file) { | ||
$videos[] = $file; | ||
|
@@ -505,8 +489,8 @@ protected function parseSlides($objSlides) | |
|
||
if ( | ||
trim($slide['backgroundImage']) && | ||
($file = \FilesModel::findByUuid($slide['backgroundImage'])) && | ||
($fileObject = new \File($file->path, true)) && | ||
($file = FilesModel::findByUuid($slide['backgroundImage'])) && | ||
($fileObject = new File($file->path, true)) && | ||
($fileObject->isGdImage || $fileObject->isImage) | ||
) { | ||
$meta = $this->getMetaData($file->meta, $objPage->language); | ||
|
@@ -527,8 +511,8 @@ protected function parseSlides($objSlides) | |
} | ||
|
||
if ($slide['backgroundVideos']) { | ||
$videoFiles = deserialize($slide['backgroundVideos'], true); | ||
$videoFiles = \FilesModel::findMultipleByUuids($videoFiles); | ||
$videoFiles = StringUtil::deserialize($slide['backgroundVideos'], true); | ||
$videoFiles = FilesModel::findMultipleByUuids($videoFiles); | ||
$videos = array(); | ||
foreach ($videoFiles as $file) { | ||
$videos[] = $file; | ||
|
@@ -540,8 +524,8 @@ protected function parseSlides($objSlides) | |
$slide['thumb'] = new \stdClass; | ||
if ( | ||
trim($slide['thumbImage']) && | ||
($file = \FilesModel::findByUuid($slide['thumbImage'])) && | ||
($fileObject = new \File($file->path, true)) && | ||
($file = FilesModel::findByUuid($slide['thumbImage'])) && | ||
($fileObject = new File($file->path, true)) && | ||
($fileObject->isGdImage || $fileObject->isImage) | ||
) { | ||
$this->addImageToTemplate($slide['thumb'], array( | ||
|
@@ -554,8 +538,8 @@ protected function parseSlides($objSlides) | |
elseif ( | ||
in_array($slide['type'], array('image', 'video')) && | ||
trim($slide['singleSRC']) && | ||
($file = \FilesModel::findByUuid($slide['singleSRC'])) && | ||
($fileObject = new \File($file->path, true)) && | ||
($file = FilesModel::findByUuid($slide['singleSRC'])) && | ||
($fileObject = new File($file->path, true)) && | ||
($fileObject->isGdImage || $fileObject->isImage) | ||
) { | ||
$this->addImageToTemplate($slide['thumb'], array( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,15 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Module; | ||
|
||
use Contao\ModuleEventlist; | ||
use Contao\StringUtil; | ||
|
||
/** | ||
* Slider Events Module | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class SliderEvents extends \ModuleEventlist | ||
class SliderEvents extends ModuleEventlist | ||
{ | ||
const TEMPLATE_SEPARATOR = '<!-- %%%___||| RockSolid Slider Event |||___%%% -->'; | ||
|
||
|
@@ -24,7 +27,7 @@ class SliderEvents extends \ModuleEventlist | |
*/ | ||
public function getEventItems() | ||
{ | ||
$this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar, true)); | ||
$this->cal_calendar = $this->sortOutProtected(StringUtil::deserialize($this->cal_calendar, true)); | ||
|
||
// Return if there are no calendars | ||
if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,15 @@ | |
|
||
namespace MadeYourDay\RockSolidSlider\Module; | ||
|
||
use Contao\ModuleNewsList; | ||
use Contao\StringUtil; | ||
|
||
/** | ||
* Slider News Module | ||
* | ||
* @author Martin Auswöger <[email protected]> | ||
*/ | ||
class SliderNews extends \ModuleNewsList | ||
class SliderNews extends ModuleNewsList | ||
{ | ||
/** | ||
* Get an array of news articles (HTML output) generated by Contao\ModuleNewsList | ||
|
@@ -22,7 +25,7 @@ class SliderNews extends \ModuleNewsList | |
*/ | ||
public function getNewsArticles() | ||
{ | ||
$this->news_archives = $this->sortOutProtected(deserialize($this->news_archives)); | ||
$this->news_archives = $this->sortOutProtected(StringUtil::deserialize($this->news_archives)); | ||
|
||
// Return if there are no archives | ||
if (!is_array($this->news_archives) || !count($this->news_archives)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.