/**
  * 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="' . \Controller::addToUrl('node=' . $row['id']) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $label . '</a>';
     // Return the image
     return '<a href="contao/main.php?do=feRedirect&amp;page=' . $row['id'] . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['view']) . '"' . ($dc->table != 'tl_page' ? ' class="tl_gray"' : '') . ' target="_blank">' . \Image::getHtml($image, '', $imageAttribute) . '</a> ' . $label;
 }
 /**
  * rendered the template
  *
  * @param     $string from tl_page
  * @param     $pages  array of pages
  * @param int $level  level for the menu
  *
  * @return string template
  */
 protected static function render($string, $pages, $level = 0)
 {
     $level++;
     if (!count($pages) && $level === 1) {
         return $string;
     }
     foreach ($pages as $key => $page) {
         $image = \Controller::getPageStatusIcon((object) $page);
         $pages[$key]->status_image = \Image::getHtml($image);
         if (count($page->trail)) {
             $pages[$key]->sub_pages = static::render($string, $page->trail, $level);
         }
     }
     $template = new \TwigTemplate('backend/nested_pages', 'html5');
     $data = array('lang' => $GLOBALS['TL_LANG'], 'level' => $level, 'pages' => $pages, 'string' => $string, 'do' => \Input::get('do'));
     return $template->parse($data);
 }