/**
  * REWRITE()
  *
  * rewrite URL
  * @param $params from EP URL_REWRITE
  */
 function rewrite($params)
 {
     // URL ALREADY SET BY OTHER EXTENSION
     if ($params['subject'] != '') {
         return $params['subject'];
     }
     // EP "SEO42_PRE_REWRITE"
     $url = rex_register_extension_point('SEO42_PRE_REWRITE', false, $params);
     if ($url !== false) {
         return $url;
     }
     global $REX, $SEO42_IDS;
     $id = $params['id'];
     $name = $params['name'];
     $clang = $params['clang'];
     $subdir = '';
     // 42 | $REX['ADDON']['seo42']['settings']['install_subdir']
     $notfound_id = $REX['NOTFOUND_ARTICLE_ID'];
     // GET PARAMS STRING
     $urlparams = self::makeUrlParams($params);
     // GET URL FROM PATHLIST AND APPEND PARAMS
     if (isset($SEO42_IDS[$id]) && isset($SEO42_IDS[$id][$clang])) {
         $base_url = $SEO42_IDS[$id][$clang]['url'];
         $url = $base_url . $urlparams;
         $notfound = false;
     } else {
         // RexDude
         $url = '';
         $base_url = '';
         if (!empty($SEO42_IDS)) {
             if (!isset($SEO42_IDS[$notfound_id][$clang]['url'])) {
                 $clang = $REX['START_CLANG_ID'];
             }
             $url = $base_url = $SEO42_IDS[$notfound_id][$clang]['url'];
         }
         $notfound = true;
     }
     // URL START
     // 42
     if ($REX['REDAXO'] && !(rex_request('page', 'string') == 'seo42' && rex_request('subpage', 'string') == 'help')) {
         // for seo42 debug page urls should look like in frontend
         $subdir = '';
     } else {
         $subdir = seo42::getUrlStart() . $subdir;
     }
     // HACK: EP URL_REWRITE WON'T ACCEPT EMPTY STRING AS RETURN
     if ($subdir == '' && $url == '') {
         $url = ' ';
     }
     // str_replace fixes a caching bug that appears while updating specific
     // modules/slices in the redaxo backend
     $url = str_replace('/redaxo/', '/', $subdir . $url);
     // retrieve trimmend url
     $trimmedUrl = seo42::trimUrl($url);
     // external urls / javascript urls etc. so we have to remove the url start string
     if (!seo42_utils::isInternalCustomUrl($trimmedUrl)) {
         $url = $trimmedUrl;
     }
     // EP "SEO42_POST_REWRITE"
     $ep_params = array('article_id' => $id, 'clang' => $clang, 'notfound' => $notfound, 'base_url' => $base_url, 'subdir' => $subdir, 'urlparams' => $urlparams, 'params' => $params['params'], 'divider' => $params['divider']);
     $url = rex_register_extension_point('SEO42_POST_REWRITE', $url, $ep_params);
     return $url;
 }
 public static function getFullUrl($id = '', $clang = '', $params = '', $divider = '&')
 {
     $url = self::getTrimmedUrl($id, $clang, $params, $divider);
     if (seo42_utils::isInternalCustomUrl($url)) {
         return self::getBaseUrl() . $url;
     } else {
         return $url;
     }
 }