From 6a2d38912467798fa4076454950478294d0784e4 Mon Sep 17 00:00:00 2001 From: ha1t Date: Thu, 4 Dec 2014 17:35:56 +0900 Subject: [PATCH 1/2] add url function --- app/helpers/html_helper.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/helpers/html_helper.php b/app/helpers/html_helper.php index 2cc68bd..96e2c7b 100644 --- a/app/helpers/html_helper.php +++ b/app/helpers/html_helper.php @@ -6,4 +6,27 @@ function eh($string) return; } echo htmlspecialchars($string, ENT_QUOTES); -} \ No newline at end of file +} + +function url($url = '', $params = array()) +{ + $query = http_build_query($params); + if (strlen($query) > 0) { + $query = '?' . $query; + } + if ($url === '') { + $url = substr($_SERVER['REQUEST_URI'], strlen(APP_BASE_PATH)); + $url = APP_URL . $url; + } elseif ($url === '/') { + $url = APP_URL . $query; + } elseif (strpos($url, 'http') === 0) { + $url = $url . $query; + } elseif (strpos($url, '#') === 0) { + $url = $url; + } elseif (strpos($url, '?') === 0) { + $url = $url; + } else { + $url = APP_BASE_PATH . $url . $query; + } + return $url; +} From d96064f4a30bb91c45aaf025ca321e81c32a571e Mon Sep 17 00:00:00 2001 From: ha1t Date: Tue, 16 Dec 2014 13:54:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?url()=E3=82=92=E5=88=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/default.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/default.php b/app/views/layouts/default.php index a954229..048d5ed 100644 --- a/app/views/layouts/default.php +++ b/app/views/layouts/default.php @@ -4,7 +4,7 @@ <?php eh($title)?> - + @@ -22,6 +22,6 @@ - +