public function showAllNews($NewsList, $news, $loginPage, $Message, $checkUserFlow = false) { $contentString = ''; $showYourFlow = ''; $currentAction = NewsView::getAction(); if ($currentAction == 'sport') { $flowID = $this->getSportID(); } else { $flowID = $this->getPleasureID(); } if ($this->loginModel->loginstatus()) { $showYourFlow = "<a href='?userflow'>Visa egna flödet</a>"; if ($news == 'Sport' || $news == 'Nöje') { if (!$checkUserFlow) { $contentString .= "</br><a id='follow' href='?" . $currentAction . "=" . $flowID . "&follow'>Följ</a>"; } else { $contentString .= "</br><a id='follow' href='?" . $currentAction . "=" . $flowID . "&stopfollow'>Sluta följ</a>"; } } } if ($NewsList == true) { foreach ($NewsList as $flow) { foreach ($flow->channel->item as $item) { $contentString .= "<ul id='article'>\n\t\t\t\t<a href='" . $item->link . "'><h2>" . $item->title . "</h2></a>\n\t\t\t\t<p><b>" . $item->description . "</b></p>\n\t\t\t\t<p>" . $item->pubDate . "</p>\n\n\t\t\t\t</ul>"; } } } else { $contentString .= '<h2>Något gick fel när data skulle hämtas ut.</h2>'; } $ret = "\n\t\t\t\t<h1>{$Message}</h1>\n\t\t\t\t{$loginPage} </br>\n\t\t\t\t<h1>" . $news . "</h1>\n\t\t\t\t<div id='meny'>\n\t\t\t\t\t<a href='?'>Visa alla nyheter</a>\n\t\t\t\t\t<a href='?sport=1'>Visa sportnyheter</a>\n\t\t\t\t\t<a href='?pleasure=2'>Visa nöjesNyheter</a>\n\t\t\t\t\t{$showYourFlow}\n\t\t\t\t</div>\n\t\t\t\t{$contentString}\n\t\t"; return $ret; }
public function doNews($loginPage, $operationSuccess = FALSE) { $Message = ''; try { if ($operationSuccess) { $Message = "Registreringen lyckades!"; } switch (NewsView::getAction()) { case NewsView::$actionStopFollow: $currentAction = $this->checkAction(); $userID = $this->loginmodel->getUserID(); $this->userflowmodel->deleteUserFlow($userID, $currentAction); $AllNewsList = $this->flowModel->getAllFlow(); $this->News = $this->allnews; $result = $this->view->showAllNews($AllNewsList, $this->News, $loginPage, $Message); return $result; break; case NewsView::$actionFollow: $currentAction = $this->checkAction(); $userID = $this->loginmodel->getUserID(); $this->userflowmodel->addUserFlow($userID, $currentAction); $UserFlowList = $this->userflowmodel->getFlowWithUserID($userID); $this->News = $this->userFlow; $result = $this->view->showAllNews($UserFlowList, $this->News, $loginPage, $Message); return $result; break; case NewsView::$actionSport: $userID = $this->loginmodel->getUserID(); $currentAction = $this->view->getSportID(); if ($this->loginmodel->loginstatus()) { $this->checkUserFlow = $this->checkUserFlow($userID, $currentAction); } $this->FlowTypeID = $this->view->getSportID(); $SportList = $this->flowModel->getFlowWithTypeID($this->FlowTypeID); $this->News = $this->sport; $result = $this->view->showAllNews($SportList, $this->News, $loginPage, $Message, $this->checkUserFlow); return $result; break; case NewsView::$actionPleasure: $userID = $this->loginmodel->getUserID(); $currentAction = $this->view->getPleasureID(); if ($this->loginmodel->loginstatus()) { $this->checkUserFlow = $this->checkUserFlow($userID, $currentAction); } $this->FlowTypeID = $this->view->getPleasureID(); $PleasureList = $this->flowModel->getFlowWithTypeID($this->FlowTypeID); $this->News = $this->Pleasure; $result = $this->view->showAllNews($PleasureList, $this->News, $loginPage, $Message, $this->checkUserFlow); return $result; break; case NewsView::$actionUserFlow: $userID = $this->loginmodel->getUserID(); $UserFlowList = $this->userflowmodel->getFlowWithUserID($userID); $this->News = $this->userFlow; $result = $this->view->showAllNews($UserFlowList, $this->News, $loginPage, $Message); return $result; break; case NewsView::$actionNews: default: $AllNewsList = $this->flowModel->getAllFlow(); $this->News = $this->allnews; $result = $this->view->showAllNews($AllNewsList, $this->News, $loginPage, $Message); return $result; break; } } catch (Exception $e) { die($e->getMessage()); } }