Ejemplo n.º 1
0
 /**
  * Render the list view.
  *
  * @param bool   $blnNoNativeParsing Flag determining if the parsing shall be done internal or if the template will
  *                                   handle the parsing on it's own.
  *
  * @param object $objCaller          The object calling us, might be a Module or ContentElement or anything else.
  *
  * @return string
  */
 public function render($blnNoNativeParsing, $objCaller)
 {
     $this->objTemplate->noItemsMsg = $this->getNoItemsCaption();
     $this->objTemplate->details = $this->getDetailsCaption();
     $this->prepare();
     $strOutputFormat = $this->getOutputFormat();
     if ($this->objItems->getCount() && !$blnNoNativeParsing) {
         $this->objTemplate->data = $this->objItems->parseAll($strOutputFormat, $this->objView);
     } else {
         $this->objTemplate->data = array();
     }
     $this->setTitleAndDescription();
     $this->objTemplate->caller = $objCaller;
     $this->objTemplate->items = $this->objItems;
     $this->objTemplate->filterParams = $this->arrParam;
     return $this->objTemplate->parse($strOutputFormat);
 }
Ejemplo n.º 2
0
Archivo: Base.php Proyecto: zonky2/core
 /**
  * When rendered via a template, this populates the template with values.
  *
  * @param Template $objTemplate The Template instance to populate.
  *
  * @param array    $arrRowData  The row data for the current item.
  *
  * @param ISimple  $objSettings The render settings to use for this attribute.
  *
  * @return void
  */
 protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
 {
     $objTemplate->setData(array('attribute' => $this, 'settings' => $objSettings, 'row' => $arrRowData, 'raw' => $arrRowData[$this->getColName()], 'additional_class' => $objSettings->get('additional_class') ? ' ' . $objSettings->get('additional_class') : ''));
 }
 /**
  * @param $model
  * @return string
  */
 protected function generateLabel(IItem $model)
 {
     $templateName = $this->renderSetting->get('template');
     $format = $this->getOutputFormat();
     $data = array('settings' => $this->renderSetting, 'item' => $model->parseValue($format, $this->renderSetting));
     return Template::render($templateName, $format, $data);
 }
 /**
  * Generate the content of the popup.
  *
  * @param Item          $item     The metamodel item.
  * @param RenderSetting $settings The given metamodel settings.
  *
  * @return null|string
  */
 protected function getPopupContent(Item $item, RenderSetting $settings = null)
 {
     if (!$this->model->addPopup) {
         return null;
     }
     if ($this->model->addPopup === 'attribute') {
         $popupAttribute = $this->getAttribute('popupAttribute', $item);
         $format = $this->getOutputFormat($settings, 'text');
         $parsed = $item->parseAttribute($popupAttribute->getColName(), $format, $settings);
         if (isset($parsed[$format])) {
             return $parsed[$format];
         }
         return $parsed['text'];
     }
     $value = $item->parseValue($this->getOutputFormat($settings), $settings);
     if ($settings) {
         $template = new Template($settings->get('template'));
         $template->view = $settings;
     } else {
         $template = new Template('metamodel_full');
     }
     // Metamodels always expects an list of items. Instead of requiring customized templates,
     // we pretend of having multiple items.
     $template->details = $this->getDetailsCaption($item->getMetaModel());
     $template->items = new Items(array($item));
     $template->data = array($value);
     $template->caller = $this;
     return $template->parse($this->getOutputFormat($settings, 'html5'));
 }
Ejemplo n.º 5
0
 /**
  * Render the current item using the specified render setting.
  *
  * @param ModelToLabelEvent $event The event.
  *
  * @return void
  */
 public static function render(ModelToLabelEvent $event)
 {
     $environment = $event->getEnvironment();
     /** @var IMetaModelDataDefinition $definition */
     $definition = $environment->getDataDefinition();
     /** @var Contao2BackendViewDefinitionInterface $viewSection */
     $viewSection = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
     $listing = $viewSection->getListingConfig();
     /** @var Model $model */
     $model = $event->getModel();
     if (!$model instanceof Model) {
         return;
     }
     $nativeItem = $model->getItem();
     $metaModel = $nativeItem->getMetaModel();
     $renderSetting = $metaModel->getServiceContainer()->getRenderSettingFactory()->createCollection($metaModel, $definition->getMetaModelDefinition()->getActiveRenderSetting());
     if (!$renderSetting) {
         return;
     }
     $data = array($nativeItem->parseValue('html5', $renderSetting));
     if ($listing->getShowColumns()) {
         $event->setArgs($data[0]['html5']);
         return;
     }
     $template = new Template($renderSetting->get('template'));
     $renderSetting = self::removeInvariantAttributes($nativeItem, $renderSetting);
     $template->setData(array('settings' => $renderSetting, 'items' => new Items(array($nativeItem)), 'view' => $renderSetting, 'data' => $data));
     $event->setArgs(array($template->parse('html5')));
 }