Exemplo n.º 1
0
 public static function getPageTitleBE($conf, $value)
 {
     if ($GLOBALS['TSFE']->showHiddenPage || self::isBEUserLoggedIn()) {
         $enable = ' AND deleted=0';
     } else {
         $enable = ' AND deleted=0 AND hidden=0';
     }
     $db =& $GLOBALS['TYPO3_DB'];
     $id = (int) $value[(string) $conf->saveto];
     $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cooluri']);
     $langVar = $confArray['LANGID'];
     if (empty($langVar)) {
         $langVar = 'L';
     }
     $langId = isset($value[$langVar]) ? $value[$langVar] : $GLOBALS['TSFE']->config['config']['sys_language_uid'];
     $langId = (int) $langId;
     $pagepath = array();
     if (empty($conf->alias)) {
         $sel = (string) $conf->title;
     } else {
         $sel = (string) $conf->alias;
     }
     $sel = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $sel);
     $max = 15;
     while ($max > 0 && $id) {
         if (!is_numeric($id)) {
             $id = $GLOBALS['TSFE']->sys_page->getPageIdFromAlias($id);
         }
         $q = $db->exec_SELECTquery('*', 'pages', 'uid=' . $id . $enable);
         $page = $db->sql_fetch_assoc($q);
         $temp = $db->exec_SELECTquery('COUNT(*) as num', 'sys_template', 'deleted=0 AND hidden=0 AND pid=' . $id . ' AND root=1' . $enable);
         $count = $db->sql_fetch_assoc($temp);
         if ($count['num'] > 0 || $page['is_siteroot'] == 1) {
             return $pagepath;
         }
         if ($langId) {
             $q = $db->exec_SELECTquery('*', 'pages_language_overlay', 'pid=' . $id . ' AND sys_language_uid=' . $langId . $enable);
             $lo = $db->sql_fetch_assoc($q);
             if ($lo) {
                 unset($lo['uid']);
                 unset($lo['pid']);
                 $page = array_merge($page, $lo);
             }
         }
         if (!$page) {
             break;
         }
         if ($page['tx_cooluri_exclude'] == 1 && !empty($pagepath) || $page['tx_cooluri_excludealways']) {
             ++$max;
             $id = $page['pid'];
             continue;
         }
         foreach ($sel as $s) {
             $trimmed = trim($page[$s]);
             if (!empty($trimmed)) {
                 $title = $trimmed;
                 break;
             }
         }
         if (!empty($conf->sanitize) && $conf->sanitize == 1) {
             $pagepath[] = \Bednarik\Cooluri\Core\Functions::sanitize_title_with_dashes($title);
         } elseif (!empty($conf->t3conv) && $conf->t3conv == 1) {
             $pagepath[] = \Bednarik\Cooluri\Core\Functions::specCharsToASCII($title);
         } elseif (!isset($conf->urlize) || $conf->urlize != 0) {
             $pagepath[] = \Bednarik\Cooluri\Core\Functions::URLize($title);
         } else {
             $pagepath[] = urlencode($title);
         }
         $id = $page['pid'];
         --$max;
         if (!empty($conf->maxsegments) && count($pagepath) >= (int) $conf->maxsegments) {
             $max = 0;
         }
     }
     return $pagepath;
 }