[Cs-content-commits] SF.net SVN: cs-content:[331] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-01-29 20:18:43
|
Revision: 331 http://cs-content.svn.sourceforge.net/cs-content/?rev=331&view=rev Author: crazedsanity Date: 2009-01-29 20:18:41 +0000 (Thu, 29 Jan 2009) Log Message: ----------- Implementation of cs_contentAbstract{}. NOTE::: to avoid segfaults, cs_globalFunctions does NOT extend cs_contentAbstract. /contentSystemClass.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /cs_bbCodeParser.class.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /cs_fileSystemClass.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). * cdup(): -- replaced reference of "this->gf" to "this->gfObj" * cd(): -- replaced reference of "this->gf" to "this->gfObj" * filename2absolute(): -- replaced reference of "this->gf" to "this->gfObj" * rename(): -- replaced reference of "this->gf" to "this->gfObj" * resolve_path_with_dots(): -- replaced reference of "this->gf" to "this->gfObj" * check_chroot(): -- replaced reference of "this->gf" to "this->gfObj" * movefile(): -- replaced reference of "this->gf" to "this->gfObj" /cs_genericPageClass.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /cs_phpDB.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /cs_sessionClass.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /cs_siteConfig.class.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). * parse_config(): -- replaced reference of "this->gf" to "this->gfObj" /cs_tabsClass.php: * MAIN::: -- requires /abstract/cs_content.abstract.class.php -- extends cs_contentAbstract * __construct(): -- calls parent::__construct() -- removed things involving version & cs_globalFunctions (in parent constructor). /abstract/cs_content.abstract.class.php [NEW]: * class that holds all duplicated functionality across libraries. * NOTE::: passing boolean false to the constructor avoids including or creating the cs_globalFunctions{} object. Modified Paths: -------------- trunk/1.0/contentSystemClass.php trunk/1.0/cs_bbCodeParser.class.php trunk/1.0/cs_fileSystemClass.php trunk/1.0/cs_genericPageClass.php trunk/1.0/cs_phpDB.php trunk/1.0/cs_sessionClass.php trunk/1.0/cs_siteConfig.class.php trunk/1.0/cs_tabsClass.php Added Paths: ----------- trunk/1.0/abstract/cs_content.abstract.class.php Added: trunk/1.0/abstract/cs_content.abstract.class.php =================================================================== --- trunk/1.0/abstract/cs_content.abstract.class.php (rev 0) +++ trunk/1.0/abstract/cs_content.abstract.class.php 2009-01-29 20:18:41 UTC (rev 331) @@ -0,0 +1,36 @@ +<?php +/* + * Created on Jan 29, 2009 + * + * FILE INFORMATION: + * + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +require_once(dirname(__FILE__) ."/../../cs-versionparse/cs_version.abstract.class.php"); + + +abstract class cs_contentAbstract extends cs_versionAbstract { + + //------------------------------------------------------------------------- + function __construct($makeGfObj=true) { + $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); + $this->get_version(); + $this->get_project(); + + if($makeGfObj === true) { + //make a cs_globalFunctions{} object. + require_once(dirname(__FILE__) ."/../cs_globalFunctions.php"); + $this->gfObj = new cs_globalFunctions(); + } + }//end __construct() + //------------------------------------------------------------------------- + + + +} +?> \ No newline at end of file Property changes on: trunk/1.0/abstract/cs_content.abstract.class.php ___________________________________________________________________ Added: svn:keywords + HeadURL Id LastChangedDate LastChangedBy LastChangedRevision Date Revision Author Modified: trunk/1.0/contentSystemClass.php =================================================================== --- trunk/1.0/contentSystemClass.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/contentSystemClass.php 2009-01-29 20:18:41 UTC (rev 331) @@ -70,14 +70,13 @@ $GLOBALS['SITE_ROOT'] = str_replace("/public_html", "", $GLOBALS['SITE_ROOT']); } -require_once(dirname(__FILE__) ."/cs_globalFunctions.php"); +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); require_once(dirname(__FILE__) ."/cs_fileSystemClass.php"); require_once(dirname(__FILE__) ."/cs_sessionClass.php"); require_once(dirname(__FILE__) ."/cs_genericPageClass.php"); require_once(dirname(__FILE__) ."/cs_tabsClass.php"); -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); -class contentSystem extends cs_versionAbstract { +class contentSystem extends cs_contentAbstract { protected $baseDir = NULL; //base directory for templates & includes. protected $section = NULL; //section string, derived from the URL. @@ -109,11 +108,7 @@ $this->isTest = TRUE; } else { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); - $this->get_version(); - $this->get_project(); - //make a cs_globalFunctions{} object. - $this->gfObj = new cs_globalFunctions(); + parent::__construct(); //setup the section stuff... $repArr = array($_SERVER['SCRIPT_NAME'], "/"); Modified: trunk/1.0/cs_bbCodeParser.class.php =================================================================== --- trunk/1.0/cs_bbCodeParser.class.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_bbCodeParser.class.php 2009-01-29 20:18:41 UTC (rev 331) @@ -18,9 +18,9 @@ * been converted. */ -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); -class cs_bbCodeParser extends cs_versionAbstract { +class cs_bbCodeParser extends cs_contentAbstract { /** Array containing all the codes & how to parse them. */ private $bbCodeData = NULL; @@ -30,7 +30,7 @@ * Setup internal structures. */ function __construct() { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); + parent::__construct(false); # Which BBCode is accepted here $this->bbCodeData = array( 'bold' => array( Modified: trunk/1.0/cs_fileSystemClass.php =================================================================== --- trunk/1.0/cs_fileSystemClass.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_fileSystemClass.php 2009-01-29 20:18:41 UTC (rev 331) @@ -9,10 +9,9 @@ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) ."/cs_globalFunctions.php"); -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); -class cs_fileSystemClass extends cs_versionAbstract { +class cs_fileSystemClass extends cs_contentAbstract { public $root; //actual root directory. public $cwd; //current directory; relative to $this->root @@ -20,7 +19,6 @@ public $dh; //directory handle. public $fh; //file handle. public $filename; //filename currently being used. - public $gf; //cs_globalFunctions{} object. public $lineNum = NULL; @@ -29,7 +27,6 @@ * The constructor. */ public function __construct($rootDir=NULL, $cwd=NULL, $initialMode=NULL) { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); //set the root directory that we'll be using; this is considered just like "/" in // linux. Directories above it are considered non-existent. if(($rootDir) AND (is_dir($rootDir))) { @@ -43,7 +40,8 @@ exit("UNUSEABLE ROOT: $rootDir"); } - $this->gf = new cs_globalFunctions(); + parent::__construct(); + $this->root = $this->resolve_path_with_dots($this->root); //set the CURRENT working directory... this should be a RELATIVE path to $this->root. @@ -84,8 +82,8 @@ } $myParts = explode('/', $myCwd); array_pop($myParts); - $myCwd = $this->gf->string_from_array($myParts, NULL, '/'); - $realCwd = $this->gf->create_list($this->root, $myCwd, '/'); + $myCwd = $this->gfObj->string_from_array($myParts, NULL, '/'); + $realCwd = $this->gfObj->create_list($this->root, $myCwd, '/'); if(file_exists($realCwd)) { $retval = TRUE; $this->realcwd = $realCwd; @@ -119,7 +117,7 @@ $retval = 1; } elseif(is_dir($this->realcwd .'/'. $newDir)) { //relative path... - $this->cwd = $this->gf->create_list($this->cwd, $newDir, '/'); + $this->cwd = $this->gfObj->create_list($this->cwd, $newDir, '/'); $this->realcwd .= '/'. $newDir; $retval = 1; } else { @@ -426,7 +424,7 @@ } if(!$this->check_chroot($retval, FALSE)) { - $this->gf->debug_print(func_get_args()); + $this->gfObj->debug_print(func_get_args()); throw new exception(__METHOD__ .": file is outside of allowed directory (". $retval .")"); } @@ -602,7 +600,7 @@ */ public function rename($currentFilename, $newFilename) { if($newFilename == $currentFilename) { - $this->gf->debug_print(func_get_args()); + $this->gfObj->debug_print(func_get_args()); throw new exception(__METHOD__ .": renaming file to same name"); } @@ -612,7 +610,7 @@ if($this->compare_open_filename($newFilename)) { //renaming a different file to our currently open file... - $this->gf->debug_print(func_get_args()); + $this->gfObj->debug_print(func_get_args()); throw new exception(__METHOD__ .": renaming another file (". $currentFilename .") to the currently open filename (". $newFilename .")"); } else { @@ -805,7 +803,7 @@ } } - $retval = $this->gf->string_from_array($finalPieces, NULL, '/'); + $retval = $this->gfObj->string_from_array($finalPieces, NULL, '/'); if($isAbsolute) { $retval = '/'. $retval; } @@ -844,10 +842,10 @@ $pathDir = $pathPieces[$index]; if($pathDir != $dirName) { $retval = FALSE; - $this->gf->debug_print(__METHOD__ .": failed... tmp=(". $tmp ."), dirName=(". $dirName .")"); + $this->gfObj->debug_print(__METHOD__ .": failed... tmp=(". $tmp ."), dirName=(". $dirName .")"); break; } - $tmp = $this->gf->create_list($tmp, $dirName, '/'); + $tmp = $this->gfObj->create_list($tmp, $dirName, '/'); } return($retval); @@ -884,7 +882,7 @@ $retval = rename($filename, $destination); } else { - $this->gf->debug_print(__METHOD__ .":: ". $this->check_chroot($destination),1); + $this->gfObj->debug_print(__METHOD__ .":: ". $this->check_chroot($destination),1); throw new exception(__METHOD__ .':: destination is not in the directory path (from=['. $filename .'], to=['. $destination .']'); } } Modified: trunk/1.0/cs_genericPageClass.php =================================================================== --- trunk/1.0/cs_genericPageClass.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_genericPageClass.php 2009-01-29 20:18:41 UTC (rev 331) @@ -8,9 +8,9 @@ * $LastChangedRevision$ */ require_once(dirname(__FILE__) ."/template.inc"); -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); -class cs_genericPage extends cs_versionAbstract { +class cs_genericPage extends cs_contentAbstract { var $templateObj; //template object to parse the pages var $templateVars = array(); //our copy of the global templateVars var $mainTemplate; //the default layout of the site @@ -32,13 +32,14 @@ //handle some configuration. $this->allowRedirect = $allowRedirect; + //initialize stuff from our parent... + parent::__construct(); + //initialize some internal stuff. - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); $this->initialize_locals($mainTemplateFile); //if they need to be logged-in... $this->check_login($restrictedAccess); - $this->gfObj = new cs_globalFunctions; if(!defined('CS-CONTENT_SESSION_NAME')) { define("CS-CONTENT_SESSION_NAME", ini_get('session.name')); Modified: trunk/1.0/cs_phpDB.php =================================================================== --- trunk/1.0/cs_phpDB.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_phpDB.php 2009-01-29 20:18:41 UTC (rev 331) @@ -24,17 +24,16 @@ // /////////////////////// -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); require_once(dirname(__FILE__) ."/abstract/cs_phpDB.abstract.class.php"); -class cs_phpDB extends cs_versionAbstract { +class cs_phpDB extends cs_contentAbstract { private $dbLayerObj; private $dbType; //========================================================================= public function __construct($type='pgsql') { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); if(strlen($type)) { @@ -43,12 +42,8 @@ $this->dbLayerObj = new $className; $this->dbType = $type; - $this->gfObj = new cs_globalFunctions; + parent::__construct(); - if(defined('DEBUGPRINTOPT')) { - $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - } - $this->isInitialized = TRUE; } else { Modified: trunk/1.0/cs_sessionClass.php =================================================================== --- trunk/1.0/cs_sessionClass.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_sessionClass.php 2009-01-29 20:18:41 UTC (rev 331) @@ -10,7 +10,7 @@ require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); -class cs_session extends cs_versionAbstract { +class cs_session extends cs_contentAbstract { protected $db; public $uid; @@ -26,7 +26,7 @@ * used as the session name. */ function __construct($createSession=1) { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); + parent::__construct(false); if($createSession) { if(!is_null($createSession) && strlen($createSession) && !is_numeric($createSession)) { session_name($createSession); Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_siteConfig.class.php 2009-01-29 20:18:41 UTC (rev 331) @@ -15,12 +15,12 @@ * */ -require_once(dirname(__FILE__) .'/cs_globalFunctions.php'); +require_once(dirname(__FILE__) .'/abstract/cs_content.abstract.class.php'); require_once(dirname(__FILE__) .'/cs_fileSystemClass.php'); require_once(dirname(__FILE__). '/../cs-phpxml/cs_phpxmlParser.class.php'); require_once(dirname(__FILE__) .'/../cs-phpxml/cs_phpxmlBuilder.class.php'); -class cs_siteConfig { +class cs_siteConfig extends cs_contentAbstract { /** XMLParser{} object, for reading XML config file. */ private $xmlReader; @@ -77,8 +77,7 @@ $section = strtoupper($section); $this->setVarPrefix=$setVarPrefix; - $this->gf = new cs_globalFunctions; - $this->gf->debugPrintOpt=1; + parent::__construct(); if(strlen($configFileLocation) && file_exists($configFileLocation)) { @@ -181,8 +180,8 @@ $itemValue = $itemValue['value']; if(preg_match("/{/", $itemValue)) { $origVal = $itemValue; - $itemValue = $this->gf->mini_parser($itemValue, $specialVars, '{', '}'); - $itemValue = $this->gf->mini_parser($itemValue, $parseThis, '{', '}'); + $itemValue = $this->gfObj->mini_parser($itemValue, $specialVars, '{', '}'); + $itemValue = $this->gfObj->mini_parser($itemValue, $parseThis, '{', '}'); $itemValue = preg_replace("/[\/]{2,}/", "/", $itemValue); } Modified: trunk/1.0/cs_tabsClass.php =================================================================== --- trunk/1.0/cs_tabsClass.php 2009-01-29 19:44:01 UTC (rev 330) +++ trunk/1.0/cs_tabsClass.php 2009-01-29 20:18:41 UTC (rev 331) @@ -4,7 +4,10 @@ * */ -class cs_tabs extends cs_versionAbstract { +require_once(dirname(__FILE__) .'/abstract/cs_content.abstract.class.php'); + + +class cs_tabs extends cs_contentAbstract { private $tabsArr; private $selectedTab; @@ -25,7 +28,7 @@ * @param $templateVar (str,optional) What template var to find the tab blockrows in. */ public function __construct(cs_genericPage $csPageObj, $templateVar="tabs") { - $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); + parent::__construct(false); if(is_null($csPageObj) || !is_object($csPageObj) || get_class($csPageObj) !== 'cs_genericPage') { //can't continue without that! throw new exception("cs_tabs::__construct(): cannot load without cs_genericPage{} object (". get_class($csPageObj) .")"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |