Skip to content

Commit

Permalink
Removed session and cookie usages
Browse files Browse the repository at this point in the history
  • Loading branch information
hschottm committed Jun 1, 2022
1 parent 2c62649 commit 913fa08
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 63 deletions.
48 changes: 11 additions & 37 deletions classes/TagHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class TagHelper extends \Backend
{
public static $config = array();

/**
* Load the database object
*/
Expand Down Expand Up @@ -339,19 +341,17 @@ 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);
$tags = $this->getTags($row['id'], 'tl_news');
$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] = '<a href="' . $strUrl . '">' . StringUtil::specialchars($tag) . '</a>';
$taglist[$id] = array(
'url' => $tags[$id],
Expand All @@ -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] = '<a href="' . $strUrl . '">' . StringUtil::specialchars($tag) . '</a>';
$taglist[$id] = array(
Expand All @@ -393,43 +393,17 @@ 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);
}

/**
* Check for modified news feeds and update the XML files if necessary
*/
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);
}
}

2 changes: 1 addition & 1 deletion dca/tl_news_archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions modules/ModuleNewsArchiveTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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', '');
}
}

9 changes: 3 additions & 6 deletions modules/ModuleNewsListTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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', '');
}
}

9 changes: 3 additions & 6 deletions modules/ModuleNewsReaderTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
}
}

21 changes: 14 additions & 7 deletions modules/ModuleTagCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 913fa08

Please sign in to comment.