addPageIcon() публичный статический Метод

Add an image to each page in the tree
public static addPageIcon ( array $row, string $label, DataContainer $dc = null, string $imageAttribute = '', boolean $blnReturnImage = false, boolean $blnProtected = false ) : string
$row array
$label string
$dc DataContainer
$imageAttribute string
$blnReturnImage boolean
$blnProtected boolean
Результат string
Пример #1
0
    /**
     * Add a breadcrumb menu to the page tree
     *
     * @param string $strKey
     *
     * @throws AccessDeniedException
     * @throws \RuntimeException
     */
    public static function addPagesBreadcrumb($strKey = 'tl_page_node')
    {
        /** @var AttributeBagInterface $objSession */
        $objSession = \System::getContainer()->get('session')->getBag('contao_backend');
        // Set a new node
        if (isset($_GET['pn'])) {
            // Check the path (thanks to Arnaud Buchoux)
            if (\Validator::isInsecurePath(\Input::get('pn', true))) {
                throw new \RuntimeException('Insecure path ' . \Input::get('pn', true));
            }
            $objSession->set($strKey, \Input::get('pn', true));
            \Controller::redirect(preg_replace('/&pn=[^&]*/', '', \Environment::get('request')));
        }
        $intNode = $objSession->get($strKey);
        if ($intNode < 1) {
            return;
        }
        // Check the path (thanks to Arnaud Buchoux)
        if (\Validator::isInsecurePath($intNode)) {
            throw new \RuntimeException('Insecure path ' . $intNode);
        }
        $arrIds = array();
        $arrLinks = array();
        $objUser = \BackendUser::getInstance();
        // Generate breadcrumb trail
        if ($intNode) {
            $intId = $intNode;
            $objDatabase = \Database::getInstance();
            do {
                $objPage = $objDatabase->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($intId);
                if ($objPage->numRows < 1) {
                    // Currently selected page does not exist
                    if ($intId == $intNode) {
                        $objSession->set($strKey, 0);
                        return;
                    }
                    break;
                }
                $arrIds[] = $intId;
                // No link for the active page
                if ($objPage->id == $intNode) {
                    $arrLinks[] = \Backend::addPageIcon($objPage->row(), '', null, '', true) . ' ' . $objPage->title;
                } else {
                    $arrLinks[] = \Backend::addPageIcon($objPage->row(), '', null, '', true) . ' <a href="' . \Backend::addToUrl('pn=' . $objPage->id) . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $objPage->title . '</a>';
                }
                // Do not show the mounted pages
                if (!$objUser->isAdmin && $objUser->hasAccess($objPage->id, 'pagemounts')) {
                    break;
                }
                $intId = $objPage->pid;
            } while ($intId > 0 && $objPage->type != 'root');
        }
        // Check whether the node is mounted
        if (!$objUser->hasAccess($arrIds, 'pagemounts')) {
            $objSession->set($strKey, 0);
            throw new AccessDeniedException('Page ID ' . $intNode . ' is not mounted.');
        }
        // Limit tree
        $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = array($intNode);
        // Add root link
        $arrLinks[] = \Image::getHtml('pagemounts.svg') . ' <a href="' . \Backend::addToUrl('pn=0') . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectAllNodes']) . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
        $arrLinks = array_reverse($arrLinks);
        // Insert breadcrumb menu
        $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['breadcrumb'] .= '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
    }