public function indexAction() { $this->_helper->layout->setLayout('topmenu'); $topicService = new Service_Topic(); if (is_array($townhalls = $topicService->fetchUrlList())) { if ($name = $this->getRequest()->getParam('name', FALSE)) { if ($topic = array_search($name, $townhalls)) { $resourceService = new Service_Resource(); $articleService = new Service_Article(); $newestArticles = $articleService->fetchNewest($topic); $this->view->newest = $newestArticles; $this->view->popular = $articleService->fetchPopular($topic); $this->view->title = ucfirst($name); $this->view->resourceCount = $resourceService->fetchByTopic($topic, $this->_user->id, TRUE); $this->view->topic = $topic; return $this->render(); } } return $this->_redirect("/townhalls/home"); } else { return $this->_redirect("/error"); //Modify for Error Response Page } }
public function indexAction() { //Load Townhall Resource Page if ($topicName = $this->getRequest()->getParam('topic', FALSE)) { $topicName = strtolower($topicName); $topicService = new Service_Topic(); if (is_array($topics = $topicService->fetchUrlList())) { if ($topic = array_search($topicName, $topics)) { $this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); if (is_array($resources = $resourceService->fetchByTopic($topic))) { for ($i = 0; $i < $resources['total']; $i++) { $bookmarked = false; if (count($resources['resources'][$i]['Bookmarkers'])) { foreach ($resources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $resources['resources'][$i]['bookmarked'] = $bookmarked; } $this->view->title = ucfirst($topicName); $this->view->resources = $resources['resources']; $this->view->resourceCount = $resources['total']; return $this->render('topicResources'); } else { return $this->_redirect("/resources/error"); } } else { $this->view->error = $topics; return $this->render(); return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/error"); } //Modify for Error Response Page } else { $this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); $newestResources = $resourceService->fetchNewest(); for ($i = 0; $i < count($newestResources); $i++) { $bookmarked = false; if (count($newestResources[$i]['Bookmarkers'])) { foreach ($newestResources[$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $newestResources[$i]['bookmarked'] = $bookmarked; } $this->view->newestResources = $newestResources; $locationResources = $resourceService->fetchByState($this->_user->stateprovid); for ($i = 0; $i < $locationResources['total']; $i++) { $bookmarked = false; if (count($locationResources['resources'][$i]['Bookmarkers'])) { foreach ($locationResources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $locationResources['resources'][$i]['bookmarked'] = $bookmarked; } $this->view->localResources = $locationResources; return $this->render(); } }
public function listresourcesAction() { if ($topicName = $this->getRequest()->getParam('topic', FALSE)) { $topicService = new Service_Topic(); if (is_array($topics = $topicService->fetchUrlList())) { if ($topic = array_search($topicName, $topics)) { //$this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); if (is_array($resources = $resourceService->fetchByTopic($topic))) { for ($i = 0; $i < $resources['total']; $i++) { $bookmarked = false; if (count($resources['resources'][$i]['Bookmarkers'])) { foreach ($resources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id = $bookmarker['id']) { $bookmarked = true; break; } } } $resources['resources'][$i]['bookmarked'] = $bookmarked; $resources['resources'][$i]['userid'] = $this->_user->id; } //$this->view->title = ucfirst($topicName); $this->view->result = $resources['resources']; //$this->view->resourceCount = $resources['total']; return $this->render('friend'); } else { return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/error"); } //Modify for Error Response Page } }