From d5d2aacf19a876da3d11101866a90f94ca97feb2 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 21 Mar 2012 11:54:48 +0000 Subject: [PATCH] added __LOCALURL__ --- codepot/src/codepot/controllers/site.php | 5 +- codepot/src/codepot/controllers/wiki.php | 9 +-- codepot/src/codepot/libraries/wikihelper.php | 71 +++++++++++++------- 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 04bb6733..1c832693 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -449,10 +449,7 @@ class Site extends Controller } else { - if ($link->extra === NULL) - redirect ("{$link->type}/{$link->target}/{$link->projectid}"); - else - redirect ("{$link->type}/{$link->target}/{$link->projectid}/{$link->extra}"); + redirect ($link); } } diff --git a/codepot/src/codepot/controllers/wiki.php b/codepot/src/codepot/controllers/wiki.php index 5f48b27a..abd82e86 100644 --- a/codepot/src/codepot/controllers/wiki.php +++ b/codepot/src/codepot/controllers/wiki.php @@ -109,10 +109,7 @@ class Wiki extends Controller else if ($link !== NULL) { // redirect to a special link like __WIKI__:projectid:wikiname - if ($link->extra === NULL) - redirect ("{$link->type}/{$link->target}/{$link->projectid}"); - else - redirect ("{$link->type}/{$link->target}/{$link->projectid}/{$link->extra}"); + redirect ($link); } else { @@ -270,8 +267,8 @@ class Wiki extends Controller header ('Cache-Control: max-age=0'); $reqheaders = function_exists('apache_request_headers')? apache_request_headers(): array(); - if (isset($reqheaders['If-Modified-Since']) && - strtotime($reqheaders['If-Modified-Since']) >= $mtime) + if (isset($reqheaders['If-Modified-Since']) && + strtotime($reqheaders['If-Modified-Since']) >= $mtime) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mtime).' GMT', true, 304); flush (); diff --git a/codepot/src/codepot/libraries/wikihelper.php b/codepot/src/codepot/libraries/wikihelper.php index 6263d14d..9a45587f 100644 --- a/codepot/src/codepot/libraries/wikihelper.php +++ b/codepot/src/codepot/libraries/wikihelper.php @@ -11,13 +11,17 @@ class WikiHelper if ($this->_is_reserved ($name, TRUE)) { $ex0 = $this->_trans_reserved ($name); - //redirect ("{$ex0}/home/{$projectid}"); - $link->type = $ex0; - $link->target = 'home'; - $link->projectid = $projectid; - if ($link->projectid == NULL) return FALSE; - $link->extra = NULL; + //redirect ("{$ex0}/home/{$projectid}"); + + //$link->type = $ex0; + //$link->target = 'home'; + //$link->projectid = $projectid; + //if ($link->projectid == NULL) return FALSE; + //$link->extra = NULL; + + if ($projectid == NULL) return FALSE; + $link = "{$ex0}/home/{$projectid}"; return $link; } else @@ -26,19 +30,25 @@ class WikiHelper $cnt = count($ex); if ($cnt == 2) { - if ($this->_is_reserved ($ex[0], TRUE)) + if ($ex[0] == '__LOCALURL__') + { + return ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')? 'https': 'http') . '://' . $_SERVER['HTTP_HOST'] . $ex[1]; + } + else if ($this->_is_reserved ($ex[0], TRUE)) { $ex0 = $this->_trans_reserved ($ex[0]); $ex1 = ($ex[1] == '')? $projectid: $ex[1]; //redirect ("{$ex0}/home/{$ex1}"); - $link->type = $ex0; - $link->target = 'home'; - $link->projectid = $ex1; - if ($link->projectid == NULL) return FALSE; + //$link->type = $ex0; + //$link->target = 'home'; + //$link->projectid = $ex1; + //if ($link->projectid == NULL) return FALSE; + //$link->extra = NULL; - $link->extra = NULL; + if ($ex1 == NULL) return FALSE; + $link = "{$ex0}/home/{$ex1}"; return $link; } } @@ -52,12 +62,14 @@ class WikiHelper $ex2 = $converter->AsciiToHex ($ex[2]); //redirect ("{$ex0}/show/{$ex1}/{$ex2}"); - $link->type = $ex0; - $link->target = 'show'; - $link->projectid = $ex1; - if ($link->projectid == NULL) return FALSE; + //$link->type = $ex0; + //$link->target = 'show'; + //$link->projectid = $ex1; + //if ($link->projectid == NULL) return FALSE; + //$link->extra = $ex2; - $link->extra = $ex2; + if ($ex1 == NULL) return FALSE; + $link = "{$ex0}/show/{$ex1}/{$ex2}"; return $link; } } @@ -72,12 +84,14 @@ class WikiHelper { $ex3 = $converter->AsciiToHex ($ex[3]); //redirect ("{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"); - $link->type = $ex0; - $link->target = $ex[2]; - $link->projectid = $ex1; - if ($link->projectid == NULL) return FALSE; + //$link->type = $ex0; + //$link->target = $ex[2]; + //$link->projectid = $ex1; + //if ($link->projectid == NULL) return FALSE; + //$link->extra = $ex3; - $link->extra = $ex3; + if ($ex1 == NULL) return FALSE; + $link = "{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"; return $link; } @@ -87,11 +101,16 @@ class WikiHelper { // __WIKI__:projectid:wikiname:attachment - $link->type = $this->_trans_reserved ($ex[0]); - $link->target = 'attachment0'; - $link->projectid = ($ex[1] == '')? $projectid: $ex[1]; - $link->extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); + //$link->type = $this->_trans_reserved ($ex[0]); + //$link->target = 'attachment0'; + //$link->projectid = ($ex[1] == '')? $projectid: $ex[1]; + //$link->extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); + $ex0 = $this->_trans_reserved ($ex[0]); + $ex1 = ($ex[1] == '')? $projectid: $ex[1]; + $extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); + $link = "{$ex0}/attachment0/{$ex1}/{$extra}"; + return $link; } }