/**
  * Shows the recent news item on /news
  */
 public function homeAction()
 {
     $cache = $this->get('Cache');
     $news = $cache->get('recent_news', array($this, 'getRecentNews'), array($this->getDoctrine()->getManager()));
     $breadcrumbs = array(Breadcrumb::getBreadCrumb('News'));
     return $this->render('ClassCentralSiteBundle:News:home.html.twig', array('news' => $news, 'page' => 'news', 'breadcrumbs' => $breadcrumbs));
 }
 public function newAction(Request $request, $credentialId)
 {
     $em = $this->getDoctrine()->getManager();
     $credential = $em->getRepository('ClassCentralCredentialBundle:Credential')->find($credentialId);
     if (!$credential) {
         return;
     }
     // For the completed date dropdown show the last 18 months
     $completedDates = array();
     $dt = new \DateTime();
     $dt->modify('first day of next month');
     $timePeriod = '18';
     while ($timePeriod) {
         $completedDates[$dt->format('Y-m-d')] = $dt->format('M Y');
         $dt->modify('first day of previous month');
         $timePeriod--;
     }
     $breadcrumbs = array();
     $breadcrumbs[] = Breadcrumb::getBreadCrumb('Credential');
     $breadcrumbs[] = Breadcrumb::getBreadCrumb($credential->getName());
     $breadcrumbs[] = Breadcrumb::getBreadCrumb('Review');
     return $this->render('ClassCentralCredentialBundle:CredentialReview:reviewForm.html.twig', array('degrees' => Profile::$degrees, 'progress' => CredentialReview::$progressListDropdown + $completedDates, 'credential' => $credential, 'breadcrumbs' => $breadcrumbs));
 }
 /**
  * @param Request $request
  */
 public function credentialsAction(Request $request)
 {
     $credentialService = $this->get('credential');
     $params = $credentialService->getCredentialsFilterParams($request->query->all());
     $data = $credentialService->getCredentialsInfo($params);
     extract($data);
     $breadCrumbs = array();
     $breadCrumbs[] = Breadcrumb::getBreadCrumb('Credentials', $this->generateUrl('credentials'));
     return $this->render('ClassCentralCredentialBundle:Credential:credentials.html.twig', array('page' => 'credentials', 'filterParams' => $params, 'credentials' => $credentials, 'facets' => $facets, 'numCredentials' => $numCredentials, 'breadcrumbs' => $breadCrumbs, 'subjects' => Credential::$SUBJECTS));
 }
 public function interestedAction(Request $request, $id, $slug)
 {
     $em = $this->getDoctrine()->getManager();
     $rs = $this->get('review');
     // Review service
     $cache = $this->get('Cache');
     $courseId = intval($id);
     $course = $cache->get('course_' . $courseId, array($this, 'getCourseDetails'), array($courseId, $em));
     if (!$course) {
         // TODO: render a error page
         return;
     }
     // If the slug is not the same, then redirect to the correct url
     if ($course['slug'] !== $slug) {
         $url = $this->get('router')->generate('mooc_interested', array('id' => $course['id'], 'slug' => $course['slug']));
         return $this->redirect($url, 301);
     }
     if ($course['status'] == 100) {
         throw new NotFoundHttpException("Course not found");
     }
     // Get the list of interested users
     $users = $em->getRepository('ClassCentralSiteBundle:Course')->getInterestedUsers($id);
     // Breadcrumbs
     // Breadcrumbs
     $breadcrumbs = array();
     if (!empty($course['initiative']['name'])) {
         $breadcrumbs[] = Breadcrumb::getBreadCrumb($course['initiative']['name'], $this->generateUrl('ClassCentralSiteBundle_initiative', array('type' => $course['initiative']['code'])));
     } else {
         $breadcrumbs[] = Breadcrumb::getBreadCrumb('Others', $this->generateUrl('ClassCentralSiteBundle_initiative', array('type' => 'others')));
     }
     $breadcrumbs[] = Breadcrumb::getBreadCrumb($course['name'], $this->generateUrl('ClassCentralSiteBundle_mooc', array('id' => $id, 'slug' => $slug)));
     $breadcrumbs[] = Breadcrumb::getBreadCrumb('Interested Users');
     return $this->render('ClassCentralSiteBundle:Course:interested.html.twig', array('course' => $course, 'users' => $users, 'breadcrumbs' => $breadcrumbs));
 }
 /**
  * Renders the subjects page which shows a list of all Class Central Subjects
  */
 public function subjectsAction(Request $request)
 {
     $this->get('user_service')->autoLogin($request);
     $cache = $this->get('Cache');
     $subjects = $cache->get('stream_list_count', array($this, 'getSubjectsList'), array($this->container));
     $breadcrumbs = array(Breadcrumb::getBreadCrumb('Subjects'));
     return $this->render('ClassCentralSiteBundle:Stream:subjects.html.twig', array('page' => 'subjects', 'subjects' => $subjects, 'breadcrumbs' => $breadcrumbs));
 }
 /**
  * Renders the edit form
  * @param Request $request
  * @param $reviewId
  */
 public function editAction(Request $request, $reviewId)
 {
     $em = $this->getDoctrine()->getManager();
     $review = $em->getRepository('ClassCentralSiteBundle:Review')->find($reviewId);
     if (!$review) {
         // Show an error page
         return null;
     }
     $course = $review->getCourse();
     // Breadcrumbs
     $breadcrumbs = array();
     $initiative = $course->getInitiative();
     if (!empty($initiative)) {
         $breadcrumbs[] = Breadcrumb::getBreadCrumb($initiative->getName(), $this->generateUrl('ClassCentralSiteBundle_initiative', array('type' => strtolower($initiative->getCode()))));
     } else {
         $breadcrumbs[] = Breadcrumb::getBreadCrumb('Others', $this->generateUrl('ClassCentralSiteBundle_initiative', array('type' => 'others')));
     }
     $breadcrumbs[] = Breadcrumb::getBreadCrumb($course->getName(), $this->generateUrl('ClassCentralSiteBundle_mooc', array('id' => $course->getId(), 'slug' => $course->getSlug())));
     $breadcrumbs[] = Breadcrumb::getBreadCrumb('Review');
     return $this->render('ClassCentralSiteBundle:Review:review.html.twig', array('page' => 'edit_course', 'course' => $course, 'reviewId' => $reviewId, 'breadcrumbs' => $breadcrumbs));
 }
 public function byLanguage($slug, Request $request)
 {
     $cache = $this->container->get('cache');
     $data = $cache->get('language_' . $slug . $request->server->get('QUERY_STRING'), function ($slug, $request) {
         $finder = $this->container->get('course_finder');
         $em = $this->container->get('doctrine')->getManager();
         $language = $em->getRepository('ClassCentralSiteBundle:Language')->findOneBySlug($slug);
         if (!$language) {
             throw new \Exception("Language {$slug} not found");
         }
         $pageInfo = PageHeaderFactory::get($language);
         $pageInfo->setPageUrl($this->container->getParameter('baseurl') . $this->container->get('router')->generate('lang', array('slug' => $slug)));
         $breadcrumbs = array(Breadcrumb::getBreadCrumb('Languages', $this->container->get('router')->generate('languages')), Breadcrumb::getBreadCrumb($language->getName(), $this->container->get('router')->generate('lang', array('slug' => $language->getSlug()))));
         extract($this->getInfoFromParams($request->query->all()));
         $courses = $finder->byLanguage($slug, $filters, $sort, $pageNo);
         extract($this->getFacets($courses));
         return compact('allSubjects', 'allSessions', 'courses', 'sortField', 'sortClass', 'pageNo', 'pageInfo', 'breadcrumbs', 'language');
     }, array($slug, $request));
     return $data;
 }
 public function faqAction(Request $request)
 {
     $this->get('user_service')->autoLogin($request);
     $breadcrumbs = array(Breadcrumb::getBreadCrumb('FAQ', $this->container->get('router')->generate('ClassCentralSiteBundle_faq')));
     return $this->render('ClassCentralSiteBundle:Default:faq.html.twig', array('page' => 'faq', 'breadcrumbs' => $breadcrumbs));
 }
 /**
  * Shows a page which lists all languages
  * @param Request $request
  */
 public function languagesAction(Request $request)
 {
     $cache = $this->get('cache');
     $languages = $cache->get('language_list_count', array($this, 'getLanguagesList'), array($this->container));
     $breadcrumbs = array(Breadcrumb::getBreadCrumb('Languages', $this->generateUrl('languages')));
     return $this->render('ClassCentralSiteBundle:Language:languages.html.twig', array('page' => 'languages', 'languages' => $languages, 'breadcrumbs' => $breadcrumbs));
 }