public static function getPageStatusIcon($objPage) { $sub = 0; $image = $objPage->type . '.svg'; // Page not published or not active if (!$objPage->published || $objPage->start != '' && $objPage->start > time() || $objPage->stop != '' && $objPage->stop < time()) { $sub += 1; } // Page hidden from menu if ($objPage->hide && !in_array($objPage->type, array('root', 'error_403', 'error_404'))) { $sub += 2; } // Page protected if ($objPage->protected && !in_array($objPage->type, array('root', 'error_403', 'error_404'))) { $sub += 4; } // Get the image name if ($sub > 0) { $image = $objPage->type . '_' . $sub . '.svg'; } // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['getPageStatusIcon']) && is_array($GLOBALS['TL_HOOKS']['getPageStatusIcon'])) { foreach ($GLOBALS['TL_HOOKS']['getPageStatusIcon'] as $callback) { $image = static::importStatic($callback[0])->{$callback[1]}($objPage, $image); } } return $image; }
/** * 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 static function addPageIcon($row, $label, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false) { if ($blnProtected) { $row['protected'] = true; } $image = \Controller::getPageStatusIcon((object) $row); $imageAttribute = trim($imageAttribute . ' data-icon="' . \Controller::getPageStatusIcon((object) array_merge($row, array('published' => '1'))) . '" data-icon-disabled="' . \Controller::getPageStatusIcon((object) array_merge($row, array('published' => ''))) . '"'); // Return the image only if ($blnReturnImage) { return \Image::getHtml($image, '', $imageAttribute); } // Mark root pages if ($row['type'] == 'root' || \Input::get('do') == 'article') { $label = '<strong>' . $label . '</strong>'; } // Add the breadcrumb link $label = '<a href="' . \Backend::addToUrl('pn=' . $row['id']) . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $label . '</a>'; // Return the image return '<a href="contao/main.php?do=feRedirect&page=' . $row['id'] . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['view']) . '"' . ($dc->table != 'tl_page' ? ' class="tl_gray"' : '') . ' target="_blank">' . \Image::getHtml($image, '', $imageAttribute) . '</a> ' . $label; }