Merge branch 'master' of git+ssh://git.sihnon.net/home/git/public/sihnon-php-lib
This commit is contained in:
@@ -91,7 +91,7 @@ class SihnonFramework_Main {
|
||||
}
|
||||
|
||||
public function absoluteUrl($relative_url) {
|
||||
$secure = isset($_SERVER['secure']);
|
||||
$secure = isset($_SERVER['SECURE']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on');
|
||||
$port = $_SERVER['SERVER_PORT'];
|
||||
return 'http' . ($secure ? 's' : '') . '://'
|
||||
. $_SERVER['HTTP_HOST'] . (($port == 80 || ($secure && $port == 443)) ? '' : ':' . $port)
|
||||
|
||||
@@ -52,7 +52,7 @@ class SihnonFramework_Page {
|
||||
}
|
||||
|
||||
// Include the template code file, which will do all the work for this page
|
||||
$real_code_filename = './source/pages/' . $code_filename;
|
||||
$real_code_filename = $this->request->template_code_dir() . DIRECTORY_SEPARATOR . $code_filename;
|
||||
if ($code_filename && file_exists($real_code_filename)) {
|
||||
include $real_code_filename;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,13 @@ class SihnonFramework_RequestParser {
|
||||
private $page = array();
|
||||
private $vars = array();
|
||||
|
||||
public function __construct($request_string) {
|
||||
$this->request_string = $request_string;
|
||||
private $template_dir;
|
||||
private $template_code_dir;
|
||||
|
||||
public function __construct($request_string, $template_dir = './source/templates', $template_code_dir = './source/pages') {
|
||||
$this->request_string = $request_string;
|
||||
$this->template_dir = $template_dir;
|
||||
$this->template_code_dir = $template_code_dir;
|
||||
|
||||
$this->parse();
|
||||
}
|
||||
@@ -25,7 +30,7 @@ class SihnonFramework_RequestParser {
|
||||
|
||||
// Read through the components list looking for elements matching known directories and files
|
||||
// to determine which page this request is for
|
||||
$base_dir = './source/templates';
|
||||
$base_dir = $this->template_dir;
|
||||
while (true) {
|
||||
if ($components && ! $components[0]) {
|
||||
// Skip over any empty components before we find a page
|
||||
@@ -118,6 +123,14 @@ class SihnonFramework_RequestParser {
|
||||
return $this->request_string;
|
||||
}
|
||||
|
||||
public function template_dir() {
|
||||
return $this->template_dir;
|
||||
}
|
||||
|
||||
public function template_code_dir() {
|
||||
return $this->template_code_dir;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user