/** * Invoke the rendering. * * @param array $row The child as array. * * @return mixed|string */ public function __invoke($row) { $buffer = call_user_func($this->callback, $row); if ($row['ptable'] === 'tl_content_node') { $parent = \ContentModel::findByPk($row['pid']); if ($this->registry->hasNodeType($parent->type)) { $node = $this->registry->getNode($parent->type); return $node->generateChildInBackendView($row, $buffer); } } return $buffer; }
/** * Inject the breadcrumb. * * @param string $buffer The generated output. * @param string $template The template name. * * @return string */ public function injectBreadcrumb($buffer, $template) { if (!$this->isBreadcrumbRequired($template)) { return $buffer; } $items = array(); $model = \ContentModel::findByPk(CURRENT_ID); $current = $model; while ($model && $this->registry->hasNodeType($model->type)) { array_unshift($items, $model); if ($model->ptable !== 'tl_content_node') { break; } $model = \ContentModel::findByPk($model->pid); } if ($items) { $breadcrumb = new Breadcrumb(); $this->addParentToBreadcrumb($model, $breadcrumb); foreach ($items as $item) { $this->registry->getNode($item->type)->buildBreadcrumb($breadcrumb, $item); } $replacement = $breadcrumb->generate() . '<div class="tl_listing_container node-' . $current->type; $buffer = str_replace('<div class="tl_listing_container', $replacement, $buffer); } return $buffer; }
/** * Generate the header fields. * * @param array $fields The header fields. * * @return array */ public function generateHeaderFields($fields) { $model = \ContentModel::findByPk(CURRENT_ID); if ($model instanceof \ContentModel && $this->registry->hasNodeType($model->type)) { return $this->registry->getNode($model->type)->generateHeaderFields($fields, $model); } return $fields; }
/** * Restrict the content elements. * * @param int $contentId The id of the current content element. * @param Node $node The node type. * * @return void * @throws AccessDeniedException When an invalid content element type is accessed. * * @SuppressWarnings(PHPMD.Superglobals) */ public function restrict($contentId, Node $node = null) { $nodeType = $node ? $node->getName() : null; $allowedElements = $this->registry->filterContentElements($GLOBALS['TL_CTE'], $nodeType); if (empty($allowedElements)) { $this->closeDataContainer(); } elseif (!in_array($this->definition->get('fields/type/default'), $allowedElements)) { $this->setDefaults($allowedElements); } if ($this->input->get('act') != '' && $this->input->get('act') !== 'select') { $GLOBALS['TL_CTE'] = $allowedElements; $this->restrictIds($allowedElements, $contentId); } }