From 913fa08fd22b9fdc50e540ec58aa1082d178fdeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20Schottm=C3=BCller?= Date: Wed, 1 Jun 2022 14:23:54 +0200 Subject: [PATCH] Removed session and cookie usages --- classes/TagHelper.php | 48 +++++++------------------------ dca/tl_news_archive.php | 2 +- modules/ModuleNewsArchiveTags.php | 9 ++---- modules/ModuleNewsListTags.php | 9 ++---- modules/ModuleNewsReaderTags.php | 9 ++---- modules/ModuleTagCloud.php | 21 +++++++++----- 6 files changed, 35 insertions(+), 63 deletions(-) diff --git a/classes/TagHelper.php b/classes/TagHelper.php index 1467f03..f551401 100644 --- a/classes/TagHelper.php +++ b/classes/TagHelper.php @@ -12,6 +12,8 @@ class TagHelper extends \Backend { + public static $config = array(); + /** * Load the database object */ @@ -339,11 +341,9 @@ private function getTagsForArticle($moduleArticle, $max_tags = 0, $relevance = 0 public function parseArticlesHook($objTemplate, $row) { global $objPage; - $this->import('Session'); - $news_showtags = $this->Session->get('news_showtags'); - $news_jumpto = $this->Session->get('news_jumpto'); - $tag_named_class = $this->Session->get('news_tag_named_class'); - $objTemplate->showTags = $news_showtags; + $news_showtags = static::$config['news_showtags']; + $news_jumpto = static::$config['news_jumpto']; + $tag_named_class = static::$config['news_tag_named_class']; if ($news_showtags) { $pageObj = self::getPageObj($news_jumpto); @@ -351,7 +351,7 @@ public function parseArticlesHook($objTemplate, $row) $taglist = array(); foreach ($tags as $id => $tag) { - $strUrl = StringUtil::ampersand($pageObj->getFrontendUrl($items . '/tag/' . \TagHelper::encode($tag))); + $strUrl = StringUtil::ampersand($pageObj->getFrontendUrl('/tag/' . \TagHelper::encode($tag))); $tags[$id] = '' . StringUtil::specialchars($tag) . ''; $taglist[$id] = array( 'url' => $tags[$id], @@ -373,7 +373,7 @@ public function getTagsAndTaglistForIdAndTable($id, $table, $jumpto) $taglist = array(); foreach ($tags as $id => $tag) { - $strUrl = StringUtil::ampersand($pageObj->getFrontendUrl($items . '/tag/' . \TagHelper::encode($tag))); + $strUrl = StringUtil::ampersand($pageObj->getFrontendUrl('/tag/' . \TagHelper::encode($tag))); if (strlen(\Environment::get('queryString'))) $strUrl .= "?" . \Environment::get('queryString'); $tags[$id] = '' . StringUtil::specialchars($tag) . ''; $taglist[$id] = array( @@ -393,21 +393,8 @@ public function getTagsAndTaglistForIdAndTable($id, $table, $jumpto) */ public function generateEventFeed() { - $session = $this->Session->get('calendar_feed_updater'); - - if (!is_array($session) || count($session) < 1) - { - return; - } - - $this->import('CalendarTags'); - - foreach ($session as $id) - { - $this->CalendarTags->generateFeedsByCalendar($id); - } - - $this->Session->set('calendar_feed_updater', null); + //$this->import('CalendarTags'); + //$this->CalendarTags->generateFeedsByCalendar($id); } /** @@ -415,21 +402,8 @@ public function generateEventFeed() */ public function generateNewsFeed() { - $session = $this->Session->get('news_feed_updater'); - - if (!is_array($session) || count($session) < 1) - { - return; - } - - $this->import('NewsTags'); - - foreach ($session as $id) - { - $this->NewsTags->generateFeedsByArchive($id); - } - - $this->Session->set('news_feed_updater', null); + //$this->import('NewsTags'); + //$this->NewsTags->generateFeedsByArchive($id); } } diff --git a/dca/tl_news_archive.php b/dca/tl_news_archive.php index 842055d..ade4ca4 100644 --- a/dca/tl_news_archive.php +++ b/dca/tl_news_archive.php @@ -16,7 +16,7 @@ { if (is_array($arr) && strcmp($arr[0], 'tl_news_archive') == 0 && strcmp($arr[1], 'generateFeed') == 0) { - $GLOBALS['TL_DCA']['tl_news_archive']['config']['onload_callback'][$key] = array('TagHelper', 'generateNewsFeed'); + //$GLOBALS['TL_DCA']['tl_news_archive']['config']['onload_callback'][$key] = array('TagHelper', 'generateNewsFeed'); } } } diff --git a/modules/ModuleNewsArchiveTags.php b/modules/ModuleNewsArchiveTags.php index 55a9264..9c0dc79 100644 --- a/modules/ModuleNewsArchiveTags.php +++ b/modules/ModuleNewsArchiveTags.php @@ -186,9 +186,9 @@ protected function compileFromParent($arrIds) */ protected function compile() { - $this->Session->set('news_showtags', $this->news_showtags); - $this->Session->set('news_jumpto', $this->tag_jumpTo); - $this->Session->set('news_tag_named_class', $this->tag_named_class); + \TagHelper::$config['news_showtags'] = $this->news_showtags; + \TagHelper::$config['news_jumpto'] = $this->tag_jumpTo; + \TagHelper::$config['news_tag_named_class'] = $this->tag_named_class; if ((strlen(\TagHelper::decode(\Input::get('tag'))) && (!$this->tag_ignore)) || (strlen($this->tag_filter))) { $tagids = array(); @@ -238,9 +238,6 @@ protected function compile() { parent::compile(); } - $this->Session->set('news_showtags', ''); - $this->Session->set('news_jumpto', ''); - $this->Session->set('news_tag_named_class', ''); } } diff --git a/modules/ModuleNewsListTags.php b/modules/ModuleNewsListTags.php index 9dc53d7..86167f5 100644 --- a/modules/ModuleNewsListTags.php +++ b/modules/ModuleNewsListTags.php @@ -195,9 +195,9 @@ protected function compileFromParent($arrIds) */ protected function compile() { - $this->Session->set('news_showtags', $this->news_showtags); - $this->Session->set('news_jumpto', $this->tag_jumpTo); - $this->Session->set('news_tag_named_class', $this->tag_named_class); + \TagHelper::$config['news_showtags'] = $this->news_showtags; + \TagHelper::$config['news_jumpto'] = $this->tag_jumpTo; + \TagHelper::$config['news_tag_named_class'] = $this->tag_named_class; if ((strlen(\TagHelper::decode(\Input::get('tag'))) && (!$this->tag_ignore)) || (strlen($this->tag_filter))) { $tagids = array(); @@ -247,9 +247,6 @@ protected function compile() { parent::compile(); } - $this->Session->set('news_showtags', ''); - $this->Session->set('news_jumpto', ''); - $this->Session->set('news_tag_named_class', ''); } } diff --git a/modules/ModuleNewsReaderTags.php b/modules/ModuleNewsReaderTags.php index 7623a81..22f5bcb 100644 --- a/modules/ModuleNewsReaderTags.php +++ b/modules/ModuleNewsReaderTags.php @@ -20,13 +20,10 @@ class ModuleNewsReaderTags extends \ModuleNewsReader */ protected function compile() { - $this->Session->set('news_showtags', $this->news_showtags); - $this->Session->set('news_jumpto', $this->tag_jumpTo); - $this->Session->set('news_tag_named_class', $this->tag_named_class); + \TagHelper::$config['news_showtags'] = $this->news_showtags; + \TagHelper::$config['news_jumpto'] = $this->tag_jumpTo; + \TagHelper::$config['news_tag_named_class'] = $this->tag_named_class; parent::compile(); - $this->Session->set('news_showtags', ''); - $this->Session->set('news_jumpto', ''); - $this->Session->set('news_tag_named_class', ''); } } diff --git a/modules/ModuleTagCloud.php b/modules/ModuleTagCloud.php index de36ac0..9266d69 100644 --- a/modules/ModuleTagCloud.php +++ b/modules/ModuleTagCloud.php @@ -28,13 +28,13 @@ class ModuleTagCloud extends \Module protected $checkForArticleOnPage = false; protected $checkForContentElementOnPage = false; + public static $tagCloudStates = array(); + protected function toggleTagCloud() { if (\Input::post('toggleTagCloud') == 1) { - $ts = deserialize(\Input::cookie('tagcloud_states'), true); - $ts[\Input::post('cloudPageID')][\Input::post('cloudID')] = \Input::post('display'); - $this->setCookie('tagcloud_states', serialize($ts), (time() + 60*60*24*30), $GLOBALS['TL_CONFIG']['websitePath']); + static::$tagCloudStates[\Input::post('cloudPageID')][\Input::post('cloudID')] = \Input::post('display'); } } @@ -218,10 +218,17 @@ protected function showTags() } $this->arrTopTenTags[$idx]['tag_url'] = $strUrl; } - $ts = deserialize(\Input::cookie('tagcloud_states'), true); - $this->Template->expandedTopTen = (strlen($ts[$this->id]['topten'])) ? ((strcmp($ts[$this->id]['topten'], 'none') == 0) ? 0 : 1) : $this->tag_topten_expanded; - $this->Template->expandedAll = (strlen($ts[$this->id]['alltags'])) ? ((strcmp($ts[$this->id]['alltags'], 'none') == 0) ? 0 : 1) : $this->tag_all_expanded; - $this->Template->expandedRelated = (strlen($ts[$this->id]['related'])) ? ((strcmp($ts[$this->id]['related'], 'none') == 0) ? 0 : 1) : 1; + $topten = ""; + $expandedAll = ""; + $expandedRelated = ""; + if (array_key_exists($this->id, static::$tagCloudStates)) { + $topten = static::$tagCloudStates[$this->id]['topten']; + $expandedAll = static::$tagCloudStates[$this->id]['alltags']; + $expandedRelated = static::$tagCloudStates[$this->id]['related']; + } + $this->Template->expandedTopTen = (strlen($topten)) ? ((strcmp($topten, 'none') == 0) ? 0 : 1) : $this->tag_topten_expanded; + $this->Template->expandedAll = (strlen($expandedAll)) ? ((strcmp($expandedAll, 'none') == 0) ? 0 : 1) : $this->tag_all_expanded; + $this->Template->expandedRelated = (strlen($expandedRelated)) ? ((strcmp($expandedRelated, 'none') == 0) ? 0 : 1) : 1; $this->Template->toptentags = $this->arrTopTenTags; } }