Skip to content

Commit

Permalink
Added compatibility with Contao 3.5
Browse files Browse the repository at this point in the history
Moved templates into directories
Actualized templates based on current Contao templates
Actualized classes based on current Contao classes
  • Loading branch information
hschottm committed Dec 29, 2015
1 parent d1b21de commit ec49a9b
Show file tree
Hide file tree
Showing 36 changed files with 834 additions and 267 deletions.
30 changes: 14 additions & 16 deletions config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2014 Leo Feyer
* Copyright (c) 2005-2015 Leo Feyer
*
* @package Tags
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
* @license LGPL-3.0+
*/


Expand Down Expand Up @@ -63,18 +61,18 @@
*/
TemplateLoader::addFiles(array
(
'event_default_tags' => 'system/modules/tags/templates',
'event_default_tags' => 'system/modules/tags/templates/events',
'event_full_tags' => 'system/modules/tags/templates/events',
'event_list_tags' => 'system/modules/tags/templates/events',
'mod_article_tags' => 'system/modules/tags/templates',
'mod_global_articlelist' => 'system/modules/tags/templates',
'mod_tag_contentlist' => 'system/modules/tags/templates',
'mod_tag_listbycategory' => 'system/modules/tags/templates',
'mod_tagcloud' => 'system/modules/tags/templates',
'mod_tagscope' => 'system/modules/tags/templates',
'news_full_tags' => 'system/modules/tags/templates',
'taglist' => 'system/modules/tags/templates',
'tags_feed' => 'system/modules/tags/templates',
'tags_inserttag' => 'system/modules/tags/templates',
'tags_used' => 'system/modules/tags/templates',
'mod_article_tags' => 'system/modules/tags/templates/modules',
'mod_global_articlelist' => 'system/modules/tags/templates/modules',
'mod_tag_contentlist' => 'system/modules/tags/templates/modules',
'mod_tag_listbycategory' => 'system/modules/tags/templates/modules',
'mod_tagcloud' => 'system/modules/tags/templates/modules',
'mod_tagscope' => 'system/modules/tags/templates/modules',
'news_full_tags' => 'system/modules/tags/templates/news',
'taglist' => 'system/modules/tags/templates/tags',
'tags_feed' => 'system/modules/tags/templates/tags',
'tags_inserttag' => 'system/modules/tags/templates/tags',
'tags_used' => 'system/modules/tags/templates/tags',
));
58 changes: 5 additions & 53 deletions elements/ContentGalleryTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,12 @@
class ContentGalleryTags extends ContentGallery
{
/**
* Return if there are no files
* @return string
* Generate the content element
*/
public function generate()
public function compile()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN)
{
$this->import('FrontendUser', 'User');

if ($this->User->assignDir && $this->User->homeDir)
{
$this->multiSRC = array($this->User->homeDir);
}
}
else
{
$this->multiSRC = deserialize($this->multiSRC);
}

// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC))
{
return '';
}

$newMultiSRC = array();

// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);

if ($this->objFiles === null)
{
if (!\Validator::isUuid($this->multiSRC[0]))
{
return '<p class="error">'.$GLOBALS['TL_LANG']['ERR']['version2format'].'</p>';
}

return '';
}

if ((strlen(\Input::get('tag')) && (!$this->tag_ignore)) || (strlen($this->tag_filter)))
{
$tagids = array();
Expand Down Expand Up @@ -112,25 +77,12 @@ public function generate()
}
$this->multiSRC = $newMultiSRC;
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
}

// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC))
{
return '';
}

if ($this->objFiles === null)
{
if (!\Validator::isUuid($this->multiSRC[0]))
if ($this->objFiles === null)
{
return '<p class="error">'.$GLOBALS['TL_LANG']['ERR']['version2format'].'</p>';
return '';
}

return '';
}

return parent::generate();
parent::compile();
}

protected function getFilterTags()
Expand Down
28 changes: 14 additions & 14 deletions modules/ModuleEventReaderTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ModuleEventReaderTags extends \ModuleEventReader
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;

$this->Template->event = '';
Expand All @@ -39,16 +40,11 @@ protected function compile()
// Get the current event
$objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);

if ($objEvent === null)
if (null === $objEvent)
{
// Do not index or cache the page
$objPage->noSearch = 1;
$objPage->cache = 0;

// Send a 404 header
header('HTTP/1.1 404 Not Found');
$this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
return;
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($objPage->id);
}

// Overwrite the page title (see #2853 and #4955)
Expand Down Expand Up @@ -127,17 +123,18 @@ protected function compile()
{
$size = deserialize($this->imgSize);

if ($size[0] > 0 || $size[1] > 0)
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2]))
{
$objEvent->size = $this->imgSize;
}
}

/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->cal_template);
$objTemplate->setData($objEvent->row());

$objTemplate->date = $date;
$objTemplate->start = $intStartTime;
$objTemplate->begin = $intStartTime;
$objTemplate->end = $intEndTime;
$objTemplate->class = ($objEvent->cssClass != '') ? ' ' . $objEvent->cssClass : '';
$objTemplate->recurring = $recurring;
Expand All @@ -151,7 +148,7 @@ protected function compile()
{
while ($objElement->next())
{
$objTemplate->details .= $this->getContentElement($objElement->id);
$objTemplate->details .= $this->getContentElement($objElement->current());
}
}

Expand Down Expand Up @@ -187,7 +184,7 @@ protected function compile()
$this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
}

////////// CHANGES BY ModuleEventlistTags
////////// CHANGES BY ModuleEventReaderTags
$objTemplate->showTags = $this->event_showtags;
if ($this->event_showtags)
{
Expand All @@ -199,17 +196,19 @@ protected function compile()
$objTemplate->tags = $tags;
$objTemplate->taglist = $taglist;
}
////////// CHANGES BY ModuleEventlistTags
////////// CHANGES BY ModuleEventReaderTags

$this->Template->event = $objTemplate->parse();

// HOOK: comments extension required
if ($objEvent->noComments || !in_array('comments', \ModuleLoader::getActive()))
{
$this->Template->allowComments = false;

return;
}

/** @var \CalendarModel $objCalendar */
$objCalendar = $objEvent->getRelated('pid');
$this->Template->allowComments = $objCalendar->allowComments;

Expand All @@ -235,6 +234,7 @@ protected function compile()
// Notify the author
if ($objCalendar->notify != 'notify_admin')
{
/** @var \UserModel $objAuthor */
if (($objAuthor = $objEvent->getRelated('author')) !== null && $objAuthor->email != '')
{
$arrNotifies[] = $objAuthor->email;
Expand Down
Loading

0 comments on commit ec49a9b

Please sign in to comment.