Provide miscellaneous methods that are used by the data configuration array.
Inheritance: extends Backend
Exemplo n.º 1
0
 public function addSublineToLabel($row, $label, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
 {
     if (!empty($row['subLineBz'])) {
         $label .= ' <span style="color:#b3b3b3;padding-left:3px">[' . $row['subLineBz'] . ']</span>';
     }
     return parent::addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
 }
 public function languageLabels($row, $label, $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
 {
     // generate the default label
     $objDcaClass = null;
     if (in_array('cacheicon', ModuleLoader::getActive())) {
         $objDcaClass = new tl_page_cacheicon();
     } elseif (in_array('Avisota', ModuleLoader::getActive())) {
         $objDcaClass = new tl_page_avisota();
     } else {
         $objDcaClass = new tl_page();
     }
     $label = $objDcaClass->addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     // return the label for root or folder page
     if ($row['type'] == 'root' || $row['type'] == 'folder') {
         return $label;
     }
     // load the current page
     $objPage = PageModel::findWithDetails($row['id']);
     // prepare alternate pages
     $objAlternates = null;
     if ($objPage->languageMain) {
         // get all pages referencing the same fallback page
         $t = \PageModel::getTable();
         $objAlternates = PageModel::findBy(array("{$t}.languageMain = ? OR {$t}.id = ?"), array($objPage->languageMain, $objPage->languageMain));
     } else {
         // get all pages referencing the current page as its fallback
         $objAlternates = PageModel::findByLanguageMain($objPage->id);
     }
     // check if alternates were found
     if ($objAlternates !== null) {
         $label .= '<ul class="tl_page_language_alternates">';
         // go through each page and add link
         while ($objAlternates->next()) {
             if ($objAlternates->id == $objPage->id) {
                 continue;
             }
             $objAlternates->current()->loadDetails();
             $label .= '<li><a href="contao/main.php?do=page&amp;node=' . $objAlternates->id . '&amp;ref=' . TL_REFERER_ID . '">' . $objAlternates->language . '</a></li>';
         }
         $label .= '</ul>';
     }
     return $label;
 }
Exemplo n.º 3
0
    /**
     * Add the breadcrumb menu
     * @return void
     */
    public function addBreadcrumb()
    {
        // Set a new node
        if (isset($_GET['node'])) {
            $this->Session->set('tl_page_node', $this->Input->get('node'));
            $this->redirect(preg_replace('/&node=[^&]*/', '', $this->Environment->request));
        }
        $intNode = $this->Session->get('tl_page_node');
        if ($intNode < 1) {
            return;
        }
        $arrIds = array();
        $arrLinks = array();
        // Generate breadcrumb trail
        if ($intNode) {
            $this->loadDataContainer('tl_page');
            $tl_page = new tl_page();
            $intId = $intNode;
            do {
                $objPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($intId);
                if ($objPage->numRows < 1) {
                    // Currently selected page does not exits
                    if ($intId == $intNode) {
                        $this->Session->set('tl_page_node', 0);
                        return;
                    }
                    break;
                }
                $arrIds[] = $intId;
                // No link for the active page
                if ($objPage->id == $intNode) {
                    $arrLinks[] = $tl_page->addIcon($objPage->row(), '', null, '', true) . ' ' . $objPage->title;
                } else {
                    $arrLinks[] = $tl_page->addIcon($objPage->row(), '', null, '', true) . ' <a href="' . $this->addToUrl('node=' . $objPage->id) . '">' . $objPage->title . '</a>';
                }
                // Do not show the mounted pages
                if (!$this->User->isAdmin && in_array($objPage->id, $this->User->pagemounts)) {
                    break;
                }
                $intId = $objPage->pid;
            } while ($intId > 0 && $objPage->type != 'root');
        }
        // Check whether the node is mounted
        if (!$this->User->isAdmin && !$this->User->hasAccess($arrIds, 'pagemounts')) {
            $this->Session->set('tl_page_node', 0);
            $this->log('Page ID ' . $intNode . ' was not mounted', 'tl_page addBreadcrumb', TL_ERROR);
            $this->redirect($this->Environment->script . '?act=error');
        }
        // Limit tree
        $arrNodes = array_merge(array($intNode), $this->getChildRecords($intNode, 'tl_page'));
        $objProducts = $this->Database->execute("SELECT pid FROM tl_iso_product_categories WHERE page_id IN (" . implode(',', $arrNodes) . ")");
        if ($objProducts->numRows) {
            $GLOBALS['TL_DCA']['tl_iso_products']['list']['sorting']['root'] = $objProducts->fetchEach('pid');
        } else {
            $berror = '

<ul id="tl_breadcrumb">
  <li>' . $GLOBALS['TL_LANG']['ERR']['breadcrumbEmpty'] . '</li>
</ul>';
        }
        // Add root link
        $arrLinks[] = '<img src="system/themes/' . $this->getTheme() . '/images/pagemounts.gif" width="18" height="18" alt=""> <a href="' . $this->addToUrl('node=0') . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
        $arrLinks = array_reverse($arrLinks);
        // Insert breadcrumb menu
        $GLOBALS['TL_DCA']['tl_iso_products']['list']['sorting']['breadcrumb'] = '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>' . $berror;
    }
Exemplo n.º 4
0
 public function addIcon($row, $label, DataContainer $dc = null, $imageAttribute = '', $returnImage = false, $isProtected = false)
 {
     if ($row['type'] == 'avisota') {
         $sub = 0;
         $image = 'system/modules/avisota/html/page.png';
         // Page not published or not active
         if (!$row['published'] || $row['start'] && $row['start'] > time() || $row['stop'] && $row['stop'] < time()) {
             $sub += 1;
         }
         // Page protected
         if ($row['protected'] && !in_array($row['type'], array('root', 'error_403', 'error_404'))) {
             $sub += 2;
         }
         // Get image name
         if ($sub > 0) {
             $image = 'system/modules/avisota/html/page_' . $sub . '.png';
         }
         // Return the image only
         if ($returnImage) {
             return $this->generateImage($image, '', $imageAttribute);
         }
         // Return image
         return $this->generateImage($image, '', $imageAttribute) . ' ' . $label;
     }
     return parent::addIcon($row, $label, $dc, $imageAttribute, $returnImage);
 }
Exemplo n.º 5
0
 /**
  * Show notice if no fallback page is set
  */
 public function addFallbackNotice($row, $label, $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
 {
     if (in_array('cacheicon', $this->Config->getActiveModules())) {
         $objPage = new tl_page_cacheicon();
         $label = $objPage->addImage($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     } elseif (in_array('Avisota', $this->Config->getActiveModules())) {
         $objPage = new tl_page_avisota();
         $label = $objPage->addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     } else {
         $objPage = new tl_page();
         $label = $objPage->addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     }
     if (!$row['languageMain']) {
         // Save resources if we are not a regular page
         if ($row['type'] == 'root' || $row['type'] == 'folder') {
             return $label;
         }
         $objPage = $this->getPageDetails($row['id']);
         $objRootPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($objPage->rootId);
         $objFallback = $this->Database->prepare("SELECT id FROM tl_page WHERE type='root' AND fallback='1' AND id!=? AND (dns=? OR id=?)")->limit(1)->execute($objRootPage->id, $objPage->domain, $objRootPage->fallback ? $objRootPage->languageRoot : 0);
         if ($objFallback->numRows) {
             $label .= '<span style="color:#b3b3b3; padding-left:3px;">[' . $GLOBALS['TL_LANG']['MSC']['noMainLanguage'] . ']</span>';
         }
     }
     return $label;
 }
Exemplo n.º 6
0
 /**
  * Import the back end user object
  */
 public function __construct()
 {
     parent::__construct();
 }
Exemplo n.º 7
0
 public function adjustAlias($value, $dc)
 {
     // Nothing to adjust if no folderUrls
     if (!$GLOBALS['TL_CONFIG']['folderUrl']) {
         return $value;
     }
     // If current page is of type folder, update children
     if ($dc->activeRecord && $dc->activeRecord->type == 'folder') {
         $childRecords = \Database::getInstance()->getChildRecords(array($dc->id), 'tl_page');
         $this->updateChildren($childRecords);
         return $value;
     }
     $tl_page = new \tl_page();
     // Clean the alias
     $value = $this->cleanAlias($value);
     try {
         $value = $tl_page->generateAlias($value, $dc);
     } catch (\Exception $e) {
         // The alias already exists so add ID just like the original method would
         $value = $value . '-' . $dc->id;
         // Validate the alias once again and throw an error if it exists
         $value = $tl_page->generateAlias($value, $dc);
     }
     return $value;
 }