Thread: [Cs-content-commits] SF.net SVN: cs-content:[358] trunk/1.0/contentSystem.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-06 15:10:47
|
Revision: 358 http://cs-content.svn.sourceforge.net/cs-content/?rev=358&view=rev Author: crazedsanity Date: 2009-02-06 15:10:43 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Remove debugging code from last commit. /contentSystem.class.php: * add_include(): -- added header to explain what it does -- removed debugging information -- silently ignores duplicate includes (this should potentially cause an exception...) Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-02-05 22:04:03 UTC (rev 357) +++ trunk/1.0/contentSystem.class.php 2009-02-06 15:10:43 UTC (rev 358) @@ -871,20 +871,14 @@ //------------------------------------------------------------------------ + /** + * 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->gfObj->debug_print("<h1><font color='red'>". __METHOD__ .": file (". $myFile .") already exists... </h1>". cs_debug_backtrace(0) ."</font>"); - #exit; - } - else { + if(!array_search($myFile, $this->includesList)) { $this->includesList[] = $myFile; - - $this->gfObj->debug_print("<h1>". __METHOD__ .": included (". $myFile .")</h1>"); } - if($file == 'index.inc') { - cs_debug_backtrace(1); - } }//end add_include() //------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-06 16:47:06
|
Revision: 359 http://cs-content.svn.sourceforge.net/cs-content/?rev=359&view=rev Author: crazedsanity Date: 2009-02-06 16:47:03 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Another related to issue #246 where index.inc included invalidly. /contentSystem.class.php: * load_includes(): -- added a local variable, $addIndex -- set $addIndex to true if it can cd() into the final section's dir. -- set $addIndex to false if the code can't cd() into that final dir. -- code that checks for index.inc also checks $addIndex to be true. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-02-06 15:10:43 UTC (rev 358) +++ trunk/1.0/contentSystem.class.php 2009-02-06 16:47:03 UTC (rev 359) @@ -652,6 +652,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) { @@ -670,8 +671,13 @@ //attempt to cd() into the next directory, or die if we can't. if(!$this->fileSystemObj->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; + } } } @@ -680,7 +686,7 @@ if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); } - if(isset($lsData['index.inc']) && is_array($lsData['index.inc'])) { + if(isset($lsData['index.inc']) && is_array($lsData['index.inc']) && $addIndex==true) { $this->add_include('index.inc'); } }//end load_includes() @@ -877,6 +883,7 @@ private final function add_include($file) { $myFile = $this->fileSystemObj->realcwd .'/'. $file; if(!array_search($myFile, $this->includesList)) { + $this->gfObj->debug_print(__METHOD__ .": adding (". $myFile .")"); $this->includesList[] = $myFile; } }//end add_include() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-06 20:38:44
|
Revision: 360 http://cs-content.svn.sourceforge.net/cs-content/?rev=360&view=rev Author: crazedsanity Date: 2009-02-06 20:38:40 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Remove debug_print statement. /contentSystem.class.php: * add_include(): -- remove debug_print statement (for testing). Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-02-06 16:47:03 UTC (rev 359) +++ trunk/1.0/contentSystem.class.php 2009-02-06 20:38:40 UTC (rev 360) @@ -883,7 +883,6 @@ private final function add_include($file) { $myFile = $this->fileSystemObj->realcwd .'/'. $file; if(!array_search($myFile, $this->includesList)) { - $this->gfObj->debug_print(__METHOD__ .": adding (". $myFile .")"); $this->includesList[] = $myFile; } }//end add_include() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-03-02 21:10:33
|
Revision: 368 http://cs-content.svn.sourceforge.net/cs-content/?rev=368&view=rev Author: crazedsanity Date: 2009-03-02 21:10:18 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Fix problem with index.inc not always being included. /contentSystem.class.php: * parse_section(): -- remove leading slashes from the DEFAULT_SECTION value. * prepare(): -- remove reference to uninitialized var $cdResult * load_includes(): -- remove extra code ($addIndex) that determines if the index.inc file is included (breaking into two FS objects fixed the problem that the removed code bandaided): if the file exists, include it. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-03-02 20:33:06 UTC (rev 367) +++ trunk/1.0/contentSystem.class.php 2009-03-02 21:10:18 UTC (rev 368) @@ -287,7 +287,7 @@ //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)) && defined('DEFAULT_SECTION')) { - $this->section = constant('DEFAULT_SECTION'); + $this->section = preg_replace('/^\//', '', constant('DEFAULT_SECTION')); } $myArr = split('/', $this->section); @@ -366,7 +366,7 @@ $foundIncludes = count($this->includesList); $validatePageRes = $this->validate_page(); - if($foundIncludes || ($cdResult && $validatePageRes)) { + if($foundIncludes || $validatePageRes) { //okay, get template directories & start loading $tmplDirs = $this->get_template_dirs(); @@ -670,7 +670,6 @@ $this->load_dir_includes($this->baseDir); //okay, now loop through $this->sectionArr & see if we can include anything else. - $addIndex=false; if(($this->incFs->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { @@ -689,13 +688,8 @@ //attempt to cd() into the next directory, or die if we can't. 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; - } } } @@ -704,7 +698,7 @@ if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); } - if(isset($lsData['index.inc']) && is_array($lsData['index.inc']) && $addIndex==true) { + if(isset($lsData['index.inc']) && is_array($lsData['index.inc'])) { $this->add_include('index.inc'); } }//end load_includes() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-03-02 20:33:27
|
Revision: 367 http://cs-content.svn.sourceforge.net/cs-content/?rev=367&view=rev Author: crazedsanity Date: 2009-03-02 20:33:06 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Seperate cs_fileSystem objects for includes and template files. /contentSystem.class.php: * MAIN::: -- deleted protected var $fileSystemObj -- added protected var $tmplFs -- added protected var $incFs * __construct(): -- throws an exception if SITE_ROOT isn't defined. * initialize_locals(): -- create one object for handling templates and one for includes. -- use tmplFs object for checking versions. * get_template_dirs(): -- uses tmplFs instead of fileSystemObj * prepare(): -- call load_includes() unconditionally. -- don't cd() into "/templates" anymore; using two objects eliminates the need for this. -- set both FS objects back to their root directory. * validate_page(): -- uses tmplFs instead of fileSystemObj * load_page_templates(): -- uses tmplFs instead of fileSystemObj * load_main_templates(): -- use tmplFs instead of fileSystemObj -- remove extra unnecessary call to cd(). * load_shared_templates(): -- use tmplFs instead of fileSystemObj. * arrange_directory_contents(): -- use tmplFs instead of fileSystemObj * load_includes(): -- use incFs instead of fileSystemObj * load_dir_includes(): -- use incFs instead of fileSystemObj * finish(): -- use incFs instead of fileSystemObj when setting local "myRoot" * add_include(): -- use incFs instead of fileSystemObj Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-03-02 17:54:58 UTC (rev 366) +++ trunk/1.0/contentSystem.class.php 2009-03-02 20:33:06 UTC (rev 367) @@ -81,7 +81,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' @@ -110,6 +115,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']); @@ -144,9 +153,22 @@ } $this->templateObj->add_template_var('CURRENT_URL', $myUrl); - //create a fileSystem object. - $this->fileSystemObj = new cs_fileSystem(); + //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 +177,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 +200,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; @@ -340,13 +362,9 @@ */ 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)) { @@ -366,7 +384,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. @@ -389,13 +408,13 @@ 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); + $this->tmplFs->cd('/'); $mySectionArr = $this->sectionArr; $finalSection = array_pop($mySectionArr); $this->finalSection = $finalSection; if(count($mySectionArr) > 0) { foreach($mySectionArr as $dir) { - if(!$this->fileSystemObj->cd($dir)) { + if(!$this->tmplFs->cd($dir)) { break; } } @@ -407,9 +426,9 @@ $indexFilename = 'index.content.tmpl'; } - $lsDir = $this->fileSystemObj->ls($indexFilename); + $lsDir = $this->tmplFs->ls($indexFilename); $lsDirVals = array_values($lsDir); - $lsFile = $this->fileSystemObj->ls("$finalSection.content.tmpl"); + $lsFile = $this->tmplFs->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") @@ -424,14 +443,14 @@ } //check the index file for validity... this is kind of a dirty hack... but it works. - $checkMe = $this->fileSystemObj->ls($myIndex); + $checkMe = $this->tmplFs->ls($myIndex); if(!is_array($checkMe[$myIndex])) { unset($myIndex); } if(isset($myIndex)) { $valid = TRUE; - $this->fileSystemObj->cd('/templates'); + $this->tmplFs->cd('/'); } else { $this->reason = __METHOD__ .": couldn't find page template for ". $this->section; @@ -440,11 +459,11 @@ 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); + $sectionLsData = $this->tmplFs->ls($myFile); //if the baseDir is "help", this would try to use "/help.content.tmpl" $sectionFile = $this->baseDir .'.content.tmpl'; - $lsData = $this->fileSystemObj->ls(); + $lsData = $this->tmplFs->ls(); if(isset($lsData[$sectionFile]) && is_array($lsData[$sectionFile])) { $valid = TRUE; @@ -485,7 +504,7 @@ $this->templateList[$mySection] = $myTmpl; } } - if(!$this->fileSystemObj->cd($value)) { + if(!$this->tmplFs->cd($value)) { break; } } @@ -504,7 +523,7 @@ } } } - 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'])) { @@ -527,9 +546,8 @@ * 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'); if(is_array($dirContents)) { foreach($dirContents as $mySection => $subArr) { @@ -550,10 +568,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. @@ -575,13 +593,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. @@ -653,7 +671,7 @@ //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,7 +687,7 @@ $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; @@ -682,7 +700,7 @@ } //include the final shared & index files. - $lsData = $this->fileSystemObj->ls(); + $lsData = $this->incFs->ls(); if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); } @@ -700,7 +718,7 @@ * solely by load_includes(). */ private function load_dir_includes($section) { - $lsData = $this->fileSystemObj->ls(); + $lsData = $this->incFs->ls(); //attempt to load the shared includes file. if(isset($lsData['shared.inc']) && $lsData['shared.inc']['type'] == 'file') { @@ -714,10 +732,10 @@ } if(isset($lsData[$section]) && !count($this->sectionArr)) { - $this->fileSystemObj->cd($section); - $lsData = $this->fileSystemObj->ls(); + $this->incFs->cd($section); + $lsData = $this->incFs->ls(); if(isset($lsData['index.inc'])) { - $this->includesList[] = $this->fileSystemObj->realcwd .'/index.inc'; + $this->includesList[] = $this->incFs->realcwd .'/index.inc'; } } }//end load_dir_includes() @@ -798,7 +816,7 @@ } } 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", @@ -881,7 +899,7 @@ * Method that appends filenames to the list of include scripts. */ private final function add_include($file) { - $myFile = $this->fileSystemObj->realcwd .'/'. $file; + $myFile = $this->incFs->realcwd .'/'. $file; if(!array_search($myFile, $this->includesList)) { $this->includesList[] = $myFile; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-03-03 19:07:53
|
Revision: 369 http://cs-content.svn.sourceforge.net/cs-content/?rev=369&view=rev Author: crazedsanity Date: 2009-03-03 19:07:51 +0000 (Tue, 03 Mar 2009) Log Message: ----------- Fix problems from last commit & minor bug with adding includes. /contentSystem.class.php: * parse_section(): -- when checking the size of the $myArr var, don't check the value of the first (0) index. -- added a TODO about possible problems from an empty array -- throw an exception if no array is retrieved from section (shouldn't ever happen). * validate_page(): -- NOTE::: this method was very much overhauled to make it simpler. -- checks for two template files that would indicate it is a valid page instead of doing so much cd()'ing and such with a lot of duplicated and confusing code (I was even confused, and I wrote it). * load_page_templates(): -- instead of using the last item in the internal sectionArr, it uses the internal "finalSection" variable. -- always load the final template list followed by loading items for the final section instead of doing an if/else statement (which could cause some frustrating & unexpected bahaviour). * load_main_templates(): -- cd() into the baseDir again (allows the final content template to be loaded again; previous commit broke this). * load_includes(): -- cd() to the internal "finalSection" and include the index and shared files (but only if the cd() succeeds). * add_include(): -- fix problems with extra slashes in the filename causing files to be included multiple times -- only load a new include if the result of array_search() isn't numeric: previously, if the requested include was already in index 0, it would get included again. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-03-02 21:10:18 UTC (rev 368) +++ trunk/1.0/contentSystem.class.php 2009-03-03 19:07:51 UTC (rev 369) @@ -292,10 +292,15 @@ $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() //------------------------------------------------------------------------ @@ -400,84 +405,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->tmplFs->cd('/'); $mySectionArr = $this->sectionArr; - $finalSection = array_pop($mySectionArr); - $this->finalSection = $finalSection; - if(count($mySectionArr) > 0) { - foreach($mySectionArr as $dir) { - if(!$this->tmplFs->cd($dir)) { - break; - } - } - } - - //check for the file & the directory... - $indexFilename = $finalSection ."/index.content.tmpl"; - if(!strlen($finalSection)) { - $indexFilename = 'index.content.tmpl'; - } - - $lsDir = $this->tmplFs->ls($indexFilename); - $lsDirVals = array_values($lsDir); - $lsFile = $this->tmplFs->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->tmplFs->ls($myIndex); - if(!is_array($checkMe[$myIndex])) { - unset($myIndex); - } - - if(isset($myIndex)) { - $valid = TRUE; - $this->tmplFs->cd('/'); - } - 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->tmplFs->ls($myFile); - - //if the baseDir is "help", this would try to use "/help.content.tmpl" - $sectionFile = $this->baseDir .'.content.tmpl'; - $lsData = $this->tmplFs->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); @@ -495,7 +452,7 @@ // 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])) { @@ -509,20 +466,20 @@ } } - //load the final template(s). $finalTmplList = $this->arrange_directory_contents('name', 'section'); + foreach($finalTmplList as $mySection => $subArr) { + foreach($subArr as $internalSection => $myTmpl) { + $this->templateList[$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; } } - elseif(is_array($finalTmplList)) { - foreach($finalTmplList as $mySection => $subArr) { - foreach($subArr as $internalSection => $myTmpl) { - $this->templateList[$mySection] = $myTmpl; - } - } - } + if($this->tmplFs->cd($finalSection)) { //load the index stuff. $tmplList = $this->arrange_directory_contents('name', 'section'); @@ -549,6 +506,7 @@ //check to see if the present section is valid. $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) { @@ -694,13 +652,15 @@ } //include the final shared & index files. - $lsData = $this->incFs->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['index.inc']) && is_array($lsData['index.inc'])) { + $this->add_include('index.inc'); + } } - if(isset($lsData['index.inc']) && is_array($lsData['index.inc'])) { - $this->add_include('index.inc'); - } }//end load_includes() //------------------------------------------------------------------------ @@ -893,8 +853,8 @@ * Method that appends filenames to the list of include scripts. */ private final function add_include($file) { - $myFile = $this->incFs->realcwd .'/'. $file; - if(!array_search($myFile, $this->includesList)) { + $myFile = preg_replace('/\/{2,}/', '/', $this->incFs->realcwd .'/'. $file); + if(!is_numeric(array_search($myFile, $this->includesList))) { $this->includesList[] = $myFile; } }//end add_include() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-22 16:29:20
|
Revision: 378 http://cs-content.svn.sourceforge.net/cs-content/?rev=378&view=rev Author: crazedsanity Date: 2009-05-22 16:29:11 +0000 (Fri, 22 May 2009) Log Message: ----------- Implement feature request #273 (post-include file support). /contentSystem.class.php: * MAIN::: -- added new (protected) property, afterIncludesList=array() * load_includes(): -- check for that final "shared.after.inc" file (load_dir_includes() will not do this for the final section). * load_dir_includes(): -- initialize blank array for holding list of "after" includes. -- checks for shared.after.inc and {section}.after.inc -- NOTE::: if ordering works properly from inside add_include(), then the "after" includes should be done through add_include($file,true) as well to avoid confusion. * finish(): -- processes the "after" includes once the normal includes are done. * add_include(): -- ARG CHANGE: NEW ARG: #2 ($addAfter=false) -- support for adding includes to the "after" array (defaults to using the normal array)--each item is put to the TOP of the list for proper order of inclusion. -- NOTE::: see note for load_dir_includes() about this... Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-15 15:21:15 UTC (rev 377) +++ trunk/1.0/contentSystem.class.php 2009-05-22 16:29:11 UTC (rev 378) @@ -94,6 +94,7 @@ ); protected $templateList = array(); protected $includesList = array(); + protected $afterIncludesList= array(); public $templateObj = NULL; protected $gfObj = NULL; protected $tabs = NULL; @@ -659,6 +660,9 @@ 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'); } @@ -676,22 +680,32 @@ private function load_dir_includes($section) { $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->incFs->cd($section); - $lsData = $this->incFs->ls(); - if(isset($lsData['index.inc'])) { - $this->includesList[] = $this->incFs->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() @@ -783,6 +797,14 @@ $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->incFs->root); @@ -869,10 +891,15 @@ /** * Method that appends filenames to the list of include scripts. */ - private final function add_include($file) { + private final function add_include($file, $addAfter=false) { $myFile = preg_replace('/\/{2,}/', '/', $this->incFs->realcwd .'/'. $file); if(!is_numeric(array_search($myFile, $this->includesList))) { - $this->includesList[] = $myFile; + if($addAfter === true) { + array_unshift($this->afterIncludesList, $myFile); + } + else { + $this->includesList[] = $myFile; + } } }//end add_include() //------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-22 17:28:37
|
Revision: 379 http://cs-content.svn.sourceforge.net/cs-content/?rev=379&view=rev Author: crazedsanity Date: 2009-05-22 17:28:18 +0000 (Fri, 22 May 2009) Log Message: ----------- Added "curYear" template var, since it is used in an example template. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-22 16:29:11 UTC (rev 378) +++ trunk/1.0/contentSystem.class.php 2009-05-22 17:28:18 UTC (rev 379) @@ -149,6 +149,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) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-27 16:06:26
|
Revision: 381 http://cs-content.svn.sourceforge.net/cs-content/?rev=381&view=rev Author: crazedsanity Date: 2009-05-27 16:06:18 +0000 (Wed, 27 May 2009) Log Message: ----------- Fix for if contentSystem starts deeper in the URL (i.e. "/{app}/{content}") NOTE::: the "APPURL" constant is required for this behavior and may not be appropriately named, or may cause invalid assumptions by the developer. /contentSystem.class.php: * clean_url(): -- if "APPURL" is a valid constant, strip that from the beginning of the section string. -- EXAMPLE: if an app that uses cs-content is installed on a server where initial URL is "/apps/project/", set APPURL="/apps/project" so everything beyond that will work. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-27 04:54:31 UTC (rev 380) +++ trunk/1.0/contentSystem.class.php 2009-05-27 16:06:18 UTC (rev 381) @@ -327,7 +327,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)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-28 04:19:31
|
Revision: 383 http://cs-content.svn.sourceforge.net/cs-content/?rev=383&view=rev Author: crazedsanity Date: 2009-05-28 04:19:30 +0000 (Thu, 28 May 2009) Log Message: ----------- Implemented changes that had been incorrectly commited to releases/1.0 @r380: *** ORIGINAL COMMIT LOG (releases/1.0@380) *** Fix problem where includes/content/index.inc wasn't loaded for the "/" URL. /contentSystem.class.php: * prepare(): -- sets the internal "finalSection" variable as the last element in the internal sectionArr (previously, it would be set as the last accessible directory in the includes directory). -- NOTE: finalSection was moved here because otherwise it was created too late for use in load_includes(). -- NOTE2: if the internal sectionArr is empty, it will now throw an exception... * validate_page(): -- no longer sets the internal finalSection value. * load_includes(): -- when considering inclusion of index.inc, has extra checks to allow it if finalSection is "index". Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-28 03:54:58 UTC (rev 382) +++ trunk/1.0/contentSystem.class.php 2009-05-28 04:19:30 UTC (rev 383) @@ -378,6 +378,17 @@ * Retrieves the list of templates & includes in preparation for later work. */ private function prepare() { + + //Set the final section... + if(count($this->sectionArr)) { + $mySectionArr = $this->sectionArr; + $this->finalSection = array_pop($mySectionArr); + } + else { + throw new exception(__METHOD__ .": FATAL - section array is empty"); + } + + //attempt to load any includes... $this->load_includes(); $foundIncludes = count($this->includesList); @@ -432,8 +443,24 @@ $reasonText = "page template"; } else { - $this->finalSection = $this->baseDir; - $reasonText = "base template"; + //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; + } + elseif(isset($sectionLsData[$myFile]) && $sectionLsData[$myFile]['type'] == 'file') { + //we're good. + $valid = TRUE; + } + else { + $this->reason = __METHOD__ .": couldn't find base template."; + } } $tmplFile1 = $this->section .".content.tmpl"; @@ -640,6 +667,10 @@ $this->load_dir_includes($this->baseDir); //okay, now loop through $this->sectionArr & see if we can include anything else. + $addIndex=false; + if($this->finalSection == 'index') { + $addIndex = true; + } if(($this->incFs->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { @@ -658,6 +689,9 @@ //attempt to cd() into the next directory, or die if we can't. if(!$this->incFs->cd($mySection)) { //no dice. Break the loop. + if($this->finalSection == 'index') { + $addIndex = true; + } break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-28 14:23:08
|
Revision: 384 http://cs-content.svn.sourceforge.net/cs-content/?rev=384&view=rev Author: crazedsanity Date: 2009-05-28 13:56:42 +0000 (Thu, 28 May 2009) Log Message: ----------- Revert changes from previous commit: they're broken and based on released code which is vastly different than trunk... Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-28 04:19:30 UTC (rev 383) +++ trunk/1.0/contentSystem.class.php 2009-05-28 13:56:42 UTC (rev 384) @@ -378,17 +378,6 @@ * Retrieves the list of templates & includes in preparation for later work. */ private function prepare() { - - //Set the final section... - if(count($this->sectionArr)) { - $mySectionArr = $this->sectionArr; - $this->finalSection = array_pop($mySectionArr); - } - else { - throw new exception(__METHOD__ .": FATAL - section array is empty"); - } - - //attempt to load any includes... $this->load_includes(); $foundIncludes = count($this->includesList); @@ -443,24 +432,8 @@ $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; - } - elseif(isset($sectionLsData[$myFile]) && $sectionLsData[$myFile]['type'] == 'file') { - //we're good. - $valid = TRUE; - } - else { - $this->reason = __METHOD__ .": couldn't find base template."; - } + $this->finalSection = $this->baseDir; + $reasonText = "base template"; } $tmplFile1 = $this->section .".content.tmpl"; @@ -667,10 +640,6 @@ $this->load_dir_includes($this->baseDir); //okay, now loop through $this->sectionArr & see if we can include anything else. - $addIndex=false; - if($this->finalSection == 'index') { - $addIndex = true; - } if(($this->incFs->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { @@ -689,9 +658,6 @@ //attempt to cd() into the next directory, or die if we can't. if(!$this->incFs->cd($mySection)) { //no dice. Break the loop. - if($this->finalSection == 'index') { - $addIndex = true; - } break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-31 21:22:11
|
Revision: 385 http://cs-content.svn.sourceforge.net/cs-content/?rev=385&view=rev Author: crazedsanity Date: 2009-05-31 21:22:05 +0000 (Sun, 31 May 2009) Log Message: ----------- All setting of template vars in contentSystem occurs within one method. /contentSystem.class.php: * load_page_templates(); -- converted to using add_template(). * load_shared_templates(): -- use add_template(). * finish(): -- when swapping index into the "content" var, call add_template_var() * add_template_var() [NEW]: -- method for assigning template vars to files internally. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-28 13:56:42 UTC (rev 384) +++ trunk/1.0/contentSystem.class.php 2009-05-31 21:22:05 UTC (rev 385) @@ -469,8 +469,7 @@ $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->tmplFs->cd($value)) { @@ -481,14 +480,14 @@ $finalTmplList = $this->arrange_directory_contents('name', 'section'); foreach($finalTmplList as $mySection => $subArr) { foreach($subArr as $internalSection => $myTmpl) { - $this->templateList[$mySection] = $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); } } @@ -497,12 +496,12 @@ $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() @@ -522,7 +521,7 @@ if(is_array($dirContents)) { foreach($dirContents as $mySection => $subArr) { foreach($subArr as $subIndex=>$templateFilename) { - $this->templateList[$mySection] = $templateFilename; + $this->add_template($mySection, $templateFilename); } } } @@ -549,7 +548,7 @@ if(count($dirContents['shared'])) { foreach($dirContents['shared'] as $section => $template) { - $this->templateList[$section] = $template; + $this->add_template($section, $template); } } }//end load_shared_templates() @@ -782,7 +781,7 @@ //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']); } @@ -916,6 +915,22 @@ //------------------------------------------------------------------------ + private final function add_template($var, $file, $allowIndex=false) { + if($var == 'index' && $allowIndex !== true) { + $this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); + } + else { + if(isset($this->templateList[$var])) { + $this->gfObj->debug_print(__METHOD__ .": REPLACING [". $var ."], was (". $this->templateList[$var] .") with (". $file .")"); + } + $this->templateList[$var] = $file; + } + }//end add_template() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ public function inject_var($varName, $value) { $this->injectVars[$varName] = $value; }//end inject_var() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-08 03:49:38
|
Revision: 388 http://cs-content.svn.sourceforge.net/cs-content/?rev=388&view=rev Author: crazedsanity Date: 2009-06-08 03:49:30 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Fix add_template() to not care about the index file anymore... /contentSystem.class.php: * add_template(): -- ARG CHANGE: DELETED ARG: #3 ($allowIndex=false) -- no longer checks anything when adding a template. -- NOTE: the implementation of only allowing index at certain times was broken. More refining of the system needs to be done, I think. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Property Changed: ---------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-06-04 15:11:11 UTC (rev 387) +++ trunk/1.0/contentSystem.class.php 2009-06-08 03:49:30 UTC (rev 388) @@ -920,13 +920,8 @@ //------------------------------------------------------------------------ - private final function add_template($var, $file, $allowIndex=false) { - if($var == 'index' && $allowIndex !== true) { - //$this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); - } - else { - $this->templateList[$var] = $file; - } + private final function add_template($var, $file) { + $this->templateList[$var] = $file; }//end add_template() //------------------------------------------------------------------------ Property changes on: trunk/1.0/contentSystem.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-08 19:12:28
|
Revision: 389 http://cs-content.svn.sourceforge.net/cs-content/?rev=389&view=rev Author: crazedsanity Date: 2009-06-08 19:12:26 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Fix PHP error/warning/notice about "this->session" being undefined. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-06-08 03:49:30 UTC (rev 388) +++ trunk/1.0/contentSystem.class.php 2009-06-08 19:12:26 UTC (rev 389) @@ -779,7 +779,7 @@ } } - if(is_object($this->session)) { + if(isset($this->session) && is_object($this->session)) { $page->session =& $this->session; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-09 23:20:16
|
Revision: 427 http://cs-content.svn.sourceforge.net/cs-content/?rev=427&view=rev Author: crazedsanity Date: 2009-08-09 23:20:09 +0000 (Sun, 09 Aug 2009) Log Message: ----------- Fix inclusion of "index.inc" script. /contentSystem.class.php: * load_includes(): -- cd() into the full section, instead of using finalSection (which is sometimes blank, apparently). Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-09 22:18:34 UTC (rev 426) +++ trunk/1.0/contentSystem.class.php 2009-08-09 23:20:09 UTC (rev 427) @@ -669,7 +669,7 @@ } //include the final shared & index files. - if($this->incFs->cd($this->finalSection)) { + if($this->incFs->cd('/'. $this->section)) { $lsData = $this->incFs->ls(); if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-10 00:50:26
|
Revision: 428 http://cs-content.svn.sourceforge.net/cs-content/?rev=428&view=rev Author: crazedsanity Date: 2009-08-09 23:58:15 +0000 (Sun, 09 Aug 2009) Log Message: ----------- Fix issue caused by last fix. /contentSystem.class.php: * load_includes(): -- remove "/index" from the section if it exists. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-09 23:20:09 UTC (rev 427) +++ trunk/1.0/contentSystem.class.php 2009-08-09 23:58:15 UTC (rev 428) @@ -669,7 +669,11 @@ } //include the final shared & index files. - if($this->incFs->cd('/'. $this->section)) { + $mySection = $this->section; + if(preg_match('/\/index$/', $mySection)) { + $mySection = preg_replace('/\/index$/','', $mySection); + } + if($this->incFs->cd('/'. $mySection)) { $lsData = $this->incFs->ls(); if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-12 15:40:55
|
Revision: 431 http://cs-content.svn.sourceforge.net/cs-content/?rev=431&view=rev Author: crazedsanity Date: 2009-08-12 15:40:46 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Don't pass session object by reference, since it may be an overloaded object... Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-12 15:10:23 UTC (rev 430) +++ trunk/1.0/contentSystem.class.php 2009-08-12 15:40:46 UTC (rev 431) @@ -792,7 +792,7 @@ } if(isset($this->session) && is_object($this->session)) { - $page->session =& $this->session; + $page->session = $this->session; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-18 20:31:57
|
Revision: 443 http://cs-content.svn.sourceforge.net/cs-content/?rev=443&view=rev Author: crazedsanity Date: 2009-08-18 20:31:49 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Add templates immediately instead of during finish(). /contentSystem.class.php: * finish(): -- no longer add templates at this point (already added) * add_template(): -- calls templateObj->add_template_file() immediately (facilitates more unit testing). Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-18 18:55:52 UTC (rev 442) +++ trunk/1.0/contentSystem.class.php 2009-08-18 20:31:49 UTC (rev 443) @@ -807,13 +807,6 @@ unset($this->templateList['index']); } - foreach($this->templateList as $mySection => $myTmpl) { - $myTmpl = preg_replace("/\/\//", "/", $myTmpl); - $page->add_template_file($mySection, $myTmpl); - } - unset($mySection); - unset($myTmpl); - //make the "final section" available to scripts. $finalSection = $this->finalSection; $sectionArr = $this->sectionArr; @@ -938,7 +931,8 @@ //------------------------------------------------------------------------ private final function add_template($var, $file) { - $this->templateList[$var] = $file; + $file = preg_replace("/\/\//", "/", $file); + $this->templateObj->add_template_file($var, $file); }//end add_template() //------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-20 16:33:08
|
Revision: 452 http://cs-content.svn.sourceforge.net/cs-content/?rev=452&view=rev Author: crazedsanity Date: 2009-08-20 16:32:56 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Set some commonly-used template vars. /contentSystem.class.php: * initialize_locals(): -- add an array of commonly-used vars::: ++ date ++ time ++ curYear ++ curDate ++ curMonth ++ timezone ++ DOMAIN ++ PHP_SELF ++ REQUEST_URI ++ FULL_URL ++ error_msg -- use a simple foreach loop to set them into templateObj. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-20 16:13:49 UTC (rev 451) +++ trunk/1.0/contentSystem.class.php 2009-08-20 16:32:56 UTC (rev 452) @@ -149,10 +149,24 @@ $this->templateObj = new cs_genericPage(FALSE, $root ."/templates/main.shared.tmpl"); //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')); + $defaultVars = array( + 'date' => date('m-d-Y'), + 'time' => date('H:i:s'), + 'curYear' => date('Y'), + 'curDate' => date("F j, Y"), + 'curMonth' => date("m"), + 'timezone' => date("T"), + 'DOMAIN' => $_SERVER['SERVER_NAME'], + 'PHP_SELF' => $_SERVER['SCRIPT_NAME'], + 'REQUEST_URI' => $_SERVER['REQUEST_URI'], + 'FULL_URL' => $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], + 'error_msg' => "" + ); + foreach($defaultVars as $k=>$v) { + $this->templateObj->add_template_var($k, $v); + } + $myUrl = '/'; if(strlen($this->section) && $this->section !== 0) { $myUrl = '/'. $this->section; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-09-23 14:46:27
|
Revision: 464 http://cs-content.svn.sourceforge.net/cs-content/?rev=464&view=rev Author: crazedsanity Date: 2009-09-23 14:46:10 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Die gracefully on CLI too... /contentSystem.class.php: * die_gracefully(): -- only spit out HTML if it is NOT on the command line interface (CLI) -- remove TODO that was already done. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-09-21 14:38:05 UTC (rev 463) +++ trunk/1.0/contentSystem.class.php 2009-09-23 14:46:10 UTC (rev 464) @@ -731,8 +731,8 @@ * Called when something is broken. */ private function die_gracefully($details=NULL) { - header('HTTP/1.0 404 Not Found'); - if($this->templateObj->template_file_exists('system/404.shared.tmpl')) { + if(isset($_SERVER['SERVER_PROTOCOL']) && $this->templateObj->template_file_exists('system/404.shared.tmpl')) { + header('HTTP/1.0 404 Not Found'); //Simple "Page Not Found" error... show 'em. $this->templateObj->add_template_var('main', $this->templateObj->file_to_string('system/404.shared.tmpl')); @@ -748,7 +748,6 @@ exit; } else { - //TODO: make it *actually* die gracefully... the way it works now looks more like puke than grace. throw new exception(__METHOD__ .": Couldn't find 404 template, plus additional error... \nDETAILS::: $details" . "\nREASON::: ". $this->reason); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-10-20 23:33:11
|
Revision: 465 http://cs-content.svn.sourceforge.net/cs-content/?rev=465&view=rev Author: crazedsanity Date: 2009-10-20 23:32:57 +0000 (Tue, 20 Oct 2009) Log Message: ----------- Add fullSectionArr to show the URL with file extensions, etc. /contentSystem.class.php: * MAIN::: -- new (protected) var $fullSectionArr=array() * __construct(): -- build internal fullSectionArr just like sectionArr, but prior to any cleaning. May be different than sectionArr if APPURL is set. * finish(): -- create $fullSectionArr as a local variable for include scripts. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-09-23 14:46:10 UTC (rev 464) +++ trunk/1.0/contentSystem.class.php 2009-10-20 23:32:57 UTC (rev 465) @@ -69,6 +69,7 @@ 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 $fullsectionArr = array(); protected $tmplFs = NULL; //Object used to access the TEMPLATES filesystem @@ -106,6 +107,7 @@ $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); //figure out the section & subsection stuff. + $this->fullSectionArr = split('/', $_SERVER['REQUEST_URI']); //TODO: will this cope with an APPURL being set? $this->section = $this->clean_url($_SERVER['REQUEST_URI']); $this->initialize_locals($siteRoot); @@ -796,6 +798,7 @@ //make the "final section" available to scripts. $finalSection = $this->finalSection; $sectionArr = $this->sectionArr; + $fullSectionArr = $this->fullSectionArr; array_unshift($sectionArr, $this->baseDir); $finalURL = $this->gfObj->string_from_array($sectionArr, NULL, '/'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-10-23 14:58:31
|
Revision: 468 http://cs-content.svn.sourceforge.net/cs-content/?rev=468&view=rev Author: crazedsanity Date: 2009-10-23 14:58:22 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Set "PHP_SELF" template var as expected (previously, it was only a partial). NOTE::: see issue #306 for more details. /contentSystem.class.php: * initialize_locals(): -- commented-out "PHP_SELF" template var, with note that it is now set in finish(). * finish(): -- set PHP_SELF template var to be the URL form of $sectionArr. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-10-21 16:30:53 UTC (rev 467) +++ trunk/1.0/contentSystem.class.php 2009-10-23 14:58:22 UTC (rev 468) @@ -152,7 +152,7 @@ 'curMonth' => date("m"), 'timezone' => date("T"), 'DOMAIN' => $_SERVER['SERVER_NAME'], - 'PHP_SELF' => $_SERVER['SCRIPT_NAME'], + //'PHP_SELF' => $_SERVER['SCRIPT_NAME'], // --> set in finish(). 'REQUEST_URI' => $_SERVER['REQUEST_URI'], 'FULL_URL' => $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], 'error_msg' => "" @@ -804,6 +804,7 @@ $fullSectionArr = $this->fullSectionArr; array_unshift($sectionArr, $this->baseDir); $finalURL = $this->gfObj->string_from_array($sectionArr, NULL, '/'); + $this->templateObj->add_template_var('PHP_SELF', '/'. $this->gfObj->string_from_array($sectionArr, NULL, '/')); $page = $this->templateObj; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2010-03-01 14:44:11
|
Revision: 471 http://cs-content.svn.sourceforge.net/cs-content/?rev=471&view=rev Author: crazedsanity Date: 2010-03-01 14:44:04 +0000 (Mon, 01 Mar 2010) Log Message: ----------- Fix issue #318 /contentSystem.class.php: * initialize_locals(): -- strip trailing "/" from DOCUMENT_ROOT (issue #318) Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-11-11 01:06:10 UTC (rev 470) +++ trunk/1.0/contentSystem.class.php 2010-03-01 14:44:04 UTC (rev 471) @@ -132,7 +132,8 @@ //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 = preg_replace('/\/public_html$/', '', $_SERVER['DOCUMENT_ROOT']); + $root = preg_replace('/\/$/', '', $_SERVER['DOCUMENT_ROOT']); + $root = preg_replace('/\/public_html$/', '', $root); $root = preg_replace('/\/html/', '', $root); if(!is_null($siteRoot) && is_dir($siteRoot)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2010-05-14 17:14:22
|
Revision: 473 http://cs-content.svn.sourceforge.net/cs-content/?rev=473&view=rev Author: crazedsanity Date: 2010-05-14 17:14:14 +0000 (Fri, 14 May 2010) Log Message: ----------- Suppress some PHP warnings. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2010-04-14 22:54:33 UTC (rev 472) +++ trunk/1.0/contentSystem.class.php 2010-05-14 17:14:14 UTC (rev 473) @@ -578,8 +578,8 @@ $filename = preg_replace('/^\/\//', '/', $filename); //call another method to rip the filename apart properly, then arrange things as needed. $pieces = $this->parse_filename($index); - $myPriIndex = $pieces[$primaryIndex]; - $mySecIndex = $pieces[$secondaryIndex]; + $myPriIndex = @$pieces[$primaryIndex]; + $mySecIndex = @$pieces[$secondaryIndex]; if(strlen($myPriIndex) && strlen($mySecIndex)) { //only load if it's got BOTH parts of the filename. $arrangedArr[$myPriIndex][$mySecIndex] = $filename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2010-05-18 13:29:48
|
Revision: 474 http://cs-content.svn.sourceforge.net/cs-content/?rev=474&view=rev Author: crazedsanity Date: 2010-05-18 13:29:42 +0000 (Tue, 18 May 2010) Log Message: ----------- Minor change to remove a PHP warning. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2010-05-14 17:14:14 UTC (rev 473) +++ trunk/1.0/contentSystem.class.php 2010-05-18 13:29:42 UTC (rev 474) @@ -550,7 +550,7 @@ //pull a list of the files. $dirContents = $this->arrange_directory_contents(); - if(count($dirContents['shared'])) { + if(isset($dirContents['shared']) && count($dirContents['shared'])) { foreach($dirContents['shared'] as $section => $template) { $this->add_template($section, $template); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |