Add lcfirst implementation for PHP < 5.3

This commit is contained in:
ruan 2016-01-18 09:50:54 +02:00
parent 676931a4a9
commit 816d9c781d
3 changed files with 12 additions and 2 deletions

View File

@ -30,7 +30,7 @@ class Check {
$from_type = $page->type_info($from); $from_type = $page->type_info($from);
$type = $from_type['type']; $type = $from_type['type'];
if ($type !== null) { if ($type !== null) {
$href .= "&from=" . lcfirst($from_type['title']); $href .= "&from=" . Page::lc_first($from_type['title']);
} }
echo "<br><script type=\"text/javascript\">document.location=\"$href\";</script>"; echo "<br><script type=\"text/javascript\">document.location=\"$href\";</script>";

View File

@ -95,7 +95,7 @@ if (isset($_GET['from'])) {
$info = $page->type_info($_GET['from']); $info = $page->type_info($_GET['from']);
if ($info['type'] !== null) { if ($info['type'] !== null) {
$from_title = $info['title']; $from_title = $info['title'];
$from = lcfirst($from_title); $from = Page::lc_first($from_title);
$from_href = "$from.php"; $from_href = "$from.php";
} }
} }

View File

@ -390,4 +390,14 @@ class Page {
echo "<script type=\"text/javascript\">withjQuery(function(){ $('tr').click(function(){var href=$(this).find('a').attr('href');if(href!==undefined)window.location=href;}).hover(function(){\$(this).toggleClass('hover');}); });</script>"; echo "<script type=\"text/javascript\">withjQuery(function(){ $('tr').click(function(){var href=$(this).find('a').attr('href');if(href!==undefined)window.location=href;}).hover(function(){\$(this).toggleClass('hover');}); });</script>";
} }
} }
/**
* lcfirst is only supported in PHP >= 5.3
* @param $str
* @return string
*/
static function lc_first($str) {
$str[0] = strtolower($str[0]);
return (string)$str;
}
} }