/** * Add an image to each page in the tree * @param array * @param string * @param \DataContainer * @param string * @param boolean * @param boolean * @return string */ public function addIcon($row, $label, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false) { $this->import('BackendUser', 'User'); $html = Backend::addPageIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected); if ($this->User->om_flags && $row['type'] == 'root') { $html .= '<strong> - ' . $row['language'] . '</strong>'; } return $html; }
/** * Add a breadcrumb menu to the page tree * * @param string $strKey * * @throws \RuntimeException */ public static function addPagesBreadcrumb($strKey = 'tl_page_node') { $objSession = \Session::getInstance(); // Set a new node if (isset($_GET['node'])) { // Check the path (thanks to Arnaud Buchoux) if (\Validator::isInsecurePath(\Input::get('node', true))) { throw new \RuntimeException('Insecure path ' . \Input::get('node', true)); } $objSession->set($strKey, \Input::get('node', true)); \Controller::redirect(preg_replace('/&node=[^&]*/', '', \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 exits 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="' . \Controller::addToUrl('node=' . $objPage->id) . '" title="' . 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); \System::log('Page ID ' . $intNode . ' was not mounted', __METHOD__, TL_ERROR); \Controller::redirect('contao/main.php?act=error'); } // Limit tree $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = array($intNode); // Add root link $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/pagemounts.gif" width="18" height="18" alt=""> <a href="' . \Controller::addToUrl('node=0') . '" title="' . 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(' > </li><li>', $arrLinks) . '</li> </ul>'; }
/** * Add an image to each page in the tree * * @param array $row * @param string $label * @param DataContainer $dc * @param string $imageAttribute * @param boolean $blnReturnImage * @param boolean $blnProtected * * @return string */ public function addIcon($row, $label, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false) { return Backend::addPageIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected); }