From: Nicolas Boisselier Date: Tue, 7 Jul 2015 16:34:50 +0000 (+0100) Subject: filename2title X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=1fcac35738764b82f72f7f73b5115c6a80db43d9;p=nb.git filename2title --- diff --git a/lib/php/page.php b/lib/php/page.php index 85b9b571..c3e9e46b 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -84,9 +84,10 @@ class Page { function filename2title() { $str = ''; - if (isset($_SERVER['REQUEST_URI'])) $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']); + if (isset($_SERVER['REQUEST_URI'])) $str = preg_replace('/\?.*$/','',preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI'])); if ($str == '' or $str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']); $str = preg_replace('@[\'_-]+$@',' ',$str); + if ($str == 'index') return 'Home'; return mb_strtoupper(mb_substr($str,0,1)).mb_strtolower(mb_substr($str,1,mb_strlen($str))); }