cs-content-commits Mailing List for CS-Content [Dynamic Content System] (Page 5)
PHP Templating & Includes System
Brought to you by:
crazedsanity
You can subscribe to this list here.
2009 |
Jan
(32) |
Feb
(24) |
Mar
(5) |
Apr
(1) |
May
(14) |
Jun
(16) |
Jul
(11) |
Aug
(43) |
Sep
(9) |
Oct
(5) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(4) |
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(6) |
Feb
(3) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
(2) |
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <cra...@us...> - 2009-07-29 19:03:45
|
Revision: 412 http://cs-content.svn.sourceforge.net/cs-content/?rev=412&view=rev Author: crazedsanity Date: 2009-07-29 19:03:37 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Minor adjustment to add a bit of flexibility to tabs. /cs_tabs.class.php: * display_tabs(): -- add "cleanTitle" to the (small) list of things that can be parsed into the tab template: it is basically the title, but stripped-down to alphanumerics ONLY, with anything else replaced with underscores. -- NOTE::: in a title that has multiple replaced characters in a row, they will have the corresponding number of underscores. For instance, "My - Tab" would become "My___Tab". Modified Paths: -------------- trunk/1.0/cs_tabs.class.php Modified: trunk/1.0/cs_tabs.class.php =================================================================== --- trunk/1.0/cs_tabs.class.php 2009-07-22 04:54:48 UTC (rev 411) +++ trunk/1.0/cs_tabs.class.php 2009-07-29 19:03:37 UTC (rev 412) @@ -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, '%%', '%%'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-22 04:54:50
|
Revision: 411 http://cs-content.svn.sourceforge.net/cs-content/?rev=411&view=rev Author: crazedsanity Date: 2009-07-22 04:54:48 +0000 (Wed, 22 Jul 2009) Log Message: ----------- Fix a bad quoting issue. /cs_globalFunctions.class.php: * string_from_array(): -- (style=select) don't pass the forceSqlQuotes to create_list(). Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2009-07-21 03:21:21 UTC (rev 410) +++ trunk/1.0/cs_globalFunctions.class.php 2009-07-22 04:54:48 UTC (rev 411) @@ -282,7 +282,7 @@ if(!is_numeric($value) && 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-21 03:21:22
|
Revision: 410 http://cs-content.svn.sourceforge.net/cs-content/?rev=410&view=rev Author: crazedsanity Date: 2009-07-21 03:21:21 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Fix sql quoting, insert style to allows non-quoted NULLs, update gives error. /cs_globalFunctions.class.php: * switch_force_sql_quotes(): -- if there's no new setting but an old value exists, use that instead of throwing an exception. * string_from_array(): -- (style=insert): change the two "if" statements to if/elseif, where the "NULL" value doesn't have single quotes around it. /cs_phpDB.class.php: * run_update(): -- capture error if one exists -- throw a different exception on error. Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2009-07-20 21:57:33 UTC (rev 409) +++ trunk/1.0/cs_globalFunctions.class.php 2009-07-21 03:21:21 UTC (rev 410) @@ -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 .")"); } @@ -191,14 +194,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); } Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-20 21:57:33 UTC (rev 409) +++ trunk/1.0/cs_phpDB.class.php 2009-07-21 03:21:21 UTC (rev 410) @@ -165,9 +165,13 @@ public function run_update($sql, $zeroIsOk=false) { $this->exec($sql); + $dberror = $this->errorMsg(); $numAffected = $this->numAffected(); - if($numAffected==0 && $zeroIsOk == false) { + 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); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-20 21:57:34
|
Revision: 409 http://cs-content.svn.sourceforge.net/cs-content/?rev=409&view=rev Author: crazedsanity Date: 2009-07-20 21:57:33 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Fix run_insert() to work with pgsql (accidentally removed). Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-20 18:58:30 UTC (rev 408) +++ trunk/1.0/cs_phpDB.class.php 2009-07-20 21:57:33 UTC (rev 409) @@ -138,13 +138,13 @@ /** * Handles performing the insert statement & returning the last inserted ID. */ - public function run_insert($sql) { + 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(); + $retval = $this->lastID($sequence); } else { //something broke... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-20 18:58:32
|
Revision: 408 http://cs-content.svn.sourceforge.net/cs-content/?rev=408&view=rev Author: crazedsanity Date: 2009-07-20 18:58:30 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Add information for debugging, MySQL transactions shouldn't autocommit. /cs_phpDB.class.php: * run_update(): -- add the SQL string to the error so it can be debugged. /db_types/cs_phpDB__mysql.class.php: * beginTrans(): -- turn off autocommit so changes aren't committed unless the transaction actually succeeded. Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-20 05:26:02 UTC (rev 407) +++ trunk/1.0/cs_phpDB.class.php 2009-07-20 18:58:30 UTC (rev 408) @@ -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 { @@ -133,13 +138,13 @@ /** * Handles performing the insert statement & returning the last inserted ID. */ - public function run_insert($sql, $sequence='null') { + public function run_insert($sql) { $this->exec($sql); if($this->numAffected() == 1 && !strlen($this->errorMsg())) { //retrieve the ID just created. - $retval = $this->lastID($sequence); + $retval = $this->lastID(); } else { //something broke... @@ -163,13 +168,26 @@ $numAffected = $this->numAffected(); if($numAffected==0 && $zeroIsOk == false) { - throw new exception(__METHOD__ .": no rows updated (". $numAffected .")"); + 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: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-20 05:26:02 UTC (rev 407) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-20 18:58:30 UTC (rev 408) @@ -793,7 +793,7 @@ //========================================================================= public function beginTrans() { - $this->exec('BEGIN'); + $this->exec('BEGIN;SET autocommit=0;'); return(true); }//end beginTrans() //========================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-20 05:26:04
|
Revision: 407 http://cs-content.svn.sourceforge.net/cs-content/?rev=407&view=rev Author: crazedsanity Date: 2009-07-20 05:26:02 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Fix run_insert() for pgsql so the last ID can be found /cs_phpDB.class.php: * run_insert(): -- ARG CHANGE: NEW ARG: $sequence=null -- add sequence so lastID() works for pgsql Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-15 16:14:38 UTC (rev 406) +++ trunk/1.0/cs_phpDB.class.php 2009-07-20 05:26:02 UTC (rev 407) @@ -133,13 +133,13 @@ /** * Handles performing the insert statement & returning the last inserted ID. */ - public function run_insert($sql) { + 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(); + $retval = $this->lastID($sequence); } else { //something broke... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-15 16:14:41
|
Revision: 406 http://cs-content.svn.sourceforge.net/cs-content/?rev=406&view=rev Author: crazedsanity Date: 2009-07-15 16:14:38 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Transaction support for mysql (sort of). NOTE::: transactions only work for tables that are InnoDB... rolling back a transaction that is against tables that don't support transactions can/will cause data to become corrupted. /db_types/cs_phpDB__mysql.class.php: * beginTrans() [NEW]: -- sends "BEGIN" to the backend & always returns true * commitTrans() [NEW]: -- sends "COMMIT" to the backend, always returns true * rollbackTrans() [NEW]: -- sends "ROLLBACK" to the backend, always returns true Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-15 14:54:41 UTC (rev 405) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-15 16:14:38 UTC (rev 406) @@ -791,6 +791,31 @@ + //========================================================================= + public function beginTrans() { + $this->exec('BEGIN'); + 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 ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-15 14:54:46
|
Revision: 405 http://cs-content.svn.sourceforge.net/cs-content/?rev=405&view=rev Author: crazedsanity Date: 2009-07-15 14:54:41 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Var for the name of the configuration file itself in site config. /cs_siteConfig.class.php: * MAIN::: -- new private var, $configFile * __construct(): -- set internal configFile as $configFileLocation. * build_special_vars(): -- set special var for "_CONFIGFILE_" (points to the location of the configuration file, within which this directive is placed). -- another name for _CONFIGFILE_ is _THISFILE_ Modified Paths: -------------- trunk/1.0/cs_siteConfig.class.php Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-07-06 19:49:55 UTC (rev 404) +++ trunk/1.0/cs_siteConfig.class.php 2009-07-15 14:54:41 UTC (rev 405) @@ -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)); @@ -370,6 +374,8 @@ $specialVars = array( '_DIRNAMEOFFILE_' => $this->configDirname, + '_CONFIGFILE_' => $this->configFile, + '_THISFILE_' => $this->configFile, '_APPURL_' => $appUrl ); return($specialVars); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-06 19:50:01
|
Revision: 404 http://cs-content.svn.sourceforge.net/cs-content/?rev=404&view=rev Author: crazedsanity Date: 2009-07-06 19:49:55 +0000 (Mon, 06 Jul 2009) Log Message: ----------- Ability to ping connection to see if it's alive. /db_types/cs_phpDB__mysql.class.php: * ping() [NEW]: -- call (and return output of) mysql_ping() /db_types/cs_phpDB__pgsql.class.php: * ping [NEW]: -- call (and return output of) pg_ping() Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php trunk/1.0/db_types/cs_phpDB__pgsql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-06 16:02:22 UTC (rev 403) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-06 19:49:55 UTC (rev 404) @@ -283,7 +283,15 @@ + //========================================================================= + public function ping() { + return(mysql_ping($this->connectionID)); + }//end ping() + //========================================================================= + + + //////////////////// // Cursor movement //////////////////// Modified: trunk/1.0/db_types/cs_phpDB__pgsql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__pgsql.class.php 2009-07-06 16:02:22 UTC (rev 403) +++ trunk/1.0/db_types/cs_phpDB__pgsql.class.php 2009-07-06 19:49:55 UTC (rev 404) @@ -305,7 +305,15 @@ + //========================================================================= + public function ping() { + return(pg_ping($this->connectionID)); + }//end ping() + //========================================================================= + + + //////////////////// // Cursor movement //////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-07-06 16:02:29
|
Revision: 403 http://cs-content.svn.sourceforge.net/cs-content/?rev=403&view=rev Author: crazedsanity Date: 2009-07-06 16:02:22 +0000 (Mon, 06 Jul 2009) Log Message: ----------- Minor fixes for update logic. /cs_phpDB.class.php: * run_update() [NEW]: -- simple logic for running updates ("run_query()" fails, since it attempts to call numRows() without checking numAffected()). /db_types/cs_phpDB__mysql.class.php: * numRows(): -- return 0 if the result is null OR if it isn't a valid resource. Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-07-02 15:40:51 UTC (rev 402) +++ trunk/1.0/cs_phpDB.class.php 2009-07-06 16:02:22 UTC (rev 403) @@ -151,6 +151,25 @@ }//end run_insert() //========================================================================= + + + //========================================================================= + /** + * Performs the update & returns how many rows were affected. + */ + public function run_update($sql, $zeroIsOk=false) { + $this->exec($sql); + + $numAffected = $this->numAffected(); + + if($numAffected==0 && $zeroIsOk == false) { + throw new exception(__METHOD__ .": no rows updated (". $numAffected .")"); + } + + return($numAffected); + }//end run_update() + //========================================================================= + } // end class phpDB ?> Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-02 15:40:51 UTC (rev 402) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-07-06 16:02:22 UTC (rev 403) @@ -635,11 +635,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; } @@ -670,7 +669,6 @@ $retval = 0; } else { - //TODO: implement MySQL version.. $retval = mysql_num_fields($this->result); } return($retval); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-29 17:53:56
|
Revision: 401 http://cs-content.svn.sourceforge.net/cs-content/?rev=401&view=rev Author: crazedsanity Date: 2009-06-29 17:53:55 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Fix references to invalid method call. /cs_phpDB.class.php: * run_insert(): -- replace calls to exception_handler() with exceptions. * run_query(): -- replace calls to exception_handler() with exceptions. Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-06-29 17:28:31 UTC (rev 400) +++ trunk/1.0/cs_phpDB.class.php 2009-06-29 17:53:55 UTC (rev 401) @@ -116,11 +116,11 @@ $retval = false; } else { - $this->exception_handler(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); + throw new exception(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); } } else { - $this->exception_handler(__METHOD__ .": invalid length SQL (". $sql .")"); + throw new exception(__METHOD__ .": invalid length SQL (". $sql .")"); } return($retval); @@ -143,7 +143,7 @@ } else { //something broke... - $this->exception_handler(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " + throw new exception(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " ."ERROR::: ". $this->errorMsg() ."\n -- SQL:::: ". $sql); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-29 17:28:32
|
Revision: 400 http://cs-content.svn.sourceforge.net/cs-content/?rev=400&view=rev Author: crazedsanity Date: 2009-06-29 17:28:31 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Change protected method to public. /cs_phpDB.class.php: * run_insert(): -- changed from protected to public. Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-06-26 17:32:51 UTC (rev 399) +++ trunk/1.0/cs_phpDB.class.php 2009-06-29 17:28:31 UTC (rev 400) @@ -133,7 +133,7 @@ /** * Handles performing the insert statement & returning the last inserted ID. */ - protected function run_insert($sql) { + public function run_insert($sql) { $this->exec($sql); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-26 17:33:59
|
Revision: 399 http://cs-content.svn.sourceforge.net/cs-content/?rev=399&view=rev Author: crazedsanity Date: 2009-06-26 17:32:51 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Fix exception so it is more informative. /cs_siteConfig.class.php: * get_section(): -- give the referenced section when saying it is invalid or contains no data. Modified Paths: -------------- trunk/1.0/cs_siteConfig.class.php Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-06-25 21:32:15 UTC (rev 398) +++ trunk/1.0/cs_siteConfig.class.php 2009-06-26 17:32:51 UTC (rev 399) @@ -277,7 +277,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 { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-25 21:32:23
|
Revision: 398 http://cs-content.svn.sourceforge.net/cs-content/?rev=398&view=rev Author: crazedsanity Date: 2009-06-25 21:32:15 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Add simple methods for querying & running inserts + fix mysql lastID(). /cs_phpDB.class.php: * run_query() [NEW]: -- runs a query and returns data in the requested array format. * run_insert() [NEW]: -- runs an insert & returns the newly-created ID. /db_types/cs_phpDB__mysql.class.php: * lastID(): -- use internal connectionID to avoid problems with multiple connections. -- fix comment (referred to "lastOID()") Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-06-25 19:01:25 UTC (rev 397) +++ trunk/1.0/cs_phpDB.class.php 2009-06-25 21:32:15 UTC (rev 398) @@ -77,6 +77,80 @@ }//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 { + $this->exception_handler(__METHOD__ .": no rows (". $numRows .") or dbError::: ". $dbError ."<BR>\nSQL::: ". $sql); + } + } + else { + $this->exception_handler(__METHOD__ .": invalid length SQL (". $sql .")"); + } + + return($retval); + }//end run_query() + //========================================================================= + + + + //========================================================================= + /** + * Handles performing the insert statement & returning the last inserted ID. + */ + protected function run_insert($sql) { + + $this->exec($sql); + + if($this->numAffected() == 1 && !strlen($this->errorMsg())) { + //retrieve the ID just created. + $retval = $this->lastID(); + } + else { + //something broke... + $this->exception_handler(__METHOD__ .": failed to insert, rows=(". $this->numRows .")... " + ."ERROR::: ". $this->errorMsg() ."\n -- SQL:::: ". $sql); + } + + return($retval); + }//end run_insert() + //========================================================================= + } // end class phpDB ?> Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-25 19:01:25 UTC (rev 397) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-25 21:32:15 UTC (rev 398) @@ -692,9 +692,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() //========================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-25 19:01:49
|
Revision: 397 http://cs-content.svn.sourceforge.net/cs-content/?rev=397&view=rev Author: crazedsanity Date: 2009-06-25 19:01:25 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Allow selecting db on open connection (instead of doing a reconnect) /db_types/cs_phpDB__mysql.class.php: * select_db() [NEW]: -- select a different database. -- NOTE: this changes the internal "dbname" var on success, and throws an exception on failure. Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-19 14:20:16 UTC (rev 396) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-25 19:01:25 UTC (rev 397) @@ -772,6 +772,19 @@ + //========================================================================= + 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() + //========================================================================= + + + } // end class phpDB ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-19 14:20:17
|
Revision: 396 http://cs-content.svn.sourceforge.net/cs-content/?rev=396&view=rev Author: crazedsanity Date: 2009-06-19 14:20:16 +0000 (Fri, 19 Jun 2009) Log Message: ----------- A few fixes for the mysql database layer. /db_types/cs_phpDB__mysql.class.php: * close(): -- resent transStatus, inTrans, and transactionTree. * connect(): -- only check if paramsAreSet, so the connection can be reset (i.e. a new connection can be created). Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-17 15:19:02 UTC (rev 395) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-19 14:20:16 UTC (rev 396) @@ -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(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-17 15:19:04
|
Revision: 395 http://cs-content.svn.sourceforge.net/cs-content/?rev=395&view=rev Author: crazedsanity Date: 2009-06-17 15:19:02 +0000 (Wed, 17 Jun 2009) Log Message: ----------- Minor changes to pgsql layer for compatibility with mysql layer. NOTE::: the main cs_phpDB class should have an abstract class or interface that defines all methods, etc that are required to work with it, so there is an easy-to-identify standard list of method names. /cs_phpDB.class.php: * get_dbtype() [NEW]: -- returns internal private $dbType /db_types/cs_phpDB__pgsql.class.php: * lastID() [NEW]: -- for compatibility with mysql calls (except this requires the sequence name; without some fancy SQL to retrieve the given sequence, any code attempting to use this will have to be coded around PostgreSQL so it knows the sequence name, or will have to build its schema so the sequence name is known and ALWAYS pass it). Modified Paths: -------------- trunk/1.0/cs_phpDB.class.php trunk/1.0/db_types/cs_phpDB__pgsql.class.php Modified: trunk/1.0/cs_phpDB.class.php =================================================================== --- trunk/1.0/cs_phpDB.class.php 2009-06-12 13:52:39 UTC (rev 394) +++ trunk/1.0/cs_phpDB.class.php 2009-06-17 15:19:02 UTC (rev 395) @@ -69,6 +69,14 @@ }//end __call() //========================================================================= + + + //========================================================================= + public function get_dbtype() { + return($this->dbType); + }//end get_dbtype() + //========================================================================= + } // end class phpDB ?> Modified: trunk/1.0/db_types/cs_phpDB__pgsql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__pgsql.class.php 2009-06-12 13:52:39 UTC (rev 394) +++ trunk/1.0/db_types/cs_phpDB__pgsql.class.php 2009-06-17 15:19:02 UTC (rev 395) @@ -1115,6 +1115,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 ?> 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:15:01
|
Revision: 393 http://cs-content.svn.sourceforge.net/cs-content/?rev=393&view=rev Author: crazedsanity Date: 2009-06-12 13:31:08 +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 VERSIONS::: r363:392 Modified Paths: -------------- trunk/1.0/VERSION Modified: trunk/1.0/VERSION =================================================================== --- trunk/1.0/VERSION 2009-06-11 15:22:55 UTC (rev 392) +++ trunk/1.0/VERSION 2009-06-12 13:31:08 UTC (rev 393) @@ -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 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-06-11 15:22:57
|
Revision: 392 http://cs-content.svn.sourceforge.net/cs-content/?rev=392&view=rev Author: crazedsanity Date: 2009-06-11 15:22:55 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fix to automatically detect APPURL so it can be added to the config. NOTE::: maybe cs_siteConfig should just set the constant? Seems rather convoluted to derive where their app lives, only to allow them to put the value into a configuration file...? Future consideration, anyway. /cs_siteConfig.class.php: * parse_config(): -- the $specialVars array is created by build_special_vars(). * build_special_vars() [NEW]: -- creates the array of special vars that can be put into the config file, such as the old _DIRNAMEOFFILE_. -- this now creates "_APPURL_", which can be used to define the standard "APPURL" constant required by cs-content when the app is in a non-root subdirectory. Modified Paths: -------------- trunk/1.0/cs_siteConfig.class.php Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-06-10 17:40:57 UTC (rev 391) +++ trunk/1.0/cs_siteConfig.class.php 2009-06-11 15:22:55 UTC (rev 392) @@ -161,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(); @@ -349,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 ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-10 17:41:50
|
Revision: 391 http://cs-content.svn.sourceforge.net/cs-content/?rev=391&view=rev Author: crazedsanity Date: 2009-06-10 17:40:57 +0000 (Wed, 10 Jun 2009) Log Message: ----------- Updated MySQL db abstraction layer. /db_types/cs_phpDB__mysql.class.php: * set_row(): -- call mysql_data_seek() to change rows. -- throws an exception if the call returns false * farray(): -- don't change internal row arbitrarily anymore. -- call mysql_fetch_array() without the second arg ($this->row). -- NOTE: passing the second argument caused strange behaviour, since mysql_fetch_array() was assuming that was indicative of what type of data it should return (numeric, associative, or both). Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-09 18:39:50 UTC (rev 390) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-10 17:40:57 UTC (rev 391) @@ -384,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 .")"); @@ -430,10 +433,7 @@ $retval = NULL; } else { - if($this->row == 0) { - $this->row = 1; - } - $retval = mysql_fetch_array($this->result,$this->row); + $retval = mysql_fetch_array($this->result); } return($retval); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-09 18:40:03
|
Revision: 390 http://cs-content.svn.sourceforge.net/cs-content/?rev=390&view=rev Author: crazedsanity Date: 2009-06-09 18:39:50 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Various fixes to work with MySQL databases. /db_types/cs_phpDB__mysql.class.php: * connect(): -- give the actual error if the connection fails. -- if no connection error is present, give a generic one so at least the developer knows *something* happened. * farray(): -- increment internal row to 1 if it's at zero. * farray_fieldnames(): -- initialize the temporary variables $tArr and $newArr. -- only add to $newArr if there's an array to be had -- throw an exception if the data from farray() isn't an array. Modified Paths: -------------- trunk/1.0/db_types/cs_phpDB__mysql.class.php Modified: trunk/1.0/db_types/cs_phpDB__mysql.class.php =================================================================== --- trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-08 19:12:26 UTC (rev 389) +++ trunk/1.0/db_types/cs_phpDB__mysql.class.php 2009-06-09 18:39:50 UTC (rev 390) @@ -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); } } @@ -422,7 +430,9 @@ $retval = NULL; } else { - //TODO: implement MySQL version.. + if($this->row == 0) { + $this->row = 1; + } $retval = mysql_fetch_array($this->result,$this->row); } @@ -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()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-08 19:12:28
|
Revision: 389 http://cs-content.svn.sourceforge.net/cs-content/?rev=389&view=rev Author: crazedsanity Date: 2009-06-08 19:12:26 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Fix PHP error/warning/notice about "this->session" being undefined. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-06-08 03:49:30 UTC (rev 388) +++ trunk/1.0/contentSystem.class.php 2009-06-08 19:12:26 UTC (rev 389) @@ -779,7 +779,7 @@ } } - if(is_object($this->session)) { + if(isset($this->session) && is_object($this->session)) { $page->session =& $this->session; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-08 03:49:38
|
Revision: 388 http://cs-content.svn.sourceforge.net/cs-content/?rev=388&view=rev Author: crazedsanity Date: 2009-06-08 03:49:30 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Fix add_template() to not care about the index file anymore... /contentSystem.class.php: * add_template(): -- ARG CHANGE: DELETED ARG: #3 ($allowIndex=false) -- no longer checks anything when adding a template. -- NOTE: the implementation of only allowing index at certain times was broken. More refining of the system needs to be done, I think. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Property Changed: ---------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-06-04 15:11:11 UTC (rev 387) +++ trunk/1.0/contentSystem.class.php 2009-06-08 03:49:30 UTC (rev 388) @@ -920,13 +920,8 @@ //------------------------------------------------------------------------ - private final function add_template($var, $file, $allowIndex=false) { - if($var == 'index' && $allowIndex !== true) { - //$this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); - } - else { - $this->templateList[$var] = $file; - } + private final function add_template($var, $file) { + $this->templateList[$var] = $file; }//end add_template() //------------------------------------------------------------------------ Property changes on: trunk/1.0/contentSystem.class.php ___________________________________________________________________ Deleted: svn:mergeinfo - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-06-04 15:11:26
|
Revision: 387 http://cs-content.svn.sourceforge.net/cs-content/?rev=387&view=rev Author: crazedsanity Date: 2009-06-04 15:11:11 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Fix cs_globalFunctions::debug_print() so GLOBALS settings override constants. /cs_globalFunctions.class.php: * __construct(): -- reset internal debugRemoveHr and debugPrintOpt to GLOBAL values if present, even when CONSTANT values were previously used. Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2009-06-01 14:49:57 UTC (rev 386) +++ trunk/1.0/cs_globalFunctions.class.php 2009-06-04 15:11:11 UTC (rev 387) @@ -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'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |