[pLog-svn] r6989 - in plog/trunk/class: cache config database database/pdb database/pdb/datadict database/pdb/drivers file net/http/session
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed Feb 17 16:35:50 EST 2010
Author: jondaley
Date: 2010-02-17 16:35:50 -0500 (Wed, 17 Feb 2010)
New Revision: 6989
Removed:
plog/trunk/class/database/db.class.php
Modified:
plog/trunk/class/cache/cachemanager.class.php
plog/trunk/class/config/config.class.php
plog/trunk/class/database/ltdb.class.php
plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php
plog/trunk/class/database/pdb/drivers/pdbpgsqldriver.class.php
plog/trunk/class/database/pdb/pdb.class.php
plog/trunk/class/file/file.class.php
plog/trunk/class/net/http/session/sessionmanager.class.php
Log:
php5 updates. use static keyword in various places. php requires child class methods to have the same signature as parent methods. ugh
Modified: plog/trunk/class/cache/cachemanager.class.php
===================================================================
--- plog/trunk/class/cache/cachemanager.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/cache/cachemanager.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -18,7 +18,7 @@
* meaning that it will have to be loaded every time.
* @return The current global instance of the Lite class
*/
- function &getCache( $cacheEnabled = true )
+ static function &getCache( $cacheEnabled = true )
{
static $cache;
Modified: plog/trunk/class/config/config.class.php
===================================================================
--- plog/trunk/class/config/config.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/config/config.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -75,7 +75,7 @@
* @see ConfigFileStorage
* @static
*/
- function &getConfig( $storage = DEFAULT_STORAGE_BACKEND, $params = null )
+ static function &getConfig( $storage = DEFAULT_STORAGE_BACKEND, $params = null )
{
static $configInstance;
Deleted: plog/trunk/class/database/db.class.php
===================================================================
--- plog/trunk/class/database/db.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/db.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -1,16 +0,0 @@
-<?php
-
-
-
- /**
- * \ingroup Database
- *
- * @deprecated
- * This class is left here for compatibility reasons, since as of Lifetype 2.0, the original Db class
- * was renamed to LtDb in order not to clash with PEAR's Db class. Please modify your plugins and
- * custom code to refer to the new LtDb class.
- */
- class Db extends LtDb
- {
- }
-?>
\ No newline at end of file
Modified: plog/trunk/class/database/ltdb.class.php
===================================================================
--- plog/trunk/class/database/ltdb.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/ltdb.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -58,7 +58,7 @@
* @return Returns a reference to a PDb driver, with a working connection to the database.
* @see PDb::getDriver()
*/
- function &getDb()
+ static function &getDb()
{
static $db;
@@ -108,7 +108,7 @@
* @param dbname The name of the database
* @param returns a reference to a PDb driver or dies if there was an error connecting
*/
- function &getNewDb( $host, $username, $password, $dbname )
+ static function &getNewDb( $host, $username, $password, $dbname )
{
static $dbs;
@@ -136,7 +136,7 @@
* @return A string containing the database prefix
* @static
*/
- function getPrefix()
+ static function getPrefix()
{
static $prefix;
@@ -165,7 +165,7 @@
* to account for different database engines. e.g. this function should
* be completely removed, and each db engine should quote its own stuff
*/
- function qstr($string) {
+ static function qstr($string) {
$string = str_replace("\\", "\\\\", $string);
$string = str_replace("'", "''", $string);
return $string;
Modified: plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php
===================================================================
--- plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/datadict/pdbbasedatadict.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -7,16 +7,6 @@
the BSD license will take precedence.
*/
-
-
- // compatibility stuff
- if (!function_exists('ctype_alnum')) {
- function ctype_alnum($text) {
- return preg_match('/^[a-z0-9]*$/i', $text);
- }
- }
-
-
/**
* Base class for data dictionaries. Data dictionaries allow to use a meta-language to describe a database schema, which
* will be processed by the data dictionary and which will allow to automatically modify a database. This meta-language
Modified: plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -16,6 +16,7 @@
{
var $_dbname;
+ var $_charset;
var $_host;
var $_user;
var $_password;
@@ -33,6 +34,9 @@
function PDbDriverBase()
{
$this->_opts = Array();
+
+ // character set, 'default' until one is explicitly set
+ $this->_charset = 'default';
}
/**
@@ -84,12 +88,15 @@
* @param dbname The name of the database to which we're connecting
* @return Returns true if successful or false otherwise
*/
- function Connect( $host, $username, $password, $dbname = null )
+ function Connect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
$this->_host = $host;
$this->_username = $username;
$this->_password = $password;
$this->_dbname = $dbname;
+ if($dbcharset)
+ $this->_charset = $dbcharset;
$this->_connected = true;
// extra functionality to be implemented by child classes...
@@ -105,12 +112,15 @@
* @param dbname The name of the database to which we're connecting
* @return Returns true if successful or false otherwise
*/
- function PConnect( $host, $username, $password, $dbname )
+ function PConnect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
$this->_host = $host;
$this->_username = $username;
$this->_password = $password;
$this->_dbname = $dbname;
+ if($dbcharset)
+ $this->_charset = $dbcharset;
$this->_connected = true;
// extra functionality to be implemented by child classes...
@@ -217,7 +227,7 @@
* @param driverName the driver name.
* @param A reference to the driver-specific PDbBaseDataDict object
*/
- function &getDriverDataDictionary( $driverName )
+ function &getDriverDataDictionary( $driverName="" )
{
$dataDictPath = PLOG_CLASS_PATH."class/database/pdb/datadict/pdb".strtolower($driverName)."datadict.class.php";
@@ -232,7 +242,7 @@
$className = "PDb{$driverName}DataDict";
- $class =& new $className();
+ $class = new $className();
$class->dataProvider = $this;
$class->connection = &$this;
@@ -407,11 +417,11 @@
}
/**
- * @return Returns the name of current character set, or 'default' if none has been explicitely selected
+ * @return Returns the name of current character set
*/
function getDbCharacterSet()
{
- return( 'default' );
+ return( $this->_charset );
}
/**
Modified: plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -1,7 +1,5 @@
<?php
-
-
/**
* \ingroup PDb
*
@@ -11,8 +9,6 @@
{
var $_res;
- var $_dbname;
- var $_charset;
/**
* Constructor of the driver. Doesn't do much.
@@ -24,8 +20,6 @@
// the driver name
$this->_type = 'mysql';
- // character set, 'default' until one is explicitely set
- $this->_charset = 'default';
}
/**
@@ -70,16 +64,18 @@
/**
* @see PDbDriverBase::Connect()
*/
- function Connect( $host, $username, $password, $dbname = null, $dbcharset = null )
+ function Connect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
PDbDriverBase::Connect( $host, $username, $password, $dbname );
// try to connect and quit if unsuccessful
- $this->_res = mysql_connect( $host, $username, $password );
+ $this->_res = mysql_connect( $host, $username, $password );
if( !$this->_res )
return false;
- // set the right character encoding for mysql 4.1+ client, connection and collation
+ // set the right character encoding for mysql 4.1+ client,
+ // connection and collation
if( !empty( $dbcharset ) && $dbcharset != "default" ) {
mysql_query( "SET NAMES ".$dbcharset, $this->_res );
$this->_charset = $dbcharset;
@@ -95,16 +91,18 @@
/**
* @see PDbDriverBase::PConnect()
*/
- function PConnect( $host, $username, $password, $dbname = null, $dbcharset = null )
+ function PConnect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
- PDbDriverBase::Connect( $host, $username, $password, $dbname );
+ PDbDriverBase::Connect( $host, $username, $password, $dbname );
// try to connect and quit if unsuccessful
- $this->_res = mysql_pconnect( $host, $username, $password );
+ $this->_res = mysql_pconnect( $host, $username, $password );
if( !$this->_res )
return false;
- // set the right character encoding for mysql 4.1+ client, connection and collation
+ // set the right character encoding for mysql 4.1+ client,
+ // connection and collation
if( !empty( $dbcharset ) && $dbcharset != "default" ) {
mysql_query( "SET NAMES ".$dbcharset, $this->_res );
$this->_charset = $dbcharset;
@@ -152,7 +150,7 @@
/**
* @see PDbDriverBase::getDriverDataDictionary()
*/
- function getDriverDataDictionary()
+ function &getDriverDataDictionary( $unused="" )
{
return( PDbDriverBase::getDriverDataDictionary( 'mysql' ));
}
@@ -174,16 +172,6 @@
return( $enableFullText );
}
- /**
- * Return the name of the character set currently being used
- *
- * @see PDbDriverBase::getDbCharacterSet()
- */
- function getDbCharacterSet()
- {
- return( $this->_charset );
- }
-
/**
* Returns the character sets available in the server
Modified: plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqlrecordset.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -1,7 +1,5 @@
<?php
-
-
/**
* \ingroup PDb
*
Modified: plog/trunk/class/database/pdb/drivers/pdbpgsqldriver.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbpgsqldriver.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/drivers/pdbpgsqldriver.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -1,9 +1,5 @@
<?php
-
-
-
-
/**
* \ingroup PDb
*
@@ -13,8 +9,6 @@
{
var $_res;
- var $_dbname;
- var $_charset;
var $_lastInsertTable;
/**
@@ -27,9 +21,6 @@
// the driver name
$this->_type = 'pgsql';
- // character set, 'default' until one is explicitely set
- $this->_charset = 'default';
-
$this->_lastInsertTable = "";
$this->log =& LoggerManager::getLogger();
@@ -85,12 +76,14 @@
* so we're going to use the 'postgres' database that should technically be
* available in all system (as far as I can tell)
*/
- function Connect( $host, $username, $password, $dbname = null, $dbcharset = null )
+ function Connect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
if( $dbname == null )
$dbname = "postgres";
- PDbDriverBase::Connect( $host, $username, $password, $dbname );
+ PDbDriverBase::Connect( $host, $username, $password,
+ $dbname, $dbcharset );
// try to connect and quit if unsuccessful
$connectStr = "host=$host user=$username password=$password";
@@ -116,12 +109,14 @@
* so we're going to use the 'postgres' database that should technically be
* available in all system (as far as I can tell)
*/
- function PConnect( $host, $username, $password, $dbname = null, $dbcharset = null )
+ function PConnect( $host, $username, $password,
+ $dbname = null, $dbcharset = null )
{
if( $dbname == null )
$dbname = "postgres";
- PDbDriverBase::Connect( $host, $username, $password, $dbname );
+ PDbDriverBase::Connect( $host, $username, $password,
+ $dbname, $dbcharset );
// try to connect and quit if unsuccessful
$connectStr = "host=$host user=$username password=$password";
@@ -209,16 +204,6 @@
}
/**
- * Return the name of the character set currently being used
- *
- * @see PDbDriverBase::getDbCharacterSet()
- */
- function getDbCharacterSet()
- {
- return( $this->_charset );
- }
-
- /**
* Returns the server's character set
*/
function getServerCharacterSet()
Modified: plog/trunk/class/database/pdb/pdb.class.php
===================================================================
--- plog/trunk/class/database/pdb/pdb.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/database/pdb/pdb.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -41,7 +41,7 @@
* database access.
* @see PDbDriverBase
*/
- function getDriver( $driver )
+ static function getDriver( $driver )
{
$validDrivers = PDb::getValidDrivers();
@@ -65,7 +65,7 @@
* @return An associative array, where the key is the name of the driver and the
* value is the name of the class implementing the driver
*/
- function getValidDrivers()
+ static function getValidDrivers()
{
$_drivers = Array( "mysql" => "PDbMySQLDriver", "pgsql" => "PDbPgSQLDriver" );
@@ -79,26 +79,8 @@
* @return An array with the driver names
* @see PDb::getDriver()
*/
- function listDrivers()
+ static function listDrivers()
{
return array_keys( PDb::getValidDrivers() );
}
}
-
- /**
- * ADOdb compatibility, although this method was renamed to NewLifeTypeDataDictionary() not
- * to collide with ADOdb's own in those system where these two libraries may be loaded at the
- * same time (i.e. when the gallery2 plugin is loaded)
- *
- * @param driver A driver class whose data dictionary class we'd like to get. This method is obsolete
- * and you should call PDbDriverBase::getDriverDataDictionary(). This method is only here for compatibility
- * reasons.
- *
- * @see PDbDriverBase::getDriverDataDictionary()
- * @deprecated
- */
- function NewPDbDataDictionary( $driver )
- {
- return( $driver->getDriverDataDictionary());
- }
-?>
Modified: plog/trunk/class/file/file.class.php
===================================================================
--- plog/trunk/class/file/file.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/file/file.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -34,8 +34,6 @@
*/
function File( $fileName )
{
-
-
$this->_fileName = $fileName;
}
@@ -164,7 +162,7 @@
}
/**
- * Returns true wether the file is a directory. See
+ * Returns true whether the file is a directory. See
* http://fi.php.net/manual/en/function.is-dir.php for more details.
*
* @param file The filename we're trying to check. If omitted, the
@@ -172,7 +170,7 @@
* static as long as the file parameter is provided)
* @return Returns true if the file is a directory.
*/
- function isDir( $file = null )
+ static function isDir( $file = null )
{
if( $file == null )
$file = $this->_fileName;
@@ -190,7 +188,7 @@
* static as long as the file parameter is provided)
* @return Returns true if the file is writable, or false otherwise.
*/
- function isWritable( $file = null )
+ static function isWritable( $file = null )
{
if( $file == null )
$file = $this->_fileName;
@@ -206,7 +204,7 @@
* it will check for the readability status of the file
* @return true if readable or false otherwise
*/
- function isReadable( $file = null )
+ static function isReadable( $file = null )
{
if( $file == null )
$file = $this->_fileName;
@@ -223,7 +221,7 @@
* @param optionally, name of the file to delete
* @return True if successful or false otherwise
*/
- function delete( $file = null )
+ static function delete( $file = null )
{
if( $file == null )
$file = $this->_fileName;
@@ -253,7 +251,7 @@
* @return True if successful or false otherwise
* @static
*/
- function deleteDir( $dirName, $recursive = false, $onlyFiles = false, $excludedFiles = array('') )
+ static function deleteDir( $dirName, $recursive = false, $onlyFiles = false, $excludedFiles = array('') )
{
// if the directory can't be read, then quit with an error
if( !File::isReadable( $dirName ) || !File::exists( $dirName )) {
@@ -310,7 +308,7 @@
* @param recursive
* @return Returns true if no problem or false otherwise.
*/
- function createDir( $dirName,
+ static function createDir( $dirName,
$mode = File::FILE_DEFAULT_DIRECTORY_CREATION_MODE,
$recursive = true )
{
@@ -352,7 +350,7 @@
*
* @param dir
*/
- function chDir( $dir )
+ static function chDir( $dir )
{
return( chdir( $dir ));
}
@@ -362,7 +360,7 @@
*
* @return a temporary name
*/
- function getTempName()
+ static function getTempName()
{
return md5(microtime());
}
@@ -376,7 +374,7 @@
* be used as static if a file name is specified.
* @return An integer specifying the size of the file.
*/
- function getSize( $fileName = null )
+ static function getSize( $fileName = null )
{
if( $fileName == null )
$fileName = $this->_fileName;
@@ -388,21 +386,22 @@
return $size;
}
- /**
- * renames a file
- *
- * http://www.php.net/manual/en/function.rename.php
- *
- * This function can be used as static if inFile and outFile are both
- * not empty. if outFile is empty, then the internal file of the
- * current object will be used as the input file and the first
- * parameter of this method will become the destination file name.
- *
- * @param inFile Original file
- * @param outFile Destination file.
- * @return Returns true if file was renamed ok or false otherwise.
- */
- function rename( $inFile, $outFile = null )
+ /**
+ * renames a file
+ *
+ * http://www.php.net/manual/en/function.rename.php
+ *
+ * This function can be used as static if inFile and outFile are
+ * both
+ * not empty. if outFile is empty, then the internal file of the
+ * current object will be used as the input file and the first
+ * parameter of this method will become the destination file name.
+ *
+ * @param inFile Original file
+ * @param outFile Destination file.
+ * @return Returns true if file was renamed ok or false otherwise.
+ */
+ static function rename( $inFile, $outFile = null )
{
// check how many parameters we have
if( $outFile == null ) {
@@ -446,7 +445,7 @@
* @return True if successful or false otherwise
* @static
*/
- function copy( $inFile, $outFile )
+ static function copy( $inFile, $outFile )
{
return @copy( $inFile, $outFile );
}
@@ -460,7 +459,7 @@
* @return true if successful or false otherwise
* @static
*/
- function chMod( $inFile, $mode = 0644 )
+ static function chMod( $inFile, $mode = 0644 )
{
return chmod( $inFile, $mode );
}
@@ -490,7 +489,7 @@
* @see PHP Function touch()
*
*/
- function touch( $fileName = null )
+ static function touch( $fileName = null )
{
if( $fileName == null )
return false;
@@ -505,7 +504,7 @@
* @see PHP Function basename()
*
*/
- function basename( $fileName = null )
+ static function basename( $fileName )
{
if( $fileName == null )
return false;
@@ -524,8 +523,8 @@
* @return String
* @static
*/
- function expandPath($path)
- {
+ static function expandPath($path)
+ {
$oldP = "";
$newP = $path;
while( $newP != $oldP) {
@@ -549,8 +548,9 @@
* @param string $source Source path
* @param string $dest Destination path
* @return bool Returns TRUE on success, FALSE on failure
+ * @static
*/
- function copyDir($source, $dest)
+ static function copyDir($source, $dest)
{
clearstatcache();
Modified: plog/trunk/class/net/http/session/sessionmanager.class.php
===================================================================
--- plog/trunk/class/net/http/session/sessionmanager.class.php 2010-02-17 21:01:23 UTC (rev 6988)
+++ plog/trunk/class/net/http/session/sessionmanager.class.php 2010-02-17 21:35:50 UTC (rev 6989)
@@ -1,11 +1,5 @@
<?php
-
-
-
-
-
-
$__sessionManagerInitialized = false;
/**
@@ -26,7 +20,7 @@
* @see SessionInfo
* @see SessionManager::setSessionSavePath()
*/
- function init()
+ static function init()
{
global $__sessionManagerInitialized;
@@ -70,7 +64,7 @@
* Sets the session cookie path to the right path
* @return nothing
*/
- function setSessionCookiePath()
+ static function setSessionCookiePath()
{
// get the current base url and fetch it dynamically according to the values
// returned by Apache/PHP if not set yet in the config settings
@@ -94,7 +88,7 @@
* Sets the right domain for the cookie
* @return nothing
*/
- function setSessionCookieDomain()
+ static function setSessionCookieDomain()
{
$scriptUrl = HttpVars::getBaseUrl();
@@ -119,7 +113,7 @@
*
* @static
*/
- function setSessionSavePath()
+ static function setSessionSavePath()
{
$config =& Config::getConfig();
$sessionFolder = $config->getValue( "session_save_path" );
@@ -161,7 +155,7 @@
* @param key The name of the parameter
* @return The value assigned to this key
*/
- function getSessionValue( $key )
+ static function getSessionValue( $key )
{
// switch that informs whether the session manager has already been initialized or not
global $__sessionManagerInitialized;
@@ -187,7 +181,7 @@
* @param value The value assigned
* @return always true
*/
- function setSessionValue( $key, $value )
+ static function setSessionValue( $key, $value )
{
// switch that informs whether the session manager has already been initialized or not
global $__sessionManagerInitialized;
@@ -214,7 +208,7 @@
*
* @return A UserInfo object if found, or false otherwise
*/
- function getUserInfoFromSession()
+ static function getUserInfoFromSession()
{
$session = HttpVars::getSession();
$sessionInfo = $session["SessionInfo"];
More information about the pLog-svn
mailing list