[Cs-content-commits] SF.net SVN: cs-content:[461] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-09-21 03:26:13
|
Revision: 461 http://cs-content.svn.sourceforge.net/cs-content/?rev=461&view=rev Author: crazedsanity Date: 2009-09-21 03:26:01 +0000 (Mon, 21 Sep 2009) Log Message: ----------- Minor updates to __autoload(), fixes for setting root path. /__autoload.php: * __autoload(): -- drop unused code where all libraries were linked to their respective file names through GLOBALS (never implemented). -- check if class exists after including a file before breaking. -- minor update to debug prints if it couldn't find the file. /contentSystem.class.php: * __construct(): -- drop section requiring the constant SITE_ROOT * initialize_locals(): -- when setting $root, remove "public_html" and "html" from the path. Modified Paths: -------------- trunk/1.0/__autoload.php trunk/1.0/contentSystem.class.php Modified: trunk/1.0/__autoload.php =================================================================== --- trunk/1.0/__autoload.php 2009-09-15 20:53:51 UTC (rev 460) +++ trunk/1.0/__autoload.php 2009-09-21 03:26:01 UTC (rev 461) @@ -21,11 +21,6 @@ function __autoload($class) { - if(is_array($GLOBALS['__autoload__libDefs']) && isset($GLOBALS['__autoload__libDefs'][$class])) { - require_once($GLOBALS['__autoload__libDefs'][$class]); - } - else { - $tried = array(); $fsRoot = dirname(__FILE__) .'/../../'; @@ -55,8 +50,10 @@ if(isset($lsData[$filename])) { $tried[] = $fs->realcwd .'/'. $filename; require_once($fs->realcwd .'/'. $filename); - $found=true; - break; + if(class_exists($class)) { + $found=true; + break; + } } } @@ -70,8 +67,10 @@ if(file_exists($fileLocation)) { $tried[] = $fileLocation; require_once($fileLocation); - $found=true; - break; + if(class_exists($class)) { + $found=true; + break; + } } } } @@ -80,11 +79,10 @@ } } } - } if(!$found) { $gf = new cs_globalFunctions; - $gf->debug_print(__FILE__ ." - line#". __LINE__ ."::: couldn't find (". $class .")",1); + $gf->debug_print(__FILE__ ." - line #". __LINE__ ."::: couldn't find (". $class .")",1); $gf->debug_print($tried,1); $gf->debug_print($tryThis,1); exit; Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-09-15 20:53:51 UTC (rev 460) +++ trunk/1.0/contentSystem.class.php 2009-09-21 03:26:01 UTC (rev 461) @@ -101,10 +101,6 @@ public function __construct($siteRoot=null) { parent::__construct(); - if(is_null($siteRoot) && !defined('SITE_ROOT')) { - throw new exception(__METHOD__ .": must set siteRoot or constant 'SITE_ROOT'"); - } - //setup the section stuff... $repArr = array($_SERVER['SCRIPT_NAME'], "/"); $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); @@ -133,7 +129,9 @@ //build the templating engine: this may cause an immediate redirect, if they need to be logged-in. //TODO: find a way to define this on a per-page basis. Possibly have templateObj->check_login() // run during the "finish" stage... probably using GenericPage{}->check_login(). - $root = $_SERVER['DOCUMENT_ROOT']; + $root = preg_replace('/\/public_html$/', '', $_SERVER['DOCUMENT_ROOT']); + $root = preg_replace('/\/html/', '', $root); + if(!is_null($siteRoot) && is_dir($siteRoot)) { $root = $siteRoot; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |