Thread: [Cs-content-commits] SF.net SVN: cs-content:[340] releases/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-01-30 14:32:23
|
Revision: 340 http://cs-content.svn.sourceforge.net/cs-content/?rev=340&view=rev Author: crazedsanity Date: 2009-01-30 14:32:17 +0000 (Fri, 30 Jan 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA2 *** SUMMARY OF CHANGES::: * added abstract class for cs_phpDB{} to hold duplicated code. * added abstract class for all libs for some basic functionality. * renamed all classes & filenames to match "(className).class.php" convention. NOTE: the mass renaming of files (and some class names) was to facilitate the ability to use the magic PHP __autoload() function. Modified Paths: -------------- releases/1.0/VERSION releases/1.0/cs_bbCodeParser.class.php releases/1.0/cs_sessionClass.php releases/1.0/cs_siteConfig.class.php releases/1.0/db_types/cs_phpDB__mysql.class.php releases/1.0/db_types/cs_phpDB__pgsql.class.php releases/1.0/db_types/cs_phpDB__sqlite.class.php releases/1.0/sample_files/public_html/content releases/1.0/sample_files/public_html/index.php releases/1.0/tests/testOfCSContent.php Added Paths: ----------- releases/1.0/abstract/ releases/1.0/abstract/cs_content.abstract.class.php releases/1.0/abstract/cs_phpDB.abstract.class.php 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_phpDB.class.php releases/1.0/cs_tabs.class.php releases/1.0/required/ releases/1.0/required/template.inc Removed Paths: ------------- releases/1.0/abstract/cs_content.abstract.class.php releases/1.0/abstract/cs_phpDB.abstract.class.php releases/1.0/contentSystemClass.php releases/1.0/cs_fileSystemClass.php releases/1.0/cs_genericPageClass.php releases/1.0/cs_globalFunctions.php releases/1.0/cs_phpDB.php releases/1.0/cs_tabsClass.php releases/1.0/required/template.inc releases/1.0/template.inc Property Changed: ---------------- releases/1.0/db_types/cs_phpDB__mysql.class.php releases/1.0/db_types/cs_phpDB__pgsql.class.php releases/1.0/db_types/cs_phpDB__sqlite.class.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-01-29 21:57:59 UTC (rev 339) +++ releases/1.0/VERSION 2009-01-30 14:32:17 UTC (rev 340) @@ -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-ALPHA1 +VERSION: 1.0-ALPHA2 PROJECT: cs-content $HeadURL$ \ No newline at end of file Deleted: releases/1.0/abstract/cs_content.abstract.class.php =================================================================== --- trunk/1.0/abstract/cs_content.abstract.class.php 2009-01-29 21:57:59 UTC (rev 339) +++ releases/1.0/abstract/cs_content.abstract.class.php 2009-01-30 14:32:17 UTC (rev 340) @@ -1,36 +0,0 @@ -<?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.class.php"); - $this->gfObj = new cs_globalFunctions(); - } - }//end __construct() - //------------------------------------------------------------------------- - - - -} -?> \ No newline at end of file Copied: releases/1.0/abstract/cs_content.abstract.class.php (from rev 339, trunk/1.0/abstract/cs_content.abstract.class.php) =================================================================== --- releases/1.0/abstract/cs_content.abstract.class.php (rev 0) +++ releases/1.0/abstract/cs_content.abstract.class.php 2009-01-30 14:32:17 UTC (rev 340) @@ -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.class.php"); + $this->gfObj = new cs_globalFunctions(); + } + }//end __construct() + //------------------------------------------------------------------------- + + + +} +?> \ No newline at end of file Deleted: releases/1.0/abstract/cs_phpDB.abstract.class.php =================================================================== --- trunk/1.0/abstract/cs_phpDB.abstract.class.php 2009-01-29 21:57:59 UTC (rev 339) +++ releases/1.0/abstract/cs_phpDB.abstract.class.php 2009-01-30 14:32:17 UTC (rev 340) @@ -1,166 +0,0 @@ -<?php -/* - * Created on Jan 29, 2009 - * - * FILE INFORMATION: - * - * $HeadURL$ - * $Id$ - * $LastChangedDate$ - * $LastChangedBy$ - * $LastChangedRevision$ - */ - -abstract class cs_phpDBAbstract { - - /** Internal result set pointer. */ - protected $result = NULL; - - /** Internal error code. */ - protected $errorCode = 0; - - /** Status of the current transaction. */ - protected $transStatus = NULL; - - /** Whether there is a transaction in progress or not. */ - protected $inTrans = FALSE; - - /** Holds the last query performed. */ - protected $lastQuery = NULL; - - /** List of queries that have been run */ - protected $queryList=array(); - - /** How many seconds to wait for a query before cancelling it. */ - protected $timeOutSeconds = NULL; - - /** Internal check to determine if a connection has been established. */ - protected $isConnected=FALSE; - - /** Internal check to determine if the parameters have been set. */ - protected $paramsAreSet=FALSE; - - /** Resource handle. */ - protected $connectionID = -1; - - /** Hostname or IP to connect to */ - protected $host; - - /** Port to connect to (default for Postgres is 5432) */ - protected $port; - - /** Name of the database */ - protected $dbname; - - /** Username to connect to the database */ - protected $user; - - /** password to connect to the database */ - protected $password; - - /** Row counter for looping through records */ - protected $row = -1; - - /** cs_globalFunctions object, for string stuff. */ - protected $gfObj; - - /** Internal check to ensure the object has been properly created. */ - protected $isInitialized=FALSE; - - /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ - protected $preparedStatements = array(); - - /** Set to TRUE to save all queries into an array. */ - protected $useQueryList=FALSE; - - /** array that essentially remembers how many times beginTrans() was called. */ - protected $transactionTree = NULL; - - - - //Define some abstract methods so they MUST be provided in order for things to work. - abstract public function set_db_info(array $params); - abstract public function close(); - abstract public function connect(array $dbParams=NULL, $forceNewConnection=FALSE); - abstract public function exec($query); - abstract public function errorMsg($setMessage=null, $logError=null); - abstract public function fobject(); - abstract public function farray(); - abstract public function farray_fieldnames($index=null, $numbered=null,$unsetIndex=1); - abstract public function farray_nvp($name, $value); - abstract public function farray_numbered(); - abstract public function numAffected(); - abstract public function numRows(); - abstract public function is_connected(); - - - //========================================================================= - public function __construct() { - $this->gfObj = new cs_globalFunctions; - $this->isInitialized = true; - }//end __construct() - //========================================================================= - - - - //========================================================================= - /** - * Make sure the object is sane. - */ - final protected function sanity_check() { - if($this->isInitialized !== TRUE) { - throw new exception(__METHOD__ .": not properly initialized"); - } - }//end sanity_check() - //========================================================================= - - - - //========================================================================= - /** - * Disconnect from the database (calls internal "close()" method). - */ - public function disconnect() { - return($this->close()); - }//end disconnect() - //========================================================================= - - - - //========================================================================= - public function affectedRows() { - return($this->numAffected()); - }//end affectedRows() - //========================================================================= - - - - //========================================================================= - public function currRow() { - return($this->row); - }//end currRow() - //========================================================================= - - - - //========================================================================= - public function querySafe($string) { - return($this->gfObj->cleanString($string,"query")); - }//end querySafe() - //========================================================================= - - - - //========================================================================= - /** - * Make it SQL safe. - */ - public function sqlSafe($string) { - return($this->gfObj->cleanString($string,"sql")); - }//end sqlSafe() - //========================================================================= - - - -} -?> \ No newline at end of file Copied: releases/1.0/abstract/cs_phpDB.abstract.class.php (from rev 339, trunk/1.0/abstract/cs_phpDB.abstract.class.php) =================================================================== --- releases/1.0/abstract/cs_phpDB.abstract.class.php (rev 0) +++ releases/1.0/abstract/cs_phpDB.abstract.class.php 2009-01-30 14:32:17 UTC (rev 340) @@ -0,0 +1,166 @@ +<?php +/* + * Created on Jan 29, 2009 + * + * FILE INFORMATION: + * + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +abstract class cs_phpDBAbstract { + + /** Internal result set pointer. */ + protected $result = NULL; + + /** Internal error code. */ + protected $errorCode = 0; + + /** Status of the current transaction. */ + protected $transStatus = NULL; + + /** Whether there is a transaction in progress or not. */ + protected $inTrans = FALSE; + + /** Holds the last query performed. */ + protected $lastQuery = NULL; + + /** List of queries that have been run */ + protected $queryList=array(); + + /** How many seconds to wait for a query before cancelling it. */ + protected $timeOutSeconds = NULL; + + /** Internal check to determine if a connection has been established. */ + protected $isConnected=FALSE; + + /** Internal check to determine if the parameters have been set. */ + protected $paramsAreSet=FALSE; + + /** Resource handle. */ + protected $connectionID = -1; + + /** Hostname or IP to connect to */ + protected $host; + + /** Port to connect to (default for Postgres is 5432) */ + protected $port; + + /** Name of the database */ + protected $dbname; + + /** Username to connect to the database */ + protected $user; + + /** password to connect to the database */ + protected $password; + + /** Row counter for looping through records */ + protected $row = -1; + + /** cs_globalFunctions object, for string stuff. */ + protected $gfObj; + + /** Internal check to ensure the object has been properly created. */ + protected $isInitialized=FALSE; + + /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ + protected $preparedStatements = array(); + + /** Set to TRUE to save all queries into an array. */ + protected $useQueryList=FALSE; + + /** array that essentially remembers how many times beginTrans() was called. */ + protected $transactionTree = NULL; + + + + //Define some abstract methods so they MUST be provided in order for things to work. + abstract public function set_db_info(array $params); + abstract public function close(); + abstract public function connect(array $dbParams=NULL, $forceNewConnection=FALSE); + abstract public function exec($query); + abstract public function errorMsg($setMessage=null, $logError=null); + abstract public function fobject(); + abstract public function farray(); + abstract public function farray_fieldnames($index=null, $numbered=null,$unsetIndex=1); + abstract public function farray_nvp($name, $value); + abstract public function farray_numbered(); + abstract public function numAffected(); + abstract public function numRows(); + abstract public function is_connected(); + + + //========================================================================= + public function __construct() { + $this->gfObj = new cs_globalFunctions; + $this->isInitialized = true; + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Make sure the object is sane. + */ + final protected function sanity_check() { + if($this->isInitialized !== TRUE) { + throw new exception(__METHOD__ .": not properly initialized"); + } + }//end sanity_check() + //========================================================================= + + + + //========================================================================= + /** + * Disconnect from the database (calls internal "close()" method). + */ + public function disconnect() { + return($this->close()); + }//end disconnect() + //========================================================================= + + + + //========================================================================= + public function affectedRows() { + return($this->numAffected()); + }//end affectedRows() + //========================================================================= + + + + //========================================================================= + public function currRow() { + return($this->row); + }//end currRow() + //========================================================================= + + + + //========================================================================= + public function querySafe($string) { + return($this->gfObj->cleanString($string,"query")); + }//end querySafe() + //========================================================================= + + + + //========================================================================= + /** + * Make it SQL safe. + */ + public function sqlSafe($string) { + return($this->gfObj->cleanString($string,"sql")); + }//end sqlSafe() + //========================================================================= + + + +} +?> \ No newline at end of file Copied: releases/1.0/contentSystem.class.php (from rev 339, trunk/1.0/contentSystem.class.php) =================================================================== --- releases/1.0/contentSystem.class.php (rev 0) +++ releases/1.0/contentSystem.class.php 2009-01-30 14:32:17 UTC (rev 340) @@ -0,0 +1,854 @@ +<?php +/* + * FILE INFORMATION: + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedRevision$ + * $LastChangedBy$ + * + * HOW THE SYSTEM WORKS::: + * TEMPLATE FILES: + * Automatically loads templates based on the URL, and optionally includes scripts in the includes directory. + * + * MAIN SECTION: + * For the main section, i.e. "/content", it requires a template in a directory of that name beneath + * /templates, with a file called "index.content.tmpl"... i.e. /templatee/content/index.content.tmpl. + * SUB SECTIONS: + * For any subsection to be valid, i.e. "/content/members", it must have an associated template, i.e. + * "/templates/content/members.content.tmpl". If a subdirectory with an index.content.tmpl file exists, it will + * be used instead of the file in the sub directory (i.e. "/templates/content/members/index.content.tmpl"). + * SUB SECTION TEMPLATE INHERITANCE: + * All pages load the base set of "shared" templates, which are in the form "<section>.shared.tmpl" in + * the root of the templates directory. + * + * Shared files within each directory, in the form "<section>.shared.tmpl", will be loaded for ANY subsection. + * + * For any subsection, it inherits a previous section's templates in the following manner (any "content" + * templates are ignored for inheritance, as they're require for page load). + * /content ---> /templates/content/index.*.tmpl + * + * /content/members |--> /templates/content/index.*.tmpl + * `--> /templates/content/members.*.tmpl + * + * /content/members/test |--> /templates/content/index.*.tmpl + * |--> /templates/content/members.*.tmpl + * |--> /templates/content/members/index.*.tmpl + * `--> /templates/content/members/test.*.tmpl + * AUTOMATIC INCLUDES: + * Much in the same way templates are included, so are scripts, from the /includes directory, though the logic + * is decidedly simpler: all scripts must have the extension of ".inc", and must have either the section's name + * as the first part of the filename, or "shared". Shared scripts will be loaded for ALL subsections. + * + * INCLUDES INHERITANCE: + * The template inheritance scheme is as laid-out below. The content system will go as far into the + * includes directory as it can for the given section, regardless of if any intermediate files are missing. + * + * It is important to note that the content system will NOT regard a section as valid if there are include + * scripts but no templates. + * + * /content |--> /includes/shared.inc + * `--> /includes/content.inc + * + * /content/members |--> /includes/shared.inc + * |--> /includes/content.inc + * |--> /includes/content/shared.inc + * `--> /includes/content/members.inc + * + * /content/members/test |--> /includes/shared.inc + * |--> /includes/content.inc + * |--> /includes/content/shared.inc + * |--> /includes/content/members.inc + * |--> /includes/content/members/shared.inc + * |--> /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_sessionClass.php"); +require_once(dirname(__FILE__) ."/cs_genericPage.class.php"); +require_once(dirname(__FILE__) ."/cs_tabs.class.php"); + +class contentSystem extends cs_contentAbstract { + + 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 $ignoredList = array( //array of files & folders that are implicitely ignored. + 'file' => array('.htaccess'), + 'dir' => array('.svn','CVS' + ) + ); + protected $templateList = array(); + protected $includesList = array(); + public $templateObj = NULL; + protected $gfObj = NULL; + protected $tabs = NULL; + + protected $finalSection; + + private $isValid=FALSE; + private $reason=NULL; + + //------------------------------------------------------------------------ + /** + * The CONSTRUCTOR. Duh. + */ + public function __construct($testOnly=FALSE) { + if($testOnly === 'unit_test') { + //It's just a test, don't do anything we might regret later. + $this->isTest = TRUE; + } + else { + parent::__construct(); + + //setup the section stuff... + $repArr = array($_SERVER['SCRIPT_NAME'], "/"); + $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); + + //figure out the section & subsection stuff. + $this->section = $this->clean_url($_SERVER['REQUEST_URI']); + + $this->initialize_locals(); + } + }//end __construct() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Creates internal objects & prepares for later usage. + */ + private function initialize_locals() { + //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(). + $this->templateObj = new cs_genericPage(FALSE, "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')); + + $myUrl = '/'; + if(strlen($this->section) && $this->section !== 0) { + $myUrl = '/'. $this->section; + } + $this->templateObj->add_template_var('CURRENT_URL', $myUrl); + + //create a fileSystem object. + $this->fileSystemObj = new cs_fileSystem(); + + //create a tabs object, in case they want to load tabs on the page. + $this->tabs = new cs_tabs($this->templateObj); + + //check versions, make sure they're all the same. + $myVersion = $this->get_version(); + 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->gfObj->get_version() !== $myVersion) { + throw new exception(__METHOD__ .": ". get_class($this->gfObj) ." has mismatched version (". $this->gfObj->get_version() ." does not equal ". $myVersion .")"); + } + if($this->tabs->get_version() !== $myVersion) { + throw new exception(__METHOD__ .": ". get_class($this->tabs) ." has mismatched version (". $this->tabs->get_version() ." does not equal ". $myVersion .")"); + } + + //split apart the section so we can do stuff with it later. + $this->parse_section(); + + //get ready for when we have to load templates & such. + $this->prepare(); + }//end initialize_locals() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + private function get_template_dirs() { + if(is_array($this->sectionArr)) { + $this->fileSystemObj->cd("/templates/". $this->baseDir); + $retval = array(); + $retval[] = $this->fileSystemObj->cwd; + foreach($this->sectionArr as $index=>$name) { + if($this->fileSystemObj->cd($name)) { + $retval[] = $this->fileSystemObj->cwd; + } + else { + break; + } + } + } + else { + throw new exception(__METHOD__ .": section array is invalid"); + } + + return($retval); + }//end get_template_dirs() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Call this to require that users accessing the given URL are authenticated; + * if they're not, this will cause them to be redirected to another URL + * (generally, so they can login). + */ + public function force_authentication($redirectToUrl, $destinationArg='loginDestination') { + if(is_object($this->session) && method_exists($this->session, 'is_authenticated')) { + if(strlen($redirectToUrl)) { + $cleanedRedirect = $this->clean_url($redirectToUrl); + if($this->section != $cleanedRedirect) { + if(!$this->session->is_authenticated()) { + //run the redirect. + if(strlen($destinationArg)) { + $redirectToUrl .= '?'. $destinationArg .'=/'. urlencode($_SERVER['REQUEST_URI']); + } + $this->gfObj->conditional_header($redirectToUrl, TRUE); + } + } + else { + throw new exception(__METHOD__ .": redirect url (". $redirectToUrl .") matches current URL"); + } + } + else { + throw new exception(__METHOD__ .": failed to provide proper redirection URL"); + } + } + else { + throw new exception(__METHOD__ .": cannot force authentication (missing method)"); + } + }//end force_authentication() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Used to determine if contentSystem{} should handle creating the session. + */ + public function handle_session(&$sessionObj=NULL) { + if(is_object($sessionObj)) { + //they want us to use a different class... fine. + $this->session = $sessionObj; + } + else { + //use our own session handler. + $this->session = new cs_session; + } + + if(!method_exists($this->session, 'is_authenticated')) { + throw new exception(__METHOD__ .": session class ('". get_class($this->session) ."') is missing method is_authenticated()"); + } + }//end handle_session() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Rips apart the "section" string, setting $this->section and $this->sectionArr. + */ + private function parse_section() { + if($this->section === 0 || is_null($this->section) || !strlen($this->section)) { + $this->section = "content/index"; + } + $myArr = split('/', $this->section); + + //if we've got something in the array, keep going. + if(is_array($myArr) && count($myArr) && ($myArr[0] !== 0)) { + $this->baseDir = array_shift($myArr); + $this->sectionArr = $myArr; + } + }//end parse_section() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Removes all the crap from the url, so we can figure out what section we + * need to load templates & includes for. + */ + private function clean_url($section=NULL) { + if(!strlen($section) && strlen($this->section)) { + //if argument wasn't given, use internal pointer. + $section = $this->section; + } + + //make sure we've still got something valid to work with. + if(!strlen($section)) { + //TODO: remove the extra return statement (should only be one at the bottom of the method). + return(NULL); + } + else { + //check the string to make sure it doesn't begin or end with a "/" + if($section[0] == '/') { + $section = substr($section, 1, strlen($section)); + } + + //check the last char for a "/"... + if($section[strlen($section) -1] == '/') { + //last char is a '/'... kill it. + $section = substr($section, 0, strlen($section) -1); + } + + //if we've been sent a query, kill it off the string... + if(preg_match('/\?/', $section)) { + $section = split('\?', $section); + $section = $section[0]; + } + + if(ereg("\.", $section)) { + //disregard file extensions, but keep everything else... + // i.e. "index.php/yermom.html" becomes "index/yermom" + $tArr = split('/', $section); + foreach($tArr as $tSecName) { + $temp = split("\.", $tSecName); + if(strlen($temp[0]) > 1) { + $tSecName = $temp[0]; + } + $tSection = $this->gfObj->create_list($tSection, $tSecName, '/'); + } + $section = $tSection; + } + } + + return($section); + }//end clean_url() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Retrieves the list of templates & includes in preparation for later work. + */ + private function prepare() { + //attempt to load any includes... + if($this->fileSystemObj->cd('/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)) { + + //okay, get template directories & start loading + $tmplDirs = $this->get_template_dirs(); + + $this->load_shared_templates(); + foreach($tmplDirs as $myPath) { + //load shared templates. + $this->load_shared_templates($myPath); + } + + //load templates for the main section. + $this->load_main_templates(); + + //load templates for the page. + $this->load_page_templates(); + + //now cd() all the way back. + $this->fileSystemObj->cd('/'); + } + else { + //couldn't find the templates directory, and no includes... it's dead. + $this->die_gracefully(__METHOD__ .": unable to find the templates directory, or non-valid page [". $this->validate_page() ."]"); + } + }//end prepare() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Ensures the page we're on would actually load, so other methods don't have to do + * so much extra checking. + */ + 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. + 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; + } + } + 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->isValid = $valid; + + return($valid); + }//end validate_page() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Loads the templates for the current page (performs template inheritance, too). + */ + private function load_page_templates() { + //should already be in the proper directory, start looping through sectionArr, + // looking for templates. + $mySectionArr = $this->sectionArr; + + $finalSection = $this->sectionArr[(count($this->sectionArr) -1)]; + 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; + } + } + if(!$this->fileSystemObj->cd($value)) { + break; + } + } + + //load the final template(s). + $finalTmplList = $this->arrange_directory_contents('name', 'section'); + 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->fileSystemObj->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; + } + } + 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']; + } + } + }//end load_page_templates() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * 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); + $dirContents = $this->arrange_directory_contents('name', 'section'); + if(is_array($dirContents)) { + foreach($dirContents as $mySection => $subArr) { + foreach($subArr as $subIndex=>$templateFilename) { + $this->templateList[$mySection] = $templateFilename; + } + } + } + }//end load_main_templates() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Loads any shared templates: these can be overwritten later. + */ + private function load_shared_templates($path=NULL) { + + if(!is_null($path)) { + $this->fileSystemObj->cd($path); + } + else { + $this->fileSystemObj->cd('/templates'); + } + + //pull a list of the files. + $dirContents = $this->arrange_directory_contents(); + if(count($dirContents['shared'])) { + + foreach($dirContents['shared'] as $section => $template) { + $this->templateList[$section] = $template; + } + } + }//end load_shared_templates() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Pulls a list of files in the current directory, & arranges them by section & + * name, or vice-versa. + */ + private function arrange_directory_contents($primaryIndex='section', $secondaryIndex='name') { + $directoryInfo = $this->fileSystemObj->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 = preg_replace('/^\/templates/', '', $filename); + $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]; + if(strlen($myPriIndex) && strlen($mySecIndex)) { + //only load if it's got BOTH parts of the filename. + $arrangedArr[$myPriIndex][$mySecIndex] = $filename; + } + } + } + } + + return($arrangedArr); + }//end arrange_directory_contents() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Takes a filename (string) and breaks it down into the "type", "section", and + * "name". I.E. for the filename "test.content.tmpl", type=tmpl, section="content", + * and "name"=test. + * TODO: set a way to define how the filenames are setup, so filenames can be "name.section.type" or "section.name.type". + */ + private function parse_filename($filename) { + //break it into it's various parts. + $myParts = explode('.', $filename); + $retval = array(); + $count = count($myParts); + if($count >= 3) { + //"type" is the last element of the array, and "section" is the second-to-last. + $type = array_pop($myParts); + + //define what types of files that are accepted: if it's not one of them, don't bother. + $acceptedTypes = array("tmpl"); + if(in_array($type, $acceptedTypes)) { + $section = array_pop($myParts); + + //just in case we want to allow templates with "."'s in them, rip off the + // last two parts, and use what's left as the name. + $stripThis = '.'. $section .'\.'. $type .'$'; + $name = preg_replace('/'. $stripThis .'/', '', $filename); + + $retval = array( + 'name' => $name, + 'section' => $section, + 'type' => $type + ); + } + } + + return($retval); + }//end parse_filename() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Finds all scripts in the /inlcudes directory, & adds them to the includesList array. + */ + private function load_includes() { + + //first load includes for the base directory. + $this->load_dir_includes($this->baseDir); + + //okay, now loop through $this->sectionArr & see if we can include anything else. + if(($this->fileSystemObj->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { + + foreach($this->sectionArr as $mySection) { + //Run includes. + $this->load_dir_includes($mySection); + + //attempt to cd() into the next directory, or die if we can't. + if(!$this->fileSystemObj->cd($mySection)) { + //no dice. Break the loop. + break; + } + } + } + + }//end load_includes() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Attempts to add a shared include & the given section's include file: used + * solely by load_includes(). + */ + private function load_dir_includes($section) { + $lsData = $this->fileSystemObj->ls(); + + //attempt to load the shared includes file. + if(isset($lsData['shared.inc']) && $lsData['shared.inc']['type'] == 'file') { + $this->includesList[] = $this->fileSystemObj->realcwd .'/shared.inc'; + } + + //attempt to load the section's includes file. + $myFile = $section .'.inc'; + if(isset($lsData[$myFile]) && $lsData[$myFile]['type'] == 'file') { + $this->includesList[] = $this->fileSystemObj->realcwd .'/'. $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'; + } + } + }//end load_dir_includes() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * 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')) { + //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); + $this->templateObj->add_template_var('datetime', date('m-d-Y H:i:s')); + $this->templateObj->print_page(); + 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); + } + }//end die_gracefully() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * The super-magical method that includes files & finalizes things using + * the given templating engine. + * NOTE: the local variable "$page" is made so that the included scripts + * can make calls to the templating engine, just like they used to. It's + * AWESOME. + */ + function finish() { + //Avoid problems when REGISTER_GLOBALS is on... + $badUrlVars = array('page', 'this'); + foreach($badUrlVars as $badVarName) { + unset($_GET[$badVarName], $_POST[$badVarName]); + } + + $page =& $this->templateObj; + if(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']; + 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; + array_unshift($sectionArr, $this->baseDir); + $finalURL = $this->gfObj->string_from_array($sectionArr, NULL, '/'); + + //now include the includes scripts, if there are any. + if(is_array($this->includesList) && count($this->includesList)) { + try { + foreach($this->includesList as $myInternalIndex=>$myInternalScriptName) { + $this->myLastInclude = $myInternalScriptName; + include_once($this->myLastInclude); + } + } + catch(exception $e) { + $myRoot = preg_replace('/\//', '\\\/', $this->fileSystemObj->root); + $displayableInclude = preg_replace('/^'. $myRoot .'/', '', $this->myLastInclude); + $this->templateObj->set_message_wrapper(array( + 'title' => "Fatal Error", + 'message' => __METHOD__ .": A fatal error occurred while processing <b>". + $displayableInclude ."</b>:<BR>\n<b>ERROR</b>: ". $e->getMessage(), + 'type' => "fatal" + )); + + //try to pass the error on to the user's exception handler, if there is one. + if(function_exists('exception_handler')) { + exception_handler($e); + } + } + unset($myInternalIndex); + unset($myInternalScriptName); + } + + if(is_bool($this->templateObj->allow_invalid_urls() === TRUE) && $this->isValid === FALSE) { + $this->isValid = $this->templateObj->allow_invalid_urls(); + } + + if($this->isValid === TRUE) { + $page->print_page(); + } + else { + $this->die_gracefully($this->reason); + } + }//end finish() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Method for accessing the protected $this->sectionArr array. + */ + public function get_sectionArr() { + //give 'em what they want. + return($this->sectionArr); + }//end get_sectionArr() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Method for accessing the protected member $this->finalSection. + */ + public function get_finalSection() { + //give 'em what they want. + return($this->finalSection); + }//end get_finalSection() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Method for accessing "baseDir", only referenced as the base section. + */ + public function get_baseSection() { + return($this->baseDir); + }//end get_baseSection() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * The destructor... does nothing, right now. + */ + public function __destruct() { + }//end __destruct() + //------------------------------------------------------------------------ + + +}//end contentSystem{} +?> Deleted: releases/1.0/contentSystemClass.php =================================================================== --- releases/1.0/contentSystemClass.php 2009-01-29 21:57:59 UTC (rev 339) +++ releases/1.0/contentSystemClass.php 2009-01-30 14:32:17 UTC (rev 340) @@ -1,859 +0,0 @@ -<?php -/* - * FILE INFORMATION: - * $HeadURL$ - * $Id$ - * $LastChangedDate$ - * $LastChangedRevision$ - * $LastChangedBy$ - * - * HOW THE SYSTEM WORKS::: - * TEMPLATE FILES: - * Automatically loads templates based on the URL, and optionally includes scripts in the includes directory. - * - * MAIN SECTION: - * For the main section, i.e. "/content", it requires a template in a directory of that name beneath - * /templates, with a file called "index.content.tmpl"... i.e. /templatee/content/index.content.tmpl. - * SUB SECTIONS: - * For any subsection to be valid, i.e. "/content/members", it must have an associated template, i.e. - * "/templates/content/members.content.tmpl". If a subdirectory with an index.content.tmpl file exists, it will - * be used instead of the file in the sub directory (i.e. "/templates/content/members/index.content.tmpl"). - * SUB SECTION TEMPLATE INHERITANCE: - * All pages load the base set of "shared" templates, which are in the form "<section>.shared.tmpl" in - * the root of the templates directory. - * - * Shared files within each directory, in the form "<section>.shared.tmpl", will be loaded for ANY subsection. - * - * For any subsection, it inherits a previous section's templates in the following manner (any "content" - * templates are ignored for inheritance, as they're require for page load). - * /content ---> /templates/content/index.*.tmpl - * - * /content/members |--> /templates/content/index.*.tmpl - * `--> /templates/content/members.*.tmpl - * - * /content/members/test |--> /templates/content/index.*.tmpl - * |--> /templates/content/members.*.tmpl - * |--> /templates/content/members/index.*.tmpl - * `--> /templates/content/members/test.*.tmpl - * AUTOMATIC INCLUDES: - * Much in the same way templates are included, so are scripts, from the /includes directory, though the logic - * is decidedly simpler: all scripts must have the extension of ".inc", and must have either the section's name - * as the first part of the filename, or "shared". Shared scripts will be loaded for ALL subsections. - * - * INCLUDES INHERITANCE: - * The template inheritance scheme is as laid-out below. The content system will go as far into the - * includes directory as it can for the given section, regardless of if any intermediate files are missing. - * - * It is important to note that the content system will NOT regard a section as valid if there are include - * scripts but no templates. - * - * /content |--> /includes/shared.inc - * `--> /includes/content.inc - * - * /content/members |--> /includes/shared.inc - * |--> /includes/content.inc - * |--> /includes/content/shared.inc - * `--> /includes/content/members.inc - * - * /content/members/test |--> /includes/shared.inc - * |--> /includes/content.inc - * |--> /includes/content/shared.inc - * |--> /includes/content/members.inc - * |--> /includes/content/members/shared.inc - * |--> /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__) ."/cs_globalFunctions.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 { - - 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 $ignoredList = array( //array of files & folders that are implicitely ignored. - 'file' => array('.htaccess'), - 'dir' => array('.svn','CVS' - ) - ); - protected $templateList = array(); - protected $includesList = array(); - public $templateObj = NULL; - protected $gfObj = NULL; - protected $tabs = NULL; - - protected $finalSection; - - private $isValid=FALSE; - private $reason=NULL; - - //------------------------------------------------------------------------ - /** - * The CONSTRUCTOR. Duh. - */ - public function __construct($testOnly=FALSE) { - if($testOnly === 'unit_test') { - //It's just a test, don't do anything we might regret later. - $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(); - - //setup the section stuff... - $repArr = array($_SERVER['SCRIPT_NAME'], "/"); - $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); - - //figure out the section & subsection stuff. - $this->section = $this->clean_url($_SERVER['REQUEST_URI']); - - $this->initialize_locals(); - } - }//end __construct() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - /** - * Creates internal objects & prepares for later usage. - */ - private function initialize_locals() { - //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(). - $this->templateObj = new cs_genericPage(FALSE, "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')); - - $myUrl = '/'; - if(strlen($this->section) && $this->section !== 0) { - $myUrl = '/'. $this->section; - } - $this->templateObj->add_template_var('CURRENT_URL', $myUrl); - - //create a fileSystem object. - $this->fileSystemObj = new cs_fileSystemClass(); - - //create a tabs object, in case they want to load tabs on the page. - $this->tabs = new cs_tabs($this->templateObj); - - //check versions, make sure they're all the same. - $myVersion = $this->get_version(); - 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->gfObj->get_version() !== $myVersion) { - throw new exception(__METHOD__ .": ". get_class($this->gfObj) ." has mismatched version (". $this->gfObj->get_version() ." does not equal ". $myVersion .")"); - } - if($this->tabs->get_version() !== $myVersion) { - throw new exception(__METHOD__ .": ". get_class($this->tabs) ." has mismatched version (". $this->tabs->get_version() ." does not equal ". $myVersion .")"); - } - - //split apart the section so we can do stuff with it later. - $this->parse_section(); - - //get ready for when we have to load templates & such. - $this->prepare(); - }//end initialize_locals() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - private function get_template_dirs() { - if(is_array($this->sectionArr)) { - $this->fileSystemObj->cd("/templates/". $this->baseDir); - $retval = array(); - $retval[] = $this->fileSystemObj->cwd; - foreach($this->sectionArr as $index=>$name) { - if($this->fileSystemObj->cd($name)) { - $retval[] = $this->fileSystemObj->cwd; - } - else { - break; - } - } - } - else { - throw new exception(__METHOD__ .": section array is invalid"); - } - - return($retval); - }//end get_template_dirs() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - /** - * Call this to require that users accessing the given URL are authenticated; - * if they're not, this will cause them to be redirected to another URL - * (generally, so they can login). - */ - public function force_authentication($redirectToUrl, $destinationArg='loginDestination') { - if(is_object($this->session) && method_exists($this->session, 'is_authenticated')) { - if(strlen($redirectToUrl)) { - $cleanedRedirect = $this->clean_url($redirectToUrl); - if($this->section != $cleanedRedirect) { - if(!$this->session->is_authenticated()) { - //run the redirect. - if(strlen($destinationArg)) { - $redirectToUrl .= '?'. $destinationArg .'=/'. urlencode($_SERVER['REQUEST_URI']); - } - $this->gfObj->conditional_header($redirectToUrl, TRUE); - } - } - else { - throw new exception(__METHOD__ .": redirect url (". $redirectToUrl .") matches current URL"); - } - } - else { - throw new exception(__METHOD__ .": failed to provide proper redirection URL"); - } - } - else { - throw new exception(__METHOD__ .": cannot force authentication (missing method)"); - } - }//end force_authentication() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - /** - * Used to determine if contentSystem{} should handle creating the session. - */ - public function handle_session(&$sessionObj=NULL) { - if(is_object($sessionObj)) { - //they want us to use a different class... fine. - $this->session = $sessionObj; - } - else { - //use our own session handler. - $this->session = new cs_session; - } - - if(!method_exists($this->session, 'is_authenticated')) { - throw new exception(__METHOD__ .": session class ('". get_class($this->session) ."') is missing method is_authenticated()"); - } - }//end handle_session() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - /** - * Rips apart the "section" string, setting $this->section and $this->sectionArr. - */ - private function parse_section() { - if($this->section === 0 || is_null($this->section) || !strlen($this->section)) { - $this->section = "content/index"; - } - $myArr = split('/', $this->section); - - //if we've got something in the array, keep going. - if(is_array($myArr) && count($myArr) && ($myArr[0] !== 0)) { - $this->baseDir = array_shift($myArr); - $this->sectionArr = $myArr; - } - }//end parse_section() - //------------------------------------------------------------------------ - - - - //------------------------------------------------------------------------ - /** - * Removes all the crap from the url, so we can figure out what section we - * need to load templates & includes for. - */ - private function clean_url($section=NULL) { - if(!strlen($section) && strlen($this->section)) { - //if argument wasn't given, use internal pointer. - $section = $this->section; - } - - //make sure we've still got something valid to work with. - if(!strlen($section)) { - //TODO: remove the extra return statement (should only be one at the bottom of the method). - return(NULL); - } - else { - //check the string to make sure it doesn't begin or end with a "/" - if($section[0] == '/') { - $section = substr($section, 1, strlen($section)); - } - - //check the last char for a "/"... - if($section[strlen($section) -1] == '/') { - //last char is a '/'... kill it. - $section = substr($section, 0, strlen($section) -1); - } - - //if we've been sent a query, kill it off the string... - if(preg_match('/\?/', $section)) { - $section = split('\?', $section); - $section = $section[0]; - } - - if(ereg("\.", $section)) { - //disregard file extensions, but keep everything else... - // i.e. "index.php/yermom.html" becomes "index/yermom" - $tArr = split('/', $section); - foreach($tArr as $tSecName) { - $temp = split("\.", $tSecName); - if(strlen($temp[0]) > 1) { - $tSecName = $temp[0]; - } - $tSection = $this->gfObj->create_list($tSection, $tSecName, '/'); - } - $section = $tSection; - } - } - - return($section); - }//end clean_url() - //---------------------------... [truncated message content] |
From: <cra...@us...> - 2009-02-01 18:12:56
|
Revision: 343 http://cs-content.svn.sourceforge.net/cs-content/?rev=343&view=rev Author: crazedsanity Date: 2009-02-01 18:12:51 +0000 (Sun, 01 Feb 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA3 *** SUMMARY OF CHANGES: * fix problem with begin+end definition for block row on same line (#230) SVN COMMAND: merge --depth=infinity -r340:HEAD https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0 Modified Paths: -------------- releases/1.0/VERSION releases/1.0/cs_genericPage.class.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-02-01 17:54:01 UTC (rev 342) +++ releases/1.0/VERSION 2009-02-01 18:12:51 UTC (rev 343) @@ -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-ALPHA2 +VERSION: 1.0-ALPHA3 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-02-01 17:54:01 UTC (rev 342) +++ releases/1.0/cs_genericPage.class.php 2009-02-01 18:12:51 UTC (rev 343) @@ -530,14 +530,14 @@ if(strlen($templateContents) >= 31) { //looks good to me. Run the regex... $flags = PREG_PATTERN_ORDER; - $reg = "/<!-- BEGIN (.+) -->/"; + $reg = "/<!-- BEGIN (\S{1,}) -->/"; preg_match_all($reg, $templateContents, $beginArr, $flags); $beginArr = $beginArr[1]; - $endReg = "/<!-- END (.+) -->/"; + $endReg = "/<!-- END (\S{1,}) -->/"; preg_match_all($endReg, $templateContents, $endArr, $flags); $endArr = $endArr[1]; - + //create a part of the array that shows any orphaned "BEGIN" statements (no matching "END" // statement), and orphaned "END" statements (no matching "BEGIN" statements) // NOTE::: by doing this, should easily be able to tell if the block rows were defined @@ -577,6 +577,7 @@ $rowDefs = $this->get_block_row_defs($templateVar); $useTheseBlockRows = $rowDefs['ordered']; + $retval = array(); if(is_array($useTheseBlockRows)) { foreach($useTheseBlockRows as $blockRowName) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-03 19:28:41
|
Revision: 349 http://cs-content.svn.sourceforge.net/cs-content/?rev=349&view=rev Author: crazedsanity Date: 2009-02-03 19:28:36 +0000 (Tue, 03 Feb 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA4 *** SUMMARY OF CHANGES::: * rename cs_sessionClass.php to cs_session.class.php to match naming conventions. * minor change to contentSystem so version parsing always works. * minor require_once statement for session class so version stuff works. SVN COMMAND::: merge --depth=infinity -r343: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 Added Paths: ----------- releases/1.0/cs_session.class.php Removed Paths: ------------- releases/1.0/cs_sessionClass.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-02-03 19:25:44 UTC (rev 348) +++ releases/1.0/VERSION 2009-02-03 19:28:36 UTC (rev 349) @@ -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-ALPHA3 +VERSION: 1.0-ALPHA4 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-02-03 19:25:44 UTC (rev 348) +++ releases/1.0/contentSystem.class.php 2009-02-03 19:28:36 UTC (rev 349) @@ -72,7 +72,7 @@ require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); require_once(dirname(__FILE__) ."/cs_fileSystem.class.php"); -require_once(dirname(__FILE__) ."/cs_sessionClass.php"); +require_once(dirname(__FILE__) ."/cs_session.class.php"); require_once(dirname(__FILE__) ."/cs_genericPage.class.php"); require_once(dirname(__FILE__) ."/cs_tabs.class.php"); @@ -103,12 +103,12 @@ * The CONSTRUCTOR. Duh. */ public function __construct($testOnly=FALSE) { + parent::__construct(); if($testOnly === 'unit_test') { //It's just a test, don't do anything we might regret later. $this->isTest = TRUE; } else { - parent::__construct(); //setup the section stuff... $repArr = array($_SERVER['SCRIPT_NAME'], "/"); Copied: releases/1.0/cs_session.class.php (from rev 348, trunk/1.0/cs_session.class.php) =================================================================== --- releases/1.0/cs_session.class.php (rev 0) +++ releases/1.0/cs_session.class.php 2009-02-03 19:28:36 UTC (rev 349) @@ -0,0 +1,145 @@ +<?php +/* + * FILE INFORMATION: + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); +require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); + +class cs_session extends cs_contentAbstract { + + protected $db; + public $uid; + public $sid; + public $sid_check = 1; + + //--------------------------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $createSession (mixed,optional) determines if a session will be started or not; if + * this parameter is non-null and non-numeric, the value will be + * used as the session name. + */ + function __construct($createSession=1) { + parent::__construct(false); + if($createSession) { + if(!is_null($createSession) && strlen($createSession) && !is_numeric($createSession)) { + session_name($createSession); + } + + //now actually create the session. + session_start(); + } + + //check if there's a uid in the session already. + //TODO: need a setting somewhere that says what the name of this var should be, + // instead of always forcing "uid". + $this->uid = 0; + if($_SESSION['uid']) { + $this->uid = $_SESSION['uid']; + } + + //grab what our session_id is... + $this->sid = session_id(); + + }//end __construct() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Required method, so passing the object to contentSystem::handle_session() + * will work properly. + * + * @param (none) + * + * @return FALSE FAIL: user is not authenticated (hard-coded this way). + */ + public function is_authenticated() { + return(FALSE); + }//end is_authenticated() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Retrieve data for an existing cookie. + * + * @param $name (string) Name of cookie to retrieve value for. + * + * @return NULL FAIL (?): cookie doesn't exist or has NULL value. + * @return (string) PASS: value of cookie. + */ + public function get_cookie($name) { + $retval = NULL; + if(isset($_COOKIE) && $_COOKIE[$name]) { + $retval = $_COOKIE[$name]; + } + return($retval); + }//end get_cookie() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Create a new cookie. + * + * @param $name (string) Name of cookie + * @param $value (string) value of cookie + * @param $expiration (string/number) unix timestamp or value for strtotime(). + */ + public function create_cookie($name, $value, $expiration=NULL) { + + $expTime = NULL; + if(!is_null($expiration)) { + if(is_numeric($expiration)) { + $expTime = $expiration; + } + elseif(preg_match('/ /', $expiration)) { + $expTime = strtotime($expiration); + } + else { + throw new exception(__METHOD__ .": invalid timestamp given (". $expiration .")"); + } + } + + $retval = setcookie($name, $value, $expTime, '/'); + return($retval); + + }//end create_cookie() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Destroy (expire) an existing cookie. + * + * @param $name (string) Name of cookie to destroy + * + * @return FALSE FAIL: no cookie by that name. + * @return TRUE PASS: cookie destroyed. + */ + public function drop_cookie($name) { + $retval = FALSE; + if(isset($_COOKIE[$name])) { + setcookie($name, $_COOKIE[$name], time() -10000, '/'); + unset($_COOKIE[$name]); + $retval = TRUE; + } + return($retval); + }//end drop_cookie() + //--------------------------------------------------------------------------------------------- + + +}//end cs_session{} +?> \ No newline at end of file Deleted: releases/1.0/cs_sessionClass.php =================================================================== --- releases/1.0/cs_sessionClass.php 2009-02-03 19:25:44 UTC (rev 348) +++ releases/1.0/cs_sessionClass.php 2009-02-03 19:28:36 UTC (rev 349) @@ -1,144 +0,0 @@ -<?php -/* - * FILE INFORMATION: - * $HeadURL$ - * $Id$ - * $LastChangedDate$ - * $LastChangedBy$ - * $LastChangedRevision$ - */ - -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); - -class cs_session extends cs_contentAbstract { - - protected $db; - public $uid; - public $sid; - public $sid_check = 1; - - //--------------------------------------------------------------------------------------------- - /** - * The constructor. - * - * @param $createSession (mixed,optional) determines if a session will be started or not; if - * this parameter is non-null and non-numeric, the value will be - * used as the session name. - */ - function __construct($createSession=1) { - parent::__construct(false); - if($createSession) { - if(!is_null($createSession) && strlen($createSession) && !is_numeric($createSession)) { - session_name($createSession); - } - - //now actually create the session. - session_start(); - } - - //check if there's a uid in the session already. - //TODO: need a setting somewhere that says what the name of this var should be, - // instead of always forcing "uid". - $this->uid = 0; - if($_SESSION['uid']) { - $this->uid = $_SESSION['uid']; - } - - //grab what our session_id is... - $this->sid = session_id(); - - }//end __construct() - //--------------------------------------------------------------------------------------------- - - - - //--------------------------------------------------------------------------------------------- - /** - * Required method, so passing the object to contentSystem::handle_session() - * will work properly. - * - * @param (none) - * - * @return FALSE FAIL: user is not authenticated (hard-coded this way). - */ - public function is_authenticated() { - return(FALSE); - }//end is_authenticated() - //--------------------------------------------------------------------------------------------- - - - - //--------------------------------------------------------------------------------------------- - /** - * Retrieve data for an existing cookie. - * - * @param $name (string) Name of cookie to retrieve value for. - * - * @return NULL FAIL (?): cookie doesn't exist or has NULL value. - * @return (string) PASS: value of cookie. - */ - public function get_cookie($name) { - $retval = NULL; - if(isset($_COOKIE) && $_COOKIE[$name]) { - $retval = $_COOKIE[$name]; - } - return($retval); - }//end get_cookie() - //--------------------------------------------------------------------------------------------- - - - - //--------------------------------------------------------------------------------------------- - /** - * Create a new cookie. - * - * @param $name (string) Name of cookie - * @param $value (string) value of cookie - * @param $expiration (string/number) unix timestamp or value for strtotime(). - */ - public function create_cookie($name, $value, $expiration=NULL) { - - $expTime = NULL; - if(!is_null($expiration)) { - if(is_numeric($expiration)) { - $expTime = $expiration; - } - elseif(preg_match('/ /', $expiration)) { - $expTime = strtotime($expiration); - } - else { - throw new exception(__METHOD__ .": invalid timestamp given (". $expiration .")"); - } - } - - $retval = setcookie($name, $value, $expTime, '/'); - return($retval); - - }//end create_cookie() - //--------------------------------------------------------------------------------------------- - - - - //--------------------------------------------------------------------------------------------- - /** - * Destroy (expire) an existing cookie. - * - * @param $name (string) Name of cookie to destroy - * - * @return FALSE FAIL: no cookie by that name. - * @return TRUE PASS: cookie destroyed. - */ - public function drop_cookie($name) { - $retval = FALSE; - if(isset($_COOKIE[$name])) { - setcookie($name, $_COOKIE[$name], time() -10000, '/'); - unset($_COOKIE[$name]); - $retval = TRUE; - } - return($retval); - }//end drop_cookie() - //--------------------------------------------------------------------------------------------- - - -}//end cs_session{} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-04 16:42:56
|
Revision: 352 http://cs-content.svn.sourceforge.net/cs-content/?rev=352&view=rev Author: crazedsanity Date: 2009-02-04 16:42:52 +0000 (Wed, 04 Feb 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA5 *** SUMMARY OF CHANGES::: * better handling of block rows and template vars. * a few more methods for testing & stripping undefined template vars. * fixed problem with mainTemplate getting an invalid prefix when an absolute path is defined (#236) SVN COMMAND::: merge --depth=infinity -r349:HEAD https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0 Modified Paths: -------------- releases/1.0/VERSION releases/1.0/cs_genericPage.class.php releases/1.0/tests/testOfCSContent.php Added Paths: ----------- releases/1.0/tests/files/gptest_all-together.txt releases/1.0/tests/files/templates/ releases/1.0/tests/files/templates/content.shared.tmpl releases/1.0/tests/files/templates/footer.shared.tmpl releases/1.0/tests/files/templates/infobar.shared.tmpl releases/1.0/tests/files/templates/main.shared.tmpl releases/1.0/tests/files/templates/menubar.shared.tmpl releases/1.0/tests/files/templates/title.shared.tmpl Removed Paths: ------------- releases/1.0/tests/files/templates/content.shared.tmpl releases/1.0/tests/files/templates/footer.shared.tmpl releases/1.0/tests/files/templates/infobar.shared.tmpl releases/1.0/tests/files/templates/main.shared.tmpl releases/1.0/tests/files/templates/menubar.shared.tmpl releases/1.0/tests/files/templates/title.shared.tmpl Property Changed: ---------------- releases/1.0/tests/files/sampleConfig.xml Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/VERSION 2009-02-04 16:42:52 UTC (rev 352) @@ -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-ALPHA4 +VERSION: 1.0-ALPHA5 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/cs_genericPage.class.php 2009-02-04 16:42:52 UTC (rev 352) @@ -11,9 +11,10 @@ require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); 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 + public $templateObj; //template object to parse the pages + public $templateVars = array(); //our copy of the global templateVars + public $mainTemplate; //the default layout of the site + public $unhandledVars=array(); private $tmplDir; private $libDir; @@ -60,9 +61,15 @@ */ protected function initialize_locals($mainTemplateFile) { - //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'; + + if(strlen(dirname($mainTemplateFile)) && dirname($mainTemplateFile) !== '/') { + $this->tmplDir = dirname($mainTemplateFile); + } + else { + //NOTE: this **requires** that the global variable "SITE_ROOT" is already set. + $this->siteRoot = preg_replace('/\/public_html/', '', $_SERVER['DOCUMENT_ROOT']); + } + $this->siteRoot = preg_replace('/\/templates$/', '', $this->tmplDir); $this->libDir = $this->siteRoot .'/lib'; //if there have been some global template vars (or files) set, read 'em in here. @@ -81,7 +88,7 @@ //build a new instance of the template library (from PHPLib) $this->templateObj=new Template($this->tmplDir,"keep"); //initialize a new template parser - if(preg_match('/^\//', $mainTemplateFile)) { + if(!preg_match('/^\//', $mainTemplateFile)) { $mainTemplateFile = $this->tmplDir ."/". $mainTemplateFile; } $this->mainTemplate=$mainTemplateFile; //load the default layout @@ -199,7 +206,7 @@ $name = $handle; $str = $this->templateVars[$parent]; - $reg = "/<!-- BEGIN $handle -->.+<!-- END $handle -->/sU"; + $reg = "/<!-- BEGIN $handle -->(.+){0,}<!-- END $handle -->/sU"; preg_match_all($reg, $str, $m); if(!is_string($m[0][0])) { #exit("set_block_row(): couldn't find '$handle' in var '$parent'"); @@ -273,6 +280,7 @@ if(!$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->parse("out", "out"); @@ -524,10 +532,10 @@ //cast $retArr as an array, so it's clean. $retArr = array(); - //NOTE: the value 31 isn't just a randomly chosen length; it's the minimum - // number of characters to have a block row. EG: "<!-- BEGIN x -->o<!-- END x -->" + //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) >= 31) { + if(strlen($templateContents) >= 30) { //looks good to me. Run the regex... $flags = PREG_PATTERN_ORDER; $reg = "/<!-- BEGIN (\S{1,}) -->/"; @@ -615,6 +623,48 @@ return($this->allowInvalidUrls); }//end allow_invalid_urls() //--------------------------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function return_printed_page($stripUndefVars=1) { + ob_start(); + $this->print_page($stripUndefVars); + $retval = ob_get_contents(); + ob_end_clean(); + return($retval); + }//end return_printed_page() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function strip_undef_template_vars($section='content') { + $numLoops = 0; + if(isset($this->templateVars[$section])) { + $templateContents = $this->templateVars[$section]; + while(preg_match_all('/\{.\S+?\}/', $templateContents, $tags) && $numLoops < 50) { + $tags = $tags[0]; + + //TODO: figure out why this works when running it twice. + foreach($tags as $key=>$str) { + $str2 = str_replace("{", "", $str); + $str2 = str_replace("}", "", $str2); + if(!$this->templateVars[$str2]) { + //TODO: set an internal pointer or something to use here, so they can see what was missed. + $templateContents = str_replace($str, '', $templateContents); + } + } + $this->templateObj->parse("out", "out"); + $numLoops++; + } + } + else { + throw new exception(__METHOD__ .": section (". $section .") does not exist"); + } + return($templateContents); + //------------------------------------------------------------------------- + } }//end cs_genericPage{} ?> Copied: releases/1.0/tests/files/gptest_all-together.txt (from rev 351, trunk/1.0/tests/files/gptest_all-together.txt) =================================================================== --- releases/1.0/tests/files/gptest_all-together.txt (rev 0) +++ releases/1.0/tests/files/gptest_all-together.txt 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1,19 @@ +<html> + <head> + <title>This is the title.</title> + </head> +<body> + <table>This is the infobar.</table> + --- the menubar (DATE: 2009-01-01) +---+++ CONTENT STARTS HERE +++--- + <!-- BEGIN blockRow1 -->This is a TEST<!-- comment --><!-- END blockRow1 --> + <!-- BEGIN blockRow2 -->This + is second blockRow<!-- END blockRow2 --> +<!-- BEGIN blockRow3 --> Some data In here... + <!-- END blockRow3 --> + + <!-- BEGIN blockRow4 --><!-- END blockRow4 --> +---+++ CONTENT ENDS HERE +++--- + --- the footer. +</body> +</html> \ No newline at end of file Property changes on: releases/1.0/tests/files/sampleConfig.xml ___________________________________________________________________ Added: svn:eol-style + native Deleted: releases/1.0/tests/files/templates/content.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/content.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/content.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1,8 +0,0 @@ - - <!-- BEGIN blockRow1 -->This is a TEST<!-- comment --><!-- END blockRow1 --> - <!-- BEGIN blockRow2 -->This - is second blockRow<!-- END blockRow2 --> -<!-- BEGIN blockRow{blockRowTestVal} --> Some data In here... - <!-- END blockRow3 --> - - <!-- BEGIN blockRow4 --><!-- END blockRow4 -->{invisibleTemplateVar} Copied: releases/1.0/tests/files/templates/content.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/content.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/content.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/content.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1,8 @@ + + <!-- BEGIN blockRow1 -->This is a TEST<!-- comment --><!-- END blockRow1 --> + <!-- BEGIN blockRow2 -->This + is second blockRow<!-- END blockRow2 --> +<!-- BEGIN blockRow{blockRowTestVal} --> Some data In here... + <!-- END blockRow3 --> + + <!-- BEGIN blockRow4 --><!-- END blockRow4 -->{invisibleTemplateVar} Deleted: releases/1.0/tests/files/templates/footer.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/footer.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/footer.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1 +0,0 @@ ---- the footer. \ No newline at end of file Copied: releases/1.0/tests/files/templates/footer.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/footer.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/footer.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/footer.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1 @@ +--- the footer. \ No newline at end of file Deleted: releases/1.0/tests/files/templates/infobar.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/infobar.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/infobar.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1 +0,0 @@ -<table>This is the infobar.</table> \ No newline at end of file Copied: releases/1.0/tests/files/templates/infobar.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/infobar.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/infobar.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/infobar.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1 @@ +<table>This is the infobar.</table> \ No newline at end of file Deleted: releases/1.0/tests/files/templates/main.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/main.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/main.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1,11 +0,0 @@ -<html> - <head> - <title>{title}</title> - </head> -<body> - {infobar} - {menubar} ----+++ CONTENT STARTS HERE +++---{content}---+++ CONTENT ENDS HERE +++--- - {footer} -</body> -</html> \ No newline at end of file Copied: releases/1.0/tests/files/templates/main.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/main.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/main.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/main.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1,11 @@ +<html> + <head> + <title>{title}</title> + </head> +<body> + {infobar} + {menubar} +---+++ CONTENT STARTS HERE +++---{content}---+++ CONTENT ENDS HERE +++--- + {footer} +</body> +</html> \ No newline at end of file Deleted: releases/1.0/tests/files/templates/menubar.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/menubar.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/menubar.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1 +0,0 @@ ---- the menubar (DATE: {date}) \ No newline at end of file Copied: releases/1.0/tests/files/templates/menubar.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/menubar.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/menubar.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/menubar.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1 @@ +--- the menubar (DATE: {date}) \ No newline at end of file Deleted: releases/1.0/tests/files/templates/title.shared.tmpl =================================================================== --- trunk/1.0/tests/files/templates/title.shared.tmpl 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/files/templates/title.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -1 +0,0 @@ -This is the title. \ No newline at end of file Copied: releases/1.0/tests/files/templates/title.shared.tmpl (from rev 351, trunk/1.0/tests/files/templates/title.shared.tmpl) =================================================================== --- releases/1.0/tests/files/templates/title.shared.tmpl (rev 0) +++ releases/1.0/tests/files/templates/title.shared.tmpl 2009-02-04 16:42:52 UTC (rev 352) @@ -0,0 +1 @@ +This is the title. \ No newline at end of file Modified: releases/1.0/tests/testOfCSContent.php =================================================================== --- releases/1.0/tests/testOfCSContent.php 2009-02-04 16:41:11 UTC (rev 351) +++ releases/1.0/tests/testOfCSContent.php 2009-02-04 16:42:52 UTC (rev 352) @@ -22,8 +22,8 @@ require_once(dirname(__FILE__) .'/../cs_globalFunctions.class.php'); require_once(dirname(__FILE__) .'/../cs_siteConfig.class.php'); - $this->gf = new cs_globalFunctions; - $this->gf->debugPrintOpt=1; + $this->gfObj = new cs_globalFunctions; + $this->gfObj->debugPrintOpt=1; }//end __construct() //------------------------------------------------------------------------- @@ -245,6 +245,63 @@ + //------------------------------------------------------------------------- + function test_genericPage() { + $filesDir = dirname(__FILE__) .'/files'; + + $page = new cs_genericPage(false, $filesDir .'/templates/main.shared.tmpl', false); + $fs = new cs_fileSystem($filesDir .'/templates'); + + $lsData = $fs->ls(); + + foreach($lsData as $index=>$value) { + $filenameBits = explode('.', $index); + $page->add_template_var($filenameBits[0], $page->file_to_string($index)); + } + + $page->add_template_var('blockRowTestVal', 3); + $page->add_template_var('date', '2009-01-01'); + + $checkThis = $page->return_printed_page(); + + + $this->assertEqual($checkThis, file_get_contents($filesDir .'/gptest_all-together.txt')); + + //now let's rip all the template rows out & add them back in. + $rowDefs = $page->get_block_row_defs('content'); + $rippedRows = $page->rip_all_block_rows('content'); + + $this->assertEqual($rowDefs['ordered'], array_keys($rippedRows)); + $remainingRows = $page->rip_all_block_rows('content'); + $this->assertEqual(array(), $remainingRows, "ERROR: some block rows exist after ripping: ". + $this->gfObj->string_from_array(array_keys($remainingRows), 'null', ',')); + + + foreach($rippedRows as $name=>$data) { + $page->add_template_var($name, $data); + } + $checkThis2 = $page->return_printed_page(); + + $this->assertEqual($checkThis, $checkThis2); + + $checkThis = $page->return_printed_page(0); + $this->assertTrue(preg_match('/\{.\S+?\}/', $checkThis)); + + //clone the page object so we can change stuff & not affect the original. + $page2 = clone $page; + unset($page2->templateVars); + $this->assertNotEqual($page->templateVars, $page2->templateVars); + $page2 = clone $page; + + $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars('content')); + $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars('content')); + $page2->templateVars['content'] = $page2->strip_undef_template_vars('content'); + $this->assertEqual($page->return_printed_page(1), $page2->return_printed_page(1)); + }//end test_genericPage + //------------------------------------------------------------------------- + + + }//end TestOfCSContent //============================================================================= ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-04 17:04:42
|
Revision: 355 http://cs-content.svn.sourceforge.net/cs-content/?rev=355&view=rev Author: crazedsanity Date: 2009-02-04 17:04:36 +0000 (Wed, 04 Feb 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA6 *** SUMMARY OF CHANGES::: * fix minor logic problem in previous release. SVN COMMAND::: merge --depth=infinity -r352:HEAD https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0 Modified Paths: -------------- releases/1.0/VERSION releases/1.0/cs_genericPage.class.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-02-04 17:02:47 UTC (rev 354) +++ releases/1.0/VERSION 2009-02-04 17:04:36 UTC (rev 355) @@ -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-ALPHA5 +VERSION: 1.0-ALPHA6 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-02-04 17:02:47 UTC (rev 354) +++ releases/1.0/cs_genericPage.class.php 2009-02-04 17:04:36 UTC (rev 355) @@ -62,14 +62,15 @@ protected function initialize_locals($mainTemplateFile) { - if(strlen(dirname($mainTemplateFile)) && dirname($mainTemplateFile) !== '/') { + if(strlen(dirname($mainTemplateFile)) && dirname($mainTemplateFile) !== '/' && !preg_match('/^\./', dirname($mainTemplateFile))) { $this->tmplDir = dirname($mainTemplateFile); + $this->siteRoot = preg_replace('/\/templates$/', '', $this->tmplDir); } 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'; } - $this->siteRoot = preg_replace('/\/templates$/', '', $this->tmplDir); $this->libDir = $this->siteRoot .'/lib'; //if there have been some global template vars (or files) set, read 'em in here. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-09 20:33:28
|
Revision: 364 http://cs-content.svn.sourceforge.net/cs-content/?rev=364&view=rev Author: crazedsanity Date: 2009-02-09 20:33:21 +0000 (Mon, 09 Feb 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA8 *** NOTE:: this includes changes from ALPHA7, which was never committed to releases. CHANGE LOG::: * cs_siteConfig attempts to fix problems with invalid vars * functionality for stripping undefined template vars from text * fix problem with not including all includes (#246) SVN COMMAND::: merge --depth=infinity -r355: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_genericPage.class.php releases/1.0/cs_siteConfig.class.php releases/1.0/tests/testOfCSContent.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-02-09 20:16:19 UTC (rev 363) +++ releases/1.0/VERSION 2009-02-09 20:33:21 UTC (rev 364) @@ -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-ALPHA6 +VERSION: 1.0-ALPHA8 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-02-09 20:16:19 UTC (rev 363) +++ releases/1.0/contentSystem.class.php 2009-02-09 20:33:21 UTC (rev 364) @@ -262,6 +262,8 @@ * Rips apart the "section" string, setting $this->section and $this->sectionArr. */ 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"; } @@ -650,20 +652,43 @@ $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) { - foreach($this->sectionArr as $mySection) { + + //if the last item in the array is "index", disregard it... + $loopThis = $this->sectionArr; + $lastSection = $this->sectionArr[(count($this->sectionArr) -1)]; + if($lastSection == 'index') { + array_pop($loopThis); + } + + + foreach($loopThis as $mySection) { //Run includes. $this->load_dir_includes($mySection); //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; + } } } + //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(isset($lsData['index.inc']) && is_array($lsData['index.inc']) && $addIndex==true) { + $this->add_include('index.inc'); + } }//end load_includes() //------------------------------------------------------------------------ @@ -679,13 +704,13 @@ //attempt to load the shared includes file. if(isset($lsData['shared.inc']) && $lsData['shared.inc']['type'] == 'file') { - $this->includesList[] = $this->fileSystemObj->realcwd .'/shared.inc'; + $this->add_include('shared.inc'); } //attempt to load the section's includes file. $myFile = $section .'.inc'; if(isset($lsData[$myFile]) && $lsData[$myFile]['type'] == 'file') { - $this->includesList[] = $this->fileSystemObj->realcwd .'/'. $myFile; + $this->add_include($myFile); } if(isset($lsData[$section]) && !count($this->sectionArr)) { @@ -850,5 +875,19 @@ //------------------------------------------------------------------------ + + //------------------------------------------------------------------------ + /** + * 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; + } + }//end add_include() + //------------------------------------------------------------------------ + + }//end contentSystem{} ?> Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-02-09 20:16:19 UTC (rev 363) +++ releases/1.0/cs_genericPage.class.php 2009-02-09 20:33:21 UTC (rev 364) @@ -61,7 +61,13 @@ */ protected function initialize_locals($mainTemplateFile) { + //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)) { + $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); @@ -640,32 +646,40 @@ //------------------------------------------------------------------------- - public function strip_undef_template_vars($section='content') { + public function strip_undef_template_vars($templateContents) { $numLoops = 0; - if(isset($this->templateVars[$section])) { - $templateContents = $this->templateVars[$section]; - while(preg_match_all('/\{.\S+?\}/', $templateContents, $tags) && $numLoops < 50) { - $tags = $tags[0]; - - //TODO: figure out why this works when running it twice. - foreach($tags as $key=>$str) { - $str2 = str_replace("{", "", $str); - $str2 = str_replace("}", "", $str2); - if(!$this->templateVars[$str2]) { - //TODO: set an internal pointer or something to use here, so they can see what was missed. - $templateContents = str_replace($str, '', $templateContents); - } + while(preg_match_all('/\{.\S+?\}/', $templateContents, $tags) && $numLoops < 50) { + $tags = $tags[0]; + + //TODO: figure out why this works when running it twice. + foreach($tags as $key=>$str) { + $str2 = str_replace("{", "", $str); + $str2 = str_replace("}", "", $str2); + if(!$this->templateVars[$str2]) { + //TODO: set an internal pointer or something to use here, so they can see what was missed. + $templateContents = str_replace($str, '', $templateContents); } - $this->templateObj->parse("out", "out"); - $numLoops++; } + $numLoops++; } + return($templateContents); + }//end strip_undef_template_vars() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function strip_undef_template_vars_from_section($section='content') { + if(isset($this->templateVars[$section])) { + $this->templateVars[$section] = $this->strip_undef_template_vars($this->templateVars[$section]); + } else { throw new exception(__METHOD__ .": section (". $section .") does not exist"); } - return($templateContents); + + return($this->templateVars[$section]); + }//strip_undef_template_vars_from_section() //------------------------------------------------------------------------- - } }//end cs_genericPage{} ?> Modified: releases/1.0/cs_siteConfig.class.php =================================================================== --- releases/1.0/cs_siteConfig.class.php 2009-02-09 20:16:19 UTC (rev 363) +++ releases/1.0/cs_siteConfig.class.php 2009-02-09 20:33:21 UTC (rev 364) @@ -180,9 +180,18 @@ $itemValue = $itemValue['value']; if(preg_match("/{/", $itemValue)) { $origVal = $itemValue; + + //remove double-slashes (//) + $itemValue = preg_replace('/[\/]{2,}/', '\/', $itemValue); + + //remove leading slash for string replaces (i.e. "{/MAIN/SITE_ROOT}" becomes "{MAIN/SITE_ROOT}") + $itemValue = preg_replace('/{\//', '{', $itemValue); + + //replace special vars. $itemValue = $this->gfObj->mini_parser($itemValue, $specialVars, '{', '}'); + + //replace internal vars. $itemValue = $this->gfObj->mini_parser($itemValue, $parseThis, '{', '}'); - $itemValue = preg_replace("/[\/]{2,}/", "/", $itemValue); } if($attribs['CLEANPATH']) { Modified: releases/1.0/tests/testOfCSContent.php =================================================================== --- releases/1.0/tests/testOfCSContent.php 2009-02-09 20:16:19 UTC (rev 363) +++ releases/1.0/tests/testOfCSContent.php 2009-02-09 20:33:21 UTC (rev 364) @@ -293,9 +293,9 @@ $this->assertNotEqual($page->templateVars, $page2->templateVars); $page2 = clone $page; - $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars('content')); - $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars('content')); - $page2->templateVars['content'] = $page2->strip_undef_template_vars('content'); + $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars($page2->templateVars['content'])); + $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars($page2->templateVars['content'])); + $page2->templateVars['content'] = $page2->strip_undef_template_vars($page2->templateVars['content']); $this->assertEqual($page->return_printed_page(1), $page2->return_printed_page(1)); }//end test_genericPage //------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-05-28 03:55:00
|
Revision: 382 http://cs-content.svn.sourceforge.net/cs-content/?rev=382&view=rev Author: crazedsanity Date: 2009-05-28 03:54:58 +0000 (Thu, 28 May 2009) Log Message: ----------- Revert changes from r380 (accidentally committed to trunk). Modified Paths: -------------- releases/1.0/contentSystem.class.php Property Changed: ---------------- 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_phpDB.class.php releases/1.0/cs_session.class.php releases/1.0/cs_siteConfig.class.php releases/1.0/cs_tabs.class.php releases/1.0/required/template.inc Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-05-27 16:06:18 UTC (rev 381) +++ releases/1.0/contentSystem.class.php 2009-05-28 03:54:58 UTC (rev 382) @@ -339,17 +339,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... if($this->fileSystemObj->cd('/includes')) { $this->load_includes(); @@ -459,10 +448,12 @@ 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."; @@ -662,9 +653,6 @@ //okay, now loop through $this->sectionArr & see if we can include anything else. $addIndex=false; - if($this->finalSection == 'index') { - $addIndex = true; - } if(($this->fileSystemObj->cd($this->baseDir)) && is_array($this->sectionArr) && count($this->sectionArr) > 0) { @@ -684,9 +672,6 @@ if(!$this->fileSystemObj->cd($mySection)) { //no dice. Break the loop. $addIndex = false; - if($this->finalSection == 'index') { - $addIndex = true; - } break; } else { Property changes on: releases/1.0/contentSystem.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_fileSystem.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_genericPage.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_globalFunctions.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_phpDB.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_session.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_siteConfig.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/cs_tabs.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: releases/1.0/required/template.inc ___________________________________________________________________ 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-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. |
From: <cra...@us...> - 2009-08-06 20:16:37
|
Revision: 424 http://cs-content.svn.sourceforge.net/cs-content/?rev=424&view=rev Author: crazedsanity Date: 2009-08-06 20:16:24 +0000 (Thu, 06 Aug 2009) Log Message: ----------- *** RELEASE 1.0-ALPHA10 *** SUMMARY OF CHANGES::: * compatibility changes between pgsql & mysql layers * support in mysql layer for resetting connect * better transaction support in MySQL (with notes on caveats) * ability to change selected database on an open database connection in MySQL * generic methods in cs_phpDB for doing queries, updates, and inserts. * unit tests for database layers & cs_globalFunctions. * ability to ping db connection * cs_siteConfig has special var for its location & support for prefixes. * cs_tabs can use different templates + more vars parsed. * lots of fixes to remove/suppress PHP warnings * database storage of session info by setting constants! * conversion script to push content of session files into database. SVN COMMAND::: merge --depth=infinity -r393: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_globalFunctions.class.php releases/1.0/cs_phpDB.class.php releases/1.0/cs_session.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/db_types/cs_phpDB__pgsql.class.php releases/1.0/tests/testOfCSContent.php Added Paths: ----------- releases/1.0/cs_sessionDB.class.php releases/1.0/sample_files/bin/ releases/1.0/sample_files/bin/convertSessionFilesToDB.php releases/1.0/schema/ releases/1.0/schema/db_session_schema.mysql.sql releases/1.0/schema/db_session_schema.pgsql.sql releases/1.0/tests/dbSchema/ releases/1.0/tests/dbSchema/cs_content_test.mysql.sql releases/1.0/tests/testOfCSGlobalFunctions.php releases/1.0/tests/testOfCSPHPDB.php Removed Paths: ------------- releases/1.0/sample_files/bin/convertSessionFilesToDB.php releases/1.0/schema/db_session_schema.mysql.sql releases/1.0/schema/db_session_schema.pgsql.sql releases/1.0/tests/dbSchema/cs_content_test.mysql.sql Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/VERSION 2009-08-06 20:16:24 UTC (rev 424) @@ -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-ALPHA9 +VERSION: 1.0-ALPHA10 PROJECT: cs-content $HeadURL$ \ No newline at end of file Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/contentSystem.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -134,6 +134,14 @@ * Creates internal objects & prepares for later usage. */ private function initialize_locals() { + + //create a session that gets stored in a database if they so desire... + if(defined('SESSION_DBSAVE')) { + require_once(dirname(__FILE__) .'/cs_sessionDB.class.php'); + $obj = new cs_sessionDB(); + $this->handle_session($obj); + } + //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(). Modified: releases/1.0/cs_fileSystem.class.php =================================================================== --- releases/1.0/cs_fileSystem.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_fileSystem.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -195,17 +195,18 @@ */ public function get_fileinfo($tFile) { + //TODO: shouldn't require putting the "@" in front of these calls! $retval = array( - "size" => filesize($tFile), + "size" => @filesize($tFile), "type" => @filetype($tFile), - "accessed" => fileatime($tFile), - "modified" => filemtime($tFile), - "owner" => $this->my_getuser_group(fileowner($tFile), 'uid'), - "uid" => fileowner($tFile), - "group" => $this->my_getuser_group(filegroup($tFile), 'gid'), - "gid" => filegroup($tFile), - "perms" => $this->translate_perms(fileperms($tFile)), - "perms_num" => substr(sprintf('%o', fileperms($tFile)), -4) + "accessed" => @fileatime($tFile), + "modified" => @filemtime($tFile), + "owner" => @$this->my_getuser_group(fileowner($tFile), 'uid'), + "uid" => @fileowner($tFile), + "group" => @$this->my_getuser_group(filegroup($tFile), 'gid'), + "gid" => @filegroup($tFile), + "perms" => @$this->translate_perms(fileperms($tFile)), + "perms_num" => @substr(sprintf('%o', fileperms($tFile)), -4) ); return($retval); Modified: releases/1.0/cs_globalFunctions.class.php =================================================================== --- releases/1.0/cs_globalFunctions.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_globalFunctions.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -54,6 +54,9 @@ $newSetting = 0; } } + elseif(!is_bool($newSetting) && is_bool($this->oldForceSqlQuotes)) { + $newSetting = $this->oldForceSqlQuotes; + } else { throw new exception(__METHOD__ .": invalid new setting (". $newSetting .")"); } @@ -159,7 +162,6 @@ } //make sure $style is valid. - $typesArr = array("insert", "update"); $style = strtolower($style); if(is_array($array)) { @@ -191,14 +193,14 @@ foreach($array as $key=>$value) { @$tmp[0] = $this->create_list($tmp[0], $key); //clean the string, if required. - if($cleanString) { + if(is_null($value)) { + $value = "NULL"; + } + elseif($cleanString) { //make sure it's not full of poo... $value = $this->cleanString($value, "sql"); #$value = "'". $value ."'"; } - if((is_null($value)) OR ($value == "")) { - $value = "NULL"; - } @$tmp[1] = $this->create_list($tmp[1], $value, ",", 1); } @@ -219,10 +221,17 @@ if(($value === "NULL" || $value === NULL) && !$this->forceSqlQuotes) { $sqlQuotes = 0; } - if($cleanString && !preg_match('/^\'/',$value)) { + if($cleanString && !(preg_match('/^\'/',$value) && preg_match('/\'$/', $value))) { //make sure it doesn't have crap in it... $value = $this->cleanString($value, "sql",$sqlQuotes); } + if($value == "'") { + //Fix possible SQL-injection. + $value = "'\''"; + } + elseif(!strlen($value)) { + $value = "''"; + } $retval = $this->create_list($retval, $field . $separator . $value); } break; @@ -274,12 +283,12 @@ } if($cleanString) { //make sure it doesn't have crap in it... - $value = $this->cleanString($value, "sql"); + $value = $this->cleanString($value, "sql", $this->forceSqlQuotes); } - if(!is_numeric($value) && isset($separator)) { + if(isset($separator)) { $value = "'". $value ."'"; } - $retval = $this->create_list($retval, $field . $separator . $value, " $delimiter ", $this->forceSqlQuotes); + $retval = $this->create_list($retval, $field . $separator . $value, " $delimiter "); } } break; @@ -801,8 +810,12 @@ //now figure out the value to return. if(is_numeric($interpretThis)) { + if(preg_match('/\.[0-9]{1,}/', $interpretThis)) { + //if it is a decimal number, remove the dot (i.e. "0.000001" -> "0000001" -> 1) + $interpretThis = str_replace('.', '', $interpretThis); + } settype($interpretThis, 'integer'); - if($interpretThis == '0') { + if($interpretThis == 0) { $index=0; } else { Modified: releases/1.0/cs_phpDB.class.php =================================================================== --- releases/1.0/cs_phpDB.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_phpDB.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -31,6 +31,7 @@ private $dbLayerObj; private $dbType; + public $connectParams = array(); //========================================================================= public function __construct($type='pgsql') { @@ -60,6 +61,10 @@ */ public function __call($methodName, $args) { if(method_exists($this->dbLayerObj, $methodName)) { + if($methodName == 'connect' && is_array($args[0])) { + //capture the connection parameters. + $this->connectParams = $args[0]; + } $retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args); } else { @@ -69,6 +74,124 @@ }//end __call() //========================================================================= + + + //========================================================================= + public function get_dbtype() { + return($this->dbType); + }//end get_dbtype() + //========================================================================= + + + + //========================================================================= + /** + * Performs queries which require results. Passing $indexField returns a + * complex array indexed from that field; passing $valueField will change + * it to a name=>value formatted array. + * + * NOTE:: when using an index field, be sure it is guaranteed to be unique, + * i.e. it is a primary key! If duplicates are found, the database class + * will throw an exception! + */ + public function run_query($sql, $indexField=null, $valueField=null) { + + $retval = array(); + + //length must be 19 as that's about the shortest valid SQL: "select * from table" + if(strlen($sql) >= 19) { + $this->exec($sql); + + $numRows = $this->numRows(); + $dbError = $this->errorMsg(); + if($numRows > 0 && !strlen($dbError)) { + if(strlen($indexField) && (is_null($valueField) || !strlen($valueField))) { + //return a complex array based on a given field. + $retval = $this->farray_fieldnames($indexField, null, 0); + } + elseif(strlen($indexField) && strlen($valueField)) { + //return an array as name=>value pairs. + $retval = $this->farray_nvp($indexField, $valueField); + } + else { + $retval = $this->farray_fieldnames(); + } + } + elseif($numRows == 0 && !strlen($dbError)) { + $retval = false; + } + else { + throw new exception(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); + } + } + else { + throw new exception(__METHOD__ .": invalid length SQL (". $sql .")"); + } + + return($retval); + }//end run_query() + //========================================================================= + + + + //========================================================================= + /** + * Handles performing the insert statement & returning the last inserted ID. + */ + public function run_insert($sql, $sequence='null') { + + $this->exec($sql); + + if($this->numAffected() == 1 && !strlen($this->errorMsg())) { + //retrieve the ID just created. + $retval = $this->lastID($sequence); + } + else { + //something broke... + throw new exception(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " + ."ERROR::: ". $this->errorMsg() ."\n -- SQL:::: ". $sql); + } + + return($retval); + }//end run_insert() + //========================================================================= + + + + //========================================================================= + /** + * Performs the update & returns how many rows were affected. + */ + public function run_update($sql, $zeroIsOk=false) { + $this->exec($sql); + + $dberror = $this->errorMsg(); + $numAffected = $this->numAffected(); + + if(strlen($dberror)) { + throw new exception(__METHOD__ .": error while running update::: ". $dberror ." -- SQL::: ". $sql); + } + elseif($numAffected==0 && $zeroIsOk == false) { + throw new exception(__METHOD__ .": no rows updated (". $numAffected ."), SQL::: ". $sql); + } + + return($numAffected); + }//end run_update() + //========================================================================= + + + + //========================================================================= + public function reconnect() { + if(is_array($this->connectParams) && count($this->connectParams)) { + $this->dbLayerObj->connect($this->connectParams, true); + } + else { + throw new exception(__METHOD__ .": no connection parameters stored"); + } + }//end reconnect() + //========================================================================= + } // end class phpDB ?> Modified: releases/1.0/cs_session.class.php =================================================================== --- releases/1.0/cs_session.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_session.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -13,12 +13,11 @@ class cs_session extends cs_contentAbstract { - protected $db; - public $uid; - public $sid; - public $sid_check = 1; + protected $uid; + protected $sid; + protected $sid_check = 1; - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** * The constructor. * @@ -26,10 +25,10 @@ * this parameter is non-null and non-numeric, the value will be * used as the session name. */ - function __construct($createSession=1) { - parent::__construct(false); + function __construct($createSession=true) { + parent::__construct(true); if($createSession) { - if(!is_null($createSession) && strlen($createSession) && !is_numeric($createSession)) { + if(is_string($createSession) && strlen($createSession) >2) { session_name($createSession); } @@ -49,11 +48,11 @@ $this->sid = session_id(); }//end __construct() - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** * Required method, so passing the object to contentSystem::handle_session() * will work properly. @@ -65,11 +64,11 @@ public function is_authenticated() { return(FALSE); }//end is_authenticated() - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** * Retrieve data for an existing cookie. * @@ -85,11 +84,11 @@ } return($retval); }//end get_cookie() - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** * Create a new cookie. * @@ -116,11 +115,11 @@ return($retval); }//end create_cookie() - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** * Destroy (expire) an existing cookie. * @@ -138,7 +137,20 @@ } return($retval); }//end drop_cookie() - //--------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * PHP5 magic method for retrieving the value of internal vars; this allows + * code to find the value of these variables, but not modify them (modifying + * requires the "__set($var,$val)" method). + */ + public function __get($var) { + return($this->$var); + }//end __get() + //------------------------------------------------------------------------- }//end cs_session{} Copied: releases/1.0/cs_sessionDB.class.php (from rev 423, trunk/1.0/cs_sessionDB.class.php) =================================================================== --- releases/1.0/cs_sessionDB.class.php (rev 0) +++ releases/1.0/cs_sessionDB.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -0,0 +1,294 @@ +<?php +/* + * FILE INFORMATION: + * $HeadURL$ + * $Id$ + * $LastChangedDate$ + * $LastChangedBy$ + * $LastChangedRevision$ + */ + +require_once(dirname(__FILE__) .'/cs_session.class.php'); +require_once(constant('LIBDIR') .'/cs-phpxml/cs_arrayToPath.class.php'); + +class cs_sessionDB extends cs_session { + + protected $db; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $createSession (mixed,optional) determines if a session will be started or not; if + * this parameter is non-null and non-numeric, the value will be + * used as the session name. + */ + function __construct() { + + + //map some constants to connection parameters. + //NOTE::: all constants should be prefixed... + $constantPrefix = 'SESSION_DB_'; + $params = array('host', 'port', 'dbname', 'user', 'password'); + foreach($params as $name) { + $value = null; + $constantName = $constantPrefix . strtoupper($name); + if(defined($constantName)) { + $value = constant($constantName); + } + $dbParams[$name] = $value; + } + $this->db = new cs_phpDB(constant('DBTYPE')); + $this->db->connect($dbParams); + + $this->tableName = 'cs_session_store_table'; + $this->tablePKey = 'session_store_id'; + $this->sequenceName = 'cs_session_store_table_session_store_id_seq'; + + if(!$this->sessdb_table_exists()) { + $this->load_table(); + } + + //now tell PHP to use this class's methods for saving the session. + session_set_save_handler( + array(&$this, 'sessdb_open'), + array(&$this, 'sessdb_close'), + array(&$this, 'sessdb_read'), + array(&$this, 'sessdb_write'), + array(&$this, 'sessdb_destroy'), + array(&$this, 'sessdb_gc') + ); + + parent::__construct(true); + + //Stop things from going into an audit log... see + //http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711/page3.html + // NOTE::: not sure if this is valid or not... + $this->audit_logging = false; + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Determines if the appropriate table exists in the database. + */ + public function sessdb_table_exists() { + try { + $test = $this->db->run_query("SELECT * FROM ". $this->tableName . + " ORDER BY ". $this->tablePKey ." LIMIT 1"); + $exists = true; + } + catch(exception $e) { + $exists = false; + } + + return($exists); + }//end sessdb_table_exists() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + private function load_table() { + $filename = dirname(__FILE__) .'/schema/db_session_schema.'. $this->db->get_dbtype() .'.sql'; + if(file_exists($filename)) { + try { + $this->db->run_update(file_get_contents($filename),true); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to load required table " . + "into your database automatically::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": while attempting to load required " . + "table into your database, discovered you have a missing schema " . + "file (". $filename .")"); + } + $this->logger->append_to_file(__METHOD__ .": done". microtime(true)); + }//end load_table() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function is_valid_sid($sid) { + $isValid = false; + if(strlen($sid) == 32) { + try { + $sql = "SELECT * FROM ". $this->tableName ." WHERE session_id='". + $sid ."'"; + $this->db->run_query($sql); + $numrows = $this->db->numRows(); + if($numrows == 1) { + $isValid = true; + } + elseif($numrows > 0 || $numrows < 0) { + throw new exception(__METHOD__ .": invalid numrows returned (". $numrows .")"); + } + } + catch(exception $e) { + //well... do nothing I guess. + } + } + + return($isValid); + }//end is_valid_sid() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Open the session (doesn't really do anything) + */ + public function sessdb_open($savePath, $sessionName) { + return(true); + }//end sessdb_open() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Close the session (call the "gc" method) + */ + public function sessdb_close() { + return($this->sessdb_gc(0)); + }//end sessdb_close() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Read information about the session. If there is no data, it MUST return + * an empty string instead of NULL. + */ + public function sessdb_read($sid) { + $retval = ''; + try { + $sql = "SELECT * FROM ". $this->tableName ." WHERE session_id='". + $sid ."'"; + $data = $this->db->run_query($sql); + + if($this->db->numRows() == 1) { + $retval = $data['session_data']; + } + } + catch(exception $e) { + //no throwing exceptions... + } + return($retval); + }//end sessdb_read() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function sessdb_write($sid, $data) { + $data = array( + 'session_data' => $data, + 'user_id' => null + ); + $cleanString = array( + 'session_data' => 'sql', + 'user_id' => 'numeric' + ); + + + + //pull the uid out of the session... + if(defined('SESSION_DBSAVE_UIDPATH')) { + $a2p = new cs_arrayToPath($_SESSION); + $uidVal = $a2p->get_data(constant('SESSION_DBSAVE_UIDPATH')); + + if(is_string($uidVal) || is_numeric($uidVal)) { + $data['user_id'] = $uidVal; + } + } + + $afterSql = ""; + if($this->is_valid_sid($sid)) { + $type = 'update'; + $sql = "UPDATE ". $this->tableName ." SET "; + $afterSql = "WHERE session_id='". $sid ."'"; + $data['last_updated'] = 'NOW()'; + $secondArg = false; + } + else { + $type = 'insert'; + $sql = "INSERT INTO ". $this->tableName ." "; + $data['session_id'] = $sid; + $secondArg = $this->sequenceName; + } + + $sql .= $this->gfObj->string_from_array($data, $type, null, $cleanString) .' '. $afterSql; + try { + $funcName = 'run_'. $type; + $res = $this->db->$funcName($sql, $secondArg); + } + catch(exception $e) { + //umm... yeah. + } + + return(true); + }//end sessdb_write() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function sessdb_destroy($sid) { + try { + $sql = "DELETE FROM ". $this->tableName ." WHERE session_id='". $sid ."'"; + $this->db->run_update($sql, true); + } + catch(exception $e) { + //do... nothing? + } + return(true); + }//end sessdb_destroy() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Define maximum lifetime (in seconds) to store sessions in the database. + * Anything that is older than that time will be purged (gc='garbage collector'). + */ + public function sessdb_gc($maxLifetime=null) { + + $nowTime = date('Y-m-d H:i:s'); + if(is_null($maxLifetime) || !is_numeric($maxLifetime) || $maxLifetime < 0) { + //pull it from PHP's ini settings. + $maxLifetime = ini_get("session.gc_maxlifetime"); + } + $interval = $maxLifetime .' seconds'; + + $dt1 = strtotime($nowTime .' - '. $interval); + $dt2 = date('Y-m-d H:i:s', $dt1); + + + + try { + //destroy old sessions, but don't complain if nothing is deleted. + $sql = "DELETE FROM ". $this->tableName ." WHERE last_updated < ". $dt2; + #$this->db->run_update($sql, true); + } + catch(exception $e) { + //probably should do something here. + } + + return(true); + + }//end sessdb_gc() + //------------------------------------------------------------------------- + + +}//end cs_session{} +?> \ No newline at end of file Modified: releases/1.0/cs_siteConfig.class.php =================================================================== --- releases/1.0/cs_siteConfig.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_siteConfig.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -42,6 +42,9 @@ /** Directory for the config file. */ private $configDirname; + /** Location of the configuration file itself. */ + private $configFile; + /** Active section of the full site configuration. */ private $activeSection; @@ -84,6 +87,7 @@ if(strlen($configFileLocation) && file_exists($configFileLocation)) { $this->configDirname = dirname($configFileLocation); + $this->configFile = $configFileLocation; $this->fs = new cs_fileSystem($this->configDirname); $this->xmlReader = new cs_phpxmlParser($this->fs->read($configFileLocation)); @@ -212,7 +216,7 @@ $itemValue = $this->gfObj->mini_parser($itemValue, $parseThis, '{', '}'); } - if($attribs['CLEANPATH']) { + if(isset($attribs['CLEANPATH'])) { $itemValue = $this->fs->resolve_path_with_dots($itemValue); } @@ -221,10 +225,20 @@ $data[$section][$itemName]['value'] = $itemValue; $setVarIndex = $this->setVarPrefix . $itemName; - if($attribs['SETGLOBAL']) { + if(isset($attribs['SETGLOBAL'])) { $GLOBALS[$setVarIndex] = $itemValue; } - if($attribs['SETCONSTANT']) { + if(isset($attribs['SETCONSTANT'])) { + if(isset($attribs['SETCONSTANTPREFIX'])) { + //did they give a specific prefix, or just a number/true? + if(strlen($attribs['SETCONSTANTPREFIX']) == 1) { + $setVarIndex = $section ."-". $setVarIndex; + } + else { + //use the prefix they gave. + $setVarIndex = $attribs['SETCONSTANTPREFIX'] ."-". $setVarIndex; + } + } define($setVarIndex, $itemValue); } } @@ -277,7 +291,7 @@ $retval = $data; } else { - throw new exception(__METHOD__ .": invalid section or no data (". $data['type'] .")"); + throw new exception(__METHOD__ .": invalid section (". $section .") or no data (". $data['type'] .")"); } } else { @@ -370,6 +384,8 @@ $specialVars = array( '_DIRNAMEOFFILE_' => $this->configDirname, + '_CONFIGFILE_' => $this->configFile, + '_THISFILE_' => $this->configFile, '_APPURL_' => $appUrl ); return($specialVars); Modified: releases/1.0/cs_tabs.class.php =================================================================== --- releases/1.0/cs_tabs.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/cs_tabs.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -149,8 +149,9 @@ } $parseThis = array( - 'title' => $tabName, - 'url' => $url + 'title' => $tabName, + 'url' => $url, + 'cleanTitle' => preg_replace('/[^a-zA-Z0-9]/', '_', $tabName) ); $finalString .= $this->csPageObj->mini_parser($useTabContent, $parseThis, '%%', '%%'); } Modified: releases/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- releases/1.0/db_types/cs_phpDB__mysql.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/db_types/cs_phpDB__mysql.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -129,7 +129,10 @@ $this->isConnected = FALSE; $retval = null; if($this->connectionID != -1) { - $retval = mysqlclose($this->connectionID); + $retval = mysql_close($this->connectionID); + $this->transStatus = null; + $this->inTrans=null; + $this->transactionTree=null; } else { throw new exception(__METHOD__ .": Failed to close connection: connection is invalid"); @@ -152,7 +155,7 @@ $this->set_db_info($dbParams); } - if($this->paramsAreSet === TRUE && $this->isConnected === FALSE) { + if($this->paramsAreSet === TRUE) { //start output buffer for displaying error. ob_start(); @@ -280,7 +283,15 @@ + //========================================================================= + public function ping() { + return(mysql_ping($this->connectionID)); + }//end ping() + //========================================================================= + + + //////////////////// // Cursor movement //////////////////// @@ -632,11 +643,10 @@ * Returns the number of rows in a result (from a SELECT query). */ function numRows() { - if ($this->result == null) { + if ($this->result == null || !is_resource($this->result)) { $retval = 0; } else { - //TODO: implement MySQL version.. $this->numrows = mysql_num_rows($this->result); $retval = $this->numrows; } @@ -667,7 +677,6 @@ $retval = 0; } else { - //TODO: implement MySQL version.. $retval = mysql_num_fields($this->result); } return($retval); @@ -689,9 +698,9 @@ * get last ID of last INSERT statement */ function lastID() { - $retval = mysql_insert_id(); + $retval = mysql_insert_id($this->connectionID); return($retval); - }//end lastOID() + }//end lastID() //========================================================================= @@ -769,6 +778,44 @@ + //========================================================================= + public function select_db($dbName) { + if(mysql_select_db($dbName, $this->connectionID)) { + $this->dbname = $dbName; + } + else { + throw new exception(__METHOD__ .": failed to select db (". $dbName .")"); + } + }//end select_db() + //========================================================================= + + + + //========================================================================= + public function beginTrans() { + $this->exec('BEGIN;SET autocommit=0;'); + return(true); + }//end beginTrans() + //========================================================================= + + + + //========================================================================= + public function commitTrans() { + $this->exec('COMMIT'); + return(true); + }//end commitTrans() + //========================================================================= + + + + //========================================================================= + public function rollbackTrans() { + $this->exec('ROLLBACK'); + return(true); + }//end rollbackTrans() + //========================================================================= + } // end class phpDB ?> Modified: releases/1.0/db_types/cs_phpDB__pgsql.class.php =================================================================== --- releases/1.0/db_types/cs_phpDB__pgsql.class.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/db_types/cs_phpDB__pgsql.class.php 2009-08-06 20:16:24 UTC (rev 424) @@ -305,7 +305,15 @@ + //========================================================================= + public function ping() { + return(pg_ping($this->connectionID)); + }//end ping() + //========================================================================= + + + //////////////////// // Cursor movement //////////////////// @@ -1115,6 +1123,22 @@ + //========================================================================= + public function lastID($sequence) { + + if(strlen($sequence)) { + $retval = $this->get_currval($sequence); + } + else { + throw new exception(__METHOD__ .": no sequence specified (required by ". $this->dbType .")"); + } + + return($retval); + }//end lastID() + //========================================================================= + + + } // end class phpDB ?> Deleted: releases/1.0/sample_files/bin/convertSessionFilesToDB.php =================================================================== --- trunk/1.0/sample_files/bin/convertSessionFilesToDB.php 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/sample_files/bin/convertSessionFilesToDB.php 2009-08-06 20:16:24 UTC (rev 424) @@ -1,156 +0,0 @@ -<?php -/* - * Created on Aug 6, 2009 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - -require_once(dirname(__FILE__) .'/../../cs_fileSystem.class.php'); -require_once(dirname(__FILE__) .'/../../cs_siteConfig.class.php'); -require_once(dirname(__FILE__) .'/../../cs_phpDB.class.php'); - -$site = new cs_siteConfig(dirname(__FILE__) .'/../../../../rw/siteConfig.xml', 'website'); -require_once(dirname(__FILE__) .'/../../cs_sessionDB.class.php'); -#error_reporting(E_ALL); -require_once(constant('LIBDIR') .'/cs_debug.php'); - -class convertFiles extends cs_sessionDB { - - //------------------------------------------------------------------------- - public function __construct() { - $this->fs = new cs_fileSystem(constant('RWDIR') .'/tmp'); - parent::__construct(); - $this->gfObj->debugPrintOpt = 1; - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function do_conversion() { - $files = $this->fs->ls(); - - $this->db->beginTrans(); - - $created = 0; - $skipped = 0; - $total = count($files); - $handled = 0; - - foreach($files as $filename=>$data) { - //get the file's contents... - $fData = $this->fs->read($filename); - - $sid = preg_replace('/^sess_/', '', $filename); - - print "Handling ". $filename ."... "; - - $data['accessed'] = strftime('%Y-%m-%d %H:%M:%S', $data['accessed']); - $data['modified'] = strftime('%Y-%m-%d %H:%M:%S', $data['modified']); - - $bits = explode('|', $fData); - $uid = null; - if(is_array($bits)) { - foreach($bits as $n=>$v) { - $check = unserialize($v); - if(is_array($check) && isset($check['userInfo'])) { - #$this->gfObj->debug_print($check); - $uid = $check['userInfo']['uid']; - #$this->gfObj->debug_print(__METHOD__ .": uid=(". $uid .")"); - break; - } - } - } - $insertData = array( - 'session_id' => $sid, - 'user_id' => $uid, - 'date_created' => $data['modified'], - 'last_updated' => $data['accessed'], - 'session_data' => $fData, - ); - if(!$this->check_sid_exists($sid)) { - $this->do_insert($insertData); - $created++; - } - else { - $skipped++; - } - $handled++; - - print " DONE (". $handled ." / ". $total .") SKIPPED=(". $skipped .") \r"; - - $this->db->commitTrans(); - } - }//end do_conversion() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - private function check_sid_exists($sid) { - $exists = false; - if(strlen($sid) == 32) { - $sql = "SELECT session_id FROM ". $this->tableName ." WHERE " . - "session_id='". $sid ."'"; - try { - $data = $this->db->run_query($sql); - $numrows = $this->db->numRows(); - if($numrows == 1) { - $exists = true; - } - elseif($numrows == 0) { - $exists = false; - } - else { - throw new exception(__METHOD__ .": invalid value of numrows (". $numrows .")"); - } - } - catch(exception $e) { - - } - } - else { - throw new exception(__METHOD__ .": invalid session id (". $sid .")"); - } - - return($exists); - }//end check_sid_exists() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - private function do_insert(array $data) { - $cleanString = array( - 'session_id' => 'sql', - 'user_id' => 'numeric', - 'date_created' => 'sql', - 'last_updated' => 'sql', - 'session_data' => 'sql' - ); - if(!is_numeric($data['user_id'])) { - unset($data['user_id']); - } - $sql = "INSERT INTO ". $this->tableName ." ". - $this->gfObj->string_from_array($data, 'insert', null, $cleanString); - - #$this->gfObj->debug_print($sql); - #$this->gfObj->debug_print($data); - $id = $this->db->run_insert($sql, $this->sequenceName); - - return($id); - }//end do_insert() - //------------------------------------------------------------------------- - -} - - -$obj = new convertFiles; -$obj->do_conversion(); - -?> Copied: releases/1.0/sample_files/bin/convertSessionFilesToDB.php (from rev 423, trunk/1.0/sample_files/bin/convertSessionFilesToDB.php) =================================================================== --- releases/1.0/sample_files/bin/convertSessionFilesToDB.php (rev 0) +++ releases/1.0/sample_files/bin/convertSessionFilesToDB.php 2009-08-06 20:16:24 UTC (rev 424) @@ -0,0 +1,156 @@ +<?php +/* + * Created on Aug 6, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +require_once(dirname(__FILE__) .'/../../cs_fileSystem.class.php'); +require_once(dirname(__FILE__) .'/../../cs_siteConfig.class.php'); +require_once(dirname(__FILE__) .'/../../cs_phpDB.class.php'); + +$site = new cs_siteConfig(dirname(__FILE__) .'/../../../../rw/siteConfig.xml', 'website'); +require_once(dirname(__FILE__) .'/../../cs_sessionDB.class.php'); +#error_reporting(E_ALL); +require_once(constant('LIBDIR') .'/cs_debug.php'); + +class convertFiles extends cs_sessionDB { + + //------------------------------------------------------------------------- + public function __construct() { + $this->fs = new cs_fileSystem(constant('RWDIR') .'/tmp'); + parent::__construct(); + $this->gfObj->debugPrintOpt = 1; + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function do_conversion() { + $files = $this->fs->ls(); + + $this->db->beginTrans(); + + $created = 0; + $skipped = 0; + $total = count($files); + $handled = 0; + + foreach($files as $filename=>$data) { + //get the file's contents... + $fData = $this->fs->read($filename); + + $sid = preg_replace('/^sess_/', '', $filename); + + print "Handling ". $filename ."... "; + + $data['accessed'] = strftime('%Y-%m-%d %H:%M:%S', $data['accessed']); + $data['modified'] = strftime('%Y-%m-%d %H:%M:%S', $data['modified']); + + $bits = explode('|', $fData); + $uid = null; + if(is_array($bits)) { + foreach($bits as $n=>$v) { + $check = unserialize($v); + if(is_array($check) && isset($check['userInfo'])) { + #$this->gfObj->debug_print($check); + $uid = $check['userInfo']['uid']; + #$this->gfObj->debug_print(__METHOD__ .": uid=(". $uid .")"); + break; + } + } + } + $insertData = array( + 'session_id' => $sid, + 'user_id' => $uid, + 'date_created' => $data['modified'], + 'last_updated' => $data['accessed'], + 'session_data' => $fData, + ); + if(!$this->check_sid_exists($sid)) { + $this->do_insert($insertData); + $created++; + } + else { + $skipped++; + } + $handled++; + + print " DONE (". $handled ." / ". $total .") SKIPPED=(". $skipped .") \r"; + + $this->db->commitTrans(); + } + }//end do_conversion() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + private function check_sid_exists($sid) { + $exists = false; + if(strlen($sid) == 32) { + $sql = "SELECT session_id FROM ". $this->tableName ." WHERE " . + "session_id='". $sid ."'"; + try { + $data = $this->db->run_query($sql); + $numrows = $this->db->numRows(); + if($numrows == 1) { + $exists = true; + } + elseif($numrows == 0) { + $exists = false; + } + else { + throw new exception(__METHOD__ .": invalid value of numrows (". $numrows .")"); + } + } + catch(exception $e) { + + } + } + else { + throw new exception(__METHOD__ .": invalid session id (". $sid .")"); + } + + return($exists); + }//end check_sid_exists() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + private function do_insert(array $data) { + $cleanString = array( + 'session_id' => 'sql', + 'user_id' => 'numeric', + 'date_created' => 'sql', + 'last_updated' => 'sql', + 'session_data' => 'sql' + ); + if(!is_numeric($data['user_id'])) { + unset($data['user_id']); + } + $sql = "INSERT INTO ". $this->tableName ." ". + $this->gfObj->string_from_array($data, 'insert', null, $cleanString); + + #$this->gfObj->debug_print($sql); + #$this->gfObj->debug_print($data); + $id = $this->db->run_insert($sql, $this->sequenceName); + + return($id); + }//end do_insert() + //------------------------------------------------------------------------- + +} + + +$obj = new convertFiles; +$obj->do_conversion(); + +?> Deleted: releases/1.0/schema/db_session_schema.mysql.sql =================================================================== --- trunk/1.0/schema/db_session_schema.mysql.sql 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/schema/db_session_schema.mysql.sql 2009-08-06 20:16:24 UTC (rev 424) @@ -1,17 +0,0 @@ - - --- --- Store session data in here. --- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 --- - -CREATE TABLE `test`.`sess_tmp` ( - `session_store_id` int NOT NULL AUTO_INCREMENT, - `session_id` varchar(32) NOT NULL, - `user_id` varchar(16) NOT NULL, - `date_created` datetime NOT NULL, - `last_updated` datetime NOT NULL, - `session_data` LONGTEXT NOT NULL, - PRIMARY KEY (`session_store_id`) -) -ENGINE = MyISAM; \ No newline at end of file Copied: releases/1.0/schema/db_session_schema.mysql.sql (from rev 423, trunk/1.0/schema/db_session_schema.mysql.sql) =================================================================== --- releases/1.0/schema/db_session_schema.mysql.sql (rev 0) +++ releases/1.0/schema/db_session_schema.mysql.sql 2009-08-06 20:16:24 UTC (rev 424) @@ -0,0 +1,17 @@ + + +-- +-- Store session data in here. +-- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 +-- + +CREATE TABLE `test`.`sess_tmp` ( + `session_store_id` int NOT NULL AUTO_INCREMENT, + `session_id` varchar(32) NOT NULL, + `user_id` varchar(16) NOT NULL, + `date_created` datetime NOT NULL, + `last_updated` datetime NOT NULL, + `session_data` LONGTEXT NOT NULL, + PRIMARY KEY (`session_store_id`) +) +ENGINE = MyISAM; \ No newline at end of file Deleted: releases/1.0/schema/db_session_schema.pgsql.sql =================================================================== --- trunk/1.0/schema/db_session_schema.pgsql.sql 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/schema/db_session_schema.pgsql.sql 2009-08-06 20:16:24 UTC (rev 424) @@ -1,16 +0,0 @@ - - --- --- Store session data in here. --- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 --- - -CREATE TABLE cs_session_store_table ( - session_store_id serial NOT NULL PRIMARY KEY, - session_id varchar(32) NOT NULL DEFAULT '' UNIQUE, - user_id varchar(16), - date_created timestamp NOT NULL DEFAULT NOW(), - last_updated timestamp NOT NULL DEFAULT NOW(), - session_data text -); - Copied: releases/1.0/schema/db_session_schema.pgsql.sql (from rev 423, trunk/1.0/schema/db_session_schema.pgsql.sql) =================================================================== --- releases/1.0/schema/db_session_schema.pgsql.sql (rev 0) +++ releases/1.0/schema/db_session_schema.pgsql.sql 2009-08-06 20:16:24 UTC (rev 424) @@ -0,0 +1,16 @@ + + +-- +-- Store session data in here. +-- Idea originally from: http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711 +-- + +CREATE TABLE cs_session_store_table ( + session_store_id serial NOT NULL PRIMARY KEY, + session_id varchar(32) NOT NULL DEFAULT '' UNIQUE, + user_id varchar(16), + date_created timestamp NOT NULL DEFAULT NOW(), + last_updated timestamp NOT NULL DEFAULT NOW(), + session_data text +); + Deleted: releases/1.0/tests/dbSchema/cs_content_test.mysql.sql =================================================================== --- trunk/1.0/tests/dbSchema/cs_content_test.mysql.sql 2009-08-06 20:10:49 UTC (rev 423) +++ releases/1.0/tests/dbSchema/cs_content_test.mysql.sql 2009-08-06 20:16:24 UTC (rev 424) @@ -1,2328 +0,0 @@ --- MySQL Administrator dump 1.4 --- --- ------------------------------------------------------ --- Server version 5.0.75-0ubuntu10.2 - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; - - --- --- Create schema mysql --- - -CREATE DATABASE IF NOT EXISTS mysql; -USE mysql; - --- --- Definition of table `mysql`.`columns_priv` --- - -DROP TABLE IF EXISTS `mysql`.`columns_priv`; -CREATE TABLE `mysql`.`columns_priv` ( - `Host` char(60) collate utf8_bin NOT NULL default '', - `Db` char(64) collate utf8_bin NOT NULL default '', - `User` char(16) collate utf8_bin NOT NULL default '', - `Table_name` char(64) collate utf8_bin NOT NULL default '', - `Column_name` char(64) collate utf8_bin NOT NULL default '', - `Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `Column_priv` set('Select','Insert','Update','References') character set utf8 NOT NULL default '', - PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'; - --- --- Dumping data for table `mysql`.`columns_priv` --- - -/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; -LOCK TABLES `columns_priv` WRITE; -UNLOCK TABLES; -/*!40000 ALTER TABLE `columns_priv` ENABLE KEYS */; - - --- --- Definition of table `mysql`.`db` --- - -DROP TABLE IF EXISTS `mysql`.`db`; -CREATE TABLE `mysql`.`db` ( - `Host` char(60) collate utf8_bin NOT NULL default '', - `Db` char(64) collate utf8_bin NOT NULL default '', - `User` char(16) collate utf8_bin NOT NULL default '', - `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Delete_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Create_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Drop_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Grant_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `References_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Index_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Alter_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Create_tmp_table_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Lock_tables_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Create_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Show_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Create_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Alter_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - `Execute_priv` enum('N','Y') character set utf8 NOT NULL default 'N', - PRIMARY KEY (`Host`,`Db`,`User`), - KEY `User` (`User`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'; - --- --- Dumping data for table `mysql`.`db` --- - -/*!40000 ALTER TABLE `db` DISABLE KEYS */; -LOCK TABLES `db` WRITE; -INSERT INTO `mysql`.`db` VALUES (0x25,0x74657374,'','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'), - (0x25,0x746573745C5F25,'','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'), - (0x25,0x7265736F7572636572657175657374,0x63686174746572,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x25,0x6D7973716C,0x63686174746572,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x25,0x696E666F726D6174696F6E5F736368656D61,0x63686174746572,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x25,0x63686174,0x63686174746572,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x31302E25,0x7265736F7572636572657175657374,0x726F6F74,'Y','Y','Y','Y','N','N','N','N','N','N','N','Y','N','N','N','N','N'), - (0x3132372E302E302E31,0x7265736F7572636572657175657374,0x726F6F74,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x6C6F63616C686F7374,0x7265736F7572636572657175657374,0x726F6F74,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'), - (0x736B6974746C6573,0x7265736F7572636572657175657374,0x726F6F74,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -INSERT INTO `mysql`.`db` VALUES (0x25,0x7265736F7572636572657175657374,0x7265736F7572636572657175657374,'Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','N','N','N','N','N'), - (0x3132372E25,0x7265736F7572636572657175657374,0x7265736F7572636572657175657374,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -UNLOCK TABLES; -/*!40000 ALTER TABLE `db` ENABLE KEYS */; - - --- --- Definition of table `mysql`.`func` --- - -DROP TABLE IF EXISTS `mysql`.`func`; -CREATE TABLE `mysql`.`func` ( - `name` char(64) collate utf8_bin NOT NULL default '', - `ret` tinyint(1) NOT NULL default '0', - `dl` char(128) collate utf8_bin NOT NULL default '', - `type` enum('function','aggregate') character set utf8 NOT NULL, - PRIMARY KEY (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'; - --- --- Dumping data for table `mysql`.`func` --- - -/*!40000 ALTER TABLE `func` DISABLE KEYS */; -LOCK TABLES `func` WRITE; -UNLOCK TABLES; -/*!40000 ALTER TABLE `func` ENABLE KEYS */; - - --- --- Definition of table `mysql`.`help_category` --- - -DROP TABLE IF EXISTS `mysql`.`help_category`; -CREATE TABLE `mysql`.`help_category` ( - `help_category_id` smallint(5) unsigned NOT NULL, - `name` char(64) NOT NULL, - `parent_category_id` smallint(5) unsigned default NULL, - `url` char(128) NOT NULL, - PRIMARY KEY (`help_category_id`), - UNIQUE KEY `name` (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='help categories'; - --- --- Dumping data for table `mysql`.`help_category` --- - -/*!40000 ALTER TABLE `help_category` DISABLE KEYS */; -LOCK TABLES `help_category` WRITE; -INSERT INTO `mysql`.`help_category` VALUES (1,'Geographic',0,''), - (2,'Polygon properties',31,''), - (3,'WKT',31,''), - (4,'Numeric Functions',35,''), - (5,'MBR',31,''), - (6,'Control flow functions',35,''), - (7,'Transactions',32,''), - (8,'Account Management',32,''), - (9,'Point properties',31,''), - (10,'Encryption Functions',35,''), - (11,'LineString properties',31,''), - (12,'Logical operators',35,''), - (13,'Miscellaneous Functions',35,''), - (14,'Information Functions',35,''), - (15,'Functions and Modifiers for Use with GROUP BY',32,''), - (16,'Comparison operators',35,''), - (17,'Bit Functions',35,''), - (18,'Table Maintenance',32,''), - (19,'Data Types',32,''), - (20,'User-Defined Functions',32,''), - (21,'Compound Statements',32,''), - (22,'Geometry constructors',31,''), - (23,'GeometryCollection properties',1,''), - (24,'Administration',32,''), - (25,'Data Manipulation',32,''), - (26,'Utility',32,''), - (27,'Language Structure',32,''), - (28,'Geometry relations',31,''), - (29,'Date and Time Functions',35,''), - (30,'WKB',31,''); -INSERT INTO `mysql`.`help_category` VALUES (31,'Geographic Features',32,''), - (32,'Contents',0,''), - (33,'Geometry properties',31,''), - (34,'String Functions',35,''), - (35,'Functions',32,''), - (36,'Data Definition',32,''); -UNLOCK TABLES; -/*!40000 ALTER TABLE `help_category` ENABLE KEYS */; - - --- --- Definition of table `mysql`.`help_keyword` --- - -DROP TABLE IF EXISTS `mysql`.`help_keyword`; -CREATE TABLE `mysql`.`help_keyword` ( - `help_keyword_id` int(10) unsigned NOT NULL, - `name` char(64) NOT NULL, - PRIMARY KEY (`help_keyword_id`), - UNIQUE KEY `name` (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='help keywords'; - --- --- Dumping data for table `mysql`.`help_keyword` --- - -/*!40000 ALTER TABLE `help_keyword` DISABLE KEYS */; -LOCK TABLES `help_keyword` WRITE; -INSERT INTO `mysql`.`help_keyword` VALUES (0,'JOIN'), - (1,'REPEAT'), - (2,'SERIALIZABLE'), - (3,'REPLACE'), - (4,'RETURNS'), - (5,'MASTER_SSL_CA'), - (6,'NCHAR'), - (7,'COLUMNS'), - (8,'WORK'), - (9,'DATETIME'), - (10,'MODE'), - (11,'OPEN'), - (12,'INTEGER'), - (13,'ESCAPE'), - (14,'VALUE'), - (15,'SQL_BIG_RESULT'), - (16,'DROP'), - (17,'GEOMETRYCOLLECTIONFROMWKB'), - (18,'EVENTS'), - (19,'MONTH'), - (20,'INFO'), - (21,'PROFILES'), - (22,'DUPLICATE'), - (23,'REPLICATION'), - (24,'UNLOCK'), - (25,'INNODB'), - (26,'YEAR_MONTH'), - (27,'SUBJECT'), - (28,'PREPARE'), - (29,'LOCK'), - (30,'NDB'), - (31,'CHECK'), - (32,'FULL'), - (33,'INT4'), - (34,'BY'), - (35,'NO'), - (36,'MINUTE'), - (37,'DATA'), - (38,'DAY'), - (39,'SHARE'), - (40,'REAL'), - (41,'SEPARATOR'), - (42,'DELETE'), - (43,'ON'), - (44,'CONNECTION'), - (45,'CLOSE'), - (46,'X509'), - (47,'USE'), - (48,'WHERE'), - (49,'PRIVILEGES'), - (50,'SPATIAL'), - (51,'SUPER'), - (52,'SQL_BUFFER_RESULT'), - (53,'IGNORE'), - (54,'QUICK'), - (55,'SIGNED'), - (56,'SECURITY'), - (57,'NDBCLUSTER'), - (58,'POLYGONFROMWKB'), - (59,'FALSE'); -INSERT INTO `mysql`.`help_keyword` VALUES (60,'LEVEL'), - (61,'FORCE'), - (62,'BINARY'), - (63,'TO'), - (64,'CHANGE'), - (65,'HOUR_MINUTE'), - (66,'UPDATE'), - (67,'INTO'), - (68,'FEDERATED'), - (69,'VARYING'), - (70,'HOUR_SECOND'), - (71,'VARIABLE'), - (72,'ROLLBACK'), - (73,'RTREE'), - (74,'PROCEDURE'), - (75,'TIMESTAMP'), - (76,'IMPORT'), - (77,'AGAINST'), - (78,'CHECKSUM'), - (79,'COUNT'), - (80,'LONGBINARY'), - (81,'THEN'), - (82,'INSERT'), - (83,'ENGINES'), - (84,'HANDLER'), - (85,'DAY_SECOND'), - (86,'EXISTS'), - (87,'MUTEX'), - (88,'RELEASE'), - (89,'BOOLEAN'), - (90,'MOD'), - (91,'DEFAULT'), - (92,'TYPE'), - (93,'NO_WRITE_TO_BINLOG'), - (94,'OPTIMIZE'), - (95,'RESET'), - (96,'ITERATE'), - (97,'DO'), - (98,'BIGINT'), - (99,'SET'), - (100,'ISSUER'), - (101,'DATE'), - (102,'STATUS'), - (103,'FULLTEXT'), - (104,'COMMENT'), - (105,'MASTER_CONNECT_RETRY'), - (106,'INNER'), - (107,'STOP'), - (108,'MASTER_LOG_FILE'), - (109,'MRG_MYISAM'), - (110,'PRECISION'), - (111,'REQUIRE'), - (112,'TRAILING'), - (113,'LONG'), - (114,'OPTION'), - (115,'ELSE'), - (116,'DEALLOCATE'); -INSERT INTO `mysql`.`help_keyword` VALUES (117,'IO_THREAD'), - (118,'CASE'), - (119,'CIPHER'), - (120,'CONTINUE'), - (121,'FROM'), - (122,'READ'), - (123,'LEFT'), - (124,'ELSEIF'), - (125,'MINUTE_SECOND'), - (126,'COMPACT'), - (127,'RESTORE'), - (128,'DEC'), - (129,'FOR'), - (130,'WARNINGS'), - (131,'MIN_ROWS'), - (132,'CONDITION'), - (133,'STRING'), - (134,'ENCLOSED'), - (135,'FUNCTION'), - (136,'AGGREGATE'), - (137,'FIELDS'), - (138,'INT3'), - (139,'ARCHIVE'), - (140,'AVG_ROW_LENGTH'), - (141,'ADD'), - (142,'KILL'), - (143,'FLOAT4'), - (144,'VIEW'), - (145,'REPEATABLE'), - (146,'INFILE'), - (147,'ORDER'), - (148,'USING'), - (149,'MIDDLEINT'), - (150,'GRANT'), - (151,'UNSIGNED'), - (152,'DECIMAL'), - (153,'GEOMETRYFROMTEXT'), - (154,'INDEXES'), - (155,'FOREIGN'), - (156,'CACHE'), - (157,'HOSTS'), - (158,'COMMIT'), - (159,'SCHEMAS'), - (160,'LEADING'), - (161,'SNAPSHOT'), - (162,'DECLARE'), - (163,'LOAD'), - (164,'SQL_CACHE'), - (165,'CONVERT'), - (166,'DYNAMIC'), - (167,'COLLATE'), - (168,'POLYGONFROMTEXT'), - (169,'BYTE'), - (170,'GLOBAL'), - (171,'LINESTRINGFROMWKB'); -INSERT INTO `mysql`.`help_keyword` VALUES (172,'BERKELEYDB'), - (173,'WHEN'), - (174,'HAVING'), - (175,'AS'), - (176,'STARTING'), - (177,'RELOAD'), - (178,'AUTOCOMMIT'), - (179,'REVOKE'), - (180,'GRANTS'), - (181,'OUTER'), - (182,'FLOOR'), - (183,'EXPLAIN'), - (184,'WITH'), - (185,'AFTER'), - (186,'STD'), - (187,'CSV'), - (188,'DISABLE'), - (189,'OUTFILE'), - (190,'LOW_PRIORITY'), - (191,'FILE'), - (192,'BDB'), - (193,'SCHEMA'), - (194,'SONAME'), - (195,'POW'), - (196,'MULTIPOINTFROMWKB'), - (197,'INDEX'), - (198,'DUAL'), - (199,'BACKUP'), - (200,'MULTIPOINTFROMTEXT'), - (201,'EXTENDED'), - (202,'MULTILINESTRINGFROMWKB'), - (203,'CROSS'), - (204,'NATIONAL'), - (205,'GROUP'), - (206,'SHA'), - (207,'UNDO'), - (208,'ZEROFILL'), - (209,'CLIENT'), - (210,'MASTER_PASSWORD'), - (211,'RELAY_LOG_FILE'), - (212,'TRUE'), - (213,'CHARACTER'), - (214,'MASTER_USER'), - (215,'TABLE'), - (216,'ENGINE'), - (217,'INSERT_METHOD'), - (218,'CASCADE'), - (219,'RELAY_LOG_POS'), - (220,'SQL_CALC_FOUND_ROWS'), - (221,'UNION'), - (222,'MYISAM'), - (223,'LEAVE'), - (224,'MODIFY'); -INSERT INTO `mysql`.`help_keyword` VALUES (225,'MATCH'), - (226,'MASTER_LOG_POS'), - (227,'DESC'), - (228,'DISTINCTROW'), - (229,'TIME'), - (230,'NUMERIC'), - (231,'EXPANSION'), - (232,'CURSOR'), - (233,'CODE'), - (234,'GEOMETRYCOLLECTIONFROMTEXT'), - (235,'CHAIN'), - (236,'FLUSH'), - (237,'CREATE'), - (238,'DESCRIBE'), - (239,'MAX_UPDATES_PER_HOUR'), - (240,'INT2'), - (241,'PROCESSLIST'), - (242,'LOGS'), - (243,'HEAP'), - (244,'SOUNDS'), - (245,'BETWEEN'), - (246,'REPAIR'), - (247,'MULTILINESTRINGFROMTEXT'), - (248,'PACK_KEYS'), - (249,'FAST'), - (250,'CALL'), - (251,'VALUES'), - (252,'LOOP'), - (253,'VARCHARACTER'), - (254,'BEFORE'), - (255,'TRUNCATE'), - (256,'SHOW'), - (257,'REDUNDANT'), - (258,'ALL'), - (259,'USER_RESOURCES'), - (260,'PARTIAL'), - (261,'BINLOG'), - (262,'END'), - (263,'SECOND'), - (264,'AND'), - (265,'FLOAT8'), - (266,'PREV'), - (267,'HOUR'), - (268,'SELECT'), - (269,'DATABASES'), - (270,'OR'), - (271,'IDENTIFIED'), - (272,'MASTER_SSL_CIPHER'), - (273,'SQL_SLAVE_SKIP_COUNTER'), - (274,'BOTH'), - (275,'BOOL'), - (276,'YEAR'), - (277,'MASTER_PORT'); -INSERT INTO `mysql`.`help_keyword` VALUES (278,'CONCURRENT'), - (279,'HELP'), - (280,'UNIQUE'), - (281,'TRIGGERS'), - (282,'PROCESS'), - (283,'CONSISTENT'), - (284,'MASTER_SSL'), - (285,'DATE_ADD'), - (286,'MAX_CONNECTIONS_PER_HOUR'), - (287,'LIKE'), - (288,'FETCH'), - (289,'IN'), - (290,'COLUMN'), - (291,'DUMPFILE'), - (292,'USAGE'), - (293,'EXECUTE'), - (294,'MEMORY'), - (295,'CEIL'), - (296,'QUERY'), - (297,'MASTER_HOST'), - (298,'LINES'), - (299,'SQL_THREAD'), - (300,'MAX_QUERIES_PER_HOUR'), - (301,'MASTER_SSL_CERT'), - (302,'MULTIPOLYGONFROMWKB'), - (303,'TRANSACTION'), - (304,'DAY_MINUTE'), - (305,'STDDEV'), - (306,'DATE_SUB'), - (307,'GEO... [truncated message content] |
From: <cra...@us...> - 2009-09-21 14:38:17
|
Revision: 463 http://cs-content.svn.sourceforge.net/cs-content/?rev=463&view=rev Author: crazedsanity Date: 2009-09-21 14:38:05 +0000 (Mon, 21 Sep 2009) Log Message: ----------- *** RELEASE 1.0.0-BETA1 *** SUMMARY OF CHANGES::: * support for database session storage (cs_sessionDB from cs-webapplibs) * fix inclusion of index.inc script * clean up PHP warnings involving arrays * initialize internal vars to fix errors * more unit testing * add template vars immediately instead of at finish() for unit testing * pass siteRoot to contentSystem{}. * cs_versionAbstract now included here (cs-versionparse project defunct) * add many commonly-used template vars. * moved extra libraries into cs-webapplibs::: -- cs_phpDB -- cs_bbCodeParser -- cs_sessionDB -- cs_siteConfig -- cs_tabs * add script with __autoload() for loading classes on-the-fly. * removed dependency on PHPLib's "Template" class (#237) * fix parsing of template vars within nested block rows (#301) * root path for contentSystem set automatically. SVN COMMAND::: merge --depth=infinity -r423:HEAD https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0 Modified Paths: -------------- releases/1.0/VERSION releases/1.0/abstract/cs_content.abstract.class.php 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_session.class.php releases/1.0/sample_files/public_html/content releases/1.0/tests/files/gptest_all-together.txt releases/1.0/tests/files/templates/content.shared.tmpl releases/1.0/tests/files/templates/footer.shared.tmpl releases/1.0/tests/files/templates/infobar.shared.tmpl releases/1.0/tests/files/templates/main.shared.tmpl releases/1.0/tests/files/templates/menubar.shared.tmpl releases/1.0/tests/files/templates/title.shared.tmpl releases/1.0/tests/testOfCSContent.php releases/1.0/tests/testOfCSGlobalFunctions.php Added Paths: ----------- releases/1.0/__autoload.php releases/1.0/abstract/cs_version.abstract.class.php releases/1.0/tests/files/gptest_blockrows.txt releases/1.0/tests/files/gptest_blockrows2.txt releases/1.0/tests/files/templates/system/ releases/1.0/tests/files/templates/system/404.shared.tmpl releases/1.0/tests/files/templates/system/message_box.tmpl releases/1.0/tests/files/version1 releases/1.0/tests/files/version2 releases/1.0/tests/files/version3 releases/1.0/tests/testOfCSFileSystem.php releases/1.0/tests/testOfCSVersionAbstract.php Removed Paths: ------------- releases/1.0/abstract/cs_phpDB.abstract.class.php releases/1.0/cs_bbCodeParser.class.php releases/1.0/cs_phpDB.class.php releases/1.0/cs_sessionDB.class.php releases/1.0/cs_siteConfig.class.php releases/1.0/cs_tabs.class.php releases/1.0/db_types/ releases/1.0/required/ releases/1.0/sample_files/bin/ releases/1.0/schema/ releases/1.0/tests/dbSchema/ releases/1.0/tests/files/templates/system/404.shared.tmpl releases/1.0/tests/files/templates/system/message_box.tmpl releases/1.0/tests/testOfCSPHPDB.php Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/VERSION 2009-09-21 14:38:05 UTC (rev 463) @@ -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-ALPHA10 +VERSION: 1.0-BETA1 PROJECT: cs-content $HeadURL$ \ No newline at end of file Copied: releases/1.0/__autoload.php (from rev 462, trunk/1.0/__autoload.php) =================================================================== --- releases/1.0/__autoload.php (rev 0) +++ releases/1.0/__autoload.php 2009-09-21 14:38:05 UTC (rev 463) @@ -0,0 +1,91 @@ +<?php +/* + * Created on Aug 28, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +//these libraries are **REQUIRED** to make __autoload() function without chicken-or-the-egg issues. +require_once(dirname(__FILE__) .'/abstract/cs_version.abstract.class.php'); +require_once(dirname(__FILE__) .'/abstract/cs_content.abstract.class.php'); +require_once(dirname(__FILE__) .'/cs_fileSystem.class.php'); +require_once(dirname(__FILE__) .'/cs_globalFunctions.class.php'); + + + + +function __autoload($class) { + + $tried = array(); + + $fsRoot = dirname(__FILE__) .'/../../'; + if(defined('LIBDIR')) { + $fsRoot = constant('LIBDIR'); + } + $fs = new cs_fileSystem($fsRoot); + + //try going into a "lib" directory. + $fs->cd('lib'); + $lsData = $fs->ls(); + + //attempt to find it here... + $tryThis = array(); + if(preg_match('/[aA]bstract/', $class)) { + $myClass = preg_replace('/[aA]bstract/', '', $class); + $tryThis[] = $class .'.abstract.class.php'; + $tryThis[] = $myClass .'.abstract.class.php'; + $tryThis[] = 'abstract/'. $myClass .'.abstract.class.php'; + } + $tryThis[] = $class .'.class.php'; + $tryThis[] = $class .'Class.php'; + $tryThis[] = $class .'.php'; + + $found=false; + foreach($tryThis as $filename) { + if(isset($lsData[$filename])) { + $tried[] = $fs->realcwd .'/'. $filename; + require_once($fs->realcwd .'/'. $filename); + if(class_exists($class)) { + $found=true; + break; + } + } + } + + if(!$found) { + //try going into sub-directories to pull the files. + foreach($lsData as $i=>$d) { + if($d['type'] == 'dir') { + $subLs = $fs->ls($i); + foreach($tryThis as $filename) { + $fileLocation = $fs->realcwd .'/'. $i .'/'. $filename; + if(file_exists($fileLocation)) { + $tried[] = $fileLocation; + require_once($fileLocation); + if(class_exists($class)) { + $found=true; + break; + } + } + } + } + if($found) { + break; + } + } + } + + if(!$found) { + $gf = new cs_globalFunctions; + $gf->debug_print(__FILE__ ." - line #". __LINE__ ."::: couldn't find (". $class .")",1); + $gf->debug_print($tried,1); + $gf->debug_print($tryThis,1); + exit; + } +}//end __autoload() +?> Modified: releases/1.0/abstract/cs_content.abstract.class.php =================================================================== --- releases/1.0/abstract/cs_content.abstract.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/abstract/cs_content.abstract.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -11,7 +11,6 @@ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) ."/../../cs-versionparse/cs_version.abstract.class.php"); abstract class cs_contentAbstract extends cs_versionAbstract { @@ -24,7 +23,6 @@ if($makeGfObj === true) { //make a cs_globalFunctions{} object. - require_once(dirname(__FILE__) ."/../cs_globalFunctions.class.php"); $this->gfObj = new cs_globalFunctions(); } }//end __construct() Deleted: releases/1.0/abstract/cs_phpDB.abstract.class.php =================================================================== --- releases/1.0/abstract/cs_phpDB.abstract.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/abstract/cs_phpDB.abstract.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -1,166 +0,0 @@ -<?php -/* - * Created on Jan 29, 2009 - * - * FILE INFORMATION: - * - * $HeadURL$ - * $Id$ - * $LastChangedDate$ - * $LastChangedBy$ - * $LastChangedRevision$ - */ - -abstract class cs_phpDBAbstract { - - /** Internal result set pointer. */ - protected $result = NULL; - - /** Internal error code. */ - protected $errorCode = 0; - - /** Status of the current transaction. */ - protected $transStatus = NULL; - - /** Whether there is a transaction in progress or not. */ - protected $inTrans = FALSE; - - /** Holds the last query performed. */ - protected $lastQuery = NULL; - - /** List of queries that have been run */ - protected $queryList=array(); - - /** How many seconds to wait for a query before cancelling it. */ - protected $timeOutSeconds = NULL; - - /** Internal check to determine if a connection has been established. */ - protected $isConnected=FALSE; - - /** Internal check to determine if the parameters have been set. */ - protected $paramsAreSet=FALSE; - - /** Resource handle. */ - protected $connectionID = -1; - - /** Hostname or IP to connect to */ - protected $host; - - /** Port to connect to (default for Postgres is 5432) */ - protected $port; - - /** Name of the database */ - protected $dbname; - - /** Username to connect to the database */ - protected $user; - - /** password to connect to the database */ - protected $password; - - /** Row counter for looping through records */ - protected $row = -1; - - /** cs_globalFunctions object, for string stuff. */ - protected $gfObj; - - /** Internal check to ensure the object has been properly created. */ - protected $isInitialized=FALSE; - - /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ - protected $preparedStatements = array(); - - /** Set to TRUE to save all queries into an array. */ - protected $useQueryList=FALSE; - - /** array that essentially remembers how many times beginTrans() was called. */ - protected $transactionTree = NULL; - - - - //Define some abstract methods so they MUST be provided in order for things to work. - abstract public function set_db_info(array $params); - abstract public function close(); - abstract public function connect(array $dbParams=NULL, $forceNewConnection=FALSE); - abstract public function exec($query); - abstract public function errorMsg($setMessage=null, $logError=null); - abstract public function fobject(); - abstract public function farray(); - abstract public function farray_fieldnames($index=null, $numbered=null,$unsetIndex=1); - abstract public function farray_nvp($name, $value); - abstract public function farray_numbered(); - abstract public function numAffected(); - abstract public function numRows(); - abstract public function is_connected(); - - - //========================================================================= - public function __construct() { - $this->gfObj = new cs_globalFunctions; - $this->isInitialized = true; - }//end __construct() - //========================================================================= - - - - //========================================================================= - /** - * Make sure the object is sane. - */ - final protected function sanity_check() { - if($this->isInitialized !== TRUE) { - throw new exception(__METHOD__ .": not properly initialized"); - } - }//end sanity_check() - //========================================================================= - - - - //========================================================================= - /** - * Disconnect from the database (calls internal "close()" method). - */ - public function disconnect() { - return($this->close()); - }//end disconnect() - //========================================================================= - - - - //========================================================================= - public function affectedRows() { - return($this->numAffected()); - }//end affectedRows() - //========================================================================= - - - - //========================================================================= - public function currRow() { - return($this->row); - }//end currRow() - //========================================================================= - - - - //========================================================================= - public function querySafe($string) { - return($this->gfObj->cleanString($string,"query")); - }//end querySafe() - //========================================================================= - - - - //========================================================================= - /** - * Make it SQL safe. - */ - public function sqlSafe($string) { - return($this->gfObj->cleanString($string,"sql")); - }//end sqlSafe() - //========================================================================= - - - -} -?> \ No newline at end of file Copied: releases/1.0/abstract/cs_version.abstract.class.php (from rev 462, trunk/1.0/abstract/cs_version.abstract.class.php) =================================================================== --- releases/1.0/abstract/cs_version.abstract.class.php (rev 0) +++ releases/1.0/abstract/cs_version.abstract.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -0,0 +1,398 @@ +<?php +/* + * Created on January 01, 2009 by Dan Falconer + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +abstract class cs_versionAbstract { + + public $isTest = FALSE; + + + + private $versionFileLocation=null; + private $fullVersionString; + private $suffixList = array( + 'ALPHA', //very unstable + 'BETA', //kinda unstable, but probably useable + 'RC' //all known bugs fixed, searching for unknown ones + ); + + + + abstract public function __construct(); + + + + //========================================================================= + /** + * Retrieve our version string from the VERSION file. + */ + final public function get_version($asArray=false) { + $retval = NULL; + + $this->auto_set_version_file(); + + if(file_exists($this->versionFileLocation)) { + $myMatches = array(); + $findIt = preg_match('/VERSION: (.+)/', file_get_contents($this->versionFileLocation), $matches); + + if($findIt == 1 && count($matches) == 2) { + $fullVersionString = $matches[1]; + $versionInfo = $this->parse_version_string($fullVersionString); + $this->fullVersionString = $this->build_full_version_string($versionInfo); + + + if($asArray) { + $retval = $versionInfo; + $retval['version_string'] = $this->fullVersionString; + } + else { + $retval = $this->build_full_version_string($versionInfo); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve version string in file " . + "(". $this->versionFileLocation .")"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve version information, file " . + "(". $this->versionFileLocation .") does not exist or was not set"); + } + + return($retval); + }//end get_version() + //========================================================================= + + + + //========================================================================= + public function __get($var) { + return($this->$var); + }//end __get() + //========================================================================= + + + + //========================================================================= + final public function get_project() { + $retval = NULL; + $this->auto_set_version_file(); + if(file_exists($this->versionFileLocation)) { + $myMatches = array(); + $findIt = preg_match('/PROJECT: (.+)/', file_get_contents($this->versionFileLocation), $matches); + + if($findIt == 1 && count($matches) == 2 && strlen($matches[1])) { + $retval = $matches[1]; + } + else { + throw new exception(__METHOD__ .": failed to retrieve project string"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve project information"); + } + + return($retval); + }//end get_project() + //========================================================================= + + + + //========================================================================= + public function set_version_file_location($location) { + if(file_exists($location)) { + $this->versionFileLocation = $location; + } + else { + throw new exception(__METHOD__ .": invalid location of VERSION file (". $location .")"); + } + }//end set_version_file_location() + //========================================================================= + + + + //========================================================================= + protected function auto_set_version_file() { + if(!strlen($this->versionFileLocation)) { + $bt = debug_backtrace(); + foreach($bt as $callNum=>$data) { + if(strlen($data['class'])) { + if($data['class'] != __CLASS__) { + $dir = dirname($data['file']); + if(preg_match('/tests$/', $dir)) { + $dir = preg_replace('/\/tests$/', '', $dir); + } + elseif(preg_match('/test$/', $dir)) { + $dir = preg_replace('/\/test$/', '', $dir); + } + break; + } + } + else { + throw new exception(__METHOD__ .": failed to locate the calling class in backtrace"); + } + } + + if(file_exists($dir .'/VERSION')) { + $this->set_version_file_location($dir .'/VERSION'); + } + else { + throw new exception(__METHOD__ .": failed to automatically set version file (tried ". $dir ."/VERSION)"); + } + } + }//end auto_set_version_file() + //========================================================================= + + + + //========================================================================= + /** + * + * TODO: add logic to split apart the suffix (i.e. "-ALPHA5" broken into "ALPHA" and "5"). + */ + public function parse_version_string($version) { + if(is_string($version) && strlen($version) && preg_match('/\./', $version)) { + $version = preg_replace('/ /', '', $version); + + $pieces = explode('.', $version); + $retval = array( + 'version_major' => $pieces[0], + 'version_minor' => $pieces[1] + ); + if(isset($pieces[2]) && strlen($pieces[2])) { + $retval['version_maintenance'] = $pieces[2]; + } + else { + $retval['version_maintenance'] = 0; + } + + if(preg_match('/-/', $retval['version_maintenance'])) { + $bits = explode('-', $retval['version_maintenance']); + $retval['version_maintenance'] = $bits[0]; + $suffix = $bits[1]; + } + elseif(preg_match('/-/', $retval['version_minor'])) { + $bits = explode('-', $retval['version_minor']); + $retval['version_minor'] = $bits[0]; + $suffix = $bits[1]; + } + else { + $suffix = ""; + } + $retval['version_suffix'] = $suffix; + } + else { + throw new exception(__METHOD__ .": invalid version string passed (". $version .")"); + } + + return($retval); + }//end parse_version_string() + //========================================================================= + + + + //========================================================================= + public function build_full_version_string(array $versionInfo) { + $requiredIndexes = array( + 'version_major', 'version_minor', 'version_maintenance', 'version_suffix' + ); + + $missing=""; + $count=0; + foreach($requiredIndexes as $indexName) { + if(isset($versionInfo[$indexName])) { + $count++; + } + else { + if(strlen($missing)) { + $missing .= ", ". $indexName; + } + else { + $missing = $indexName; + } + } + } + + if($count == count($requiredIndexes) && !strlen($missing)) { + $suffix = $versionInfo['version_suffix']; + unset($versionInfo['version_suffix']); + + $retval = ""; + foreach($versionInfo as $name=>$value) { + if(strlen($retval)) { + $retval .= ".". $value; + } + else { + $retval = $value; + } + } + if(strlen($suffix)) { + $retval .= "-". $suffix; + } + } + else { + throw new exception(__METHOD__ .": missing indexes in given array (". $missing .")"); + } + + return($retval); + + }//end build_full_version_string() + //========================================================================= + + + + //========================================================================= + public function is_higher_version($version, $checkIfHigher) { + $retval = FALSE; + $this->gfObj = new cs_globalFunctions; + if(!is_string($version) || !is_string($checkIfHigher)) { + throw new exception(__METHOD__ .": no valid version strings, version=(". $version ."), checkIfHigher=(". $checkIfHigher .")"); + } + elseif($version == $checkIfHigher) { + $retval = FALSE; + } + else { + $curVersionArr = $this->parse_version_string($version); + $checkVersionArr = $this->parse_version_string($checkIfHigher); + + unset($curVersionArr['version_string'], $checkVersionArr['version_string']); + + + $curVersionSuffix = $curVersionArr['version_suffix']; + $checkVersionSuffix = $checkVersionArr['version_suffix']; + + + unset($curVersionArr['version_suffix']); + + foreach($curVersionArr as $index=>$versionNumber) { + $checkThis = $checkVersionArr[$index]; + + if(is_numeric($checkThis) && is_numeric($versionNumber)) { + //set them as integers. + settype($versionNumber, 'int'); + settype($checkThis, 'int'); + + if($checkThis > $versionNumber) { + $retval = TRUE; + break; + } + elseif($checkThis == $versionNumber) { + //they're equal... + } + else { + //TODO: should there maybe be an option to throw an exception (freak out) here? + } + } + else { + throw new exception(__METHOD__ .": ". $index ." is not numeric in one of the strings " . + "(versionNumber=". $versionNumber .", checkThis=". $checkThis .")"); + } + } + + //now deal with those damnable suffixes, but only if the versions are so far identical: if + // the "$checkIfHigher" is actually higher, don't bother (i.e. suffixes don't matter when + // we already know there's a major, minor, or maintenance version that's also higher. + if($retval === FALSE) { + //EXAMPLE: $version="1.0.0-BETA3", $checkIfHigher="1.1.0" + // Moving from a non-suffixed version to a suffixed version isn't supported, but the inverse is: + // i.e. (1.0.0-BETA3 to 1.0.0) is okay, but (1.0.0 to 1.0.0-BETA3) is NOT. + // Also: (1.0.0-BETA3 to 1.0.0-BETA4) is okay, but (1.0.0-BETA4 to 1.0.0-BETA3) is NOT. + if(strlen($curVersionSuffix) && strlen($checkVersionSuffix) && $curVersionSuffix == $checkVersionSuffix) { + //matching suffixes. + } + elseif(strlen($curVersionSuffix) || strlen($checkVersionSuffix)) { + //we know the suffixes are there and DO match. + if(strlen($curVersionSuffix) && strlen($checkVersionSuffix)) { + //okay, here's where we do some crazy things... + $curVersionData = $this->parse_suffix($curVersionSuffix); + $checkVersionData = $this->parse_suffix($checkVersionSuffix); + + if($curVersionData['type'] == $checkVersionData['type']) { + //got the same suffix type (like "BETA"), check the number. + if($checkVersionData['number'] > $curVersionData['number']) { + //new version's suffix number higher than current... + $retval = TRUE; + } + elseif($checkVersionData['number'] == $curVersionData['number']) { + //new version's suffix number is EQUAL TO current... + $retval = FALSE; + } + else { + //new version's suffix number is LESS THAN current... + $retval = FALSE; + } + } + else { + //not the same suffix... see if the new one is higher. + $suffixValues = array_flip($this->suffixList); + if($suffixValues[$checkVersionData['type']] > $suffixValues[$curVersionData['type']]) { + $retval = TRUE; + } + else { + //current suffix type is higher... + } + } + + } + elseif(strlen($curVersionSuffix) && !strlen($checkVersionSuffix)) { + //i.e. "1.0.0-BETA1" to "1.0.0" --->>> OKAY! + $retval = TRUE; + } + elseif(!strlen($curVersionSuffix) && strlen($checkVersionSuffix)) { + //i.e. "1.0.0" to "1.0.0-BETA1" --->>> NOT ACCEPTABLE! + } + } + else { + //no suffix to care about + } + } + } + + return($retval); + + }//end is_higher_version() + //========================================================================= + + + + //========================================================================= + protected function parse_suffix($suffix) { + $retval = NULL; + if(strlen($suffix)) { + //determine what kind it is. + foreach($this->suffixList as $type) { + if(preg_match('/^'. $type .'/', $suffix)) { + $checkThis = preg_replace('/^'. $type .'/', '', $suffix); + if(strlen($checkThis) && is_numeric($checkThis)) { + //oooh... it's something like "BETA3" + $retval = array( + 'type' => $type, + 'number' => $checkThis + ); + } + else { + throw new exception(__METHOD__ .": invalid suffix (". $suffix .")"); + } + break; + } + } + } + else { + throw new exception(__METHOD__ .": invalid suffix (". $suffix .")"); + } + + return($retval); + }//end parse_suffix() + //========================================================================= + + +} +?> \ No newline at end of file Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/contentSystem.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -63,11 +63,6 @@ * |--> /includes/content/members/test.inc */ -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"); -require_once(dirname(__FILE__) ."/cs_genericPage.class.php"); -require_once(dirname(__FILE__) ."/cs_tabs.class.php"); class contentSystem extends cs_contentAbstract { @@ -103,27 +98,17 @@ /** * The CONSTRUCTOR. Duh. */ - public function __construct($testOnly=FALSE) { + public function __construct($siteRoot=null) { parent::__construct(); - if($testOnly === 'unit_test') { - //It's just a test, don't do anything we might regret later. - $this->isTest = TRUE; - } - 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']); - - //figure out the section & subsection stuff. - $this->section = $this->clean_url($_SERVER['REQUEST_URI']); - - $this->initialize_locals(); - } + + //setup the section stuff... + $repArr = array($_SERVER['SCRIPT_NAME'], "/"); + $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); + + //figure out the section & subsection stuff. + $this->section = $this->clean_url($_SERVER['REQUEST_URI']); + + $this->initialize_locals($siteRoot); }//end __construct() //------------------------------------------------------------------------ @@ -133,11 +118,10 @@ /** * Creates internal objects & prepares for later usage. */ - private function initialize_locals() { + private function initialize_locals($siteRoot=null) { //create a session that gets stored in a database if they so desire... if(defined('SESSION_DBSAVE')) { - require_once(dirname(__FILE__) .'/cs_sessionDB.class.php'); $obj = new cs_sessionDB(); $this->handle_session($obj); } @@ -145,13 +129,36 @@ //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(). - $this->templateObj = new cs_genericPage(FALSE, "main.shared.tmpl"); + $root = preg_replace('/\/public_html$/', '', $_SERVER['DOCUMENT_ROOT']); + $root = preg_replace('/\/html/', '', $root); + if(!is_null($siteRoot) && is_dir($siteRoot)) { + $root = $siteRoot; + } + elseif(defined('SITE_ROOT') && is_dir(constant('SITE_ROOT'))) { + $root = constant('SITE_ROOT'); + } + $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; @@ -164,24 +171,15 @@ } //create a fileSystem object for templates. - $tmplBaseDir = constant('SITE_ROOT') .'/templates'; - if(defined('TMPLDIR')) { - $tmplBaseDir = constant('TMPLDIR'); - } + $tmplBaseDir = $root .'/templates'; $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'); - } + $incBaseDir = $root .'/includes'; $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); - //check versions, make sure they're all the same. $myVersion = $this->get_version(); if($this->templateObj->get_version() !== $myVersion) { @@ -193,9 +191,6 @@ 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 .")"); } - if($this->tabs->get_version() !== $myVersion) { - throw new exception(__METHOD__ .": ". get_class($this->tabs) ." has mismatched version (". $this->tabs->get_version() ." does not equal ". $myVersion .")"); - } //split apart the section so we can do stuff with it later. $this->parse_section(); @@ -669,7 +664,11 @@ } //include the final shared & index files. - if($this->incFs->cd($this->finalSection)) { + $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'); @@ -773,8 +772,6 @@ unset($_GET[$badVarName], $_POST[$badVarName]); } - $page =& $this->templateObj; - if(is_array($this->injectVars) && count($this->injectVars)) { $definedVars = get_defined_vars(); foreach($this->injectVars as $myVarName=>$myVarVal) { @@ -788,29 +785,24 @@ } if(isset($this->session) && is_object($this->session)) { - $page->session =& $this->session; + $this->templateObj->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->add_template('content', $this->templateList['index']); - unset($this->templateList['index']); + if(isset($this->templateObj->templateFiles['index']) && !isset($this->templateObj->templateFiles['content'])) { + $this->add_template('content', $this->templateObj->templateFiles['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; array_unshift($sectionArr, $this->baseDir); $finalURL = $this->gfObj->string_from_array($sectionArr, NULL, '/'); + + $page = $this->templateObj; + //now include the includes scripts, if there are any. if(is_array($this->includesList) && count($this->includesList)) { try { @@ -830,7 +822,7 @@ catch(exception $e) { $myRoot = preg_replace('/\//', '\\\/', $this->incFs->root); $displayableInclude = preg_replace('/^'. $myRoot .'/', '', $this->myLastInclude); - $this->templateObj->set_message_wrapper(array( + $page->set_message_wrapper(array( 'title' => "Fatal Error", 'message' => __METHOD__ .": A fatal error occurred while processing <b>". $displayableInclude ."</b>:<BR>\n<b>ERROR</b>: ". $e->getMessage(), @@ -846,12 +838,12 @@ unset($myInternalScriptName); } - if(is_bool($this->templateObj->allow_invalid_urls() === TRUE) && $this->isValid === FALSE) { - $this->isValid = $this->templateObj->allow_invalid_urls(); + if(is_bool($page->allow_invalid_urls() === TRUE) && $this->isValid === FALSE) { + $this->isValid = $page->allow_invalid_urls(); } if($this->isValid === TRUE) { - if($this->templateObj->printOnFinish === true) { + if($page->printOnFinish === true) { $page->print_page(); } } @@ -929,7 +921,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() //------------------------------------------------------------------------ Deleted: releases/1.0/cs_bbCodeParser.class.php =================================================================== --- releases/1.0/cs_bbCodeParser.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_bbCodeParser.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -1,165 +0,0 @@ -<?php -/** - * Created on 2007-09-26 - * - * - * SVN INFORMATION::: - * ------------------ - * SVN Signature::::::: $Id$ - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - * - * - * Originally from a snippet (just the function) on PHPFreaks.com: http://www.phpfreaks.com/quickcode/BBCode/712.php - * The original code had parse errors, so it had to be fixed... While it was posted as just a basic function, - * the code within (such as the reference to "$this->bbCodeData" indicated it was from a class... so it has - * been converted. - */ - -require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); - -class cs_bbCodeParser extends cs_contentAbstract { - - /** Array containing all the codes & how to parse them. */ - private $bbCodeData = NULL; - - //========================================================================= - /** - * Setup internal structures. - */ - function __construct() { - parent::__construct(false); - # Which BBCode is accepted here - $this->bbCodeData = array( - 'bold' => array( - 'start' => array('[b]', '\[b\](.*)', '<b>\\1'), - 'end' => array('[/b]', '\[\/b\]', '</b>'), - ), - - 'underline' => array( - 'start' => array('[u]', '\[u\](.*)', '<u>\\1'), - 'end' => array('[/u]', '\[\/u\]', '</u>'), - ), - - 'italic' => array( - 'start' => array('[i]', '\[i\](.*)', '<i>\\1'), - 'end' => array('[/i]', '\[\/i\]', '</i>'), - ), - - 'image' => array( - 'start' => array('[img]', '\[img\](http:\/\/|https:\/\/|ftp:\/\/|\/)(.*)(.jpg|.jpeg|.bmp|.gif|.png)', '<img src=\'\\1\\2\\3\' />'), - 'end' => array('[/img]', '\[\/img\]', ''), - ), - - # [url]http://x.com[/url] - 'url1' => array( - 'start' => array('[url]', '\[url\](http:\/\/|https:\/\/|ftp:\/\/)(.*)', '<a target="_blank" href=\'\\1\\2\'>\\1\\2'), - 'end' => array('[/url]', '\[\/url\]', '</a>'), - ), - - # [url=http://x.com]stuff[/url] - 'url2' => array( - 'start' => array('[url]', '\[url=(http:\/\/|https:\/\/|ftp:\/\/)(.*)\](.*)', '<a target="_blank" href=\'\\1\\2\'>\\3'), - 'end' => array('[/url]', '\[\/url\]', '</a>'), - ), - - 'code' => array( - 'start' => array('[code]', '\[code\](.*)', '<br /><br /><b>CODE</b>:<div class="code">\\1'), - 'end' => array('[/code]', '\[\/code\]', '</div><br />'), - ), - ); - }//end __construct() - //========================================================================= - - - - //========================================================================= - /** - * Ensure the object is initialized properly, throw exception if not. - */ - private function isInitialized() { - if(!is_array($this->bbCodeData) || !count($this->bbCodeData)) { - throw new exception(__METHOD__ .": BBCode array not initialized"); - } - }//end isInitialized() - //========================================================================= - - - - //========================================================================= - /** - * Parse BBCode from the given string & return it with formatting. - */ - function parseString($data, $newlines2BR=FALSE) { - if(is_string($data) && strlen($data) > 10) { - $this->isInitialized(); - $data = str_replace("\n", '||newline||', $data); - - foreach( $this->bbCodeData as $k => $v ) { - if(isset($this->bbCodeData[$k]['special'])) { - $myMatches = array(); - $regex = '/'. $this->bbCodeData[$k]['start'][1] . $this->bbCodeData[$k]['end'][1] .'/'; - $x = preg_match_all($regex .'U', $data, $myMatches); - - if(count($myMatches[1])) { - $funcName = $v['special']; - $myArgs = $myMatches[1]; - $myArgs = array_unique($myArgs); - - foreach($myArgs as $index=>$value) { - $showThis = $this->$funcName($value); - $replaceThis = str_replace(array('[', ']'), array('\\[', '\\]'), $myMatches[0][$index]); - $data = preg_replace('/'. $replaceThis .'/U', $showThis, $data); - } - } - } - else { - $data = preg_replace("/".$this->bbCodeData[$k]['start'][1].$this->bbCodeData[$k]['end'][1]."/U", $this->bbCodeData[$k]['start'][2].$this->bbCodeData[$k]['end'][2], $data); - } - } - - $replaceNewlineStr = "\n"; - if($newlines2BR) { - $replaceNewlineStr = "<br />\n"; - } - $data = str_replace('||newline||', $replaceNewlineStr, $data); - - } - return $data; - }//end parseString() - //========================================================================= - - - - //========================================================================= - /** - * Enables extending classes to register a bbCode with special parsing. - * - * NOTE: right now, this will only handle syntax like "[{bbCodeString}={arg}]". - */ - protected function register_code_with_callback($bbCodeString, $method) { - - if(method_exists($this, $method)) { - $this->bbCodeData[$bbCodeString] = array( - 'special' => $method, - 'start' => array( - '['. $bbCodeString .']', - '\['. $bbCodeString .'=(.*)' - ), - 'end' => array( - '', - '\]' - ) - ); - } - else { - throw new exception(__METHOD__ .": method (". $method .") doesn't exist"); - } - - }//end register_code_with_callback() - //========================================================================= - -} -?> Modified: releases/1.0/cs_fileSystem.class.php =================================================================== --- releases/1.0/cs_fileSystem.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_fileSystem.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -9,8 +9,6 @@ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); - class cs_fileSystem extends cs_contentAbstract { public $root; //actual root directory. @@ -363,7 +361,7 @@ //something bad happened. $retval = 0; } - } + } else { throw new exception(__METHOD__ .": file is unreadable (". $filename .")"); } @@ -885,6 +883,8 @@ if($this->is_readable($filename)) { if($this->check_chroot($destination)) { //do the move. + $filename = $this->filename2absolute($filename); + $destination = $this->filename2absolute($destination); $retval = rename($filename, $destination); } else { Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_genericPage.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -7,13 +7,12 @@ * $LastChangedBy$ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) ."/required/template.inc"); -require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); class cs_genericPage extends cs_contentAbstract { - public $templateObj; //template object to parse the pages - public $templateVars = array(); //our copy of the global templateVars - public $mainTemplate; //the default layout of the site + public $templateVars = array(); //our copy of the global templateVars + public $templateFiles = array(); //our list of template files... + public $templateRows = array(); //array of block rows & their contents. + public $mainTemplate; //the default layout of the site public $unhandledVars=array(); public $printOnFinish=true; @@ -22,17 +21,13 @@ private $siteRoot; private $allowRedirect; - private $showEditableLink = FALSE; - private $allowInvalidUrls=NULL; //--------------------------------------------------------------------------------------------- /** * The constructor. */ - public function __construct($restrictedAccess=TRUE, $mainTemplateFile=NULL, $allowRedirect=TRUE) { - //handle some configuration. - $this->allowRedirect = $allowRedirect; + public function __construct($restrictedAccess=TRUE, $mainTemplateFile=NULL) { //initialize stuff from our parent... parent::__construct(); @@ -46,11 +41,6 @@ if(!defined('CS-CONTENT_SESSION_NAME')) { define("CS-CONTENT_SESSION_NAME", ini_get('session.name')); } - - //TODO: if the end page doesn't want to allow the "edit" links, will this still work? - if(defined("CS_CONTENT_MODIFIABLE") && constant("CS_CONTENT_MODIFIABLE") === TRUE) { - $this->showEditableLink = TRUE; - } }//end __construct() //--------------------------------------------------------------------------------------------- @@ -71,16 +61,30 @@ $mainTemplateFile = preg_replace('/^\//', '', $mainTemplateFile); } - - if(defined('SITE_ROOT')) { + if(isset($mainTemplateFile) && strlen($mainTemplateFile) && is_dir(dirname($mainTemplateFile)) && dirname($mainTemplateFile) != '.') { + $this->siteRoot = dirname($mainTemplateFile); + if(preg_match('/\//', $this->siteRoot) && preg_match('/templates/', $this->siteRoot)) { + $this->siteRoot .= "/.."; + } + } + elseif(defined('SITE_ROOT') && is_dir(constant('SITE_ROOT'))) { $this->siteRoot = constant('SITE_ROOT'); } + elseif(is_dir($_SERVER['DOCUMENT_ROOT'] .'/templates')) { + $this->siteRoot = $_SERVER['DOCUMENT_ROOT'] .'/templates'; + } else { - throw new exception(__METHOD__ .": required constant 'SITE_ROOT' not set"); + throw new exception(__METHOD__ .": cannot locate siteRoot from main template file (". $mainTemplateFile .")"); } + $fs = new cs_fileSystem(dirname(__FILE__)); + $this->siteRoot = $fs->resolve_path_with_dots($this->siteRoot); $this->tmplDir = $this->siteRoot .'/templates'; $this->libDir = $this->siteRoot .'/lib'; + if(!is_dir($this->tmplDir)) { + throw new exception(__METHOD__ .": invalid templates folder (". $this->tmplDir ."), siteRoot=(". $this->siteRoot .")"); + } + //if there have been some global template vars (or files) set, read 'em in here. if(is_array($GLOBALS['templateVars']) && count($GLOBALS['templateVars'])) { foreach($GLOBALS['templateVars'] as $key=>$value) { @@ -93,9 +97,6 @@ } } unset($GLOBALS['templateVars'], $GLOBALS['templateFiles']); - - //build a new instance of the template library (from PHPLib) - $this->templateObj=new Template($this->tmplDir,"keep"); //initialize a new template parser if(!preg_match('/^\//', $mainTemplateFile)) { $mainTemplateFile = $this->tmplDir ."/". $mainTemplateFile; @@ -175,13 +176,8 @@ * TODO: check if $fileName exists before blindly trying to parse it. */ public function add_template_file($handleName, $fileName){ - if($this->showEditableLink) { - $prefix = '[<a href="#NULL_page='. $fileName .'"><font color="red"><b>Edit "'. $handleName .'"</b></font></a>]<BR>'; - $this->add_template_var($handleName, $prefix .$this->file_to_string($fileName)); - } - else { - $this->add_template_var($handleName, $this->file_to_string($fileName)); - } + $this->templateFiles[$handleName] = $fileName; + $this->add_template_var($handleName, $this->file_to_string($fileName)); }//end add_template_file() //--------------------------------------------------------------------------------------------- @@ -267,42 +263,37 @@ * @return (str) Final, parsed page. */ public function print_page($stripUndefVars=1) { + $this->unhandledVars = array(); //Show any available messages. $this->process_set_message(); - //Load the default page layout. - $this->templateObj->set_file("main", $this->mainTemplate); - - //load the placeholder names and thier values - $this->templateObj->set_var($this->templateVars); - $this->templateObj->parse("out","main"); //parse the sub-files into the main page + if(isset($this->templateVars['main'])) { + //this is done to simulate old behaviour (the "main" templateVar could overwrite the entire main template). + $out = $this->templateVars['main']; + } + else { + $out = $this->file_to_string($this->mainTemplate); + } + if(!strlen($out)) { + $this->gfObj->debug_print($out); + $this->gfObj->debug_print($this->mainTemplate); + $this->gfObj->debug_print("MANUAL FILE CONTENTS::: ". htmlentities(file_get_contents($this->tmplDir .'/'. $this->mainTemplate))); + exit(__METHOD__ .": mainTemplate (". $this->mainTemplate .") was empty...?"); + } + $numLoops = 0; + $tags = array(); + while(preg_match_all('/\{.\S+?\}/', $out, $tags) && $numLoops < 10) { + $out = $this->gfObj->mini_parser($out, $this->templateVars, '{', '}'); + $numLoops++; + } + if($stripUndefVars) { - $numLoops = 0; - while(preg_match_all('/\{.\S+?\}/', $this->templateObj->varvals['out'], $tags) && $numLoops < 50) { - $tags = $tags[0]; - - //TODO: figure out why this works when running it twice. - foreach($tags as $key=>$str) { - $str2 = str_replace("{", "", $str); - $str2 = str_replace("}", "", $str2); - 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']); - if(isset($this->unhandledVars[$str2])) { - $this->unhandledVars[$str2]++; - } - else { - $this->unhandledVars[$str2] = 1; - } - } - } - $this->templateObj->parse("out", "out"); - $numLoops++; - } + $out = $this->strip_undef_template_vars($out, $this->unhandledVars); } - $this->templateObj->pparse("out","out"); //parse the main page + print($out); + }//end of print_page() //--------------------------------------------------------------------------------------------- @@ -348,9 +339,20 @@ * content & returns it. */ public function file_to_string($templateFileName) { + + if(preg_match('/templates/', $templateFileName)) { + $bits = explode('templates', $templateFileName); + if(count($bits) == 2) { + $templateFileName = $bits[1]; + } + else { + throw new exception(__METHOD__ .": full path to template file given but could not break the path into bits::: ". $templateFileName); + } + } $templateFileName = preg_replace('/\/\//', '\/', $templateFileName); - if($this->template_file_exists($templateFileName)) { - $retval = file_get_contents($this->tmplDir .'/'. $templateFileName); + $fullPathToFile = $this->template_file_exists($templateFileName); + if($fullPathToFile !== false && strlen($fullPathToFile)) { + $retval = file_get_contents($fullPathToFile); } else { $this->set_message_wrapper(array( "title" => 'Template File Error', @@ -369,7 +371,7 @@ * Checks to see if the given filename exists within the template directory. */ public function template_file_exists($file) { - $retval = 0; + $retval = false; //If the string doesn't start with a /, add one if (strncmp("/",$file,1)) { //strncmp returns 0 if they match, so we're putting a / on if they don't @@ -488,35 +490,8 @@ /** * Performs redirection, provided it is allowed. */ - function conditional_header($url, $exitAfter=TRUE) { - if($this->allowRedirect) { - //checks to see if headers were sent; if yes: use a meta redirect. - // if no: send header("location") info... - if(headers_sent()) { - //headers sent. Use the meta redirect. - print " - <HTML> - <HEAD> - <TITLE>Redirect Page</TITLE> - <META HTTP-EQUIV='refresh' content='0; URL=$url'> - </HEAD> - <a href=\"$url\"></a> - </HTML> - "; - } - else { - header("location:$url"); - } - - if($exitAfter) { - //redirecting without exitting is bad, m'kay? - exit; - } - } - else { - //TODO: should an exception be thrown, or maybe exit here anyway? - throw new exception(__METHOD__ .": auto redirects not allowed...?"); - } + function conditional_header($url, $exitAfter=TRUE,$isPermRedir=FALSE) { + $this->gfObj->conditional_header($url, $exitAfter, $isPermRedir); }//end conditional_header() //--------------------------------------------------------------------------------------------- @@ -656,7 +631,7 @@ //------------------------------------------------------------------------- - public function strip_undef_template_vars($templateContents) { + public function strip_undef_template_vars($templateContents, array &$unhandled=null) { $numLoops = 0; while(preg_match_all('/\{.\S+?\}/', $templateContents, $tags) && $numLoops < 50) { $tags = $tags[0]; @@ -665,8 +640,14 @@ foreach($tags as $key=>$str) { $str2 = str_replace("{", "", $str); $str2 = str_replace("}", "", $str2); - if(!$this->templateVars[$str2]) { + if(!isset($this->templateVars[$str2])) { //TODO: set an internal pointer or something to use here, so they can see what was missed. + if(is_array($unhandled)) { + if(!isset($unhandled[$str2])) { + $unhandled[$str2]=0; + } + $unhandled[$str2]++; + } $templateContents = str_replace($str, '', $templateContents); } } @@ -681,6 +662,7 @@ //------------------------------------------------------------------------- public function strip_undef_template_vars_from_section($section='content') { if(isset($this->templateVars[$section])) { + //rip out undefined vars from the contents of the given section. $this->templateVars[$section] = $this->strip_undef_template_vars($this->templateVars[$section]); } else { @@ -690,6 +672,31 @@ return($this->templateVars[$section]); }//strip_undef_template_vars_from_section() //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Magic PHP method for retrieving the values of private/protected vars. + */ + public function __get($var) { + return($this->$var); + }//end __get() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Magic PHP method for changing the values of private/protected vars (or + * creating new ones). + */ + public function __set($var, $val) { + + //TODO: set some restrictions on internal vars... + $this->$var = $val; + }//end __set() + //------------------------------------------------------------------------- }//end cs_genericPage{} ?> Modified: releases/1.0/cs_globalFunctions.class.php =================================================================== --- releases/1.0/cs_globalFunctions.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_globalFunctions.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -1,6 +1,5 @@ <?php -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); class cs_globalFunctions extends cs_versionAbstract { Deleted: releases/1.0/cs_phpDB.class.php =================================================================== --- releases/1.0/cs_phpDB.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_phpDB.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -1,197 +0,0 @@ -<?php - -/* - * A class for generic PostgreSQL database access. - * - * SVN INFORMATION::: - * SVN Signature:::::::: $Id$ - * Last Committted Date: $Date$ - * Last Committed Path:: $HeadURL$ - * - */ - -/////////////////////// -// ORIGINATION INFO: -// Author: Trevin Chow (with contributions from Lee Pang, wle...@ho...) -// Email: t1...@ma... -// Date: February 21, 2000 -// Last Updated: August 14, 2001 -// -// Description: -// Abstracts both the php function calls and the server information to POSTGRES -// databases. Utilizes class variables to maintain connection information such -// as number of rows, result id of last operation, etc. -// -/////////////////////// - -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_contentAbstract { - - private $dbLayerObj; - private $dbType; - public $connectParams = array(); - - //========================================================================= - public function __construct($type='pgsql') { - - if(strlen($type)) { - - require_once(dirname(__FILE__) .'/db_types/'. __CLASS__ .'__'. $type .'.class.php'); - $className = __CLASS__ .'__'. $type; - $this->dbLayerObj = new $className; - $this->dbType = $type; - - parent::__construct(); - - $this->isInitialized = TRUE; - } - else { - throw new exception(__METHOD__ .": failed to give a type (". $type .")"); - } - }//end __construct() - //========================================================================= - - - - //========================================================================= - /** - * Magic method to call methods within the database abstraction layer ($this->dbLayerObj). - */ - public function __call($methodName, $args) { - if(method_exists($this->dbLayerObj, $methodName)) { - if($methodName == 'connect' && is_array($args[0])) { - //capture the connection parameters. - $this->connectParams = $args[0]; - } - $retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args); - } - else { - throw new exception(__METHOD__ .': unsupported method ('. $methodName .') for database of type ('. $this->dbType .')'); - } - return($retval); - }//end __call() - //========================================================================= - - - - //========================================================================= - public function get_dbtype() { - return($this->dbType); - }//end get_dbtype() - //========================================================================= - - - - //========================================================================= - /** - * Performs queries which require results. Passing $indexField returns a - * complex array indexed from that field; passing $valueField will change - * it to a name=>value formatted array. - * - * NOTE:: when using an index field, be sure it is guaranteed to be unique, - * i.e. it is a primary key! If duplicates are found, the database class - * will throw an exception! - */ - public function run_query($sql, $indexField=null, $valueField=null) { - - $retval = array(); - - //length must be 19 as that's about the shortest valid SQL: "select * from table" - if(strlen($sql) >= 19) { - $this->exec($sql); - - $numRows = $this->numRows(); - $dbError = $this->errorMsg(); - if($numRows > 0 && !strlen($dbError)) { - if(strlen($indexField) && (is_null($valueField) || !strlen($valueField))) { - //return a complex array based on a given field. - $retval = $this->farray_fieldnames($indexField, null, 0); - } - elseif(strlen($indexField) && strlen($valueField)) { - //return an array as name=>value pairs. - $retval = $this->farray_nvp($indexField, $valueField); - } - else { - $retval = $this->farray_fieldnames(); - } - } - elseif($numRows == 0 && !strlen($dbError)) { - $retval = false; - } - else { - throw new exception(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": invalid length SQL (". $sql .")"); - } - - return($retval); - }//end run_query() - //========================================================================= - - - - //========================================================================= - /** - * Handles performing the insert statement & returning the last inserted ID. - */ - public function run_insert($sql, $sequence='null') { - - $this->exec($sql); - - if($this->numAffected() == 1 && !strlen($this->errorMsg())) { - //retrieve the ID just created. - $retval = $this->lastID($sequence); - } - else { - //something broke... - throw new exception(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " - ."ERROR::: ". $this->errorMsg() ."\n -- SQL:::: ". $sql); - } - - return($retval); - }//end run_insert() - //========================================================================= - - - - //========================================================================= - /** - * Performs the update & returns how many rows were affected. - */ - public function run_update($sql, $zeroIsOk=false) { - $this->exec($sql); - - $dberror = $this->errorMsg(); - $numAffected = $this->numAffected(); - - if(strlen($dberror)) { - throw new exception(__METHOD__ .": error while running update::: ". $dberror ." -- SQL::: ". $sql); - } - elseif($numAffected==0 && $zeroIsOk == false) { - throw new exception(__METHOD__ .": no rows updated (". $numAffected ."), SQL::: ". $sql); - } - - return($numAffected); - }//end run_update() - //========================================================================= - - - - //========================================================================= - public function reconnect() { - if(is_array($this->connectParams) && count($this->connectParams)) { - $this->dbLayerObj->connect($this->connectParams, true); - } - else { - throw new exception(__METHOD__ .": no connection parameters stored"); - } - }//end reconnect() - //========================================================================= - -} // end class phpDB - -?> Modified: releases/1.0/cs_session.class.php =================================================================== --- releases/1.0/cs_session.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_session.class.php 2009-09-21 14:38:05 UTC (rev 463) @@ -8,9 +8,6 @@ * $LastChangedRevision$ */ -require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); -require_once(dirname(__FILE__) ."/../cs-versionparse/cs_version.abstract.class.php"); - class cs_session extends cs_contentAbstract { protected $uid; @@ -40,7 +37,7 @@ //TODO: need a setting somewhere that says what the name of this var should be, // instead of always forcing "uid". $this->uid = 0; - if($_SESSION['uid']) { + if(isset($_SESSION['uid']) && $_SESSION['uid']) { $this->uid = $_SESSION['uid']; } Deleted: releases/1.0/cs_sessionDB.class.php =================================================================== --- releases/1.0/cs_sessionDB.class.php 2009-09-21 14:34:39 UTC (rev 462) +++ releases/1.0/cs_sessionDB.class.php 2009-09-21 14... [truncated message content] |
From: <cra...@us...> - 2010-05-18 15:49:54
|
Revision: 475 http://cs-content.svn.sourceforge.net/cs-content/?rev=475&view=rev Author: crazedsanity Date: 2010-05-18 15:49:47 +0000 (Tue, 18 May 2010) Log Message: ----------- *** RELEASE 1.0.0-RC1 *** SUMMARY OF CHANGES: * remove/suppress multiple PHP warnings. * add "is_readable" and "is_writable" to cs_fileSystem::get_fileinfo(). * fix issue with trailing "/" on DOCUMENT_ROOT. * changes for unit testing. * add $fullSectionArr as a local variable available to includes scripts. * fix output when called from CLI. SVN COMMAND::: svn merge -r463: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_session.class.php releases/1.0/tests/files/templates/system/message_box.tmpl releases/1.0/tests/testOfCSContent.php Added Paths: ----------- releases/1.0/tests/files/includes/ releases/1.0/tests/files/includes/shared.inc Removed Paths: ------------- releases/1.0/tests/files/includes/shared.inc Property Changed: ---------------- releases/1.0/ Property changes on: releases/1.0 ___________________________________________________________________ Added: svn:mergeinfo + /trunk/1.0:464-474 Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/VERSION 2010-05-18 15:49:47 UTC (rev 475) @@ -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-BETA1 +VERSION: 1.0-RC1 PROJECT: cs-content -$HeadURL$ \ No newline at end of file +$HeadURL$ Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/contentSystem.class.php 2010-05-18 15:49:47 UTC (rev 475) @@ -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,8 @@ $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); //figure out the section & subsection stuff. + $requestUri = preg_replace('/\/$/', '', $_SERVER['REQUEST_URI']); + $this->fullSectionArr = split('/', $requestUri); //TODO: will this cope with an APPURL being set? $this->section = $this->clean_url($_SERVER['REQUEST_URI']); $this->initialize_locals($siteRoot); @@ -129,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)) { @@ -149,7 +153,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' => "" @@ -546,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); @@ -574,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; @@ -731,8 +735,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 +752,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); } @@ -771,6 +774,7 @@ foreach($badUrlVars as $badVarName) { unset($_GET[$badVarName], $_POST[$badVarName]); } + unset($badUrlVars, $badVarName); if(is_array($this->injectVars) && count($this->injectVars)) { $definedVars = get_defined_vars(); @@ -783,6 +787,7 @@ } } } + unset($definedVars, $myVarName, $myVarVal); if(isset($this->session) && is_object($this->session)) { $this->templateObj->session = $this->session; @@ -797,8 +802,10 @@ //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->templateObj->add_template_var('PHP_SELF', '/'. $this->gfObj->string_from_array($sectionArr, NULL, '/')); $page = $this->templateObj; @@ -808,6 +815,7 @@ try { foreach($this->includesList as $myInternalIndex=>$myInternalScriptName) { $this->myLastInclude = $myInternalScriptName; + unset($myInternalScriptName, $myInternalIndex); include_once($this->myLastInclude); } @@ -815,6 +823,7 @@ if(is_array($this->afterIncludesList)) { foreach($this->afterIncludesList as $myInternalIndex=>$myInternalScriptName) { $this->myLastInclude = $myInternalScriptName; + unset($myInternalScriptName, $myInternalIndex); include_once($this->myLastInclude); } } Modified: releases/1.0/cs_fileSystem.class.php =================================================================== --- releases/1.0/cs_fileSystem.class.php 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/cs_fileSystem.class.php 2010-05-18 15:49:47 UTC (rev 475) @@ -204,7 +204,9 @@ "group" => @$this->my_getuser_group(filegroup($tFile), 'gid'), "gid" => @filegroup($tFile), "perms" => @$this->translate_perms(fileperms($tFile)), - "perms_num" => @substr(sprintf('%o', fileperms($tFile)), -4) + "perms_num" => @substr(sprintf('%o', fileperms($tFile)), -4), + "is_readable" => is_readable($tFile), + "is_writable" => is_writable($tFile) ); return($retval); Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/cs_genericPage.class.php 2010-05-18 15:49:47 UTC (rev 475) @@ -86,7 +86,7 @@ } //if there have been some global template vars (or files) set, read 'em in here. - if(is_array($GLOBALS['templateVars']) && count($GLOBALS['templateVars'])) { + if(isset($GLOBALS['templateVars']) && is_array($GLOBALS['templateVars']) && count($GLOBALS['templateVars'])) { foreach($GLOBALS['templateVars'] as $key=>$value) { $this->add_template_var($key, $value); } @@ -680,7 +680,7 @@ * Magic PHP method for retrieving the values of private/protected vars. */ public function __get($var) { - return($this->$var); + return(@$this->$var); }//end __get() //------------------------------------------------------------------------- Modified: releases/1.0/cs_session.class.php =================================================================== --- releases/1.0/cs_session.class.php 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/cs_session.class.php 2010-05-18 15:49:47 UTC (rev 475) @@ -30,7 +30,7 @@ } //now actually create the session. - session_start(); + @session_start(); } //check if there's a uid in the session already. Deleted: releases/1.0/tests/files/includes/shared.inc =================================================================== --- trunk/1.0/tests/files/includes/shared.inc 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/tests/files/includes/shared.inc 2010-05-18 15:49:47 UTC (rev 475) @@ -1,40 +0,0 @@ -<?php -/* - * Created on Oct 21, 2009 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - - -$page->gfObj->debugPrintOpt=1; -$page->allow_invalid_urls(true); -$page->printOnFinish=false; - -if(isset($testObj) && is_object($testObj) && get_class($testObj) == 'TestOfCSContent') { - - //start unit tests!!! - - $testObj->assertTrue(is_array($sectionArr)); - $testObj->assertTrue(is_array($fullSectionArr)); - if(!$testObj->assertEqual(count($sectionArr), count($fullSectionArr))) { - $testObj->assertEqual(false, true, $page->gfObj->debug_print($fullSectionArr)); - } - - foreach(get_defined_vars() as $n=>$v) { - $acceptableVars = array('testObj', 'page', 'sectionArr', 'fullSectionArr', 'finalURL', 'finalSection', 'this'); - $testObj->assertTrue(in_array($n, $acceptableVars), "local var '". $n ."' not allowed as a local var"); - unset($acceptableVars); - } - -} -else { - throw new exception(__FILE__ .": failed to locate unit test object (testObj) while running include script unit tests"); -} - - -?> Copied: releases/1.0/tests/files/includes/shared.inc (from rev 474, trunk/1.0/tests/files/includes/shared.inc) =================================================================== --- releases/1.0/tests/files/includes/shared.inc (rev 0) +++ releases/1.0/tests/files/includes/shared.inc 2010-05-18 15:49:47 UTC (rev 475) @@ -0,0 +1,40 @@ +<?php +/* + * Created on Oct 21, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + +$page->gfObj->debugPrintOpt=1; +$page->allow_invalid_urls(true); +$page->printOnFinish=false; + +if(isset($testObj) && is_object($testObj) && get_class($testObj) == 'TestOfCSContent') { + + //start unit tests!!! + + $testObj->assertTrue(is_array($sectionArr)); + $testObj->assertTrue(is_array($fullSectionArr)); + if(!$testObj->assertEqual(count($sectionArr), count($fullSectionArr))) { + $testObj->assertEqual(false, true, $page->gfObj->debug_print($fullSectionArr)); + } + + foreach(get_defined_vars() as $n=>$v) { + $acceptableVars = array('testObj', 'page', 'sectionArr', 'fullSectionArr', 'finalURL', 'finalSection', 'this'); + $testObj->assertTrue(in_array($n, $acceptableVars), "local var '". $n ."' not allowed as a local var"); + unset($acceptableVars); + } + +} +else { + throw new exception(__FILE__ .": failed to locate unit test object (testObj) while running include script unit tests"); +} + + +?> Modified: releases/1.0/tests/files/templates/system/message_box.tmpl =================================================================== --- releases/1.0/tests/files/templates/system/message_box.tmpl 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/tests/files/templates/system/message_box.tmpl 2010-05-18 15:49:47 UTC (rev 475) @@ -11,7 +11,7 @@ <table class="{messageType}" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td valign="top"> - <p style="border-style: solid; border-width: 0px 0px 2px 0px" class="title1">{title}</p> + <p style="border-style: solid; border-width: 0px 0px 2px 0px" class="title1">TEST -- {title}</p> <p style="margin: 5px 0px 5px 0px">{message}</p> {redirect} </td> </tr> Modified: releases/1.0/tests/testOfCSContent.php =================================================================== --- releases/1.0/tests/testOfCSContent.php 2010-05-18 13:29:42 UTC (rev 474) +++ releases/1.0/tests/testOfCSContent.php 2010-05-18 15:49:47 UTC (rev 475) @@ -24,7 +24,9 @@ $this->gfObj->debugPrintOpt=1; $filesDir = dirname(__FILE__) ."/files"; - define('TEST_FILESDIR', $filesDir); + if(!defined('TEST_FILESDIR')) { + define('TEST_FILESDIR', $filesDir); + } }//end __construct() //------------------------------------------------------------------------- @@ -68,7 +70,7 @@ foreach($sc->get_valid_sections() as $section) { $sectionData = $sc->get_section($section); foreach($sectionData as $name=>$value) { - if(is_array($value['attributes'])) { + if(isset($value['attributes']) && is_array($value['attributes'])) { if(isset($value['attributes']['SETGLOBAL'])) { $setAsGlobals[$name] = $value['value']; } @@ -247,6 +249,17 @@ + //------------------------------------------------------------------------- + public function test_contentSystem () { + + $content = new contentSystem(dirname(__FILE__) .'/files'); + $content->inject_var('testObj', $this); + $content->finish(); + }//end test_contentSystem() + //------------------------------------------------------------------------- + + + }//end TestOfCSContent //============================================================================= ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2011-11-23 23:49:04
|
Revision: 507 http://cs-content.svn.sourceforge.net/cs-content/?rev=507&view=rev Author: crazedsanity Date: 2011-11-23 23:48:55 +0000 (Wed, 23 Nov 2011) Log Message: ----------- *** RELEASE 1.0.1 *** Summary of changes: * changes for CLI use * new local variables (e.g. $fullSectionArr) * fixes for PHP warnings/notices * remove deprecated PHP functions * __autoload hints to avoid slowness on sluggish disks with lots of classes * many more unit tests * script to (attempt to) automatically create __autoload hints file * minor cookie tweaks * tweaks for filesystem stuff (such as mkdir) * no empty indexes in local "sectionArr" variable/array Modified Paths: -------------- releases/1.0/VERSION releases/1.0/__autoload.php 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_session.class.php releases/1.0/sample_files/templates/menu.shared.tmpl releases/1.0/tests/testOfCSGlobalFunctions.php Added Paths: ----------- releases/1.0/bin/ releases/1.0/bin/generateHints.bash releases/1.0/notifications/ releases/1.0/notifications/css/ releases/1.0/notifications/css/images/ releases/1.0/notifications/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png releases/1.0/notifications/css/images/ui-bg_diagonals-thick_20_666666_40x40.png releases/1.0/notifications/css/images/ui-bg_flat_10_000000_40x100.png releases/1.0/notifications/css/images/ui-bg_glass_100_f6f6f6_1x400.png releases/1.0/notifications/css/images/ui-bg_glass_100_fdf5ce_1x400.png releases/1.0/notifications/css/images/ui-bg_glass_65_ffffff_1x400.png releases/1.0/notifications/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png releases/1.0/notifications/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png releases/1.0/notifications/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png releases/1.0/notifications/css/images/ui-icons_222222_256x240.png releases/1.0/notifications/css/images/ui-icons_228ef1_256x240.png releases/1.0/notifications/css/images/ui-icons_ef8c08_256x240.png releases/1.0/notifications/css/images/ui-icons_ffd27a_256x240.png releases/1.0/notifications/css/images/ui-icons_ffffff_256x240.png releases/1.0/notifications/css/jquery-ui-1.7.3.custom.css releases/1.0/notifications/includes/ releases/1.0/notifications/js/ releases/1.0/notifications/js/jquery-1.6.2.min.js releases/1.0/notifications/js/jquery-ui-1.7.3.custom.min.js releases/1.0/notifications/js/notifications.js releases/1.0/notifications/views/ releases/1.0/notifications/views/index.php releases/1.0/useForCLI.patch Removed Paths: ------------- releases/1.0/bin/generateHints.bash releases/1.0/notifications/css/ releases/1.0/notifications/css/images/ releases/1.0/notifications/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png releases/1.0/notifications/css/images/ui-bg_diagonals-thick_20_666666_40x40.png releases/1.0/notifications/css/images/ui-bg_flat_10_000000_40x100.png releases/1.0/notifications/css/images/ui-bg_glass_100_f6f6f6_1x400.png releases/1.0/notifications/css/images/ui-bg_glass_100_fdf5ce_1x400.png releases/1.0/notifications/css/images/ui-bg_glass_65_ffffff_1x400.png releases/1.0/notifications/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png releases/1.0/notifications/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png releases/1.0/notifications/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png releases/1.0/notifications/css/images/ui-icons_222222_256x240.png releases/1.0/notifications/css/images/ui-icons_228ef1_256x240.png releases/1.0/notifications/css/images/ui-icons_ef8c08_256x240.png releases/1.0/notifications/css/images/ui-icons_ffd27a_256x240.png releases/1.0/notifications/css/images/ui-icons_ffffff_256x240.png releases/1.0/notifications/css/jquery-ui-1.7.3.custom.css releases/1.0/notifications/includes/ releases/1.0/notifications/js/ releases/1.0/notifications/js/jquery-1.6.2.min.js releases/1.0/notifications/js/jquery-ui-1.7.3.custom.min.js releases/1.0/notifications/js/notifications.js releases/1.0/notifications/views/ releases/1.0/notifications/views/index.php Property Changed: ---------------- releases/1.0/ Property changes on: releases/1.0 ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/1.0:464-474 + /trunk/1.0:464-500 /trunk/current:501-506 Modified: releases/1.0/VERSION =================================================================== --- releases/1.0/VERSION 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/VERSION 2011-11-23 23:48:55 UTC (rev 507) @@ -1,5 +1,6 @@ ## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. -VERSION: 1.0-RC1 +VERSION: 1.0.1 PROJECT: cs-content $HeadURL$ + Modified: releases/1.0/__autoload.php =================================================================== --- releases/1.0/__autoload.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/__autoload.php 2011-11-23 23:48:55 UTC (rev 507) @@ -21,71 +21,106 @@ function __autoload($class) { - $tried = array(); + $tried = array(); + + $fsRoot = dirname(__FILE__) .'/../../'; + if(defined('LIBDIR')) { + $fsRoot = constant('LIBDIR'); + } + $fs = new cs_fileSystem($fsRoot); + $fs->cd('lib'); + if(!_autoload_hints_parser($class, $fs)) { + $lsData = $fs->ls(null,false); - $fsRoot = dirname(__FILE__) .'/../../'; - if(defined('LIBDIR')) { - $fsRoot = constant('LIBDIR'); - } - $fs = new cs_fileSystem($fsRoot); - - //try going into a "lib" directory. - $fs->cd('lib'); - $lsData = $fs->ls(); - //attempt to find it here... $tryThis = array(); if(preg_match('/[aA]bstract/', $class)) { $myClass = preg_replace('/[aA]bstract/', '', $class); $tryThis[] = $class .'.abstract.class.php'; $tryThis[] = $myClass .'.abstract.class.php'; - $tryThis[] = 'abstract/'. $myClass .'.abstract.class.php'; } $tryThis[] = $class .'.class.php'; $tryThis[] = $class .'Class.php'; $tryThis[] = $class .'.php'; - $found=false; - foreach($tryThis as $filename) { - if(isset($lsData[$filename])) { - $tried[] = $fs->realcwd .'/'. $filename; - require_once($fs->realcwd .'/'. $filename); + _autoload_directory_checker($fs, $class, $tryThis); + if(!class_exists($class)) { + $gf = new cs_globalFunctions; + $gf->debug_print(__FILE__ ." - line #". __LINE__ ."::: couldn't find (". $class ."), realcwd=(". $fs->realcwd .")",1); + $gf->debug_print($tried,1); + $gf->debug_print($tryThis,1); + if(function_exists('cs_debug_backtrace')) { + cs_debug_backtrace(1); + } + exit; + } + } +}//end __autoload() + +function _autoload_hints_parser($class, $fs) { + $foundClass=false; + if(defined('AUTOLOAD_HINTS') && file_exists(constant('AUTOLOAD_HINTS'))) { + $data = $fs->read(constant('AUTOLOAD_HINTS'),true); + $myHints = array(); + foreach($data as $s) { + $bits = explode('|', rtrim($s)); + if(count($bits) == 2) { + $myHints[$bits[1]] = $bits[0]; + } + } + #print "<pre>"; + #print_r($myHints); + if(isset($myHints[$class])) { + $tryFile = constant('LIBDIR') .'/'. $myHints[$class]; + if(file_exists($tryFile)) { + require_once($tryFile); if(class_exists($class)) { - $found=true; - break; + $foundClass=true; } } } - - if(!$found) { - //try going into sub-directories to pull the files. - foreach($lsData as $i=>$d) { - if($d['type'] == 'dir') { - $subLs = $fs->ls($i); - foreach($tryThis as $filename) { - $fileLocation = $fs->realcwd .'/'. $i .'/'. $filename; - if(file_exists($fileLocation)) { - $tried[] = $fileLocation; - require_once($fileLocation); - if(class_exists($class)) { - $found=true; - break; - } - } + } + return($foundClass); +}//end _autoload_hints_parser() + + +function _autoload_directory_checker($fs, $class, $lookForFiles) { + $lsData = $fs->ls(null,false); + $dirNames = array(); + $curDirectory = $fs->realcwd; + + $found = false; + + if(is_array($lsData)) { + foreach($lsData as $objectName => $objectData) { + if($objectData['type'] == 'dir') { + $dirNames[] = $objectName; + } + elseif($objectData['type'] == 'file') { + if(in_array($objectName, $lookForFiles)) { + require_once($fs->realcwd .'/'. $objectName); + if(class_exists($class)) { + $found = true; + break; } } - if($found) { - break; - } } } + } - if(!$found) { - $gf = new cs_globalFunctions; - $gf->debug_print(__FILE__ ." - line #". __LINE__ ."::: couldn't find (". $class .")",1); - $gf->debug_print($tried,1); - $gf->debug_print($tryThis,1); - exit; + if(!$found && is_array($dirNames) && count($dirNames)) { + foreach($dirNames as $dir) { + $fs->cd($dir); + $found = _autoload_directory_checker($fs, $class, $lookForFiles); + $fs->cdup(); + + if($found === true) { + break; + } + } } -}//end __autoload() + + return($found); +} + ?> Deleted: releases/1.0/bin/generateHints.bash =================================================================== --- trunk/1.0/bin/generateHints.bash 2011-07-20 00:52:09 UTC (rev 500) +++ releases/1.0/bin/generateHints.bash 2011-11-23 23:48:55 UTC (rev 507) @@ -1,3 +0,0 @@ -#!/bin/bash -grep -i "^class " * -R --exclude=*.svn* --exclude=*.tmp| grep -e ".php" -e ".inc" | cut --delimiter=" " --fields 1,2 | sed "s/class //" | sed "s/:/\|/" | sed "s/{//" -grep -i "^abstract class " * -R --exclude=*.svn* --exclude=*.tmp| grep -e ".php" -e ".inc" | cut --delimiter=" " --fields 1,3 | sed "s/abstract //" | sed "s/:/\|/" | sed "s/{//" Copied: releases/1.0/bin/generateHints.bash (from rev 500, trunk/1.0/bin/generateHints.bash) =================================================================== --- releases/1.0/bin/generateHints.bash (rev 0) +++ releases/1.0/bin/generateHints.bash 2011-11-23 23:48:55 UTC (rev 507) @@ -0,0 +1,3 @@ +#!/bin/bash +grep -i "^class " * -R --exclude=*.svn* --exclude=*.tmp| grep -e ".php" -e ".inc" | cut --delimiter=" " --fields 1,2 | sed "s/class //" | sed "s/:/\|/" | sed "s/{//" +grep -i "^abstract class " * -R --exclude=*.svn* --exclude=*.tmp| grep -e ".php" -e ".inc" | cut --delimiter=" " --fields 1,3 | sed "s/abstract //" | sed "s/:/\|/" | sed "s/{//" Modified: releases/1.0/contentSystem.class.php =================================================================== --- releases/1.0/contentSystem.class.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/contentSystem.class.php 2011-11-23 23:48:55 UTC (rev 507) @@ -99,18 +99,22 @@ /** * The CONSTRUCTOR. Duh. */ - public function __construct($siteRoot=null) { + public function __construct($siteRoot=null, $section=null) { parent::__construct(); //setup the section stuff... $repArr = array($_SERVER['SCRIPT_NAME'], "/"); - $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); + $_SERVER['REQUEST_URI'] = preg_replace('/^\//', "", $_SERVER['REQUEST_URI']); //figure out the section & subsection stuff. $requestUri = preg_replace('/\/$/', '', $_SERVER['REQUEST_URI']); - $this->fullSectionArr = split('/', $requestUri); //TODO: will this cope with an APPURL being set? - $this->section = $this->clean_url($_SERVER['REQUEST_URI']); + $this->fullSectionArr = explode('/', $requestUri); //TODO: will this cope with an APPURL being set? + if(is_null($section)) { + $section = @$_SERVER['REQUEST_URI']; + } + $this->section = $this->clean_url($section); + $this->initialize_locals($siteRoot); }//end __construct() //------------------------------------------------------------------------ @@ -298,7 +302,7 @@ 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); + $myArr = explode('/', $this->section); //if we've got something in the array, keep going. if(is_array($myArr) && count($myArr) > 0) { @@ -327,51 +331,17 @@ } //make sure we've still got something valid to work with. - if(!strlen($section)) { - //TODO: remove the extra return statement (should only be one at the bottom of the method). - return(NULL); - } - else { - - //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); + if(strlen($section)) { + try { + $section = $this->gfObj->clean_url($section); } - - //check the string to make sure it doesn't begin with a "/" - if($section[0] == '/') { - $section = substr($section, 1, strlen($section)); + catch(Exception $e) { + //hide the exception and allow it to return NULL. } - - //check the last char for a "/"... - if($section[strlen($section) -1] == '/') { - //last char is a '/'... kill it. - $section = substr($section, 0, strlen($section) -1); - } - - //if we've been sent a query, kill it off the string... - if(preg_match('/\?/', $section)) { - $section = split('\?', $section); - $section = $section[0]; - } - - if(ereg("\.", $section)) { - //disregard file extensions, but keep everything else... - // i.e. "index.php/yermom.html" becomes "index/yermom" - $tArr = split('/', $section); - foreach($tArr as $tSecName) { - $temp = split("\.", $tSecName); - if(strlen($temp[0]) > 1) { - $tSecName = $temp[0]; - } - $tSection = $this->gfObj->create_list($tSection, $tSecName, '/'); - } - $section = $tSection; - } } - + else { + $section = null; + } return($section); }//end clean_url() //------------------------------------------------------------------------ @@ -567,7 +537,7 @@ * name, or vice-versa. */ private function arrange_directory_contents($primaryIndex='section', $secondaryIndex='name') { - $directoryInfo = $this->tmplFs->ls(); + $directoryInfo = $this->tmplFs->ls(null,false); $arrangedArr = array(); if(is_array($directoryInfo)) { foreach($directoryInfo as $index=>$data) { @@ -673,7 +643,7 @@ $mySection = preg_replace('/\/index$/','', $mySection); } if($this->incFs->cd('/'. $mySection)) { - $lsData = $this->incFs->ls(); + $lsData = $this->incFs->ls(null,false); if(isset($lsData['shared.inc']) && is_array($lsData['shared.inc'])) { $this->add_include('shared.inc'); } @@ -695,7 +665,7 @@ * solely by load_includes(). */ private function load_dir_includes($section) { - $lsData = $this->incFs->ls(); + $lsData = $this->incFs->ls(null,false); $addThese = array(); @@ -735,8 +705,10 @@ * Called when something is broken. */ private function die_gracefully($details=NULL) { - if(isset($_SERVER['SERVER_PROTOCOL']) && $this->templateObj->template_file_exists('system/404.shared.tmpl')) { - header('HTTP/1.0 404 Not Found'); + if($this->templateObj->template_file_exists('system/404.shared.tmpl')) { + if(isset($_SERVER['SERVER_PROTOCOL'])) { + 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')); @@ -802,6 +774,9 @@ //make the "final section" available to scripts. $finalSection = $this->finalSection; $sectionArr = $this->sectionArr; + if(count($sectionArr) && $sectionArr[(count($sectionArr)-1)] == "") { + array_pop($sectionArr); + } $fullSectionArr = $this->fullSectionArr; array_unshift($sectionArr, $this->baseDir); $finalURL = $this->gfObj->string_from_array($sectionArr, NULL, '/'); Modified: releases/1.0/cs_fileSystem.class.php =================================================================== --- releases/1.0/cs_fileSystem.class.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/cs_fileSystem.class.php 2011-11-23 23:48:55 UTC (rev 507) @@ -134,9 +134,10 @@ /** * Just like the linux version of the 'ls' command. */ - public function ls($filename=NULL, $args=NULL) { + public function ls($filename=NULL, $extendedInfo=true) { clearstatcache(); + $retval = null; //open the directory for reading. $this->dh = opendir($this->realcwd); clearstatcache(); @@ -145,13 +146,13 @@ $tFile=$this->filename2absolute($filename); if(file_exists($tFile)) { //it's there... get info about it. - $info = $this->get_fileinfo($tFile); + $info = $this->get_fileinfo($tFile, $extendedInfo); if($info['type'] == 'dir') { $oldCwd = $this->cwd; $oldRealCwd = $this->realcwd; $this->cd($filename); - $retval = $this->ls(); + $retval = $this->ls(null, $extendedInfo); $this->cwd = $oldCwd; $this->realcwd = $oldRealCwd; @@ -175,13 +176,10 @@ debug_print("FILE: $tFile || TYPE: $tType || is_file(): ". is_file($tFile) ."is_dir(): ". is_dir($tFile)); exit; } - #debug_print("FILE: $file || $dir". $file); unset($tType); } } } - #debug_print($retval); - #debug_print(readdir($this->dh)); return($retval); }//end ls() //======================================================================================== @@ -191,23 +189,25 @@ /** * Grabs an array of information for a given file. */ - public function get_fileinfo($tFile) { + public function get_fileinfo($tFile,$extendedInfo=true) { //TODO: shouldn't require putting the "@" in front of these calls! $retval = array( - "size" => @filesize($tFile), "type" => @filetype($tFile), - "accessed" => @fileatime($tFile), - "modified" => @filemtime($tFile), - "owner" => @$this->my_getuser_group(fileowner($tFile), 'uid'), - "uid" => @fileowner($tFile), - "group" => @$this->my_getuser_group(filegroup($tFile), 'gid'), - "gid" => @filegroup($tFile), - "perms" => @$this->translate_perms(fileperms($tFile)), - "perms_num" => @substr(sprintf('%o', fileperms($tFile)), -4), "is_readable" => is_readable($tFile), "is_writable" => is_writable($tFile) ); + if($extendedInfo) { + $retval["size"] = @filesize($tFile); + $retval["accessed"] = @fileatime($tFile); + $retval["modified"] = @filemtime($tFile); + $retval["owner"] = @$this->my_getuser_group(fileowner($tFile), 'uid'); + $retval["uid"] = @fileowner($tFile); + $retval["group"] = @$this->my_getuser_group(filegroup($tFile), 'gid'); + $retval["gid"] = @filegroup($tFile); + $retval["perms"] = @$this->translate_perms(fileperms($tFile)); + $retval["perms_num"]= @substr(sprintf('%o', fileperms($tFile)), -4); + } return($retval); }//end get_fileinfo() @@ -903,8 +903,8 @@ //======================================================================================== public function mkdir($name, $mode=0777) { - if(!is_numeric($mode) || strlen($mode) != 4) { - $mode = 0777; + if(isset($mode)) { + $mode = intval($mode); } $retval = NULL; if(!is_null($name) && strlen($name)) { Modified: releases/1.0/cs_genericPage.class.php =================================================================== --- releases/1.0/cs_genericPage.class.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/cs_genericPage.class.php 2011-11-23 23:48:55 UTC (rev 507) @@ -277,7 +277,7 @@ if(!strlen($out)) { $this->gfObj->debug_print($out); $this->gfObj->debug_print($this->mainTemplate); - $this->gfObj->debug_print("MANUAL FILE CONTENTS::: ". htmlentities(file_get_contents($this->tmplDir .'/'. $this->mainTemplate))); + $this->gfObj->debug_print("MANUAL FILE CONTENTS::: ". htmlentities(file_get_contents($this->mainTemplate))); exit(__METHOD__ .": mainTemplate (". $this->mainTemplate .") was empty...?"); } Modified: releases/1.0/cs_globalFunctions.class.php =================================================================== --- releases/1.0/cs_globalFunctions.class.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/cs_globalFunctions.class.php 2011-11-23 23:48:55 UTC (rev 507) @@ -176,7 +176,12 @@ } else { //now format it properly. - $array[$myIndex] = $this->cleanString($array[$myIndex], $myCleanStringArg); + $myUseSqlQuotes = null; + if(in_array($myCleanStringArg, array('int', 'integer', 'numeric', 'number', 'decimal', 'float'))) { + $myUseSqlQuotes = false; + } + $array[$myIndex] = $this->cleanString($array[$myIndex], $myCleanStringArg, $myUseSqlQuotes); + unset($myUseSqlQuotes); } } } @@ -398,6 +403,8 @@ break; + case "varchar": + case "text": case "sql_insert": /* * This is for descriptive fields, where double quotes don't need to be escaped: in these @@ -497,9 +504,10 @@ $cleanThis = preg_replace("/[^A-Za-z0-9\._@-]/","",$cleanThis); break; + case "email_plus": case "email_plus_spaces": //Remove all characters that aren't allowed in an email address. - $cleanThis = preg_replace("/[^A-Za-z0-9\ \._@-]/","",$cleanThis); + $cleanThis = preg_replace("/[^A-Za-z0-9\ \._@:-]/","",$cleanThis); break; case "phone_fax": @@ -507,15 +515,17 @@ $cleanThis = preg_replace("/[^0-9-+() ]/","",$cleanThis); break; + case "int": case "integer": case "numeric": + case "number": //Remove everything that's not numeric. if(is_null($cleanThis)) { $cleanThis = "NULL"; $sqlQuotes = 0; } else { - $cleanThis = preg_replace("/[^0-9]/","",$cleanThis); + $cleanThis = preg_replace("/[^0-9\-]/","",$cleanThis); } break; @@ -542,14 +552,6 @@ $cleanThis = $this->interpret_bool($cleanThis, array('f', 't')); break; - case "varchar": - $cleanThis=$this->cleanString($cleanThis,"query"); - $cleanThis="'" . $cleanThis . "'"; - if($cleanThis == "''") { - $cleanThis="NULL"; - } - break; - case "date": $cleanThis = preg_replace("/[^0-9\-]/","",$cleanThis); break; @@ -610,7 +612,7 @@ * * @return (string) printed data. */ - public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL) { + public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL, $usePreTags=true) { if(!is_numeric($removeHR)) { $removeHR = $this->debugRemoveHr; } @@ -623,9 +625,11 @@ print_r($input); $output = ob_get_contents(); ob_end_clean(); - - $output = "<pre>$output</pre>"; + if($usePreTags === true) { + $output = "<pre>$output</pre>"; + } + if(!isset($_SERVER['SERVER_PROTOCOL']) || !$_SERVER['SERVER_PROTOCOL']) { $output = strip_tags($output); $hrString = "\n***************************************************************\n"; @@ -683,12 +687,18 @@ $b="{"; $e="}"; } - - foreach($repArr as $key=>$value) { - //run the replacements. - $key = "$b" . $key . "$e"; - $template = str_replace("$key", $value, $template); + + if(is_array($repArr)) { + foreach($repArr as $key=>$value) { + //run the replacements. + $key = "$b" . $key . "$e"; + $template = str_replace("$key", $value, $template); + } } + else { + cs_debug_backtrace(1); + throw new exception(__METHOD__ .": no replacement array passed, or array was empty"); + } return($template); }//end mini_parser() @@ -863,7 +873,64 @@ return($this->debug_print($printThis, $printItForMe, $removeHr)); }//end debug_var_dump() //########################################################################## + + + + //------------------------------------------------------------------------ + /** + * Removes all the crap from the url, so we can figure out what section we + * need to load templates & includes for. + */ + public function clean_url($url=NULL) { + //make sure we've still got something valid to work with. + if(strlen($url)) { + //if there's an "APPURL" constant, drop that from the url. + if(defined('APPURL') && strlen(constant('APPURL'))) { + $dropThis = preg_replace('/^\//', '', constant('APPURL')); + $dropThis = preg_replace('/\//', '\\/', $dropThis); + $url = preg_replace('/^'. $dropThis .'/', '', $url); + } + + //check the string to make sure it doesn't begin with a "/" + if($url[0] == '/') { + $url = substr($url, 1, strlen($url)); + } + + //check the last char for a "/"... + if($url[strlen($url) -1] == '/') { + //last char is a '/'... kill it. + $url = substr($url, 0, strlen($url) -1); + } + + //if we've been sent a query, kill it off the string... + if(preg_match('/\?/', $url)) { + $url = split('\?', $url); + $url = $url[0]; + } + + if(preg_match("/\./", $url)) { + //disregard file extensions, but keep everything else... + // i.e. "index.php/yermom.html" becomes "index/yermom" + $tArr = explode('/', $url); + $tUrl = null; + foreach($tArr as $tUrlPart) { + $temp = explode(".", $tUrlPart); + if(strlen($temp[0])) { + $tUrlPart = $temp[0]; + } + $tUrl = $this->create_list($tUrl, $tUrlPart, '/'); + } + $url = $tUrl; + } + } + else { + $url = null; + } + return($url); + }//end clean_url() + //------------------------------------------------------------------------ + }//end cs_globalFunctions{} ?> Modified: releases/1.0/cs_session.class.php =================================================================== --- releases/1.0/cs_session.class.php 2011-11-23 23:42:31 UTC (rev 506) +++ releases/1.0/cs_session.class.php 2011-11-23 23:48:55 UTC (rev 507) @@ -24,14 +24,26 @@ */ function __construct($createSession=true) { parent::__construct(true); + $sessName = null; + $sessionId = null; if($createSession) { if(is_string($createSession) && strlen($createSession) >2) { + $sessName = $createSession; session_name($createSession); } + elseif(defined('SESSION_NAME') && constant('SESSION_NAME') && isset($_COOKIE) && isset($_COOKIE[constant('SESSION_NAME')])) { + $sessName = constant('SESSION_NAME'); + session_name(constant('SESSION_NAME')); + $sessionId = $_COOKIE[constant('SESSION_NAME')]; + session_id($sessionId); + } //now actually create the session. @session_start(); } + if(is_null($sessName)) { + $sessName = session_name(); + } //check if there's a uid in the session already. //TODO: need a setting somewhere that says what the name of this var should be, @@ -76,7 +88,7 @@ */ public function get_cookie($name) { $retval = NULL; - if(isset($_COOKIE) && $_COOKIE[$name]) { + if(isset($_COOKIE) && isset($_COOKIE[$name])) { $retval = $_COOKIE[$name]; } return($retval); @@ -93,7 +105,7 @@ * @param $value (string) value of cookie * @param $expiration (string/number) unix timestamp or value for strtotime(). */ - public function create_cookie($name, $value, $expiration=NULL) { + public function create_cookie($name, $value, $expiration=NULL, $path=NULL, $domain=NULL) { $expTime = NULL; if(!is_null($expiration)) { @@ -108,7 +120,16 @@ } } - $retval = setcookie($name, $value, $expTime, '/'); + if(is_null($domain)) { + $bits = explode('.', $_SERVER['SERVER_NAME']); + if(count($bits) > 1) { + $tldBit = $bits[count($bits)-1]; + $domBit = $bits[count($bits)]; + $domain = '.'. $domBit .'.'. $tldBit; + } + } + + $retval = setcookie($name, $value, $expTime, $path, $domain); return($retval); }//end create_cookie() @@ -151,4 +172,4 @@ }//end cs_session{} -?> \ No newline at end of file +?> Property changes on: releases/1.0/notifications ___________________________________________________________________ Added: svn:ignore + .buildpath .project .settings Added: bugtraq:number + true Property changes on: releases/1.0/notifications/css ___________________________________________________________________ Added: bugtraq:number + true Property changes on: releases/1.0/notifications/css/images ___________________________________________________________________ Added: bugtraq:number + true Deleted: releases/1.0/notifications/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_diagonals-thick_20_666666_40x40.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_diagonals-thick_20_666666_40x40.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_diagonals-thick_20_666666_40x40.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_flat_10_000000_40x100.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_flat_10_000000_40x100.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_flat_10_000000_40x100.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_glass_100_f6f6f6_1x400.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_glass_100_f6f6f6_1x400.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_glass_100_f6f6f6_1x400.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_glass_100_fdf5ce_1x400.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_glass_100_fdf5ce_1x400.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_glass_100_fdf5ce_1x400.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_glass_65_ffffff_1x400.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_glass_65_ffffff_1x400.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_glass_65_ffffff_1x400.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png (from rev 500, trunk/1.0/notifications/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-icons_222222_256x240.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-icons_222222_256x240.png (from rev 500, trunk/1.0/notifications/css/images/ui-icons_222222_256x240.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-icons_228ef1_256x240.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-icons_228ef1_256x240.png (from rev 500, trunk/1.0/notifications/css/images/ui-icons_228ef1_256x240.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-icons_ef8c08_256x240.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-icons_ef8c08_256x240.png (from rev 500, trunk/1.0/notifications/css/images/ui-icons_ef8c08_256x240.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-icons_ffd27a_256x240.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-icons_ffd27a_256x240.png (from rev 500, trunk/1.0/notifications/css/images/ui-icons_ffd27a_256x240.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/images/ui-icons_ffffff_256x240.png =================================================================== (Binary files differ) Copied: releases/1.0/notifications/css/images/ui-icons_ffffff_256x240.png (from rev 500, trunk/1.0/notifications/css/images/ui-icons_ffffff_256x240.png) =================================================================== (Binary files differ) Deleted: releases/1.0/notifications/css/jquery-ui-1.7.3.custom.css =================================================================== --- trunk/1.0/notifications/css/jquery-ui-1.7.3.custom.css 2011-07-20 00:52:09 UTC (rev 500) +++ releases/1.0/notifications/css/jquery-ui-1.7.3.custom.css 2011-11-23 23:48:55 UTC (rev 507) @@ -1,405 +0,0 @@ -/* -* jQuery UI CSS Framework -* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) -* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. -*/ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - -/* -* jQuery UI CSS Framework -* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) -* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. -* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px -*/ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; } -.ui-widget-content a { color: #333333; } -.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; outline: none; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; outline: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; outline: none; } -.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; outline: none; } -.ui-state-active, .ui-widget-content .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; outline: none; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; outline: none; text-decoration: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a { color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; } -.ui-state-error a, .ui-widget-content .ui-state-error a { color: #ffffff; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text { color: #ffffff; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; } -.ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; } -.ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; } -.ui-corner-top { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; } -.ui-corner-right { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; } -.ui-corner-left { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; } -.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; } - -/* Overlays */ -.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); } -.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -webkit-border-radius: 5px; }/* Resizable -----------------------------------*/ -.ui-resizable { position: relative;} -.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } -.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0px; } -.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0px; } -.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0px; height: 100%; } -.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0px; height: 100%; } -.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } -.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } -.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } -.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* Accordion -----------------------------------*/ -.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; } -.ui-accordion .ui-accordion-li-fix { display: inline; } -.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; } -.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em 2.2em; } -.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } -.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; } -.ui-accordion .ui-accordion-content-active { display: block; }/* Dialog -----------------------------------*/ -.ui-dialog { position: relative; padding: .2em; width: 300px; } -.ui-dialog .ui-dialog-titlebar { padding: .5em .3em .3em 1em; position: relative; } -.ui-dialog .ui-dialog-title { float: left; margin: .1em 0 .2em; } -.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } -.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } -.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } -.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } -.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } -.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } -.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } -.ui-draggable .ui-dialog-titlebar { cursor: move; } -/* Slider -----------------------------------*/ -.ui-slider { position: relative; text-align: left; } -.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } -.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; } - -.ui-slider-horizontal { height: .8em; } -.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } -.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } -.ui-slider-horizontal .ui-slider-range-min { left: 0; } -.ui-slider-horizontal .ui-slider-range-max { right: 0; } - -.ui-slider-vertical { width: .8em; height: 100px; } -.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } -.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } -.ui-slider-vertical .ui-slider-range-min { bottom: 0; } -.ui-slider-vertical .ui-slider-range-max { top: 0; }/* Tabs -----------------------------------*/ -.ui-tabs { padding: .2em; zoom: 1; } -.ui-tabs .ui-tabs-nav { list-style: none; position: relative; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { position: relative; float: left; border-bottom-width: 0 !important; margin: 0 .2em -1px 0; padding: 0; } -.ui-tabs .ui-tabs-nav li a { float: left; text-decoration: none; padding: .5em 1em; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 1px; border-bottom-width: 0; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border-width: 0; background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } -/* Datepicker -----------------------------------*/ -.ui-datepicker { width: 17em; padding: .2em .2em 0; } -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; } -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group {... [truncated message content] |