/**
  * Set the HTML code for the button.
  *
  * @param ParentViewChildRecordEvent $event The event being emitted.
  *
  * @param string                     $value The value returned by the callback.
  *
  * @return void
  */
 public function update($event, $value)
 {
     if (is_null($value)) {
         return;
     }
     $event->setHtml($value);
     $event->stopPropagation();
 }
Exemplo n.º 2
0
 /**
  * Add the recipient row.
  *
  * @param array
  */
 public function parentViewChildRecord(ParentViewChildRecordEvent $event)
 {
     /** @var MessageRendererInterface $renderer */
     $renderer = $GLOBALS['container']['avisota.message.renderer'];
     /** @var EntityModel $model */
     $model = $event->getModel();
     /** @var \Avisota\Contao\Entity\MessageContent $content */
     $content = $model->getEntity();
     $key = $content->getInvisible() ? 'unpublished' : 'published';
     try {
         $element = $renderer->renderContent($content);
     } catch (\Exception $exception) {
         $element = sprintf("<span style=\"color:red\">%s</span>", $exception->getMessage());
     }
     /** @var EntityAccessor $entityAccessor */
     $entityAccessor = $GLOBALS['container']['doctrine.orm.entityAccessor'];
     $context = $entityAccessor->getProperties($content);
     $context['key'] = $key;
     $context['element'] = $element;
     $template = new \TwigTemplate('avisota/backend/mce_element', 'html5');
     $event->setHtml($template->parse($context));
 }
Exemplo n.º 3
0
 /**
  * Add the recipient row.
  *
  * @param array
  */
 public function parentViewChildRecord(ParentViewChildRecordEvent $event)
 {
     /** @var EntityModel $model */
     $model = $event->getModel();
     /** @var \Avisota\Contao\Entity\Message $message */
     $message = $model->getEntity();
     if ($message->getCategory()->getBoilerplates()) {
         $language = $message->getLanguage();
         if (isset($GLOBALS['TL_LANG']['LNG'][$language])) {
             $language = $GLOBALS['TL_LANG']['LNG'][$language];
         }
         $label = sprintf('%s [%s]', $message->getSubject(), $language);
         $event->setHtml($label);
     } else {
         $icon = $model->getProperty('sendOn') ? 'visible' : 'invisible';
         $label = $model->getProperty('subject');
         if ($message->getSendOn()) {
             $parseDateEvent = new ParseDateEvent($message->getSendOn()->getTimestamp(), $GLOBALS['TL_CONFIG']['datimFormat']);
             /** @var EventDispatcher $eventDispatcher */
             $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
             $eventDispatcher->dispatch(ContaoEvents::DATE_PARSE, $parseDateEvent);
             $label .= ' <span style="color:#b3b3b3; padding-left:3px;">(' . sprintf($GLOBALS['TL_LANG']['orm_avisota_message']['sended'], $parseDateEvent->getResult()) . ')</span>';
         }
         /** @var EventDispatcher $eventDispatcher */
         $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
         $getThemeEvent = new GetThemeEvent();
         $eventDispatcher->dispatch(ContaoEvents::BACKEND_GET_THEME, $getThemeEvent);
         $event->setHtml(sprintf('<div class="list_icon" style="background-image:url(\'system/themes/%s/images/%s.gif\');">%s</div>', $getThemeEvent->getTheme(), $icon, $label));
     }
 }