public function eventAction($idEvent) { // Formulaire barre de recherche (header) $formSearchBar = $this->createForm(new SearchType()); $em = $this->getDoctrine()->getManager(); $eventRepo = $em->getRepository('AGILHallBundle:AgilEvent'); $event = $eventRepo->find($idEvent); $essence = new Essence(); $text = '<div class="row">' . '<div class="col-lg-12">' . $event->getEventText() . '</div></div>'; $eventContent = $essence->replace($text, function ($media) { return <<<HTML \t\t\t<div class="row"> <div class="well well-lg col-lg-6 col-lg-offset-3 col-md-8 col-md-offset-2 col-sm-12"> <p class="text-primary-blue text-center"> {$media->title} par <a href="{$media->authorUrl}" title="Accès à la chaine de {$media->authorName}"> {$media->authorName} </a> </p> <div class="embed-responsive embed-responsive-16by9">{$media->html}</div> </div> \t\t </div> HTML; }); return $this->render('AGILHallBundle:Event:event.html.twig', array('event' => $event, 'eventContent' => $eventContent, 'formSearchBar' => $formSearchBar->createView())); }
public function init() { $this->bot->onChannel($this->urlRegex, function (Event $event) { $essence = Essence::instance(array('Http' => new HttpNative())); if (preg_match_all($this->urlRegex, $event->getRequest()->getMessage(), $matches) !== false) { $medias = $essence->embedAll($matches['url']); foreach ($medias as $url => $info) { if ($info && $info->has('title')) { $event->addResponse(Response::msg($event->getRequest()->getSource(), $info->title . ' -> ' . $url)); } } } }); }
/** * @param string $url * @throws \Exception * @return string HTML representation of URL */ public function extract($url) { $essence = \Essence\Essence::instance(); $options = array(); $maxWidth = $this->getMaxWidth(); if (!empty($maxWidth)) { $options['maxwidth'] = $maxWidth; } $maxHeight = $this->getMaxHeight(); if (!empty($maxHeight)) { $options['maxheight'] = $maxHeight; } $media = $essence->embed($url, $options); if (!$media) { throw new \Exception(); } return $this->getTemplate($media->properties()); }
} } $courses[] = ['course' => $sessionCourse, 'description' => $courseDescription, 'tags' => $courseTags, 'objectives' => $courseObjectives, 'topics' => $courseTopics, 'coaches' => $coachesData, 'extra_fields' => $courseValues->getAllValuesForAnItem($sessionCourse->getId())]; } $sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]); $sessionRequirements = $sequenceResourceRepo->getRequirements($session->getId(), SequenceResource::SESSION_TYPE); $hasRequirements = false; foreach ($sessionRequirements as $sequence) { if (!empty($sequence['requirements'])) { $hasRequirements = true; break; } } $courseController = new CoursesController(); /* View */ //$template = new Template($session->getName(), true, true, false, true, false); $template = \Chamilo\CoreBundle\Framework\Container::getTwig(); $template->addGlobal('show_tutor', api_get_setting('session.show_session_coach') === 'true' ? true : false); $template->addGlobal('pageUrl', api_get_path(WEB_PATH) . "session/{$session->getId()}/about/"); $template->addGlobal('session', $session); $template->addGlobal('session_date', $sessionDates); $template->addGlobal('is_subscribed', SessionManager::isUserSubscribedAsStudent($session->getId(), api_get_user_id())); $template->addGlobal('subscribe_button', $courseController->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements)); $template->addGlobal('courses', $courses); $template->addGlobal('essence', \Essence\Essence::instance()); $template->addGlobal('session_extra_fields', $sessionValues->getAllValuesForAnItem($session->getId(), true)); $template->addGlobal('has_requirements', $hasRequirements); $template->addGlobal('sequences', $sessionRequirements); //$templateFolder = api_get_configuration_value('default_template'); echo $template->render('@template_style/session/about.html.twig'); //$template->assign('header', $session->getName());
/** * */ public function testReplace() { $text = 'text'; $template = function () { }; $options = []; $replaced = 'replaced text'; $Replacer = $this->getMockBuilder('\\Essence\\Replacer')->disableOriginalConstructor()->getMock(); $Replacer->expects($this->once())->method('replace')->with($this->isEqual($text), $this->isEqual($template), $this->isEqual($options))->will($this->returnValue($replaced)); $Essence = new Essence(['Replacer' => $Replacer]); $this->assertEquals($replaced, $Essence->replace($text, $template, $options)); }
$courses[] = ['course' => $sessionCourse, 'description' => $courseDescription, 'tags' => $courseTags, 'objectives' => $courseObjectives, 'topics' => $courseTopics, 'coaches' => $coachesData, 'extra_fields' => $courseValues->getAllValuesForAnItem($sessionCourse->getId())]; } $sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]); $sessionRequirements = $sequenceResourceRepo->getRequirements($session->getId(), SequenceResource::SESSION_TYPE); $hasRequirements = false; foreach ($sessionRequirements as $sequence) { if (!empty($sequence['requirements'])) { $hasRequirements = true; break; } } $courseController = new CoursesController(); /* View */ $template = new Template($session->getName(), true, true, false, true, false); $template->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false); $template->assign('pageUrl', api_get_path(WEB_PATH) . "session/{$session->getId()}/about/"); $template->assign('session', $session); $template->assign('session_date', $sessionDates); $template->assign('is_subscribed', SessionManager::isUserSubscribedAsStudent($session->getId(), api_get_user_id())); $template->assign('subscribe_button', $courseController->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements)); $template->assign('courses', $courses); $template->assign('essence', \Essence\Essence::instance()); $template->assign('session_extra_fields', $sessionValues->getAllValuesForAnItem($session->getId(), true)); $template->assign('has_requirements', $hasRequirements); $template->assign('sequences', $sessionRequirements); $templateFolder = api_get_configuration_value('default_template'); $layout = $template->get_template('session/about.tpl'); $content = $template->fetch($layout); $template->assign('header', $session->getName()); $template->assign('content', $content); $template->display_one_col_template();