Updates to the logic flow for determining the section to be loaded.
git-svn-id: http://svn.cleancode.org/svn/pickles@18 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
68efc9e5e9
commit
6871bb0f57
2 changed files with 31 additions and 28 deletions
|
@ -5,24 +5,31 @@ class Controller {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
global $smarty;
|
global $smarty;
|
||||||
|
|
||||||
define('PATH', '../logic/');
|
|
||||||
|
|
||||||
$section = $action = null;
|
$section = $action = null;
|
||||||
|
|
||||||
if (isset($_REQUEST['section'])) {
|
if (isset($_REQUEST['section'])) {
|
||||||
// Check for section.action.php
|
// Check for section.action.php
|
||||||
if (isset($_REQUEST['action']) && file_exists(PATH . $_REQUEST['section'] . '.' . $_REQUEST['action'] . '.php')) {
|
if (isset($_REQUEST['action']) && file_exists('../logic/' . $_REQUEST['section'] . '.' . $_REQUEST['action'] . '.php')) {
|
||||||
$section = $_REQUEST['section'];
|
$section = $_REQUEST['section'];
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
}
|
}
|
||||||
// else check for section.php
|
// else check for section.php
|
||||||
else if (file_exists(PATH . $_REQUEST['section'] . '.php')) {
|
else if (file_exists('../logic/' . $_REQUEST['section'] . '.php')) {
|
||||||
$section = $_REQUEST['section'];
|
$section = $_REQUEST['section'];
|
||||||
}
|
}
|
||||||
// else use the default section
|
// Check for section.action.tpl
|
||||||
else {
|
else if (isset($_REQUEST['action']) && file_exists('../templates/' . $_REQUEST['section'] . '.' . $_REQUEST['action'] . '.tpl')) {
|
||||||
$section = Config::get('default');
|
$section = $_REQUEST['section'];
|
||||||
|
$action = $_REQUEST['action'];
|
||||||
}
|
}
|
||||||
|
// else check for section.tpl
|
||||||
|
else if (file_exists('../templates/' . $_REQUEST['section'] . '.tpl')) {
|
||||||
|
$section = $_REQUEST['section'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($section)) {
|
||||||
|
$section = Config::get('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = '../logic/' . $section . ($action ? '.' . $action : null) . '.php';
|
$file = '../logic/' . $section . ($action ? '.' . $action : null) . '.php';
|
||||||
|
@ -32,26 +39,6 @@ class Controller {
|
||||||
require_once $file;
|
require_once $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@todo not sure I need this at all anymore...
|
|
||||||
|
|
||||||
if (!file_exists('../templates/' . $template)) {
|
|
||||||
$section = Config::get('default');
|
|
||||||
$action = '';
|
|
||||||
|
|
||||||
$file = '../logic/' . $section . ($action ? '.' . $action : null) . '.php';
|
|
||||||
$template = $section . ($action ? '.' . $action : null) . '.tpl';
|
|
||||||
|
|
||||||
if (file_exists('../logic/' . $file)) {
|
|
||||||
require_once $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists('../templates/' . $template)) {
|
|
||||||
// This would be considered a critical error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$smarty->assign('navigation', Config::get('navigation'));
|
$smarty->assign('navigation', Config::get('navigation'));
|
||||||
$smarty->assign('section', $section);
|
$smarty->assign('section', $section);
|
||||||
$smarty->assign('action', $action);
|
$smarty->assign('action', $action);
|
||||||
|
|
18
jLib.php
18
jLib.php
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
date_default_timezone_set('America/New_York');
|
date_default_timezone_set('America/New_York');
|
||||||
|
define('JLIB_PATH', '/var/www/josh/common/');
|
||||||
|
|
||||||
function __autoload($class) {
|
function __autoload($class) {
|
||||||
require_once "/var/www/josh/common/classes/{$class}.php";
|
require_once JLIB_PATH . 'classes/' . $class . '.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obliterates any passed in PHPSESSID (thanks Google)
|
// Obliterates any passed in PHPSESSID (thanks Google)
|
||||||
|
@ -68,6 +69,21 @@ if (Config::getSmarty()) {
|
||||||
$smarty->compile_dir = $compile_dir;
|
$smarty->compile_dir = $compile_dir;
|
||||||
|
|
||||||
$smarty->load_filter('output','trimwhitespace');
|
$smarty->load_filter('output','trimwhitespace');
|
||||||
|
|
||||||
|
// Include custom Smarty functions
|
||||||
|
$directory = JLIB_PATH . 'smarty/';
|
||||||
|
if (is_dir($directory)) {
|
||||||
|
if ($handle = opendir($directory)) {
|
||||||
|
while (($file = readdir($handle)) !== false) {
|
||||||
|
if (!preg_match('/^\./', $file)) {
|
||||||
|
list($type, $name, $ext) = split('\.', $file);
|
||||||
|
require_once $directory . $file;
|
||||||
|
$smarty->register_function($name, "smarty_{$type}_{$name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the FCKeditor instead of textareas
|
// Use the FCKeditor instead of textareas
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue