diff --git a/config/autoload.php b/config/autoload.php index 6f56a50..97ce0aa 100644 --- a/config/autoload.php +++ b/config/autoload.php @@ -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+ */ @@ -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', )); diff --git a/elements/ContentGalleryTags.php b/elements/ContentGalleryTags.php index 725756c..a779aba 100644 --- a/elements/ContentGalleryTags.php +++ b/elements/ContentGalleryTags.php @@ -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 '
'.$GLOBALS['TL_LANG']['ERR']['version2format'].'
'; - } - - return ''; - } - if ((strlen(\Input::get('tag')) && (!$this->tag_ignore)) || (strlen($this->tag_filter))) { $tagids = array(); @@ -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 ''.$GLOBALS['TL_LANG']['ERR']['version2format'].'
'; + return ''; } - - return ''; } - - return parent::generate(); + parent::compile(); } protected function getFilterTags() diff --git a/modules/ModuleEventReaderTags.php b/modules/ModuleEventReaderTags.php index 8a68af3..8ae7c9e 100644 --- a/modules/ModuleEventReaderTags.php +++ b/modules/ModuleEventReaderTags.php @@ -30,6 +30,7 @@ class ModuleEventReaderTags extends \ModuleEventReader */ protected function compile() { + /** @var \PageModel $objPage */ global $objPage; $this->Template->event = ''; @@ -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 = '' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '
'; - return; + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + $objHandler->generate($objPage->id); } // Overwrite the page title (see #2853 and #4955) @@ -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; @@ -151,7 +148,7 @@ protected function compile() { while ($objElement->next()) { - $objTemplate->details .= $this->getContentElement($objElement->id); + $objTemplate->details .= $this->getContentElement($objElement->current()); } } @@ -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) { @@ -199,7 +196,7 @@ protected function compile() $objTemplate->tags = $tags; $objTemplate->taglist = $taglist; } - ////////// CHANGES BY ModuleEventlistTags + ////////// CHANGES BY ModuleEventReaderTags $this->Template->event = $objTemplate->parse(); @@ -207,9 +204,11 @@ protected function compile() 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; @@ -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; diff --git a/modules/ModuleEventlistTags.php b/modules/ModuleEventlistTags.php index 4c8735b..9088e79 100644 --- a/modules/ModuleEventlistTags.php +++ b/modules/ModuleEventlistTags.php @@ -94,24 +94,30 @@ protected function getAllEvents($arrCalendars, $intStart, $intEnd) */ protected function compile() { + /** @var \PageModel $objPage */ global $objPage; + $blnClearInput = false; + $intYear = \Input::get('year'); + $intMonth = \Input::get('month'); + $intDay = \Input::get('day'); + // Jump to the current period if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) { switch ($this->cal_format) { case 'cal_year': - \Input::setGet('year', date('Y')); + $intYear = date('Y'); break; case 'cal_month': - \Input::setGet('month', date('Ym')); + $intMonth = date('Ym'); break; case 'cal_day': - \Input::setGet('day', date('Ymd')); + $intDay = date('Ymd'); break; } @@ -120,31 +126,37 @@ protected function compile() $blnDynamicFormat = (!$this->cal_ignoreDynamic && in_array($this->cal_format, array('cal_day', 'cal_month', 'cal_year'))); - // Display year - if ($blnDynamicFormat && \Input::get('year')) - { - $this->Date = new \Date(\Input::get('year'), 'Y'); - $this->cal_format = 'cal_year'; - $this->headline .= ' ' . date('Y', $this->Date->tstamp); - } - // Display month - elseif ($blnDynamicFormat && \Input::get('month')) + // Create the date object + try { - $this->Date = new \Date(\Input::get('month'), 'Ym'); - $this->cal_format = 'cal_month'; - $this->headline .= ' ' . \Date::parse('F Y', $this->Date->tstamp); - } - // Display day - elseif ($blnDynamicFormat && \Input::get('day')) - { - $this->Date = new \Date(\Input::get('day'), 'Ymd'); - $this->cal_format = 'cal_day'; - $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $this->Date->tstamp); + if ($blnDynamicFormat && $intYear) + { + $this->Date = new \Date($intYear, 'Y'); + $this->cal_format = 'cal_year'; + $this->headline .= ' ' . date('Y', $this->Date->tstamp); + } + elseif ($blnDynamicFormat && $intMonth) + { + $this->Date = new \Date($intMonth, 'Ym'); + $this->cal_format = 'cal_month'; + $this->headline .= ' ' . \Date::parse('F Y', $this->Date->tstamp); + } + elseif ($blnDynamicFormat && $intDay) + { + $this->Date = new \Date($intDay, 'Ymd'); + $this->cal_format = 'cal_day'; + $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $this->Date->tstamp); + } + else + { + $this->Date = new \Date(); + } } - // Display all events or upcoming/past events - else + catch (\OutOfBoundsException $e) { - $this->Date = new \Date(); + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + $objHandler->generate($objPage->id); } list($strBegin, $strEnd, $strEmpty) = $this->getDatesFromFormat($this->Date, $this->cal_format); @@ -203,24 +215,20 @@ protected function compile() if ($this->perPage > 0) { $id = 'page_e' . $this->id; - $page = \Input::get($id) ?: 1; + $page = (\Input::get($id) !== null) ? \Input::get($id) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total/$this->perPage), 1)) { - global $objPage; - $objPage->noSearch = 1; - $objPage->cache = 0; - - // Send a 404 header - header('HTTP/1.1 404 Not Found'); - return; + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + $objHandler->generate($objPage->id); } $offset = ($page - 1) * $this->perPage; $limit = min($this->perPage + $offset, $total); - $objPagination = new \Pagination($total, $this->perPage, $GLOBALS['TL_CONFIG']['maxPaginationLinks'], $id); + $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id); $this->Template->pagination = $objPagination->generate("\n "); } @@ -237,7 +245,7 @@ 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])) { $imgSize = $this->imgSize; } @@ -255,6 +263,7 @@ protected function compile() $blnIsLastEvent = true; } + /** @var \FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->cal_template); $objTemplate->setData($event); @@ -282,11 +291,12 @@ protected function compile() $objTemplate->details = $event['teaser']; } - // Add template variables + // Add the template variables $objTemplate->classList = $event['class'] . ((($headerCount % 2) == 0) ? ' even' : ' odd') . (($headerCount == 0) ? ' first' : '') . ($blnIsLastEvent ? ' last' : '') . ' cal_' . $event['parent']; $objTemplate->classUpcoming = $event['class'] . ((($eventCount % 2) == 0) ? ' even' : ' odd') . (($eventCount == 0) ? ' first' : '') . ((($offset + $eventCount + 1) >= $limit) ? ' last' : '') . ' cal_' . $event['parent']; $objTemplate->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $event['title'])); $objTemplate->more = $GLOBALS['TL_LANG']['MSC']['more']; + $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location']; // Short view if ($this->cal_noSpan) @@ -405,30 +415,6 @@ protected function compile() ////////// CHANGES BY ModuleEventlistTags } - /** - * Read tags from database - * @return string - */ - protected function getFilterTags() - { - if (strlen($this->tag_filter)) - { - $tags = preg_split("/,/", $this->tag_filter); - $placeholders = array(); - foreach ($tags as $tag) - { - array_push($placeholders, '?'); - } - array_push($tags, 'tl_calendar_events'); - return $this->Database->prepare("SELECT tid FROM tl_tag WHERE tag IN (" . join($placeholders, ',') . ") AND from_table = ? ORDER BY tag ASC") - ->execute($tags) - ->fetchEach('tid'); - } - else - { - return array(); - } - } } ?> \ No newline at end of file diff --git a/modules/ModuleFaqListTags.php b/modules/ModuleFaqListTags.php index 09a0445..9560f07 100644 --- a/modules/ModuleFaqListTags.php +++ b/modules/ModuleFaqListTags.php @@ -43,7 +43,7 @@ class ModuleFaqListTags extends \ModuleFaqList { /** - * Generate module + * Generate the module */ protected function compile() { @@ -84,6 +84,7 @@ protected function compile() if ($objFaq === null) { $this->Template->faq = array(); + return; } @@ -93,12 +94,15 @@ protected function compile() while ($objFaq->next()) { $arrTemp = $objFaq->row(); - $arrTemp['title'] = specialchars($objFaq->question, true); $arrTemp['href'] = $this->generateFaqLink($objFaq); + /** @var \FaqCategoryModel $objPid */ + $objPid = $objFaq->getRelated('pid'); + $arrFaq[$objFaq->pid]['items'][] = $arrTemp; - $arrFaq[$objFaq->pid]['headline'] = $objFaq->getRelated('pid')->headline; + $arrFaq[$objFaq->pid]['headline'] = $objPid->headline; + $arrFaq[$objFaq->pid]['title'] = $objPid->title; } $arrFaq = array_values(array_filter($arrFaq)); @@ -122,6 +126,7 @@ protected function compile() $this->Template->faq = $arrFaq; } + } ?> \ No newline at end of file diff --git a/modules/ModuleNewsArchiveTags.php b/modules/ModuleNewsArchiveTags.php index 8d4445f..c584f55 100644 --- a/modules/ModuleNewsArchiveTags.php +++ b/modules/ModuleNewsArchiveTags.php @@ -71,6 +71,7 @@ protected function getFilterTags() */ protected function compileFromParent($arrIds) { + /** @var \PageModel $objPage */ global $objPage; $limit = null; @@ -102,41 +103,44 @@ protected function compileFromParent($arrIds) } } - // Display year - if ($intYear) + // Create the date object + try { - $strDate = $intYear; - $objDate = new \Date($strDate, 'Y'); - $intBegin = $objDate->yearBegin; - $intEnd = $objDate->yearEnd; - $this->headline .= ' ' . date('Y', $objDate->tstamp); - } - - // Display month - elseif ($intMonth) - { - $strDate = $intMonth; - $objDate = new \Date($strDate, 'Ym'); - $intBegin = $objDate->monthBegin; - $intEnd = $objDate->monthEnd; - $this->headline .= ' ' . \Date::parse('F Y', $objDate->tstamp); - } - - // Display day - elseif ($intDay) - { - $strDate = $intDay; - $objDate = new \Date($strDate, 'Ymd'); - $intBegin = $objDate->dayBegin; - $intEnd = $objDate->dayEnd; - $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $objDate->tstamp); + if ($intYear) + { + $strDate = $intYear; + $objDate = new \Date($strDate, 'Y'); + $intBegin = $objDate->yearBegin; + $intEnd = $objDate->yearEnd; + $this->headline .= ' ' . date('Y', $objDate->tstamp); + } + elseif ($intMonth) + { + $strDate = $intMonth; + $objDate = new \Date($strDate, 'Ym'); + $intBegin = $objDate->monthBegin; + $intEnd = $objDate->monthEnd; + $this->headline .= ' ' . \Date::parse('F Y', $objDate->tstamp); + } + elseif ($intDay) + { + $strDate = $intDay; + $objDate = new \Date($strDate, 'Ymd'); + $intBegin = $objDate->dayBegin; + $intEnd = $objDate->dayEnd; + $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $objDate->tstamp); + } + elseif ($this->news_jumpToCurrent == 'all_items') + { + $intBegin = 0; + $intEnd = time(); + } } - - // Show all items - elseif ($this->news_jumpToCurrent == 'all_items') + catch (\OutOfBoundsException $e) { - $intBegin = 0; - $intEnd = time(); + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + #$objHandler->generate($objPage->id); } $this->Template->articles = array(); @@ -153,18 +157,14 @@ protected function compileFromParent($arrIds) // Get the current page $id = 'page_a' . $this->id; - $page = \Input::get($id) ?: 1; + $page = (\Input::get($id) !== null) ? \Input::get($id) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total/$this->perPage), 1)) { - global $objPage; - $objPage->noSearch = 1; - $objPage->cache = 0; - - // Send a 404 header - header('HTTP/1.1 404 Not Found'); - return; + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + $objHandler->generate($objPage->id); } // Set limit and offset diff --git a/modules/ModuleNewsListTags.php b/modules/ModuleNewsListTags.php index 2aabae1..82c913f 100644 --- a/modules/ModuleNewsListTags.php +++ b/modules/ModuleNewsListTags.php @@ -61,8 +61,8 @@ protected function getFilterTags() */ protected function compileFromParent($arrIds) { - $offset = intval($this->skipFirst); $limit = null; + $offset = intval($this->skipFirst); // Maximum number of items if ($this->numberOfItems > 0) @@ -108,18 +108,17 @@ protected function compileFromParent($arrIds) // Get the current page $id = 'page_n' . $this->id; - $page = \Input::get($id) ?: 1; + $page = (\Input::get($id) !== null) ? \Input::get($id) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total/$this->perPage), 1)) { + /** @var \PageModel $objPage */ global $objPage; - $objPage->noSearch = 1; - $objPage->cache = 0; - // Send a 404 header - header('HTTP/1.1 404 Not Found'); - return; + /** @var \PageError404 $objHandler */ + $objHandler = new $GLOBALS['TL_PTY']['error_404'](); + $objHandler->generate($objPage->id); } // Set limit and offset @@ -155,7 +154,6 @@ protected function compileFromParent($arrIds) } $this->Template->archives = $this->news_archives; - // new code for tags $relatedlist = (strlen(\Input::get('related'))) ? preg_split("/,/", \Input::get('related')) : array(); $headlinetags = array(); diff --git a/modules/ModuleTagCloud.php b/modules/ModuleTagCloud.php index 208549b..c232767 100644 --- a/modules/ModuleTagCloud.php +++ b/modules/ModuleTagCloud.php @@ -155,10 +155,6 @@ protected function showTags() { $this->arrTags[$idx]['tag_class'] .= ' active'; } - if (in_array($tag['tag_name'], (strlen(\Input::get('related'))) ? preg_split("/,/", \Input::get('related')) : array())) - { - $this->arrTags[$idx]['tag_class'] .= ' related'; - } if ($this->checkForArticleOnPage) { global $objPage; diff --git a/templates/events/event_default_tags.html5 b/templates/events/event_default_tags.html5 new file mode 100644 index 0000000..9c9885b --- /dev/null +++ b/templates/events/event_default_tags.html5 @@ -0,0 +1,57 @@ + +date; ?>
+recurring): ?> + +recurring; if ($this->until): ?> until; endif; ?>.
+ + +date; ?>
+recurring): ?> + +recurring; if ($this->until): ?> until; endif; ?>.
+ + +date; ?>
+= $this->date ?>
recurring): ?> -recurring; if ($this->until): ?> until; endif; ?>.
+= $this->recurring ?>until) echo ' ' . $this->until; ?>.
details): ?> - details; ?> + = $this->details ?>locationLabel; ?>: location; ?>
+= $this->locationLabel ?>: = $this->location ?>
enclosure): ?>date; ?>
+= $this->date ?>
recurring): ?> -recurring; if ($this->until): ?> until; endif; ?>.
+= $this->recurring ?>until) echo ' ' . $this->until; ?>.
details): ?> - details; ?> + = $this->details ?>locationLabel; ?>: location; ?>
+= $this->locationLabel ?>: = $this->location ?>
enclosure): ?>time . $this->span; ?>
+= $this->time . $this->span ?>
-time . $this->span; ?>
+= $this->time . $this->span ?>
-empty; ?>
+ + +empty; ?>
+ + += $this->author ?> = $this->commentCount ?>
+ + + hasSubHeadline): ?> += $this->date ?> = $this->author ?> = $this->commentCount ?>
+ + + hasSubHeadline): ?> +