Added some stuff.

git-svn-id: http://svn.cleancode.org/svn/pickles@17 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
Josh Sherman 2008-05-26 21:10:15 +00:00
parent 6c31a4b587
commit 68efc9e5e9
4 changed files with 53 additions and 24 deletions

View file

@ -5,21 +5,24 @@ class Controller {
public function __construct() {
global $smarty;
$sections = Config::get('sections');
define('PATH', '../logic/');
if (
isset($_REQUEST['section']) && in_array($_REQUEST['section'], array_keys($sections))
|| file_exists('../logic/' . $_REQUEST['section'] . ($_REQUEST['action'] ? '.' . $_REQUEST['action'] : null) . '.php')
) {
$section = $action = null;
if (isset($_REQUEST['section'])) {
// Check for section.action.php
if (isset($_REQUEST['action']) && file_exists(PATH . $_REQUEST['section'] . '.' . $_REQUEST['action'] . '.php')) {
$section = $_REQUEST['section'];
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
}
// else check for section.php
else if (file_exists(PATH . $_REQUEST['section'] . '.php')) {
$section = $_REQUEST['section'];
}
// else use the default section
else {
$section = Config::get('default');
$action = '';
}
}
$file = '../logic/' . $section . ($action ? '.' . $action : null) . '.php';
@ -30,6 +33,8 @@ class Controller {
}
/*
@todo not sure I need this at all anymore...
if (!file_exists('../templates/' . $template)) {
$section = Config::get('default');
$action = '';
@ -47,7 +52,7 @@ class Controller {
}
*/
$smarty->assign('sections', $sections);
$smarty->assign('navigation', Config::get('navigation'));
$smarty->assign('section', $section);
$smarty->assign('action', $action);
$smarty->assign('template', $template);

23
config/joshtronic.com.xml Executable file
View file

@ -0,0 +1,23 @@
<config>
<debug></debug>
<disable></disable>
<fckeditor></fckeditor>
<session></session>
<smarty>true</smarty>
<magpierss></magpierss>
<database>
<hostname>localhost</hostname>
<username>joshtronic</username>
<password>j05h7r0n1c</password>
<database>joshtronic</database>
</database>
<default>about</default>
<sections>
<about>About</about>
<family>Family</family>
<music>Music</music>
<code>Code</code>
</sections>
<admin>
</admin>
</config>

View file

@ -12,14 +12,14 @@
<database>verynicenoise</database>
</database>
<default>home</default>
<sections>
<navigation>
<home>Home</home>
<about>About</about>
<releases>Releases</releases>
<artists>Artists</artists>
<shop>Shop</shop>
<contact>Contact</contact>
</sections>
</navigation>
<admin>
<news>News</news>
<releases>Releases</releases>

View file

@ -9,8 +9,8 @@ function __autoload($class) {
// Obliterates any passed in PHPSESSID (thanks Google)
if (stripos($_SERVER['REQUEST_URI'], '?PHPSESSID=') !== false) {
list($request_uri, $phpsessid) = split('\?PHPSESSID=', $_SERVER['REQUEST_URI'], 2);
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$request_uri}");
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $request_uri);
exit();
}
@ -20,6 +20,7 @@ ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,input=src,fieldset=');
// Strips the subdomain before loading the configuration file
$config_array = split('\.', $_SERVER['SERVER_NAME']);
$subless_server = null;
if (count($config_array) == 3) {
$subless_server = $config_array[1] . '.' . $config_array[2];
}
@ -27,7 +28,7 @@ if (count($config_array) == 3) {
// Do some prep work if we're working locally
if (strpos($_SERVER['SERVER_NAME'], '.localhost')) {
foreach (array('com', 'net', 'org') as $tld) {
$config = str_replace('.localhost', '.' . $tld, $config);
$config = str_replace('.localhost', '.' . $tld, $_SERVER['SERVER_NAME']);
if (Config::check($config)) {
$_SERVER['SERVER_NAME'] = $config;