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 removeresourcebookmarkAction() { if ($this->getRequest()->isPost() && $this->_ajaxRequest) { if ($resource = $this->getRequest()->getParam('resource', FALSE)) { $resourceService = new Service_Resource(); if ($resourceService->removeBookmark($resource, $this->_user->id)) { $this->_response->appendBody('1'); return; } else { $this->_response->appendBody('0'); return; } } else { $this->_response->appendBody('0'); return; } } }
public function searchAction() { if ($this->getRequest()->isGet()) { if ($terms = $this->getRequest()->getParam('searchTerms', FALSE)) { $resourceService = new Service_Resource(); if (is_array($results = $resourceService->searchResources($terms))) { $this->_helper->layout->setLayout('topmenu'); for ($i = 0; $i < count($results); $i++) { $bookmarked = false; if (count($results[$i]['Bookmarkers'])) { foreach ($results[$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $results[$i]['bookmarked'] = $bookmarked; } $result['root'] = $results; $this->view->searchTerms = $terms; $this->view->resultTotal = count($results); $this->view->searchNoPerPage = 10; $this->view->resources = $result; return $this->render('searchresults'); } } } else { $this->render('searchresults'); } }
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 } }