/** * @return string */ function search() { $output = ''; if (!$this->isJson()) { return $this->httpError(500, 'Content Type not allowed'); } try { $search_params = json_decode($this->request->getBody(), true); $trainings = $this->training_facade->getTrainings($search_params['topic_term'], $search_params['location_term'], $search_params['level_term']); foreach ($trainings as $training) { $output .= $training->renderWith('TrainingDirectoryPage_CompanyTrainingFilteredCourses', array('FilteredCourses' => $training->getCourses(), 'TrainingURL' => $this->Link() . $training->getCompany()->URLSegment . "/" . $training->getId(), 'DetailsURL' => $this->Link())); } } catch (Exception $ex) { return $this->httpError(500, 'Server Error'); } return empty($output) ? $this->httpError(404, '') : $output; }
/** * @return string */ function search_classes() { $output = ''; if (!$this->isJson()) { return $this->httpError(500, 'Content Type not allowed'); } try { $search_params = json_decode($this->request->getBody(), true); $limit = 40 * $search_params['page_no'] - 40; $courses_dto = $this->training_facade->getFilteredClasses($search_params['location_term'], $search_params['level_term'], $search_params['company_term'], $search_params['start_date'], $search_params['end_date']); $limited_courses = $courses_dto->limit(40, $limit); $output .= $this->renderWith('TrainingDirectoryPage_CompanyTrainingFilteredClasses', array('FilteredCourses' => $limited_courses)); $result_array = array('class_html' => $output, 'class_count' => count($courses_dto)); } catch (Exception $ex) { return $this->httpError(500, 'Server Error'); } return empty($output) ? $this->httpError(404, '') : json_encode($result_array); }
}); GoogleSiteMapGenerator::getInstance()->registerDataObject($class_name = 'Distribution', $change_freq = GoogleSitemapGenerator::CHANGE_FREQ_MONTHLY, $priority = GoogleSitemapGenerator::PRIORITY_0_5, $get_url_function = function (IDistribution $distro) { $company_slug = $distro->getCompany()->URLSegment; $slug = $distro->getSlug(); $url = sprintf('/marketplace/distros/distribution/%s/%s', $company_slug, $slug); $url = Director::absoluteURL($url); return $url; }); GoogleSiteMapGenerator::getInstance()->registerDataObject($class_name = 'TrainingService', $change_freq = GoogleSitemapGenerator::CHANGE_FREQ_MONTHLY, $priority = GoogleSitemapGenerator::PRIORITY_0_5, $get_url_function = function ($training) { $company_slug = $training->getCompany()->URLSegment; $slug = $training->ID; $url = sprintf('/marketplace/training/%s/%s', $company_slug, $slug); $url = Director::absoluteURL($url); return $url; }, function () { $training_facade = new TrainingFacade(Controller::curr(), new TrainingManager(new SapphireTrainingServiceRepository(), new SapphireMarketPlaceTypeRepository(), new TrainingAddPolicy(), new TrainingShowPolicy(), new SessionCacheService(), new MarketplaceFactory(), SapphireTransactionManager::getInstance()), new SapphireCourseRepository(new MarketplaceFactory())); return $training_facade->getTrainings(); }); // News GoogleSiteMapGenerator::getInstance()->registerDataObject($class_name = 'News', $change_freq = GoogleSitemapGenerator::CHANGE_FREQ_MONTHLY, $priority = GoogleSitemapGenerator::PRIORITY_0_5, $get_url_function = function (INews $news) { $id = $news->ID; $slug = $news->HeadlineForUrl; $url = sprintf('/news/view/%s/%s', $id, $slug); $url = Director::absoluteURL($url); return $url; }, function () { $news_repository = new SapphireNewsRepository(); $featured_news = $news_repository->getFeaturedNews(); $recent_news = $news_repository->getRecentNews(); $slide_news = $news_repository->getSlideNews(); return array_merge($featured_news, $recent_news, $slide_news);
function getAllClasses() { return $this->training_facade->getAllClasses(); }
function getUpcomingCourses($limit = 20) { return $this->training_facade->getUpcomingCourses($limit); }