/** * Detect the user's preferred language. * * @return string First two letters of the languages of the client browser. */ public function getLanguage() { $oStr = new Str(); $sLang = explode(',', Server::getVar(Server::HTTP_ACCEPT_LANGUAGE))[0]; // The rtrim function is slightly faster than chop function return $oStr->escape($oStr->lower(substr(rtrim($sLang), 0, 2))); unset($oStr); }
/** * Clean URL. * * @static * @param string $sUrl * @param boolean $bFullClean Also removes points, puts characters to lowercase, etc. Default TRUE * @return string The new clean URL */ public static function clean($sUrl, $bFullClean = true) { $sUrl = preg_replace('/[\\s]+/', '-', $sUrl); $sUrl = str_replace(array('«', '»', '"', '~', '#', '$', '@', '`', '§', '$', '£', 'µ', '[', ']', '<', '>', '%', '*', '{', '}'), '-', $sUrl); if ($bFullClean) { $sUrl = str_replace(array('.', '^', ',', ':', ';', '!'), '', $sUrl); $oStr = new Str(); $sUrl = $oStr->lower($sUrl); $sUrl = $oStr->escape($sUrl, true); unset($oStr); } return $sUrl; }