[Cs-content-commits] SF.net SVN: cs-content:[394] releases/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-06-12 14:01:46
|
Revision: 394 http://cs-content.svn.sourceforge.net/cs-content/?rev=394&view=rev Author: crazedsanity Date: 2009-06-12 13:52:39 +0000 (Fri, 12 Jun 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA9 *** SUMMARY OF CHANGES::: * stop incorrectly removing leading slash for main template path * use constant (DEFAULT_SECTION) for default section instead of hard-coding. * separate cs_fileSystem objects for includes and templates * new internal method ensures includes only loaded once in proper order * debug_var_dump() method for extra debugging power * includes can now stop template system from printing at the end of finish() * many minor fixes to eliminate PHP notices/warnings * properly handles "htdocs" as a possible siteRoot. * set default message type as "notice" * inject vars into pages from where contentSystem{} is initialized * many fixes to remove PHP warnings/notices * cs_siteConfig can add entire sections to $GLOBALS (#271) * major changes to cs_tabs * tab template only parsed at display time * require SITE_ROOT constant in cs_genericPage * Support "after" includes (#273) * support non-root installations using APPURL constant * consolidated internal logic for adding template files in contentSystem * no more arbitrary setting of global SITE_ROOT * 404 page parsed using the message box instead of hard-coded into template * removed unused templates * GLOBALS settings override constants for debug settings * better support for MySQL databases * cs_siteConfig automatically sets APPURL (use "{_APPURL_}" in config file) SVN COMMAND::: merge --depth=infinity -r363:HEAD https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0 Modified Paths: -------------- releases/1.0/VERSION releases/1.0/contentSystem.class.php releases/1.0/cs_fileSystem.class.php releases/1.0/cs_genericPage.class.php releases/1.0/cs_globalFunctions.class.php releases/1.0/cs_siteConfig.class.php releases/1.0/cs_tabs.class.php releases/1.0/db_types/cs_phpDB__mysql.class.php releases/1.0/sample_files/templates/system/404.shared.tmpl releases/1.0/sample_files/templates/system/message_box.tmpl releases/1.0/tests/testOfCSContent.php Added Paths: ----------- releases/1.0/sample_files/public_html/images/ releases/1.0/sample_files/public_html/images/clear.gif releases/1.0/sample_files/public_html/images/frame/ releases/1.0/sample_files/public_html/images/frame/crn-white-bl.gif releases/1.0/sample_files/public_html/images/frame/crn-white-br.gif releases/1.0/sample_files/public_html/images/frame/crn-white-tl.gif releases/1.0/sample_files/public_html/images/frame/crn-white-tr.gif Removed Paths: ------------- releases/1.0/sample_files/public_html/images/clear.gif releases/1.0/sample_files/public_html/images/frame/ releases/1.0/sample_files/public_html/images/frame/crn-white-bl.gif releases/1.0/sample_files/public_html/images/frame/crn-white-br.gif releases/1.0/sample_files/public_html/images/frame/crn-white-tl.gif releases/1.0/sample_files/public_html/images/frame/crn-white-tr.gif releases/1.0/sample_files/templates/system/construction.content.tmpl releases/1.0/sample_files/templates/system/db_error.tmpl Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/VERSION 2009-06-12 13:52:39 UTC (rev 394) @@ -1,5 +1,5 @@ ## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. -VERSION: 1.0-ALPHA8 +VERSION: 1.0-ALPHA9 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/contentSystem.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -63,13 +63,6 @@ * |--> /includes/content/members/test.inc */ -//TODO: remove this terrible little hack. -if(!isset($GLOBALS['SITE_ROOT'])) { - //define where our scripts are located. - $GLOBALS['SITE_ROOT'] = $_SERVER['DOCUMENT_ROOT']; - $GLOBALS['SITE_ROOT'] = str_replace("/public_html", "", $GLOBALS['SITE_ROOT']); -} - require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); require_once(dirname(__FILE__) ."/cs_fileSystem.class.php"); require_once(dirname(__FILE__) ."/cs_session.class.php"); @@ -81,7 +74,12 @@ protected $baseDir = NULL; //base directory for templates & includes. protected $section = NULL; //section string, derived from the URL. protected $sectionArr = array(); //array of items, for figuring out where templates & includes are. - protected $fileSystemObj = NULL; //the object used to access the filesystem. + + + protected $tmplFs = NULL; //Object used to access the TEMPLATES filesystem + protected $incFs = NULL; //Object used to access the INCLUDES filesystem + + protected $ignoredList = array( //array of files & folders that are implicitely ignored. 'file' => array('.htaccess'), 'dir' => array('.svn','CVS' @@ -89,6 +87,7 @@ ); protected $templateList = array(); protected $includesList = array(); + protected $afterIncludesList= array(); public $templateObj = NULL; protected $gfObj = NULL; protected $tabs = NULL; @@ -98,6 +97,8 @@ private $isValid=FALSE; private $reason=NULL; + private $injectVars=array(); + //------------------------------------------------------------------------ /** * The CONSTRUCTOR. Duh. @@ -110,6 +111,10 @@ } else { + if(!defined('SITE_ROOT')) { + throw new exception(__METHOD__ .": must set required constant 'SITE_ROOT'"); + } + //setup the section stuff... $repArr = array($_SERVER['SCRIPT_NAME'], "/"); $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); @@ -137,6 +142,7 @@ //setup some default template vars. $this->templateObj->add_template_var('date', date('m-d-Y')); $this->templateObj->add_template_var('time', date('H:i:s')); + $this->templateObj->add_template_var('curYear', date('Y')); $myUrl = '/'; if(strlen($this->section) && $this->section !== 0) { @@ -144,9 +150,27 @@ } $this->templateObj->add_template_var('CURRENT_URL', $myUrl); - //create a fileSystem object. - $this->fileSystemObj = new cs_fileSystem(); + if(defined('APPURL')) { + //set the APPURL as a template var. + $this->templateObj->add_template_var('APPURL', constant('APPURL')); + } + //create a fileSystem object for templates. + $tmplBaseDir = constant('SITE_ROOT') .'/templates'; + if(defined('TMPLDIR')) { + $tmplBaseDir = constant('TMPLDIR'); + } + $this->tmplFs = new cs_fileSystem($tmplBaseDir); + + + //create a fileSystem object for includes + $incBaseDir = constant('SITE_ROOT') .'/includes'; + if(defined('INCLUDES_DIR')) { + $incBaseDir = constant('INCLUDES_DIR'); + } + $this->incFs = new cs_fileSystem($incBaseDir); + + //create a tabs object, in case they want to load tabs on the page. $this->tabs = new cs_tabs($this->templateObj); @@ -155,8 +179,8 @@ if($this->templateObj->get_version() !== $myVersion) { throw new exception(__METHOD__ .": ". get_class($this->templateObj) ." has mismatched version (". $this->templateObj->get_version() ." does not equal ". $myVersion .")"); } - if($this->fileSystemObj->get_version() !== $myVersion) { - throw new exception(__METHOD__ .": ". get_class($this->fileSystemObj) ." has mismatched version (". $this->fileSystemObj->get_version() ." does not equal ". $myVersion .")"); + if($this->tmplFs->get_version() !== $myVersion) { + throw new exception(__METHOD__ .": ". get_class($this->tmplFs) ." has mismatched version (". $this->tmplFs->get_version() ." does not equal ". $myVersion .")"); } if($this->gfObj->get_version() !== $myVersion) { throw new exception(__METHOD__ .": ". get_class($this->gfObj) ." has mismatched version (". $this->gfObj->get_version() ." does not equal ". $myVersion .")"); @@ -178,12 +202,12 @@ //------------------------------------------------------------------------ private function get_template_dirs() { if(is_array($this->sectionArr)) { - $this->fileSystemObj->cd("/templates/". $this->baseDir); + $this->tmplFs->cd('/'. $this->baseDir); $retval = array(); - $retval[] = $this->fileSystemObj->cwd; + $retval[] = $this->tmplFs->cwd; foreach($this->sectionArr as $index=>$name) { - if($this->fileSystemObj->cd($name)) { - $retval[] = $this->fileSystemObj->cwd; + if($this->tmplFs->cd($name)) { + $retval[] = $this->tmplFs->cwd; } else { break; @@ -264,16 +288,21 @@ private function parse_section() { //TODO::: this should be an OPTIONAL THING as to how to handle "/" (i.e. CSCONTENT_HANDLE_ROOTURL='content/index') - if($this->section === 0 || is_null($this->section) || !strlen($this->section)) { - $this->section = "content/index"; + if(($this->section === 0 || is_null($this->section) || !strlen($this->section)) && defined('DEFAULT_SECTION')) { + $this->section = preg_replace('/^\//', '', constant('DEFAULT_SECTION')); } $myArr = split('/', $this->section); //if we've got something in the array, keep going. - if(is_array($myArr) && count($myArr) && ($myArr[0] !== 0)) { + if(is_array($myArr) && count($myArr) > 0) { + + //TODO: if there's only one section here, sectionArr becomes BLANK... does that cause unexpected behaviour? $this->baseDir = array_shift($myArr); $this->sectionArr = $myArr; } + else { + throw new exception(__METHOD__ .": failed to get an array from section (". $this->section .")"); + } }//end parse_section() //------------------------------------------------------------------------ @@ -296,7 +325,15 @@ return(NULL); } else { - //check the string to make sure it doesn't begin or end with a "/" + + //if there's an "APPURL" constant, drop that from the section. + if(defined('APPURL') && strlen(constant('APPURL'))) { + $dropThis = preg_replace('/^\//', '', constant('APPURL')); + $dropThis = preg_replace('/\//', '\\/', $dropThis); + $section = preg_replace('/^'. $dropThis .'/', '', $section); + } + + //check the string to make sure it doesn't begin with a "/" if($section[0] == '/') { $section = substr($section, 1, strlen($section)); } @@ -340,15 +377,11 @@ */ private function prepare() { //attempt to load any includes... - if($this->fileSystemObj->cd('/includes')) { - $this->load_includes(); - } + $this->load_includes(); $foundIncludes = count($this->includesList); - //cd() in to the templates directory. - $cdResult = $this->fileSystemObj->cd('/templates'); $validatePageRes = $this->validate_page(); - if($foundIncludes || ($cdResult && $validatePageRes)) { + if($foundIncludes || $validatePageRes) { //okay, get template directories & start loading $tmplDirs = $this->get_template_dirs(); @@ -366,7 +399,8 @@ $this->load_page_templates(); //now cd() all the way back. - $this->fileSystemObj->cd('/'); + $this->tmplFs->cd('/'); + $this->incFs->cd('/'); } else { //couldn't find the templates directory, and no includes... it's dead. @@ -381,84 +415,36 @@ /** * Ensures the page we're on would actually load, so other methods don't have to do * so much extra checking. + * + * TODO: the if & else should be consolidated as much as possible... */ private function validate_page() { - $valid = FALSE; - //if we've got a non-basedir page, (instead of "/whatever", we have "/whatever/x"), see - // if there are templates that make it good... or just check the base template. + + $this->tmplFs->cd('/'); + + $valid = false; + if((count($this->sectionArr) > 0) && !((count($this->sectionArr) == 1) && ($this->sectionArr[0] == 'index'))) { - //got more than just a baseDir url... see if the template is good. - $finalLink = $this->gfObj->string_from_array($this->sectionArr, NULL, '/'); - $this->fileSystemObj->cd($this->baseDir); $mySectionArr = $this->sectionArr; - $finalSection = array_pop($mySectionArr); - $this->finalSection = $finalSection; - if(count($mySectionArr) > 0) { - foreach($mySectionArr as $dir) { - if(!$this->fileSystemObj->cd($dir)) { - break; - } - } - } - - //check for the file & the directory... - $indexFilename = $finalSection ."/index.content.tmpl"; - if(!strlen($finalSection)) { - $indexFilename = 'index.content.tmpl'; - } - - $lsDir = $this->fileSystemObj->ls($indexFilename); - $lsDirVals = array_values($lsDir); - $lsFile = $this->fileSystemObj->ls("$finalSection.content.tmpl"); - - if(is_array(array_values($lsFile)) && is_array($lsFile[$finalSection .".content.tmpl"])) { - //it's the file ("{finalSection}.content.tmpl", like "mySection.content.tmpl") - $myIndex = $finalSection .".content.tmpl"; - } - elseif(is_array(array_values($lsDir)) && (is_array($lsDir[$indexFilename]))) { - $myIndex = $indexFilename; - } - else { - //nothin' doin'. - $myIndex = NULL; - } - - //check the index file for validity... this is kind of a dirty hack... but it works. - $checkMe = $this->fileSystemObj->ls($myIndex); - if(!is_array($checkMe[$myIndex])) { - unset($myIndex); - } - - if(isset($myIndex)) { - $valid = TRUE; - $this->fileSystemObj->cd('/templates'); - } - else { - $this->reason = __METHOD__ .": couldn't find page template for ". $this->section; - } + $this->finalSection = array_pop($mySectionArr); + $reasonText = "page template"; } else { - //if the baseDir is "help", this would try to use "/help/index.content.tmpl" - $myFile = $this->baseDir .'/index.content.tmpl'; - $sectionLsData = $this->fileSystemObj->ls($myFile); - - //if the baseDir is "help", this would try to use "/help.content.tmpl" - $sectionFile = $this->baseDir .'.content.tmpl'; - $lsData = $this->fileSystemObj->ls(); - - if(isset($lsData[$sectionFile]) && is_array($lsData[$sectionFile])) { - $valid = TRUE; - $this->finalSection = $this->baseDir; - } - elseif(isset($sectionLsData[$myFile]) && $sectionLsData[$myFile]['type'] == 'file') { - //we're good. - $valid = TRUE; - $this->finalSection = $this->baseDir; - } - else { - $this->reason = __METHOD__ .": couldn't find base template."; - } + $this->finalSection = $this->baseDir; + $reasonText = "base template"; } + + $tmplFile1 = $this->section .".content.tmpl"; + $tmplFile2 = $this->section ."/index.content.tmpl"; + + if(file_exists($this->tmplFs->realcwd ."/". $tmplFile2) || file_exists($this->tmplFs->realcwd ."/". $tmplFile1)) { + $valid = true; + $this->reason=null; + } + else { + $valid = false; + $this->reason=__METHOD__ .": couldn't find ". $reasonText; + } $this->isValid = $valid; return($valid); @@ -476,45 +462,44 @@ // looking for templates. $mySectionArr = $this->sectionArr; - $finalSection = $this->sectionArr[(count($this->sectionArr) -1)]; + $finalSection = $this->finalSection; foreach($mySectionArr as $index=>$value) { $tmplList = $this->arrange_directory_contents('name', 'section'); if(isset($tmplList[$value])) { foreach($tmplList[$value] as $mySection=>$myTmpl) { - // - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } - if(!$this->fileSystemObj->cd($value)) { + if(!$this->tmplFs->cd($value)) { break; } } - //load the final template(s). $finalTmplList = $this->arrange_directory_contents('name', 'section'); + foreach($finalTmplList as $mySection => $subArr) { + foreach($subArr as $internalSection => $myTmpl) { + $this->add_template($mySection, $myTmpl); + } + } + + //go through the final section, if set, so the templates defined there are used. if(isset($finalTmplList[$finalSection])) { foreach($finalTmplList[$finalSection] as $mySection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } - elseif(is_array($finalTmplList)) { - foreach($finalTmplList as $mySection => $subArr) { - foreach($subArr as $internalSection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; - } - } - } - if($this->fileSystemObj->cd($finalSection)) { + + if($this->tmplFs->cd($finalSection)) { //load the index stuff. $tmplList = $this->arrange_directory_contents('name', 'section'); if(isset($tmplList['index'])) { foreach($tmplList['index'] as $mySection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; + $this->add_template($mySection, $myTmpl); } } if(isset($tmplList[$this->baseDir]['content'])) { //load template for the main page (if $this->baseDir == "help", this would load "/help.content.tmpl" as content) - $this->templateList['content'] = $tmplList[$this->baseDir]['content']; + $this->add_template('content', $tmplList[$this->baseDir]['content']); } } }//end load_page_templates() @@ -527,14 +512,14 @@ * loads templates for the main section they're on. */ private function load_main_templates() { - $this->fileSystemObj->cd('/templates'); //check to see if the present section is valid. - $this->fileSystemObj->cd($this->baseDir); + $this->tmplFs->cd('/'); $dirContents = $this->arrange_directory_contents('name', 'section'); + $this->tmplFs->cd($this->baseDir); if(is_array($dirContents)) { foreach($dirContents as $mySection => $subArr) { foreach($subArr as $subIndex=>$templateFilename) { - $this->templateList[$mySection] = $templateFilename; + $this->add_template($mySection, $templateFilename); } } } @@ -550,10 +535,10 @@ private function load_shared_templates($path=NULL) { if(!is_null($path)) { - $this->fileSystemObj->cd($path); + $this->tmplFs->cd($path); } else { - $this->fileSystemObj->cd('/templates'); + $this->tmplFs->cd('/'); } //pull a list of the files. @@ -561,7 +546,7 @@ if(count($dirContents['shared'])) { foreach($dirContents['shared'] as $section => $template) { - $this->templateList[$section] = $template; + $this->add_template($section, $template); } } }//end load_shared_templates() @@ -575,13 +560,13 @@ * name, or vice-versa. */ private function arrange_directory_contents($primaryIndex='section', $secondaryIndex='name') { - $directoryInfo = $this->fileSystemObj->ls(); + $directoryInfo = $this->tmplFs->ls(); $arrangedArr = array(); if(is_array($directoryInfo)) { foreach($directoryInfo as $index=>$data) { $myType = $data['type']; if(($myType == 'file') && !in_array($index, $this->ignoredList[$myType])) { - $filename = $this->gfObj->create_list($this->fileSystemObj->cwd, $index, '/'); + $filename = $this->gfObj->create_list($this->tmplFs->cwd, $index, '/'); $filename = preg_replace('/^\/templates/', '', $filename); $filename = preg_replace('/^\/\//', '/', $filename); //call another method to rip the filename apart properly, then arrange things as needed. @@ -652,8 +637,7 @@ $this->load_dir_includes($this->baseDir); //okay, now loop through $this->sectionArr & see if we can include anything else. - $addIndex=false; - if(($this->fileSystemObj->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { + if(($this->incFs->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { //if the last item in the array is "index", disregard it... @@ -669,26 +653,26 @@ $this->load_dir_includes($mySection); //attempt to cd() into the next directory, or die if we can't. - if(!$this->fileSystemObj->cd($mySection)) { + if(!$this->incFs->cd($mySection)) { //no dice. Break the loop. - $addIndex = false; break; } - else { - //okay, we made it to the final directory; add the magic "index.inc" file if it exists. - $addIndex = true; - } } } //include the final shared & index files. - $lsData = $this->fileSystemObj->ls(); - if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { - $this->add_include('shared.inc'); + if($this->incFs->cd($this->finalSection)) { + $lsData = $this->incFs->ls(); + if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { + $this->add_include('shared.inc'); + } + if(isset($lsData['shared.after.inc']) && is_array($lsData['shared.after.inc'])) { + $this->add_include('shared.after.inc',true); + } + if(isset($lsData['index.inc']) && is_array($lsData['index.inc'])) { + $this->add_include('index.inc'); + } } - if(isset($lsData['index.inc']) && is_array($lsData['index.inc']) && $addIndex==true) { - $this->add_include('index.inc'); - } }//end load_includes() //------------------------------------------------------------------------ @@ -700,24 +684,34 @@ * solely by load_includes(). */ private function load_dir_includes($section) { - $lsData = $this->fileSystemObj->ls(); + $lsData = $this->incFs->ls(); + $addThese = array(); + //attempt to load the shared includes file. if(isset($lsData['shared.inc']) && $lsData['shared.inc']['type'] == 'file') { $this->add_include('shared.inc'); } + //add the shared "after" script. + if(isset($lsData['shared.after.inc'])) { + $addThese [] = 'shared.after.inc'; + } + //attempt to load the section's includes file. $myFile = $section .'.inc'; if(isset($lsData[$myFile]) && $lsData[$myFile]['type'] == 'file') { $this->add_include($myFile); } - if(isset($lsData[$section]) && !count($this->sectionArr)) { - $this->fileSystemObj->cd($section); - $lsData = $this->fileSystemObj->ls(); - if(isset($lsData['index.inc'])) { - $this->includesList[] = $this->fileSystemObj->realcwd .'/index.inc'; + //add the section "after" script. + if(isset($lsData[$section .'.after.inc'])) { + $addThese [] = $section .'.after.inc'; + } + + if(is_array($addThese) && count($addThese)) { + foreach($addThese as $f) { + $this->add_include($f,true); } } }//end load_dir_includes() @@ -734,7 +728,14 @@ if($this->templateObj->template_file_exists('system/404.shared.tmpl')) { //Simple "Page Not Found" error... show 'em. $this->templateObj->add_template_var('main', $this->templateObj->file_to_string('system/404.shared.tmpl')); - $this->templateObj->add_template_var('details', $details); + + //add the message box & required template vars to display the error. + $this->templateObj->add_template_var('content', $this->templateObj->file_to_string('system/message_box.tmpl')); + $this->templateObj->add_template_var('messageType', 'fatal'); + $this->templateObj->add_template_var('title', "Fatal Error"); + $this->templateObj->add_template_var('message', $details); + + $this->templateObj->add_template_var('datetime', date('m-d-Y H:i:s')); $this->templateObj->print_page(); exit; @@ -765,14 +766,27 @@ } $page =& $this->templateObj; - if(is_object($this->session)) { + + if(is_array($this->injectVars) && count($this->injectVars)) { + $definedVars = get_defined_vars(); + foreach($this->injectVars as $myVarName=>$myVarVal) { + if(!isset($definedVars[$myVarName])) { + $$myVarName = $myVarVal; + } + else { + throw new exception(__METHOD__ .": attempt to inject already defined var '". $myVarName ."'"); + } + } + } + + if(isset($this->session) && is_object($this->session)) { $page->session =& $this->session; } //if we loaded an index, but there is no "content", then move 'em around so we have content. if(isset($this->templateList['index']) && !isset($this->templateList['content'])) { - $this->templateList['content'] = $this->templateList['index']; + $this->add_template('content', $this->templateList['index']); unset($this->templateList['index']); } @@ -796,9 +810,17 @@ $this->myLastInclude = $myInternalScriptName; include_once($this->myLastInclude); } + + //now load the "after" includes. + if(is_array($this->afterIncludesList)) { + foreach($this->afterIncludesList as $myInternalIndex=>$myInternalScriptName) { + $this->myLastInclude = $myInternalScriptName; + include_once($this->myLastInclude); + } + } } catch(exception $e) { - $myRoot = preg_replace('/\//', '\\\/', $this->fileSystemObj->root); + $myRoot = preg_replace('/\//', '\\\/', $this->incFs->root); $displayableInclude = preg_replace('/^'. $myRoot .'/', '', $this->myLastInclude); $this->templateObj->set_message_wrapper(array( 'title' => "Fatal Error", @@ -821,7 +843,9 @@ } if($this->isValid === TRUE) { - $page->print_page(); + if($this->templateObj->printOnFinish === true) { + $page->print_page(); + } } else { $this->die_gracefully($this->reason); @@ -880,14 +904,35 @@ /** * Method that appends filenames to the list of include scripts. */ - private final function add_include($file) { - $myFile = $this->fileSystemObj->realcwd .'/'. $file; - if(!array_search($myFile, $this->includesList)) { - $this->includesList[] = $myFile; + private final function add_include($file, $addAfter=false) { + $myFile = preg_replace('/\/{2,}/', '/', $this->incFs->realcwd .'/'. $file); + if(!is_numeric(array_search($myFile, $this->includesList))) { + if($addAfter === true) { + array_unshift($this->afterIncludesList, $myFile); + } + else { + $this->includesList[] = $myFile; + } } }//end add_include() //------------------------------------------------------------------------ + + //------------------------------------------------------------------------ + private final function add_template($var, $file) { + $this->templateList[$var] = $file; + }//end add_template() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + public function inject_var($varName, $value) { + $this->injectVars[$varName] = $value; + }//end inject_var() + //------------------------------------------------------------------------ + + }//end contentSystem{} ?> Modified: releases/1.0/cs_fileSystem.class.php =================================================================== --- releases/1.0/cs_fileSystem.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/cs_fileSystem.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -413,14 +413,19 @@ $filename = $this->resolve_path_with_dots($filename); - //see if it starts with a "/"... + //If it's a single filename beginning with a slash, strip the slash. + $x = array(); + $numSlashes = preg_match_all('/\//', $filename, $x); + if(preg_match('/^\/[\w]/', $filename) && !preg_match('/^\/\./', $filename) && $numSlashes == 1) { + $filename = preg_replace('/^\//', '', $filename); + } + + if(preg_match("/^\//", $filename)) { $retval = $filename; } else { $retval=$this->realcwd .'/'. $filename; $retval = $this->resolve_path_with_dots($retval); - #debug_print(__METHOD__ .": realcwd=(". $this->realcwd .")"); - #$this->resolve_path_with_dots($retval); } if(!$this->check_chroot($retval, FALSE)) { Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/cs_genericPage.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -15,6 +15,7 @@ public $templateVars = array(); //our copy of the global templateVars public $mainTemplate; //the default layout of the site public $unhandledVars=array(); + public $printOnFinish=true; private $tmplDir; private $libDir; @@ -63,20 +64,21 @@ //replace multiple slashes with a single one to avoid confusing other logic... $mainTemplateFile = preg_replace('/(\/){2,}/', '/', $mainTemplateFile); - if(preg_match('/\//', $mainTemplateFile) == 1 && preg_match('/^/', $mainTemplateFile)) { + + $showMatches=array(); + $numMatches = preg_match_all('/\//', $mainTemplateFile, $showMatches); + if($numMatches == 1 && preg_match('/^/', $mainTemplateFile)) { $mainTemplateFile = preg_replace('/^\//', '', $mainTemplateFile); } - if(strlen(dirname($mainTemplateFile)) && dirname($mainTemplateFile) !== '/' && !preg_match('/^\./', dirname($mainTemplateFile))) { - $this->tmplDir = dirname($mainTemplateFile); - $this->siteRoot = preg_replace('/\/templates$/', '', $this->tmplDir); + if(defined('SITE_ROOT')) { + $this->siteRoot = constant('SITE_ROOT'); } else { - //NOTE: this **requires** that the global variable "SITE_ROOT" is already set. - $this->siteRoot = preg_replace('/\/public_html/', '', $_SERVER['DOCUMENT_ROOT']); - $this->tmplDir = $this->siteRoot .'/templates'; + throw new exception(__METHOD__ .": required constant 'SITE_ROOT' not set"); } + $this->tmplDir = $this->siteRoot .'/templates'; $this->libDir = $this->siteRoot .'/lib'; //if there have been some global template vars (or files) set, read 'em in here. @@ -215,7 +217,7 @@ $reg = "/<!-- BEGIN $handle -->(.+){0,}<!-- END $handle -->/sU"; preg_match_all($reg, $str, $m); - if(!is_string($m[0][0])) { + if(!is_array($m) || !isset($m[0][0]) || !is_string($m[0][0])) { #exit("set_block_row(): couldn't find '$handle' in var '$parent'"); $retval = FALSE; } else { @@ -284,10 +286,15 @@ foreach($tags as $key=>$str) { $str2 = str_replace("{", "", $str); $str2 = str_replace("}", "", $str2); - if(!$this->templateVars[$str2] && $stripUndefVars) { + if(!isset($this->templateVars[$str2]) && $stripUndefVars) { //TODO: set an internal pointer or something to use here, so they can see what was missed. - $this->templateObj->varvals[out] = str_replace($str, '', $this->templateObj->varvals[out]); - $this->unhandledVars[$str2]++; + $this->templateObj->varvals['out'] = str_replace($str, '', $this->templateObj->varvals['out']); + if(isset($this->unhandledVars[$str2])) { + $this->unhandledVars[$str2]++; + } + else { + $this->unhandledVars[$str2] = 1; + } } } $this->templateObj->parse("out", "out"); @@ -414,7 +421,7 @@ ); if(!isset($type) || !isset($priorityArr[$type])) { //set a default type. - $arrayKeys = array_keys(); + $arrayKeys = array_keys($priorityArr); $type = $arrayKeys[0]; } @@ -541,8 +548,8 @@ //NOTE: the value 30 isn't just a randomly chosen length; it's the minimum // number of characters to have a block row. EG: "<!-- BEGIN x --><!-- END x -->" - $templateContents = $this->templateVars[$templateVar]; - if(strlen($templateContents) >= 30) { + if(isset($this->templateVars[$templateVar]) && strlen($this->templateVars[$templateVar]) >= 30) { + $templateContents = $this->templateVars[$templateVar]; //looks good to me. Run the regex... $flags = PREG_PATTERN_ORDER; $reg = "/<!-- BEGIN (\S{1,}) -->/"; @@ -588,20 +595,23 @@ //--------------------------------------------------------------------------------------------- - function rip_all_block_rows($templateVar="content", $exceptionArr=array()) { + function rip_all_block_rows($templateVar="content", $exceptionArr=array(), $removeDefs=0) { $rowDefs = $this->get_block_row_defs($templateVar); - $useTheseBlockRows = $rowDefs['ordered']; $retval = array(); - if(is_array($useTheseBlockRows)) { - foreach($useTheseBlockRows as $blockRowName) - { - if(!in_array($blockRowName, $exceptionArr)) + + if(is_array($rowDefs) && isset($rowDefs['ordered'])) { + $useTheseBlockRows = $rowDefs['ordered']; + if(is_array($useTheseBlockRows)) { + foreach($useTheseBlockRows as $blockRowName) { - //remove the block row. - $rowData = $this->set_block_row($templateVar, $blockRowName); - $retval[$blockRowName] = $rowData; + if(!is_array($exceptionArr) || !in_array($blockRowName, $exceptionArr)) + { + //remove the block row. + $rowData = $this->set_block_row($templateVar, $blockRowName, $removeDefs); + $retval[$blockRowName] = $rowData; + } } } } @@ -613,9 +623,9 @@ //--------------------------------------------------------------------------------------------- - public function set_all_block_rows($templateVar="content", $exceptionArr=array()) + public function set_all_block_rows($templateVar="content", $exceptionArr=array(), $removeDefs=0) { - $retval = $this->rip_all_block_rows($templateVar, $exceptionArr); + $retval = $this->rip_all_block_rows($templateVar, $exceptionArr, $removeDefs); return($retval); }//end set_all_block_rows() //--------------------------------------------------------------------------------------------- Modified: releases/1.0/cs_globalFunctions.class.php =================================================================== --- releases/1.0/cs_globalFunctions.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/cs_globalFunctions.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -20,14 +20,14 @@ if(defined('DEBUGREMOVEHR')) { $this->debugRemoveHr = constant('DEBUGREMOVEHR'); } - elseif(isset($GLOBALS['DEBUGREMOVEHR'])) { + if(isset($GLOBALS['DEBUGREMOVEHR'])) { $this->debugRemoveHr = $GLOBALS['DEBUGREMOVEHR']; } if(defined('DEBUGPRINTOPT')) { $this->debugPrintOpt = constant('DEBUGPRINTOPT'); } - elseif(isset($GLOBALS['DEBUGPRINTOPT'])) { + if(isset($GLOBALS['DEBUGPRINTOPT'])) { $this->debugPrintOpt = $GLOBALS['DEBUGPRINTOPT']; } $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); @@ -838,6 +838,19 @@ return($realVals[$index]); }//end interpret_bool() //########################################################################## + + + //########################################################################## + public function debug_var_dump($data, $printItForMe=null, $removeHr=null) { + + ob_start(); + var_dump($data); + $printThis = ob_get_contents(); + ob_end_clean(); + + return($this->debug_print($printThis, $printItForMe, $removeHr)); + }//end debug_var_dump() + //########################################################################## }//end cs_globalFunctions{} Modified: releases/1.0/cs_siteConfig.class.php =================================================================== --- releases/1.0/cs_siteConfig.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/cs_siteConfig.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -60,6 +60,8 @@ /** Boolean flag to determine if the object has been properly initialized or not. */ private $isInitialized=false; + /** Store a list of items that need to be pushed into $GLOBALS on a given path. */ + private $setGlobalArrays=array(); //------------------------------------------------------------------------- /** @@ -159,10 +161,7 @@ private function parse_config() { if(is_object($this->xmlReader)) { $data = $this->xmlReader->get_path($this->xmlReader->get_root_element()); - - $specialVars = array( - '_DIRNAMEOFFILE_' => $this->configDirname - ); + $specialVars = $this->build_special_vars(); $parseThis = array(); @@ -172,6 +171,25 @@ //only handle UPPERCASE index names; lowercase indexes are special entries (i.e. "type" or "attributes" if($section == strtoupper($section)) { $this->configSections[] = $section; + + unset($secData['type']); + + if(is_array($secData['attributes'])) { + $sectionAttribs = $secData['attributes']; + unset($secData['attributes']); + + //put stuff into the globals scope... + if(isset($sectionAttribs['SETGLOBAL'])) { + $path = $section; + + $setPath = $path; + if(strlen($sectionAttribs['GLOBALARRAYLOCATION'])) { + $setPath = $sectionAttribs['GLOBALARRAYLOCATION']; + } + $this->setGlobalArrays[$path] = $setPath; + } + } + foreach($secData as $itemName=>$itemValue) { $attribs = array(); if(is_array($itemValue['attributes'])) { @@ -212,8 +230,25 @@ } } } + $this->a2p = new cs_arrayToPath($data); $this->isInitialized=true; + + if(count($this->setGlobalArrays)) { + $globA2p = new cs_arrayToPath(&$GLOBALS); + foreach($this->setGlobalArrays as $configPath=>$globalsPath) { + if($this->a2p->get_data($configPath)) { + $setMe = array(); + foreach($this->a2p->get_data($configPath) as $i=>$v) { + $setMe[$i] = $v['value']; + } + $globA2p->set_data($globalsPath, $setMe); + } + else { + throw new exception(__METHOD__ .": attempted to set global array from non-existent path (". $configPath .")"); + } + } + } } else { throw new exception(__METHOD__ .": xmlReader not created, object probably not initialized"); @@ -234,6 +269,7 @@ */ public function get_section($section) { if($this->isInitialized === true) { + $section = strtoupper($section); $data = $this->a2p->get_data($section); if(is_array($data) && count($data) && $data['type'] == 'open') { @@ -310,6 +346,36 @@ }//end get_valid_sections() //------------------------------------------------------------------------- + + + //------------------------------------------------------------------------- + private function build_special_vars() { + //determine the current "APPURL" (current URL minus hostname and current filename) + { + $appUrl = $_SERVER['SCRIPT_NAME']; + $bits = explode('/', $appUrl); + if(!strlen($bits[0])) { + array_shift($bits); + } + if(count($bits)) { + array_pop($bits); + } + if(!count($bits)) { + $appUrl = '/'; + } + else { + $appUrl = '/'. $this->gfObj->string_from_array($bits, null, '/'); + } + } + + $specialVars = array( + '_DIRNAMEOFFILE_' => $this->configDirname, + '_APPURL_' => $appUrl + ); + return($specialVars); + }//end build_special_vars() + //------------------------------------------------------------------------- + }//end cs_siteConfig ?> Modified: releases/1.0/cs_tabs.class.php =================================================================== --- releases/1.0/cs_tabs.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/cs_tabs.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -8,18 +8,15 @@ class cs_tabs extends cs_contentAbstract { - private $tabsArr; + private $tabsArr=array(); private $selectedTab; private $csPageObj; private $templateVar; - /** Block row with the "selected" tab */ - private $selectedTabContent; + /** This is the default suffix to use when none is given during the add_tab() call. */ + private $defaultSuffix='tab'; - /** Block row with the "unselected" tab */ - private $unselectedTabContent; - //--------------------------------------------------------------------------------------------- /** * Build the object, and parses the given template. Tabs must be added & selected manually. @@ -64,26 +61,21 @@ //now let's parse it for the proper block rows. $blockRows = $this->csPageObj->rip_all_block_rows($this->templateVar); - if(count($blockRows) < 2 || !isset($blockRows['selected_tab']) || !isset($blockRows['unselected_tab'])) { - //not enough blocks, or they're not properly named. - throw new exception("cs_tabs::load_tabs_template(): failed to retrieve the required block rows"); - } - else { - //got the rows. Yay! - $this->selectedTabContent = $blockRows['selected_tab']; - $this->unselectedTabContent = $blockRows['unselected_tab']; - } + #if(count($blockRows) < 2) { + # //not enough blocks, or they're not properly named. + # throw new exception("cs_tabs::load_tabs_template(): failed to retrieve the required block rows"); + #} }//end load_tabs_template() //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- - public function add_tab_array(array $tabs) { + public function add_tab_array(array $tabs, $useSuffix=null) { $retval = 0; foreach($tabs as $name=>$url) { //call an internal method to do it. - $retval += $this->add_tab($name, $url); + $retval += $this->add_tab($name, $url, $useSuffix); } return($retval); @@ -107,9 +99,18 @@ //--------------------------------------------------------------------------------------------- - public function add_tab($tabName, $url) { + public function add_tab($tabName, $url, $useSuffix=null) { + + //set the default suffix. + if(is_null($useSuffix)) { + $useSuffix = $this->defaultSuffix; + } + //add it to an array. - $this->tabsArr[$tabName] = $url; + $this->tabsArr[$tabName] = array( + 'url' => $url, + 'suffix' => $useSuffix + ); }//end add_tab() //--------------------------------------------------------------------------------------------- @@ -120,16 +121,33 @@ * Call this to add the parsed tabs into the page. */ public function display_tabs() { + + if(!strlen($this->selectedTab)) { + $keys = array_keys($this->tabsArr); + $this->select_tab($keys[0]); + } + if(is_array($this->tabsArr) && count($this->tabsArr)) { $this->load_tabs_template(); $finalString = ""; //loop through the array. - foreach($this->tabsArr as $tabName=>$url) { - $useTabContent = $this->unselectedTabContent; - if(strtolower($tabName) === strtolower($this->selectedTab)) { - //it's selected. - $useTabContent = $this->selectedTabContent; + foreach($this->tabsArr as $tabName=>$tabData) { + + $url = $tabData['url']; + $suffix = $tabData['suffix']; + + $blockRowName = 'unselected_'. $suffix; + if(strtolower($tabName) == strtolower($this->selectedTab)) { + $blockRowName = 'selected_'. $suffix; } + + if(isset($this->csPageObj->templateRows[$blockRowName])) { + $useTabContent = $this->csPageObj->templateRows[$blockRowName]; + } + else { + throw new exception(__METHOD__ ."(): failed to load block row (". $blockRowName .") for tab (". $tabName .")". $this->csPageObj->gfObj->debug_print($this->csPageObj->templateRows,0)); + } + $parseThis = array( 'title' => $tabName, 'url' => $url @@ -142,11 +160,40 @@ } else { //something bombed. - throw new exception("cs_tabs::display_tabs(): no tabs to add"); + throw new exception(__METHOD__ ."(): no tabs to add"); } }//end display_tabs() //--------------------------------------------------------------------------------------------- + + //--------------------------------------------------------------------------------------------- + /** + * Determine if the given named tab exists (returns boolean true/false) + */ + public function tab_exists($tabName) { + $retval = false; + if(isset($this->tabsArr[$tabName])) { + $retval = true; + } + return($retval); + }//end tab_exists() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + public function rename_tab($tabName, $newTabName) { + if($this->tab_exists($tabName) && !$this->tab_exists($newTabName)) { + $tabContents = $this->tabsArr[$tabName]; + unset($this->tabsArr[$tabName]); + $this->tabsArr[$newTabName] = $tabContents; + } + else { + throw new exception(__METHOD__ .": tried to rename non-existent tab (". $tabName .") to (". $newTabName .")"); + } + }//end rename_tab(); + //--------------------------------------------------------------------------------------------- + } ?> Modified: releases/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- releases/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-12 13:52:39 UTC (rev 394) @@ -156,9 +156,14 @@ //start output buffer for displaying error. ob_start(); - $connID = mysql_connect($this->host, $this->user, $this->pass, $forceNewConnection); - mysql_select_db($this->dbname); - $connectError = ob_get_contents(); + $connID = mysql_connect($this->host, $this->user, $this->password, $forceNewConnection); + if(!$connID) { + $connectError = mysql_error(); + } + else { + mysql_select_db($this->dbname); + $connectError = ob_get_contents(); + } ob_end_clean(); if(is_resource($connID)) { @@ -168,6 +173,9 @@ $retval = $this->connectionID; } else { + if(is_bool($connID) && !strlen($connectError)) { + $connectError = "generic connection failure"; + } throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError); } } @@ -376,6 +384,9 @@ function set_row($row){ if(is_numeric($row)) { $this->row = $row; + if(!mysql_data_seek($this->result, $this->row)) { + throw new exception(__METHOD__ .": failed to seek row (". $this->row .")"); + } } else { throw new exception(__METHOD__ .": invalid data for row (". $row .")"); @@ -422,8 +433,7 @@ $retval = NULL; } else { - //TODO: implement MySQL version.. - $retval = mysql_fetch_array($this->result,$this->row); + $retval = mysql_fetch_array($this->result); } return($retval); @@ -478,16 +488,23 @@ ob_start(); $x = 0; + $newArr = array(); + $tArr = array(); do { $temp = $this->farray(); - foreach($temp as $key=>$value) { - //remove the numbered indexes. - if(is_string($key)) { - $tArr[$key] = $value; + if(is_array($temp) && count($temp)) { + foreach($temp as $key=>$value) { + //remove the numbered indexes. + if(is_string($key)) { + $tArr[$key] = $value; + } } + $newArr[$x] = $tArr; + $x++; } - $newArr[$x] = $tArr; - $x++; + else { + throw new exception(__METHOD__ .": no data retrieved from farray()..."); + } } while($this->next_row()); Deleted: releases/1.0/sample_files/public_html/images/clear.gif =================================================================== (Binary files differ) Copied: releases/1.0/sample_files/public_html/images/clear.gif (from rev 393, trunk/1.0/sample_files/public_html/images/clear.gif) =================================================================== (Binary files differ) Deleted: releases/1.0/sample_files/public_html/images/frame/crn-white-bl.gif =================================================================== (Binary files differ) Copied: releases/1.0/sample_files/public_html/images/frame/crn-white-bl.gif (from rev 393, trunk/1.0/sample_files/public_html/images/frame/crn-white-bl.gif) =================================================================== (Binary files differ) Deleted: releases/1.0/sample_files/public_html/images/frame/crn-white-br.gif =================================================================== (Binary files differ) Copied: releases/1.0/sample_files/public_html/images/frame/crn-white-br.gif (from rev 393, trunk/1.0/sample_files/public_html/images/frame/crn-white-br.gif) =================================================================== (Binary files differ) Deleted: releases/1.0/sample_files/public_html/images/frame/crn-white-tl.gif =================================================================== (Binary files differ) Copied: releases/1.0/sample_files/public_html/images/frame/crn-white-tl.gif (from rev 393, trunk/1.0/sample_files/public_html/images/frame/crn-white-tl.gif) =================================================================== (Binary files differ) Deleted: releases/1.0/sample_files/public_html/images/frame/crn-white-tr.gif =================================================================== (Binary files differ) Copied: releases/1.0/sample_files/public_html/images/frame/crn-white-tr.gif (from rev 393, trunk/1.0/sample_files/public_html/images/frame/crn-white-tr.gif) =================================================================== (Binary files differ) Modified: releases/1.0/sample_files/templates/system/404.shared.tmpl =================================================================== --- releases/1.0/sample_files/templates/system/404.shared.tmpl 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/sample_files/templates/system/404.shared.tmpl 2009-06-12 13:52:39 UTC (rev 394) @@ -8,37 +8,11 @@ --> <head> <title>Page Not Found</title> + <link rel="stylesheet" href="{APPURL}/css/site.css" type="text/css"> </head> <body> <table border=0 cellpadding=0 cellspacing=0 width="90%" align="center"> -<tr> - <!-- This row should span across the page. --> - - <td align="center" colspan=2> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> -<tbody><tr> - <td align="center"> - <font face="Georgia, Times New Roman, Times, serif"> - - <table border="0" cellpadding="3" cellspacing="0"> - <tbody><tr valign="middle"> - <td align="right">Crazed</td> - <td align="center" width="118"><img border="0" src="http://crazedsanity.com/images/dev-logo.gif?from=404" width="118" width="67"></td> - - <td align="left">Sanity</td> - </tr> - <tr> - <td colspan="3" align="center"> - Dot Com<BR> - </td> - </tr> - </tbody></table> - - </font> - - </td> -</tr> <TR> <td align="center"><!-- This row should span across the page. --><hr>{datetime}<hr></td> </TR> @@ -46,23 +20,14 @@ <tr> <td> - Could not find the page requested...<BR> - <pre>{details}</pre> + + + {content} + + + </td> </tr> - <tr> - <td> - <hr> - <div align="center"><font size="1"> - All content is ©opyright CrazedSanity - Computer Industries, 1998-2007. <br> - CrazedSanity Computer Industries is a division of <a href="http://unlimited.buzzkill.org">BuzzKill - Productions Unlimited ®</a>. All rights reserved. <br> - For questions, to report a problem, or to offer your first born child as a sacrifice, - contact <a href="mailto:webmaster@127.0.0.1">webmaster -at- crazedsanity.com</a>.</font><br><br> -</div> - </td> - </tr> - </table> +</table> </body> </html> Deleted: releases/1.0/sample_files/templates/system/construction.content.tmpl =================================================================== --- releases/1.0/sample_files/templates/system/construction.content.tmpl 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/sample_files/templates/system/construction.content.tmpl 2009-06-12 13:52:39 UTC (rev 394) @@ -1,5 +0,0 @@ -<!-- BEGIN content/construction_content.tmpl --> - <h2 align="center"><br> - <br> - It's broken. I don't know what to say, dude. -<!-- END content/construction_content.tmpl --> Deleted: releases/1.0/sample_files/templates/system/db_error.tmpl =================================================================== --- releases/1.0/sample_files/templates/system/db_error.tmpl 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/sample_files/templates/system/db_error.tmpl 2009-06-12 13:52:39 UTC (rev 394) @@ -1,47 +0,0 @@ -<HTML> -<HEAD> - <title>CS - Database Error</title> -</HEAD> - -<body bgcolor="white" text="#666666" link="#006666" vlink="#006666" alink="#006666"> -<table border="0" cellpadding="0" cellspacing="0" width="100%"> -<tr><!-- This row should span across the page. --> - <td align="center"> - <font face="Georgia, Times New Roman, Times, serif"> - <table border=0 cellpadding=3 cellspacing=0> - <TR> - <td>Crazed</td> - <td><img border=0 src="/images/dev-logo.gif"></td> - <td>Sanity</td> - </TR> - <TR> - <td colspan="3" align="center">Dot Com</td> - </TR> - </table> - </font> - </td> -</tr> -</table> - -<hr> - -<!-- BEGIN excuse --> -<p align="center">If you're seeing this, that means something pretty bad is happening.<BR> -Either the database went down, or bigger issues have arisen.<BR> -Check back in awhile.</p> -<!-- END excuse --> - - - <hr> -<center> -<font size="1"> - <a href="http://www.buzzkill.org/"><img src="/images/Bk3dtext.jpg" width="474" height="40" border="0"></a><BR> -All content is copyright CrazedSanity.com, 1998-2004. <br> - CrazedSanity.com is a division of -<a href="http://www.buzzkill.org/">BuzzKill Productions Unlimited ®</a>. All rights reserved. <br> - For questions or to report a problem, contact -<a href="?emailLink=spam" onClick="invalidEmailLink('webmaster')">webmaster at crazedsanity dot com</a>.</font> -</center> -</body> - -</HTML> Modified: releases/1.0/sample_files/templates/system/message_box.tmpl =================================================================== --- releases/1.0/sample_files/templates/system/message_box.tmpl 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/sample_files/templates/system/message_box.tmpl 2009-06-12 13:52:39 UTC (rev 394) @@ -1,12 +1,12 @@ -<!-- *** MESSAGE_BOX START (/help/messages/message_box.tmpl) *** --> +<!-- *** MESSAGE_BOX START (/system/message_box.tmpl) *** --> <table border="0" cellspacing="0" cellpadding="0" align="center"> <tr> - <td class="{messageType}" width="5" align="left" valign="top"><img src="/images/frame/crn-white-tl.gif" width="5" height="5" alt=""></td> - <td class="{messageType}"><img src="/images/clear.gif" width="20" height="2" alt=""></td> - <td class="{messageType}" width="5" align="right" valign="top"><img src="/images/frame/crn-white-tr.gif" width="5" height="5" alt=""></td> + <td class="{messageType}" width="5" align="left" valign="top"><img src="{APPURL}/images/frame/crn-white-tl.gif" width="5" height="5" alt=""></td> + <td class="{messageType}"><img src="{APPURL}/images/clear.gif" width="20" height="2" alt=""></td> + <td class="{messageType}" width="5" align="right" valign="top"><img src="{APPURL}/images/frame/crn-white-tr.gif" width="5" height="5" alt=""></td> </tr> <tr> - <td class="{messageType}" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> + <td class="{messageType}" width="5"><img src="{APPURL}/images/clear.gif" width="5" height="20" alt=""></td> <td> <table class="{messageType}" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> @@ -16,14 +16,14 @@ {redirect} </td> </tr> </table></td> - <td class="{messageType}" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> + <td class="{messageType}" width="5"><img src="{APPURL}/images/clear.gif" width="5" height="20" alt=""></td> </tr> <tr> - <td class="{messageType}" width="5" align="left" valign="bottom"><img src="/images/frame/crn-white-bl.gif" width="5" height="5" alt=""></td> - <td class="{messageType}"><img src="/images/clear.gif" width="20" height="2" alt=""></td> - <td class="{messageType}" width="5" align="right" valign="bottom"><img src="/images/frame/crn-white-br.gif" width="5" height="5" alt=""></td> + <td class="{messageType}" width="5" align="left" valign="bottom"><img src="{APPURL}/images/frame/crn-white-bl.gif" width="5" height="5" alt=""></td> + <td class="{messageType}"><img src="{APPURL}/images/clear.gif" width="20" height="2" alt=""></td> + <td class="{messageType}" width="5" align="right" valign="bottom"><img src="{APPURL}/images/frame/crn-white-br.gif" width="5" height="5" alt=""></td> </tr> </table> <br> -<!-- *** MESSAGE_BOX END (/help/messages/message_box.tmpl) *** --> +<!-- *** MESSAGE_BOX END (/system/message_box.tmpl) *** --> Modified: releases/1.0/tests/testOfCSContent.php =================================================================== --- releases/1.0/tests/testOfCSContent.php 2009-06-12 13:31:08 UTC (rev 393) +++ releases/1.0/tests/testOfCSContent.php 2009-06-12 13:52:39 UTC (rev 394) @@ -24,6 +24,9 @@ $this->gfObj = new cs_globalFunctions; $this->gfObj->debugPrintOpt=1; + + $filesDir = dirname(__FILE__) ."/files"; + define('TEST_FILESDIR', $filesDir); }//end __construct() //------------------------------------------------------------------------- @@ -179,7 +182,7 @@ //------------------------------------------------------------------------- public function test_siteConfig() { - $configFile = dirname(__FILE__) .'/files/sampleConfig.xml'; + $configFile = constant('TEST_FILESDIR') .'/sampleConfig.xml'; $varPrefix = preg_replace("/:/", "_", __METHOD__ ."-"); $sc = new cs_siteConfig($configFile, 'main', $varPrefix); @@ -247,7 +250,7 @@ //------------------------------------------------------------------------- function test_genericPage() { - $filesDir = dirname(__FILE__) .'/files'; + $filesDir = constant('TEST_FILESDIR'); $page = new cs_genericPage(false, $filesDir .'/templates/main.shared.tmpl', false); $fs = new cs_fileSystem($filesDir .'/templates'); @@ -302,6 +305,36 @@ + //------------------------------------------------------------------------- + function test_cs_fileSystem() { + $fs = new cs_fileSystem(constant('TEST_FILESDIR')); + + $list = array( + 'slashTest' => array('/sampleConfig.xml', 'sampleConfig.xml'), + 'slashtest2' => array('/templates/content.shared.tmpl', 'templates/content.shared.tmpl'), + 'pathWithDots' => array('templates/.././sampleConfig.xml', '/templates/.././sampleConfig.xml'), + 'multiSlashes' => array('////sampleConfig.xml', '///sampleConfig.xml', '/templates///////content.shared.tmpl/../templates/content.shared.tmpl') + ); + + foreach($list as $testName=>$files) { + foreach($files as $filename) { + $gotException=false; + try { + $data = $fs->ls('/sampleConfig.xml'); + } + catch(exception $e) { + $gotException=true; + } + + $this->assertFalse($gotException, "Failed test '". $testName ."'"); + } + } + + }//end test_cs_fileSystem() + //------------------------------------------------------------------------- + + + }//end TestOfCSContent //============================================================================= ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |