예제 #1
0
파일: HomeView.php 프로젝트: amanai/next24
    function viewNewsPage($user_id)
    {
        $htmlPage = "";
        $user_id = (int) $user_id;
        $newsModel = new NewsModel();
        $newsView = new NewsView();
        $aNewsSubscribe = $newsModel->getNewsSubscribeByUserId($user_id);
        if (!$aNewsSubscribe) {
            $aNewsTree = $newsView->getAllNewsTree();
            $isOnlySubscribeNewsTree = false;
        } else {
            $aNewsTree = $newsView->getNewsTreeByListNewsSubscribe($aNewsSubscribe);
            $isOnlySubscribeNewsTree = true;
        }
        $htmlPage = '<ul class="content-preview-list">';
        foreach ($aNewsTree as $newsTree) {
            /*    $newsCount = $newsView -> getNewsCountByNewsTreeId($newsTree['id'], $user_id, $isOnlySubscribeNewsTree);
                    if ($newsCount < 1) continue;
                    $htmlPage .= '
                 	<!-- Категория -->
                 	<div class="block_ee1"><div class="block_ee2"><div class="block_ee3"><div class="block_ee4">
                 		<div class="block_title">
                 			<div class="block_title_left">
                 			   <h2>
                 			   '.$newsView->ShowNewsTreeBreadCrumbByNewsTreeId($newsTree['id'], false).' (<a href="'.Project::getRequest()->createUrl('News', 'News', null, false).'/shownow:allnews/filterNewsTree:'.$newsTree['id'].'">все новости ['.$newsCount.']</a>)
                 			   </h2>
                 			</div>
                 			<div class="block_title_right"><img src="'.$this -> image_url.'close.png" width="21" height="24" onclick="ShowOrHide(this, \'rss_cat_n'.$newsTree['id'].'\')" style="cursor: pointer;" /></div>
                 		</div>'; */
            $htmlPage .= '<li class="expanded-view">
						<h3><a href="#">МИД России: Тбилиси выдает желаемое за действительное <img src="assets/i/temp/temp.1.jpg" alt="МИД России: Тбилиси выдает желаемое за действительное" /></a></h3>
						<p>В Москве опровергают сообщения о том, что якобы минувшим днем российские войска в Южной Осетии вели огонь по грузинской территории... <a href="#">»</a></p>
						<div class="meta">
							<span class="auth">Вести.Ru</span>
							<span class="date">20 минут назад</span>
						</div>
					</li>';
            /*		$htmlPage .= '<div id="rss_cat_n'.$newsTree['id'].'">'.
                          $newsView->ShowNewsListPreviewByNewsTreeId($newsTree['id'], 'full', $user_id, 4, array(), $isOnlySubscribeNewsTree).'
               		   <div class="rmb14"></div>
               		</div>
               
               	</div></div></div></div>
               	<!-- /Категория -->
                  '; */
        }
        $htmlPage .= '</ul>';
        return $htmlPage;
    }
 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());
     }
 }
예제 #4
0
 public function NewsAction()
 {
     $newsModel = new NewsModel();
     $request = Project::getRequest();
     $user = Project::getUser()->getDbUser();
     if (!$user->id) {
         $user->id = 0;
     }
     $isAdmin = $user->user_type_id == 1 ? true : false;
     $isPartner = $user->user_type_id == 4 ? true : false;
     $isTabsSnow = false;
     // if !$isTabsSnow you can show tabs
     //  view type and filters
     switch ($request->view) {
         // View type
         case 'full':
             // full news list
             $_SESSION['newsViewType'] = 'full';
             break;
         case 'report':
             // report news list
             $_SESSION['newsViewType'] = 'report';
             break;
         case 'news_all':
             // no filter, all news
             $_SESSION['newsViewFilter'] = 'news_all';
             break;
         case 'news_subscribe':
             // filter, only subscribe news
             $_SESSION['newsViewFilter'] = 'news_subscribe';
             break;
         case 'news_stared':
             // filter, only news star
             $_SESSION['newsViewFilter'] = 'news_stared';
             break;
     }
     $_SESSION['newsViewType'] = $_SESSION['newsViewType'] ? $_SESSION['newsViewType'] : 'report';
     $_SESSION['newsViewFilter'] = $_SESSION['newsViewFilter'] ? $_SESSION['newsViewFilter'] : 'news_subscribe';
     switch ($_SESSION['newsViewType']) {
         // View type
         case 'full':
             // full news list
             $viewCheckedClass = array('viewCheckedClass', '');
             break;
         case 'report':
             // report news list
             $viewCheckedClass = array('', 'viewCheckedClass');
             break;
     }
     switch ($_SESSION['newsViewFilter']) {
         // View filter
         case 'news_all':
             // no filter, all news
             $newsViewFilter = array('viewCheckedClass', '', '');
             $isOnlyFavoriteNews = false;
             $isOnlySubscribeNewsTree = false;
             break;
         case 'news_subscribe':
             // filter, only subscribe news
             $newsViewFilter = array('', 'viewCheckedClass', '');
             $isOnlyFavoriteNews = false;
             $isOnlySubscribeNewsTree = true;
             break;
         case 'news_stared':
             // filter, only news star
             $newsViewFilter = array('', '', 'viewCheckedClass');
             $isOnlyFavoriteNews = true;
             $isOnlySubscribeNewsTree = false;
             break;
     }
     if (!$user->id) {
         // if NOT REGISTRED USER
         $this->_view->assign('newsViewFilter', 'news_all');
         $isOnlyFavoriteNews = false;
         $isOnlySubscribeNewsTree = false;
     } else {
         $this->_view->assign('newsViewFilter', $_SESSION['newsViewFilter']);
     }
     if ($request->shownow == 'allnews') {
         // if click on "(все новости [15])"
         $this->_view->assign('newsViewType', 'full');
         $this->_view->assign('nShowRows', 0);
         // Show all news records
         if (!$isTabsSnow) {
             $newsViewModel = new NewsView();
             if ($request->filterNewsTreeFeeds) {
                 $breadCrumb = $newsViewModel->ShowNewsTreeBreadCrumbByNewsTreeFeedsId($request->filterNewsTreeFeeds, false);
             } else {
                 $breadCrumb = $newsViewModel->ShowNewsTreeBreadCrumbByNewsTreeId($request->filterNewsTree, false);
             }
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, false, false, false, false, false, array(), true, $breadCrumb));
             // Show tabs
             $isTabsSnow = true;
         }
     } else {
         $this->_view->assign('newsViewType', $_SESSION['newsViewType']);
         $this->_view->assign('nShowRows', 4);
         // Show all news records
     }
     $this->_view->assign('shownow', $request->shownow);
     $this->_view->assign('viewCheckedClass', $viewCheckedClass);
     $this->_view->assign('viewFilterCheckedClass', $newsViewFilter);
     // END view type and filters
     $this->_view->assign('user_id', $user->id);
     $this->_view->assign('isAdmin', $isAdmin);
     $this->_view->assign('isPartner', $isPartner);
     $news_tree_id = $request->news_tree_id;
     if ($request->news_id) {
         if ($isAdmin) {
             $isNewsTreeActive = false;
             $isNewsBannersActive = false;
         } else {
             $isNewsTreeActive = true;
             $isNewsBannersActive = true;
         }
         $news = $newsModel->getNewsById($request->news_id, $user->id, $isNewsTreeActive, $isNewsBannersActive);
         if (!$news) {
             Project::getResponse()->redirect(Project::getRequest()->createUrl('News', 'News'));
         }
         $this->_view->assign('news', $news);
         $tabsNews = array("title" => $newsModel->getNWordsFromText($news['news_title'], 7), "id" => $request->news_id);
         if (!$isTabsSnow) {
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, false, false, false, false, true, $tabsNews));
             // Show tabs
             $isTabsSnow = true;
         }
         $this->_view->assign('isShowOneNews', true);
         $newsModel->setNews_Views($request->news_id, 1);
     } else {
         if (!$isTabsSnow) {
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, true));
             // Show tabs
             $isTabsSnow = true;
         }
         $this->_view->assign('isShowOneNews', false);
     }
     $aNewsTreeList = $newsModel->getAllNews();
     $this->_view->assign('news_tree_list', $aNewsTreeList);
     // all News tree
     $this->_view->assign('filterNewsTree', $request->filterNewsTree);
     // filter by News tree ID
     $this->_view->assign('filterNewsTreeFeeds', $request->filterNewsTreeFeeds);
     // filter by News tree feeds ID
     // PAGER
     $news_per_page = $this->getParam("NEWS_PER_PAGE");
     $pager_view = new SitePagerView();
     if ($request->filterNewsTreeFeeds) {
         // pager for All news , filterNewsTreeFeeds
         $news_count = $newsModel->getNewsCountByNewsTreeFeedsId($request->filterNewsTreeFeeds, $user->id, $isOnlySubscribeNewsTree, $isOnlyFavoriteNews);
         $pages_number = $pager_view->getPagesNumber($news_count, $news_per_page);
         $current_page_number = $request->getKeyByNumber(2);
         $news_pager = $pager_view->show3('News', 'News', array("shownow" => "allnews", "filterNewsTreeFeeds" => $request->filterNewsTreeFeeds), $pages_number, $current_page_number);
         $this->_view->assign('news_tree_pager', $news_pager);
         $this->_view->assign('page_settings', array("record_per_page" => $news_per_page, "current_page_number" => $current_page_number + 1));
     } elseif ($request->filterNewsTree) {
         // pager for All news , filterNewsTree
         $news_count = $newsModel->getNewsCountByNewsTreeId($request->filterNewsTree, $user->id, $isOnlySubscribeNewsTree, $isOnlyFavoriteNews);
         $pages_number = $pager_view->getPagesNumber($news_count, $news_per_page);
         $current_page_number = $request->getKeyByNumber(2);
         $news_pager = $pager_view->show3('News', 'News', array("shownow" => "allnews", "filterNewsTree" => $request->filterNewsTree), $pages_number, $current_page_number);
         $this->_view->assign('news_tree_pager', $news_pager);
         $this->_view->assign('page_settings', array("record_per_page" => $news_per_page, "current_page_number" => $current_page_number + 1));
     }
     // END PAGER
     $aNewsSubscribe = $newsModel->getNewsSubscribeByUserId($user->id);
     $this->_view->assign('aNewsSubscribe', $aNewsSubscribe);
     // all NewsSubscribe
     switch ($request->view) {
         // View type
         /*        case 'full': // full news list
         	           $_SESSION['newsViewType'] = 'full';
         	           break;
         	        case 'report': // report news list
         	           $_SESSION['newsViewType'] = 'report';
         	           break;
         	         */
         case 'news_all':
             // no filter, all news
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, true, false, false, false, false, $tabsNews));
             // Show tabs
             break;
         case 'news_subscribe':
             // filter, only subscribe news
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, false, false, true, false, false, $tabsNews));
             // Show tabs
             break;
         case 'news_stared':
             // filter, only news star
             $this->_view->assign('tab_list', TabController::getNewsTabs($user->id, $isAdmin, false, false, false, false, false, $tabsNews, false, false, false, false, false, true));
             // Show tabs
             break;
     }
     $this->_view->NewsPage();
     $this->_view->parse();
 }
예제 #5
0
 public function actionOne()
 {
     $view = new NewsView();
     $view->item = NewsModel::get($_GET['id']);
     $view->display($this->path);
 }