/**
  * @param BBcodeElementNodeInterface $el
  * 
  * @return string
  */
 protected function getPreviewContent(BBcodeElementNodeInterface $el)
 {
     if ($this->parseContent()) {
         $content = "";
         foreach ($el->getChildren() as $child) {
             $content .= $child->getAsPreviewHTML();
         }
     } else {
         $content = "";
         foreach ($el->getChildren() as $child) {
             $content .= $child->getAsBBCode();
         }
     }
     return $content;
 }
 /**
  * @param BBcodeElementNodeInterface $el
  * @param bool                       $preview
  */
 protected function generateHtml(BBcodeElementNodeInterface $el, $preview = false)
 {
     $children = $el->getChildren();
     if (count($children) < 1) {
         return $this->templating->render('OpenOrchestraMediaBundle:BBcode:media_not_found.html.twig');
     }
     $mediaId = $children[0]->getAsBBCode();
     $media = $this->repository->find($mediaId);
     if ($media) {
         if ($preview) {
             return $this->displayMediaManager->displayMediaForWysiwyg($media, $this->getFormat($el));
         } else {
             return $this->displayMediaManager->displayMedia($media, $this->getFormat($el));
         }
     }
     return $this->templating->render('OpenOrchestraMediaBundle:BBcode:media_not_found.html.twig');
 }
 /**
  * @param BBcodeElementNodeInterface $el
  * @param bool                       $preview
  */
 protected function generateHtml(BBcodeElementNodeInterface $el, $preview = false)
 {
     $children = $el->getChildren();
     $option = $el->getAttribute();
     if ($preview) {
         return $this->templating->render('OpenOrchestraDisplayBundle::BBcode/link.html.twig', array('href' => '#', 'options' => html_entity_decode($option['link']), 'text' => $children[0]->getAsBBCode()));
     }
     $parameters = json_decode(html_entity_decode($option['link']), true);
     $uri = '#';
     try {
         $linkName = $this->nodeManager->getRouteDocumentName($parameters);
         try {
             $routeCompileParameters = array();
             if (array_key_exists('contentSearch_contentId', $parameters)) {
                 $routeCompileParameters['contentId'] = $parameters['contentSearch_contentId'];
             }
             $uri = $this->urlGenerator->generate($linkName, $routeCompileParameters, UrlGeneratorInterface::ABSOLUTE_PATH) . (array_key_exists('query', $parameters) ? $parameters['query'] : '');
         } catch (RouteNotFoundException $e) {
         }
     } catch (NodeNotFoundException $e) {
     }
     return $this->templating->render('OpenOrchestraDisplayBundle::BBcode/link.html.twig', array('href' => $uri, 'options' => '', 'text' => $children[0]->getAsBBCode()));
 }
 /**
  * Get requested media style
  *
  * @param BBcodeElementNodeInterface $el
  *
  * @return string
  */
 protected function getStyle(BBcodeElementNodeInterface $el)
 {
     $options = $el->getAttribute();
     $options = json_decode($options['media'], true);
     return is_array($options) && array_key_exists('style', $options) ? $options['style'] : '';
 }
 /**
  * Get requested media format
  * 
  * @param BBcodeElementNodeInterface $el
  * 
  * @return string
  */
 protected function getFormat(BBcodeElementNodeInterface $el)
 {
     $options = $el->getAttribute();
     return $options['media'];
 }