\*=====================================================================*/
/**
-* Abstract Datamanger API (api.php)
-*
-* @package ISSO
-*/
+ * Abstract Datamanger API (api.php)
+ *
+ * @package ISSO
+ */
if (!defined('REQ_AUTO'))
{
/**
- * Yes, required
- */
+ * Yes, required
+ */
define('REQ_YES', 1);
/**
- * No, not required
- */
+ * No, not required
+ */
define('REQ_NO', 0);
/**
- * Auto-increasing value
- */
+ * Auto-increasing value
+ */
define('REQ_AUTO', -1);
/**
- * Set by a cusotm set_*() function
- */
+ * Set by a cusotm set_*() function
+ */
define('REQ_SET', 2);
/**
- * Index for cleaning type
- */
+ * Index for cleaning type
+ */
define('F_TYPE', 0);
/**
- * Index for requirement type
- */
+ * Index for requirement type
+ */
define('F_REQ', 1);
}
/**
-* Abstract API
-*
-* Abstract class that is used as an API base for most common database interaction
-* schemes. Creates a simple structure that holds data and can update, remove, and
-* insert.
-*
-* Life-cycle of a new object:
-* 1. $o = new SubApi();
-* 2. $o->set('foo', 'abc');
-* 3. $o->set('test', 45);
-* 4. try { $o->insert(); <other actions that depend on the saved record> } catch (ApiException $e) {}
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Abstract API
+ *
+ * Abstract class that is used as an API base for most common database interaction
+ * schemes. Creates a simple structure that holds data and can update, remove, and
+ * insert.
+ *
+ * Life-cycle of a new object:
+ * 1. $o = new SubApi();
+ * 2. $o->set('foo', 'abc');
+ * 3. $o->set('test', 45);
+ * 4. try { $o->insert(); <other actions that depend on the saved record> } catch (ApiException $e) {}
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSApi
{
/**
- * Fields: used for verification and sanitization
- * NAME => array(TYPE, REQUIRED)
- * @var array
- */
+ * Fields: used for verification and sanitization
+ * NAME => array(TYPE, REQUIRED)
+ * @var array
+ */
protected $fields = array();
/**
protected $prefix = '';
/**
- * Values array: sanitized and validated field values
- * @var array
- */
+ * Values array: sanitized and validated field values
+ * @var array
+ */
public $values = array();
/**
- * Fields that were set by the client
- * @var array
- */
+ * Fields that were set by the client
+ * @var array
+ */
private $setfields = array();
/**
- * WHERE condition
- * @var string
- */
+ * WHERE condition
+ * @var string
+ */
protected $condition = '';
/**
- * The object table row; a fetched row that represents this instance
- * @var array
- */
+ * The object table row; a fetched row that represents this instance
+ * @var array
+ */
public $record = array();
/**
- * Insert ID from the insert() command
- * @var integer
- */
+ * Insert ID from the insert() command
+ * @var integer
+ */
public $insertid = 0;
/**
- * Error queue that builds up errors
- * @var ApiException
- */
+ * Error queue that builds up errors
+ * @var ApiException
+ */
private $exception = null;
/**
}
}
- // ###################################################################
/**
- * Adds an error into the error queue that is then hit
- *
- * @param Exception Error message
- */
+ * Adds an error into the error queue that is then hit
+ *
+ * @param Exception Error message
+ */
protected function _error(Exception $e)
{
if ($this->exception == null)
$this->exception->addException($e);
}
- // ###################################################################
/**
- * This simply throws the ApiException if it exists, which inside holds
- * all of the individual and specific errors
- */
+ * This simply throws the ApiException if it exists, which inside holds
+ * all of the individual and specific errors
+ */
private function _processErrorQueue()
{
if ($this->exception)
}
}
- // ###################################################################
/**
- * Sets a value, sanitizes it, and validates it
- *
- * @param string Field name
- * @param mixed Value
- * @param bool Do clean?
- * @param bool Do validation?
- */
+ * Sets a value, sanitizes it, and validates it
+ *
+ * @param string Field name
+ * @param mixed Value
+ * @param bool Do clean?
+ * @param bool Do validation?
+ */
public function set($field, $value, $doclean = true, $dovalidate = true)
{
if (!isset($this->fields["$field"]))
}
}
- // ###################################################################
/**
- * Sets the condition to use in the WHERE clause; if not passed, then
- * it calculates it from the REQ_AUTO field
- *
- * @param mixed String with WHERE condition; array of fields to use for WHERE builder
- */
+ * Sets the condition to use in the WHERE clause; if not passed, then
+ * it calculates it from the REQ_AUTO field
+ *
+ * @param mixed String with WHERE condition; array of fields to use for WHERE builder
+ */
public function setCondition($condition = null)
{
if (is_array($condition) && sizeof($condition) > 0)
}
}
- // ###################################################################
/**
- * Fetches a record based on the condition
- *
- * @param bool Run pre_fetch()?
- * @param bool Run post_fetch()?
- *
- * @return boolean Whether or not the row was successfully fetched
- */
+ * Fetches a record based on the condition
+ *
+ * @param bool Run pre_fetch()?
+ * @param bool Run post_fetch()?
+ *
+ * @return boolean Whether or not the row was successfully fetched
+ */
public function fetch($doPre = true, $doPost = true)
{
if (!$this->condition)
return true;
}
- // ###################################################################
/**
- * Inserts a record in the database
- *
- * @param bool Run pre_insert()?
- * @param bool Run post_insert()?
- */
+ * Inserts a record in the database
+ *
+ * @param bool Run pre_insert()?
+ * @param bool Run post_insert()?
+ */
public function insert($doPre = true, $doPost = true)
{
$this->_verifyRequired();
$this->_runActionMethod('post_insert', $doPost);
}
- // ###################################################################
/**
- * Updates a record in the database using the data in $vaues
- *
- * @param bool Run pre_update()?
- * @param bool Run post_update()?
- */
+ * Updates a record in the database using the data in $vaues
+ *
+ * @param bool Run pre_update()?
+ * @param bool Run post_update()?
+ */
public function update($doPre = true, $doPost = true)
{
if (!$this->condition)
$this->_runActionMethod('post_update', $doPost);
}
- // ###################################################################
/**
- * Deletes a record
- *
- * @param bool Run pre_remove()?
- * @param bool Run post_remove()?
- */
+ * Deletes a record
+ *
+ * @param bool Run pre_remove()?
+ * @param bool Run post_remove()?
+ */
public function remove($doPre = true, $doPost = true)
{
if (!$this->condition)
$this->_runActionMethod('post_remove', $doPost);
}
- // ###################################################################
/**
- * Verifies that all required fields are set
- */
+ * Verifies that all required fields are set
+ */
private function _verifyRequired()
{
foreach ($this->fields as $name => $options)
}
}
- // ###################################################################
/**
- * Runs a pre- or post-action method for database commands
- *
- * @param string Action to run
- * @param bool Actually run it?
- */
+ * Runs a pre- or post-action method for database commands
+ *
+ * @param string Action to run
+ * @param bool Actually run it?
+ */
private function _runActionMethod($method, $doRun)
{
if (!$doRun || !method_exists($this, $method))
$this->$method();
}
- // ###################################################################
/**
- * Prepares a value for use in a SQL query; it encases and escapes
- * strings and string-like values
- *
- * @param string Field name
- *
- * @return string Prepared value entry
- */
+ * Prepares a value for use in a SQL query; it encases and escapes
+ * strings and string-like values
+ *
+ * @param string Field name
+ *
+ * @return string Prepared value entry
+ */
private function _prepareFieldForSql($name)
{
$type = $this->fields["$name"][F_TYPE];
}
}
- // ###################################################################
/**
- * Verify field: not a zero value
- */
+ * Verify field: not a zero value
+ */
protected function _verifyIsNotZero($field)
{
if ($this->values[$field] == 0)
return true;
}
- // ###################################################################
/**
- * Verify field: not empty
- */
+ * Verify field: not empty
+ */
protected function _verifyIsNotEmpty($field)
{
if (empty($this->values[$field]))
return true;
}
- // ###################################################################
/**
- * Verify field: unique
- */
+ * Verify field: unique
+ */
protected function _verifyIsNotUnique($field)
{
$res = BSApp::$db->queryFirst("SELECT $field FROM {$this->prefix}{$this->table} WHERE $field = " . $this->_prepareFieldForSql($field) . (empty($this->condition) ? "" : " AND !({$this->condition})"));
*/
private $exceptions = array();
- // ###################################################################
/**
* Constructor
*/
parent::__construct(_('An error occurred while processing the API data.'));
}
- // ###################################################################
/**
* Adds an exception to the collection
*
$this->exceptions[] = $e;
}
- // ###################################################################
/**
* Returns an array of all the exceptions in the collection
*
*
* @author rsesek
* @copyright Copyright (c)2005 - 2008, Blue Static
- * @version $Id$
* @package ISSO
*
*/
*/
private $field;
- // ###################################################################
/**
* Constructor: create a new exception
*/
parent::__construct($error);
}
- // ###################################################################
/**
* Returns the name of the field the exception is for
*
\*=====================================================================*/
/**
-* ISSO Application Root (App.php)
-*
-* @package ISSO
-*/
+ * ISSO Application Root (App.php)
+ *
+ * @package ISSO
+ */
// we need PHP 5.2.0 to run
if (!function_exists('array_fill_keys'))
require_once(ISSO . '/Functions.php');
/**
-* Application Class
-*
-* This is an ISSO application class. It holds all of the ISSO system variables as well
-* as serving as an object registry that is avaliable in the global scope to prevent
-* globalization of variables. There can only be one instance of this existing
-* at any given time.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Application Class
+ *
+ * This is an ISSO application class. It holds all of the ISSO system variables as well
+ * as serving as an object registry that is avaliable in the global scope to prevent
+ * globalization of variables. There can only be one instance of this existing
+ * at any given time.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSApp
{
/**
- * Debug mode?
- * @var bool
- */
+ * Debug mode?
+ * @var bool
+ */
private static $debug = false;
/**
- * An array of debug messages
- * @var array
- */
+ * An array of debug messages
+ * @var array
+ */
private static $debugInfo = array();
/**
private function __construct()
{}
- // ###################################################################
/**
- * Sets the debug state
- *
- * @param bool Debug mode on?
- */
+ * Sets the debug state
+ *
+ * @param bool Debug mode on?
+ */
public static function set_debug($debug)
{
self::$debug = $debug;
}
- // ###################################################################
/**
- * Gets the debug mode state
- *
- * @return bool Debug mode on?
- */
+ * Gets the debug mode state
+ *
+ * @return bool Debug mode on?
+ */
public static function get_debug()
{
return self::$debug;
}
- // ###################################################################
/**
- * Adds a debug message to the array. This only works when debug mode
- * is enabled.
- *
- * @param string Debug message
- */
+ * Adds a debug message to the array. This only works when debug mode
+ * is enabled.
+ *
+ * @param string Debug message
+ */
public static function debug($msg)
{
if (self::$debug)
}
}
- // ###################################################################
/**
- * Returns a <select> menu of all the debug notices
- *
- * @return string Debug list
- */
+ * Returns a <select> menu of all the debug notices
+ *
+ * @return string Debug list
+ */
public static function get_debug_list()
{
$output = '<select><option>Debug Notices (' . sizeof(self::$debugInfo) . ')</option>';
\*=====================================================================*/
/**
-* Date formatting system (Date.php)
-*
-* @package ISSO
-*/
+ * Date formatting system (Date.php)
+ *
+ * @package ISSO
+ */
/**
-* Defined constant time
-*/
+ * Defined constant time
+ */
define('TIMENOW', time());
/**
-* Date Formatting System
-*
-* This framework wraps date and time functions into one neat little
-* package that takes care of modifying timestamps to meet the right
-* time zone
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Date Formatting System
+ *
+ * This framework wraps date and time functions into one neat little
+ * package that takes care of modifying timestamps to meet the right
+ * time zone
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSDate
{
/**
- * Offset in seconds; this is set using fetch_offset()
- * @var integer
- */
+ * Offset in seconds; this is set using fetch_offset()
+ * @var integer
+ */
private $offset = 0;
- // ###################################################################
/**
- * Sets the user time zone and then calculates the total offset
- *
- * @param float User time zone
- */
+ * Sets the user time zone and then calculates the total offset
+ *
+ * @param float User time zone
+ */
public function setUserTimeZone($usertz)
{
$this->offset = $usertz * 3600;
}
- // ###################################################################
/**
- * Formats a UNIX timestamp to a certain date format in the proper time
- * zone
- *
- * @param string Format of the date (same as PHP's date() function)
- * @param integer UNIX timestamp to format
- * @param bool Adjust the date to the user's language?
- *
- * @return string Formatted date
- */
+ * Formats a UNIX timestamp to a certain date format in the proper time
+ * zone
+ *
+ * @param string Format of the date (same as PHP's date() function)
+ * @param integer UNIX timestamp to format
+ * @param bool Adjust the date to the user's language?
+ *
+ * @return string Formatted date
+ */
public function format($format, $timestamp = TIMENOW, $adjust = true)
{
if ($adjust)
return gmdate($format, $timestamp);
}
- // ###################################################################
/**
- * Fetches an array of timezone names indexed by their offset
- *
- * @return array List of timezones
- */
+ * Fetches an array of timezone names indexed by their offset
+ *
+ * @return array List of timezones
+ */
public static function fetch_timezone_list()
{
$opt = array();
\*=====================================================================*/
/**
-* Abstract Database Layer (Db.php)
-*
-* @package ISSO
-*/
+ * Abstract Database Layer (Db.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Functions.php');
/**
-* Abstract Database Layer
-*
-* This class provides an abstract template for all RDBMS layers. All
-* ISSO abstraction layers should inherit this class. It provides error
-* reporting, SQL analysis, and general connection functionality.
-*
-* Constants:
-* ISSO_SHOW_QUERIES_LIVE - Show queries in page output as they are sent
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Abstract Database Layer
+ *
+ * This class provides an abstract template for all RDBMS layers. All
+ * ISSO abstraction layers should inherit this class. It provides error
+ * reporting, SQL analysis, and general connection functionality.
+ *
+ * Constants:
+ * ISSO_SHOW_QUERIES_LIVE - Show queries in page output as they are sent
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSDb
{
/**
- * Determines whether or not errors should be shown
- * @var bool
- */
+ * Determines whether or not errors should be shown
+ * @var bool
+ */
public $showerrors = true;
/**
- * Current error number
- * @var integer
- */
+ * Current error number
+ * @var integer
+ */
protected $errnum = 0;
/**
- * Description of current error
- * @var string
- */
+ * Description of current error
+ * @var string
+ */
protected $errstr = '';
/**
- * Currend open database connection
- * @var integer
- */
+ * Currend open database connection
+ * @var integer
+ */
protected $dblink = null;
/**
- * Current query ID
- * @var integer
- */
+ * Current query ID
+ * @var integer
+ */
protected $result = null;
/**
- * Current query string
- * @var string
- */
+ * Current query string
+ * @var string
+ */
protected $querystr = '';
/**
- * History of all executed queryies
- * @var array
- */
+ * History of all executed queryies
+ * @var array
+ */
protected $history = array();
- // ###################################################################
/**
- * Returns the history information array
- *
- * @return array History record
- */
+ * Returns the history information array
+ *
+ * @return array History record
+ */
public function getHistory()
{
return $this->history;
}
- // ###################################################################
- /**
- * Connect to a the specified database
- *
- * @param string Server name
- * @param string User name
- * @param string Password
- * @param string Database name
- *
- * @return bool Result of connect
- */
+ /**
+ * Connect to a the specified database
+ *
+ * @param string Server name
+ * @param string User name
+ * @param string Password
+ * @param string Database name
+ *
+ * @return bool Result of connect
+ */
public function connect($server, $user, $password, $database)
{
if ($this->dblink == false)
}
/**
- * Abstract function that returns a database link after establishing a connection. This just
- * calls the function and does not do any checking
- *
- * @param string Server name
- * @param string User name
- * @param string Password
- * @param string Database name
- *
- * @return integer Database link
- */
+ * Abstract function that returns a database link after establishing a connection. This just
+ * calls the function and does not do any checking
+ *
+ * @param string Server name
+ * @param string User name
+ * @param string Password
+ * @param string Database name
+ *
+ * @return integer Database link
+ */
protected abstract function _connect($server, $user, $password, $database);
- // ###################################################################
/**
- * Send a query to the open database link
- *
- * @param string Query string
- *
- * @return BSDbResult Result object, or NULL
- */
+ * Send a query to the open database link
+ *
+ * @param string Query string
+ *
+ * @return BSDbResult Result object, or NULL
+ */
public function query($string)
{
$time = microtime();
}
/**
- * Abstract function that executes the query command on the database
- *
- * @param string Query string
- *
- * @return integer Result ID
- */
+ * Abstract function that executes the query command on the database
+ *
+ * @param string Query string
+ *
+ * @return integer Result ID
+ */
protected abstract function _query($query);
- // ###################################################################
/**
- * Escape a string (depending on character set, if supported)
- *
- * @param string String to be escaped
- *
- * @return string Escaped string
- */
+ * Escape a string (depending on character set, if supported)
+ *
+ * @param string String to be escaped
+ *
+ * @return string Escaped string
+ */
public function escapeString($string)
{
return $this->_escapeString($string);
}
/**
- * Abstract function that calls the escape_string() method
- *
- * @param string String to escape
- *
- * @return string Escaped string
- */
+ * Abstract function that calls the escape_string() method
+ *
+ * @param string String to escape
+ *
+ * @return string Escaped string
+ */
protected abstract function _escapeString($string);
- // ###################################################################
/**
- * Escapes a binary string for insertion into the database
- *
- * @param string Unescaped data
- *
- * @return string Escaped binary data
- */
+ * Escapes a binary string for insertion into the database
+ *
+ * @param string Unescaped data
+ *
+ * @return string Escaped binary data
+ */
public function escapeBinary($binary)
{
return $this->_escapeBinary($binary);
}
/**
- * Abstract function that calls escape_binary()
- *
- * @param string Binary to escape
- *
- * @return string Escaped binary
- */
+ * Abstract function that calls escape_binary()
+ *
+ * @param string Binary to escape
+ *
+ * @return string Escaped binary
+ */
protected abstract function _escapeBinary($string);
- // ###################################################################
/**
- * Unescapes a binary string that was fetched from the database
- *
- * @param string Escaped data
- *
- * @return string Unescaped binary data
- */
+ * Unescapes a binary string that was fetched from the database
+ *
+ * @param string Escaped data
+ *
+ * @return string Unescaped binary data
+ */
public function unescapeBinary($binary)
{
return $this->_unescapeBinary($binary);
}
/**
- * Abstract function that calls unescape_binary()
- *
- * @param string Escaped data
- *
- * @return string Data that has been unescaped
- */
+ * Abstract function that calls unescape_binary()
+ *
+ * @param string Escaped data
+ *
+ * @return string Data that has been unescaped
+ */
protected abstract function _unescapeBinary($string);
- // ###################################################################
/**
- * Send a query and return the first row of the results
- *
- * @param string Query string
- * @param string Result return function (in the database layer)
- *
- * @return mixed Results in variable formats
- */
+ * Send a query and return the first row of the results
+ *
+ * @param string Query string
+ * @param string Result return function (in the database layer)
+ *
+ * @return mixed Results in variable formats
+ */
public function queryFirst($string, $callback = 'fetchArray')
{
$resource = $this->query($string);
}
}
- // ###################################################################
/**
- * Returns the errror number
- */
+ * Returns the errror number
+ */
public abstract function _errorNumber();
/**
- * Returns the error string
- */
+ * Returns the error string
+ */
public abstract function _errorString();
- // ###################################################################
/**
- * Fetch the unique ID of the record just inserted
- *
- * @return integer Insert-ID
- */
+ * Fetch the unique ID of the record just inserted
+ *
+ * @return integer Insert-ID
+ */
public function insertId()
{
return $this->_insertID();
}
/**
- * Abstract function that returns the ID of the most recently-inserted
- * record
- *
- * @return integer Insertion ID
- */
+ * Abstract function that returns the ID of the most recently-inserted
+ * record
+ *
+ * @return integer Insertion ID
+ */
protected abstract function _insertId();
- // ###################################################################
/**
- * Fetch the number of rows affected by the query
- *
- * @param integer Result
- *
- * @return integer Number of affected rows
- */
+ * Fetch the number of rows affected by the query
+ *
+ * @param integer Result
+ *
+ * @return integer Number of affected rows
+ */
public function affectedRows()
{
return $this->_affectedRows($this->result);
}
/**
- * Abstract function that returns the number of affected rows in the result
- *
- * @param integer Result ID
- *
- * @return integer Number of rows
- */
+ * Abstract function that returns the number of affected rows in the result
+ *
+ * @param integer Result ID
+ *
+ * @return integer Number of rows
+ */
protected abstract function _affectedRows($result);
- // ###################################################################
/**
- * Sends the command to start a transaction. This command should never
- * be reached as it's always overridden
- */
+ * Sends the command to start a transaction. This command should never
+ * be reached as it's always overridden
+ */
public abstract function begin();
- // ###################################################################
/**
- * Sends the command to rollback to a given savepoint. This command
- * should never be reached as it's always overridden
- *
- * @param string Named savepoint
- */
+ * Sends the command to rollback to a given savepoint. This command
+ * should never be reached as it's always overridden
+ *
+ * @param string Named savepoint
+ */
public abstract function rollback();
- // ###################################################################
/**
- * Sends the command to commit the entire transaction. This command
- * should never be reached as it's always overridden
- */
+ * Sends the command to commit the entire transaction. This command
+ * should never be reached as it's always overridden
+ */
public abstract function commit();
}
*/
private $result;
- // ###################################################################
/**
* Sets the resource and returns a result object
*
$this->result = $result;
}
- // ###################################################################
/**
- * Fetch the query result as an array
- *
- * @param integer Result
- * @param bool Return an associative array?
- *
- * @return array A row of the query result
- */
+ * Fetch the query result as an array
+ *
+ * @param integer Result
+ * @param bool Return an associative array?
+ *
+ * @return array A row of the query result
+ */
public function fetchArray($assoc = true)
{
return $this->{($assoc ? '_fetchAssocArray' : '_fetchRowArray')}($this->result);
}
/**
- * Abstract function that returns an associative array of given result
- *
- * @param integer Result
- *
- * @return array Result array
- */
+ * Abstract function that returns an associative array of given result
+ *
+ * @param integer Result
+ *
+ * @return array Result array
+ */
protected abstract function _fetchAssocArray($result);
/**
- * Abstract function that returns a row array of given result
- *
- * @param integer Result
- *
- * @return array Result array
- */
+ * Abstract function that returns a row array of given result
+ *
+ * @param integer Result
+ *
+ * @return array Result array
+ */
protected abstract function _fetchRowArray($result);
- // ###################################################################
/**
- * Fetch the query result as an object
- *
- * @param integer Result
- *
- * @return object An object with the query result
- */
+ * Fetch the query result as an object
+ *
+ * @param integer Result
+ *
+ * @return object An object with the query result
+ */
public function fetchObject()
{
return $this->_fetchObject($this->result);
}
/**
- * Abstract function that returns an object for a given result
- *
- * @param integer Result
- *
- * @return object Row object
- */
+ * Abstract function that returns an object for a given result
+ *
+ * @param integer Result
+ *
+ * @return object Row object
+ */
public abstract function _fetchObject($result);
- // ###################################################################
/**
- * Free the current query result
- *
- * @param integer Result
- */
+ * Free the current query result
+ *
+ * @param integer Result
+ */
public function free()
{
$this->_freeResult($this->result);
}
/**
- * Abstract function that frees a given result
- *
- * @param integer Result ID
- */
+ * Abstract function that frees a given result
+ *
+ * @param integer Result ID
+ */
protected abstract function _freeResult($result);
- // ###################################################################
/**
- * Fetch the number of rows in the result
- *
- * @param integer Result
- *
- * @return integer Number of rows
- */
+ * Fetch the number of rows in the result
+ *
+ * @param integer Result
+ *
+ * @return integer Number of rows
+ */
public function size()
{
return $this->_numRows($this->result);
}
/**
- * Abstract function that returns the number of rows in the result
- *
- * @param integer Result ID
- *
- * @return integer Number of rows
- */
+ * Abstract function that returns the number of rows in the result
+ *
+ * @param integer Result ID
+ *
+ * @return integer Number of rows
+ */
protected abstract function _numRows($result);
}
*/
private $query;
- // ###################################################################
/**
* Initializes a new database exception
*
parent::__construct($error, $errorNum);
}
- // ###################################################################
/**
* Returns the query that failed
*
\*=====================================================================*/
/**
-* MySQL Database Layer (DbMySql.php)
-*
-* @package ISSO
-*/
+ * MySQL Database Layer (DbMySql.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Db.php');
/**
-* MySQL Database Layer
-*
-* This framework is a function wrapper for MySQL functions so we can have
-* better error reporting and query reporting.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * MySQL Database Layer
+ *
+ * This framework is a function wrapper for MySQL functions so we can have
+ * better error reporting and query reporting.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSDbMySql extends BSDb
{
- // ###################################################################
/**
- * Wrapper: mysql_connect
- */
+ * Wrapper: mysql_connect
+ */
protected function _connect($server, $user, $password, $database)
{
$link = @mysql_connect($server, $user, $password, true);
return $link;
}
- // ###################################################################
/**
- * Opens a connection to the specified database name
- *
- * @param string Database name
- * @param integer DB-Link
- */
+ * Opens a connection to the specified database name
+ *
+ * @param string Database name
+ * @param integer DB-Link
+ */
private function _selectDb($database, $link)
{
if (!mysql_select_db($database, $link))
}
}
- // ###################################################################
/**
- * Wrapper: mysql_query
- */
+ * Wrapper: mysql_query
+ */
protected function _query($string)
{
return mysql_query($string, $this->dblink);
}
- // ###################################################################
/**
- * Wrapper: mysql_escape_string
- */
+ * Wrapper: mysql_escape_string
+ */
protected function _escapeBinary($binary)
{
return mysql_escape_string($binary);
}
- // ###################################################################
/**
- * Wrapper: mysql(_real)_escape_string
- */
+ * Wrapper: mysql(_real)_escape_string
+ */
protected function _escapeString($string)
{
if (function_exists('mysql_real_escape_string'))
}
}
- // ###################################################################
/**
- * Not supported: unescape binary string
- */
+ * Not supported: unescape binary string
+ */
protected function _unescapeBinary($string)
{
return $string;
}
- // ###################################################################
/**
- * Wrapper: mysql_insert_id
- */
+ * Wrapper: mysql_insert_id
+ */
protected function _insertId()
{
return mysql_insert_id($this->dblink);
}
- // ###################################################################
/**
- * Wrapper: mysql_affected_rows
- */
+ * Wrapper: mysql_affected_rows
+ */
protected function _affectedRows($result)
{
return mysql_affected_rows($this->dblink);
}
- // ###################################################################
/**
- * Starts a database transaction
- */
+ * Starts a database transaction
+ */
public function begin()
{
$this->query("BEGIN WORK");
}
- // ###################################################################
/**
- * Reverts a transaction back to a given savepoint
- */
+ * Reverts a transaction back to a given savepoint
+ */
public function rollback()
{
$this->query("ROLLBACK");
}
- // ###################################################################
/**
- * Commits a database transaction
- */
+ * Commits a database transaction
+ */
public function commit()
{
$this->query("COMMIT");
}
- // ###################################################################
/**
- * Returns the error number
- *
- * @return integer Error number
- */
+ * Returns the error number
+ *
+ * @return integer Error number
+ */
public function _errorNumber()
{
return mysql_errno($this->dblink);
}
- // ###################################################################
/**
- * Returns the error string
- *
- * @return string Error string
- */
+ * Returns the error string
+ *
+ * @return string Error string
+ */
public function _errorString()
{
return mysql_error($this->dblink);
*/
class BSDbMySqlResult extends BSDbResult
{
- // ###################################################################
/**
- * Wrapper: mysql_fetch_assoc
- */
+ * Wrapper: mysql_fetch_assoc
+ */
protected function _fetchAssocArray($result)
{
return mysql_fetch_assoc($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_fetch_row
- */
+ * Wrapper: mysql_fetch_row
+ */
protected function _fetchRowArray($result)
{
return mysql_fetch_row($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_fetch_object
- */
+ * Wrapper: mysql_fetch_object
+ */
public function _fetchObject($result)
{
return mysql_fetch_object($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_free_result
- */
+ * Wrapper: mysql_free_result
+ */
protected function _freeResult($result)
{
mysql_free_result($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_num_rows
- */
+ * Wrapper: mysql_num_rows
+ */
protected function _numRows($result)
{
return mysql_num_rows($result);
\*=====================================================================*/
/**
-* MySQLi Database Layer (DbMySqlI.php)
-*
-* @package ISSO
-*/
+ * MySQLi Database Layer (DbMySqlI.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Db.php');
/**
-* MySQLi Database Layer
-*
-* This framework is a function wrapper for MySQLi functions so we can have
-* better error reporting and query reporting.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * MySQLi Database Layer
+ *
+ * This framework is a function wrapper for MySQLi functions so we can have
+ * better error reporting and query reporting.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSDbMySqlI extends BSDb
{
- // ###################################################################
/**
- * Wrapper: mysql_connect
- */
+ * Wrapper: mysql_connect
+ */
protected function _connect($server, $user, $password, $database)
{
return @mysqli_connect($server, $user, $password, $database);
}
- // ###################################################################
/**
- * Wrapper: mysql_query
- */
+ * Wrapper: mysql_query
+ */
protected function _query($string)
{
return mysqli_query($this->dblink, $string);
}
- // ###################################################################
/**
- * Wrapper: mysql_escape_string
- */
+ * Wrapper: mysql_escape_string
+ */
protected function _escapeBinary($binary)
{
return mysqli_real_escape_string($this->dblink, $binary);
}
- // ###################################################################
/**
- * Wrapper: mysql(_real)_escape_string
- */
+ * Wrapper: mysql(_real)_escape_string
+ */
protected function _escapeString($string)
{
return mysqli_real_escape_string($this->dblink, $string);
}
- // ###################################################################
/**
- * Not supported: unescape binary string
- */
+ * Not supported: unescape binary string
+ */
protected function _unescapeBinary($string)
{
return $string;
}
- // ###################################################################
/**
- * Wrapper: mysql_insert_id
- */
+ * Wrapper: mysql_insert_id
+ */
protected function _insertId()
{
return mysqli_insert_id($this->dblink);
}
- // ###################################################################
/**
- * Wrapper: mysql_affected_rows
- */
+ * Wrapper: mysql_affected_rows
+ */
protected function _affectedRows($result)
{
return mysqli_affected_rows($this->dblink);
}
- // ###################################################################
/**
- * Starts a database transaction
- */
+ * Starts a database transaction
+ */
public function begin()
{
$this->query("START TRANSACTION");
}
- // ###################################################################
/**
- * Reverts a transaction back to a given savepoint
- */
+ * Reverts a transaction back to a given savepoint
+ */
public function rollback()
{
$this->query("ROLLBACK");
}
- // ###################################################################
/**
- * Commits a database transaction
- */
+ * Commits a database transaction
+ */
public function commit()
{
$this->query("COMMIT");
}
- // ###################################################################
/**
- * Returns the error number
- *
- * @return integer Error number
- */
+ * Returns the error number
+ *
+ * @return integer Error number
+ */
public function _errorNumber()
{
return mysqli_errno($this->dblink);
}
- // ###################################################################
/**
- * Returns the error string
- *
- * @return string Error string
- */
+ * Returns the error string
+ *
+ * @return string Error string
+ */
public function _errorString()
{
return mysqli_error($this->dblink);
*/
class BSDbMySqlIResult extends BSDbResult
{
- // ###################################################################
/**
- * Wrapper: mysql_fetch_assoc
- */
+ * Wrapper: mysql_fetch_assoc
+ */
protected function _fetchAssocArray($result)
{
return mysqli_fetch_assoc($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_fetch_row
- */
+ * Wrapper: mysql_fetch_row
+ */
protected function _fetchRowArray($result)
{
return mysqli_fetch_row($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_fetch_object
- */
+ * Wrapper: mysql_fetch_object
+ */
public function _fetchObject($result)
{
return mysqli_fetch_object($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_free_result
- */
+ * Wrapper: mysql_free_result
+ */
protected function _freeResult($result)
{
mysqli_free_result($result);
}
- // ###################################################################
/**
- * Wrapper: mysql_num_rows
- */
+ * Wrapper: mysql_num_rows
+ */
protected function _numRows($result)
{
return mysqli_num_rows($result);
\*=====================================================================*/
/**
-* PostgreSQL Database Layer (DbPostgreSql.php)
-*
-* @package ISSO
-*/
+ * PostgreSQL Database Layer (DbPostgreSql.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Db.php');
/**
-* PostgreSQL Database Layer
-*
-* This framework is a function wrapper for PostgreSQL functions so we can have
-* better error reporting and query reporting.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * PostgreSQL Database Layer
+ *
+ * This framework is a function wrapper for PostgreSQL functions so we can have
+ * better error reporting and query reporting.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSDbPostgreSql extends BSDb
{
/**
- * Port number to connect to
- * @var integer
- */
+ * Port number to connect to
+ * @var integer
+ */
private $port = 5432;
- // ###################################################################
/**
- * Sets the port number for the connection
- *
- * @param integer Port number
- */
+ * Sets the port number for the connection
+ *
+ * @param integer Port number
+ */
public function setPort($port)
{
$this->port = $port;
}
- // ###################################################################
/**
- * Wrapper: pg_connect
- */
+ * Wrapper: pg_connect
+ */
protected function _connect($server, $user, $password, $database)
{
return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'");
}
- // ###################################################################
/**
- * Wrapper: pg_escape_string
- */
+ * Wrapper: pg_escape_string
+ */
protected function _escapeString()
{
return pg_escape_string($string);
}
- // ###################################################################
/**
- * Wrapper/no support: error string
- */
+ * Wrapper/no support: error string
+ */
protected function _errorString()
{
if ($this->result)
return pg_last_error($this->dblink);
}
- // ###################################################################
/**
- * Not supported: error numbers
- */
+ * Not supported: error numbers
+ */
protected function _errorNumber()
{
return -1;
}
- // ###################################################################
/**
- * Overload: insertId
- */
+ * Overload: insertId
+ */
public function insertId($table, $field)
{
return $this->queryFirst("SELECT last_value FROM {$table}_{$field}_seq")->fetchObject()->last_value;
protected function _insertId()
{}
- // ###################################################################
/**
- * Wrapper: pg_affected_rows
- */
+ * Wrapper: pg_affected_rows
+ */
protected function _affectedRows($result)
{
return pg_affected_rows($result);
}
- // ###################################################################
/**
- * Starts a database transaction
- */
+ * Starts a database transaction
+ */
public function begin()
{
$this->query("BEGIN");
}
- // ###################################################################
/**
- * Reverts a transaction back to a given savepoint
- */
+ * Reverts a transaction back to a given savepoint
+ */
public function rollback()
{
$this->query("ROLLBACK");
}
- // ###################################################################
/**
- * Commits a database transaction
- */
+ * Commits a database transaction
+ */
public function commit()
{
$this->query("COMMIT");
}
- // ###################################################################
/**
- * Returns the error number
- *
- * @return integer Error number
- */
+ * Returns the error number
+ *
+ * @return integer Error number
+ */
public function _errorNumber()
{
return -1;
}
- // ###################################################################
/**
- * Returns the error string
- *
- * @return string Error string
- */
+ * Returns the error string
+ *
+ * @return string Error string
+ */
public function _errorString()
{
return pg_last_error($this->dblink);
*/
class BSDbPostgreSqlResult extends BSDbResult
{
- // ###################################################################
/**
- * Wrapper: pg_fetch_assoc
- */
+ * Wrapper: pg_fetch_assoc
+ */
protected function _fetchAssocArray($result)
{
return pg_fetch_assoc($result);
}
- // ###################################################################
/**
- * Wrapper: pg_fetch_row
- */
+ * Wrapper: pg_fetch_row
+ */
protected function _fetchRowArray($result)
{
return pg_fetch_row($result);
}
- // ###################################################################
/**
- * Wrapper: pg_fetch_object
- */
+ * Wrapper: pg_fetch_object
+ */
public function _fetchObject($result)
{
return pg_fetch_object($result);
}
- // ###################################################################
/**
- * Wrapper: pg_free_result
- */
+ * Wrapper: pg_free_result
+ */
protected function _freeResult($result)
{
pg_free_result($result);
}
- // ###################################################################
/**
- * Wrapper: pg_num_rows
- */
+ * Wrapper: pg_num_rows
+ */
protected function _numRows($result)
{
return pg_num_rows($result);
\*=====================================================================*/
/**
-* Static functions (Functions.php)
-*
-* @package ISSO
-*/
+ * Static functions (Functions.php)
+ *
+ * @package ISSO
+ */
/**
-* Functions
-*
-* This is a bunch of static functions. This class is singleton so it
-* can store data while remaining static.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Functions
+ *
+ * This is a bunch of static functions. This class is singleton so it
+ * can store data while remaining static.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSFunctions
{
/**
- * Singleton instance
- * @var object
- */
+ * Singleton instance
+ * @var object
+ */
private static $instance;
/**
- * Cookie path
- * @var string
- */
+ * Cookie path
+ * @var string
+ */
private $cookiePath = '/';
/**
- * Cookie domain setting
- * @var string
- */
+ * Cookie domain setting
+ * @var string
+ */
private $cookieDomain = '';
/**
- * Cookie expiration time
- * @var integer
- */
+ * Cookie expiration time
+ * @var integer
+ */
private $cookieTimeout = 900;
/**
- * Current swapped CSS class
- * @var string
- */
+ * Current swapped CSS class
+ * @var string
+ */
public static $cssClass = '';
- // ###################################################################
/**
- * Constructor
- */
+ * Constructor
+ */
private function __construct() {}
- // ###################################################################
/**
- * Returns the shared instance for singleton
- *
- * @return object Shared instance
- */
+ * Returns the shared instance for singleton
+ *
+ * @return object Shared instance
+ */
private function _instance()
{
if (!self::$instance)
return self::$instance;
}
- // ###################################################################
/**
- * Sets the cookie path
- *
- * @param string New path
- */
+ * Sets the cookie path
+ *
+ * @param string New path
+ */
public static function set_cookie_path($path)
{
self::_instance()->cookiePath = $path;
}
- // ###################################################################
/**
- * Sets the cookie domain setting
- *
- * @param string Cookie domain
- */
+ * Sets the cookie domain setting
+ *
+ * @param string Cookie domain
+ */
public static function set_cookie_domain($domain)
{
self::_instance()->cookieDomain = $domain;
}
- // ###################################################################
/**
- * Sets the cookie timeout
- *
- * @param integer Cookie timeout
- */
+ * Sets the cookie timeout
+ *
+ * @param integer Cookie timeout
+ */
public static function set_cookie_timeout($timeout)
{
self::_instance()->cookieTimeout = intval($timeout);
}
- // ###################################################################
/**
- * Sets a cookie in the user's computer/browing session
- *
- * @param string Name of the cookie
- * @param string Value of the cookie, FALSE to clear
- * @param bool Is the cookie permanent?
- */
+ * Sets a cookie in the user's computer/browing session
+ *
+ * @param string Name of the cookie
+ * @param string Value of the cookie, FALSE to clear
+ * @param bool Is the cookie permanent?
+ */
public static function cookie($name, $value, $sticky = true)
{
// expire the cookie
}
}
- // ###################################################################
/**
- * Alternate between two CSS classes
- *
- * @param string First CSS class name
- * @param string Second CSS class name
- */
+ * Alternate between two CSS classes
+ *
+ * @param string First CSS class name
+ * @param string Second CSS class name
+ */
public static function swap_css_classes($class1 = 'alt1', $class2 = 'alt2')
{
static $count;
$count++;
}
- // ###################################################################
/**
- * Returns the 'source path' version of a file path. It adds a
- * directory separator to the end of a string if it does not already
- * exist.
- *
- * @param string Path
- *
- * @return string Path with directory separator ending
- */
+ * Returns the 'source path' version of a file path. It adds a
+ * directory separator to the end of a string if it does not already
+ * exist.
+ *
+ * @param string Path
+ *
+ * @return string Path with directory separator ending
+ */
public static function fetch_source_path($source)
{
if (substr($source, strlen($source) - 1) != DIRECTORY_SEPARATOR)
return $source;
}
- // ###################################################################
/**
- * Force-download a file by sending application/octetstream
- *
- * @param string The text of the file to be streamed
- * @param string File name of the new file
- * @param bool Whether or not to die after stringeaming the file
- */
+ * Force-download a file by sending application/octetstream
+ *
+ * @param string The text of the file to be streamed
+ * @param string File name of the new file
+ * @param bool Whether or not to die after stringeaming the file
+ */
public static function download_file($file, $name, $exit = true)
{
header("Content-Type: application/octetstream");
}
}
- // ###################################################################
/**
- * Verify that an email address is valid via regex
- *
- * @param string An email address
- *
- * @return bool Validity of the email address
- */
+ * Verify that an email address is valid via regex
+ *
+ * @param string An email address
+ *
+ * @return bool Validity of the email address
+ */
public static function is_valid_email($email)
{
if (preg_match('#^[a-z0-9\.\-\+_]+?@(.*?\.)*?[a-z0-9\-_]+?\.[a-z]{2,4}$#i', $email))
}
}
- // ###################################################################
/**
- * Generates a random string of random length (unless otherwise
- * specified)
- *
- * @param integer Optional length
- *
- * @return string A random string
- */
+ * Generates a random string of random length (unless otherwise
+ * specified)
+ *
+ * @param integer Optional length
+ *
+ * @return string A random string
+ */
public static function random($length = 0)
{
// length wasn't provided, so create our own
return $string;
}
- // ###################################################################
/**
- * Sets the current array position to be the specified key. This
- * function should be avoided on large arrays.
- *
- * @param array The array whose counter is to be updated
- * @param mixed The key of the element of the array that the counter is to be set to
- *
- * @return mixed Return the elelment of the array that we just put the counter to
- */
+ * Sets the current array position to be the specified key. This
+ * function should be avoided on large arrays.
+ *
+ * @param array The array whose counter is to be updated
+ * @param mixed The key of the element of the array that the counter is to be set to
+ *
+ * @return mixed Return the elelment of the array that we just put the counter to
+ */
public static function array_set_current(&$array, $key)
{
reset($array);
return current($array);
}
- // ###################################################################
/**
- * Calculates the microtime difference by taking a given microtime and
- * subtracting it from the current one
- *
- * @param string The start microtime
- *
- * @return float Microtime difference
- */
+ * Calculates the microtime difference by taking a given microtime and
+ * subtracting it from the current one
+ *
+ * @param string The start microtime
+ *
+ * @return float Microtime difference
+ */
public static function fetch_microtime_diff($mtstart)
{
$mtend = microtime();
return ($endMicro + $endSec) - ($startMicro + $startSec);
}
- // ###################################################################
/**
- * Fetches the extension of a file by extracting everything after the
- * last period
- *
- * @param string Filename
- *
- * @return string The extension for the specifid file name
- */
+ * Fetches the extension of a file by extracting everything after the
+ * last period
+ *
+ * @param string Filename
+ *
+ * @return string The extension for the specifid file name
+ */
public static function fetch_extension($filename)
{
$array = explode('.', $filename);
return strval(end($array));
}
- // ###################################################################
/**
- * Gets the maximum file size for attachment uploading, as specified by
- * PHP. If no value is present, 10 MB (represented in bytes) is
- * returned.
- *
- * @return integer The maximum file upload size in bytes
- */
+ * Gets the maximum file size for attachment uploading, as specified by
+ * PHP. If no value is present, 10 MB (represented in bytes) is
+ * returned.
+ *
+ * @return integer The maximum file upload size in bytes
+ */
public static function fetch_max_php_file_size()
{
if ($size = @ini_get('upload_max_filesize'))
}
}
- // ###################################################################
/**
- * Scans a specified directory path and returns an array of all the
- * items in that directory. Directories found by this are end in a "/"
- *
- * @param string Path to scan
- * @param bool Whether or not to recursively scan the directories encountered
- * @param bool Ignore files beginning with a dot
- *
- * @return array A list of all the files in the specified path
- */
+ * Scans a specified directory path and returns an array of all the
+ * items in that directory. Directories found by this are end in a "/"
+ *
+ * @param string Path to scan
+ * @param bool Whether or not to recursively scan the directories encountered
+ * @param bool Ignore files beginning with a dot
+ *
+ * @return array A list of all the files in the specified path
+ */
public static function scan_directory($path, $recurse = true, $ignoreDot = true)
{
return self::_help_scan_directory($path, $recurse, $ignoreDot, '');
}
- // ###################################################################
/**
- * Scans a specified directory path and returns an array of all the
- * items in that directory. Directories found by this are end in a "/"
- *
- * @param string Path to scan
- * @param bool Whether or not to recursively scan the directories encountered
- * @param bool Ignore files beginning with a dot
- * @param string Add to the beginning of the path
- *
- * @return array A list of all the files in the specified path
- */
+ * Scans a specified directory path and returns an array of all the
+ * items in that directory. Directories found by this are end in a "/"
+ *
+ * @param string Path to scan
+ * @param bool Whether or not to recursively scan the directories encountered
+ * @param bool Ignore files beginning with a dot
+ * @param string Add to the beginning of the path
+ *
+ * @return array A list of all the files in the specified path
+ */
private static function _help_scan_directory($path, $recurse = true, $ignoreDot = true, $pathAdd = '')
{
$filelist = array();
return $filelist;
}
- // ###################################################################
/**
- * Changes line breaks into one format
- *
- * @param string Text
- * @param string New line break (default is UNIX \n format)
- *
- * @return string Text with one type of line break
- */
+ * Changes line breaks into one format
+ *
+ * @param string Text
+ * @param string New line break (default is UNIX \n format)
+ *
+ * @return string Text with one type of line break
+ */
public static function convert_line_breaks($text, $convert_to = "\n")
{
$text = trim($text);
return $text;
}
- // ###################################################################
/**
- * Removes all empty() [by PHP's standards] elements in an array. This
- * can be used in place of using PREG_SPLIT_NO_EMPTY.
- *
- * @param array An array to strip empties from
- *
- * @return array Full-valued array
- */
+ * Removes all empty() [by PHP's standards] elements in an array. This
+ * can be used in place of using PREG_SPLIT_NO_EMPTY.
+ *
+ * @param array An array to strip empties from
+ *
+ * @return array Full-valued array
+ */
public static function array_strip_empty($array)
{
foreach ($array as $key => $value)
return $array;
}
- // ###################################################################
/**
- * A backtrace formatter.
- *
- * This is very slightly modified from PEAR/PHP_Compat (PHP license)
- *
- * @author Laurent Laville <pear@laurent-laville.org>
- * @author Aidan Lister <aidan@php.net>
- *
- * @param array The backtrace from debug_backtrace() to format
- *
- * @return string Formatted output
- */
+ * A backtrace formatter.
+ *
+ * This is very slightly modified from PEAR/PHP_Compat (PHP license)
+ *
+ * @author Laurent Laville <pear@laurent-laville.org>
+ * @author Aidan Lister <aidan@php.net>
+ *
+ * @param array The backtrace from debug_backtrace() to format
+ *
+ * @return string Formatted output
+ */
public static function format_backtrace($backtrace)
{
// Unset call to debug_print_backtrace
return implode("\n", $calls);
}
- // ###################################################################
/**
- * A variation of PHP's substr() method that takes in the start
- * and end position of a string, rather than a start and length. This
- * mimics Java's String.substring() method.
- *
- * @param string The string
- * @param integer Start position
- * @param integer End position
- *
- * @return string Part of a string
- */
+ * A variation of PHP's substr() method that takes in the start
+ * and end position of a string, rather than a start and length. This
+ * mimics Java's String.substring() method.
+ *
+ * @param string The string
+ * @param integer Start position
+ * @param integer End position
+ *
+ * @return string Part of a string
+ */
public static function substring($string, $start, $end)
{
return substr($string, $start, $end - $start);
\*=====================================================================*/
/**
-* Input sanitizer (Input.php)
-*
-* @package ISSO
-*/
+ * Input sanitizer (Input.php)
+ *
+ * @package ISSO
+ */
/**#@+
-* Input cleaning type constant
-*/
+ * Input cleaning type constant
+ */
/**
-* Integer type
-*/
+ * Integer type
+ */
define('TYPE_INT', 1);
/**
-* Unsigned integer
-*/
+ * Unsigned integer
+ */
define('TYPE_UINT', 2);
/**
-* Float type
-*/
+ * Float type
+ */
define('TYPE_FLOAT', 4);
/**
-* Boolean type
-*/
+ * Boolean type
+ */
define('TYPE_BOOL', 8);
/**
-* String - cleaned
-*/
+ * String - cleaned
+ */
define('TYPE_STR', 16);
/**
-* String - deliberate unclean
-*/
+ * String - deliberate unclean
+ */
define('TYPE_STRUN', 32);
/**
-* No cleaning - here for use in API
-*/
+ * No cleaning - here for use in API
+ */
define('TYPE_NONE', 64);
/**
-* Macro for using DB->escape_binary() without cleaning - used in API
-*/
+ * Macro for using DB->escape_binary() without cleaning - used in API
+ */
define('TYPE_BIN', 128);
/**#@-*/
/**
-* Input Sanitizer
-*
-* This class is responsible for cleaning input.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Input Sanitizer
+ *
+ * This class is responsible for cleaning input.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSInput
{
/**
- * An array of sanitized variables that have been cleaned for HTML tag openers and double quotes
- * @var array
- */
+ * An array of sanitized variables that have been cleaned for HTML tag openers and double quotes
+ * @var array
+ */
public $in = array();
/**
- * If we are running with magic_quotes_gpc on or off
- * @var int
- */
+ * If we are running with magic_quotes_gpc on or off
+ * @var int
+ */
private $magicquotes = 0;
- // ###################################################################
/**
- * Constructor: set instance variables and execute input cleaning
- */
+ * Constructor: set instance variables and execute input cleaning
+ */
public function __construct()
{
// magic quotes
$this->_sanitizeInputData();
}
- // ###################################################################
/**
- * Recursive XSS cleaner
- *
- * @param mixed Unsanitized REQUEST data
- *
- * @return mixed Sanitized data
- */
+ * Recursive XSS cleaner
+ *
+ * @param mixed Unsanitized REQUEST data
+ *
+ * @return mixed Sanitized data
+ */
private function _sanitizeDataRecursive($data)
{
foreach ($data as $key => $value)
return $data;
}
- // ###################################################################
/**
- * Simple way to protect against HTML attacks with Unicode support
- *
- * @param string Unsanitzed text
- *
- * @return string Properly protected text that only encodes potential threats
- */
+ * Simple way to protect against HTML attacks with Unicode support
+ *
+ * @param string Unsanitzed text
+ *
+ * @return string Properly protected text that only encodes potential threats
+ */
public function sanitize($text)
{
if ($this->magicquotes)
}
}
- // ###################################################################
/**
- * Unicode-safe entity encoding system; similar to sanitize()
- *
- * @param string Unsanitized text
- *
- * @return string Unicode-safe sanitized text with entities preserved
- */
+ * Unicode-safe entity encoding system; similar to sanitize()
+ *
+ * @param string Unsanitized text
+ *
+ * @return string Unicode-safe sanitized text with entities preserved
+ */
public function entityEncode($text)
{
$text = str_replace('&', '&', $text);
return $text;
}
- // ###################################################################
/**
- * Takes text that has been processed for HTML and unsanitizes it
- *
- * @param string Text that needs to be turned back into HTML
- *
- * @return string Unsanitized text
- */
+ * Takes text that has been processed for HTML and unsanitizes it
+ *
+ * @param string Text that needs to be turned back into HTML
+ *
+ * @return string Unsanitized text
+ */
public function unsanitize($text)
{
return str_replace(array('<', '>', '"'), array('<', '>', '"'), $text);
}
- // ###################################################################
/**
- * Smart addslashes() that only applies itself it the Magic Quotes GPC
- * is off. This should only be run on database query values that come
- * from ISSO->in[] input; data that needs sanitization should be run
- * through Db->escapeString()
- *
- * @param string Some string
- * @param bool Force magic quotes to be off
- *
- * @return string String that has slashes added
- */
+ * Smart addslashes() that only applies itself it the Magic Quotes GPC
+ * is off. This should only be run on database query values that come
+ * from ISSO->in[] input; data that needs sanitization should be run
+ * through Db->escapeString()
+ *
+ * @param string Some string
+ * @param bool Force magic quotes to be off
+ *
+ * @return string String that has slashes added
+ */
public function escape($str, $force = true)
{
$db = BSApp::$db;
}
}
- // ###################################################################
/**
- * Runs through all of the input data and sanitizes it.
- */
+ * Runs through all of the input data and sanitizes it.
+ */
private function _sanitizeInputData()
{
$this->in = $this->_sanitizeDataRecursive(array_merge($_GET, $_POST, $_COOKIE));
}
- // ###################################################################
/**
- * Sanitize function for something other than a string (which
- * everything is sanitized for if you use _sanitizeInputData(). Cleaned
- * data is placed back into Input->in; this makes it so you don't have
- * to constantly intval() [etc.] data.
- *
- * @param array Array of elements to clean as varname => type
- */
+ * Sanitize function for something other than a string (which
+ * everything is sanitized for if you use _sanitizeInputData(). Cleaned
+ * data is placed back into Input->in; this makes it so you don't have
+ * to constantly intval() [etc.] data.
+ *
+ * @param array Array of elements to clean as varname => type
+ */
public function inputCleanArray($vars)
{
foreach ($vars as $varname => $type)
}
}
- // ###################################################################
/**
- * Sanitize function that does a single variable as oppoesd to an array
- * (see inputCleanArray() for more details)
- *
- * @param string Variable name in ISSO->in[]
- * @param integer Sanitization type constant
- */
+ * Sanitize function that does a single variable as oppoesd to an array
+ * (see inputCleanArray() for more details)
+ *
+ * @param string Variable name in ISSO->in[]
+ * @param integer Sanitization type constant
+ */
public function inputClean($varname, $type)
{
if (isset($this->in["$varname"]))
return $this->in["$varname"];
}
- // ###################################################################
/**
- * Runs Input->escape() on a variable on Input->in[]. This is just a
- * short-hand wrapper so that queries can be shortened. When this is used,
- * the actual value in Input->in[] is not changed, only the return value
- * is escaped.
- *
- * @param string Input variable
- *
- * @return string Escaped input
- */
+ * Runs Input->escape() on a variable on Input->in[]. This is just a
+ * short-hand wrapper so that queries can be shortened. When this is used,
+ * the actual value in Input->in[] is not changed, only the return value
+ * is escaped.
+ *
+ * @param string Input variable
+ *
+ * @return string Escaped input
+ */
public function inputEscape($varname)
{
if (isset($this->in["$varname"]))
}
}
- // ###################################################################
/**
- * Cleaning function that does the work for inputClean(); this is
- * moved here so it can be used to clean things that aren't in
- * Input->in[]
- *
- * @param mixed Data
- * @param integer Sanitization type constant
- *
- * @return mixed Cleaned data
- */
+ * Cleaning function that does the work for inputClean(); this is
+ * moved here so it can be used to clean things that aren't in
+ * Input->in[]
+ *
+ * @param mixed Data
+ * @param integer Sanitization type constant
+ *
+ * @return mixed Cleaned data
+ */
public function clean($value, $type)
{
if (is_array($value))
return $value;
}
- // ###################################################################
/**
- * Recursion function for Input->clean()
- *
- * @param array Uncleaned array
- * @param integer Sanitization type constant
- *
- * @return array Cleaned array of data
- */
+ * Recursion function for Input->clean()
+ *
+ * @param array Uncleaned array
+ * @param integer Sanitization type constant
+ *
+ * @return array Cleaned array of data
+ */
private function _cleanArray($array, $type)
{
foreach ($array as $key => $value)
return $array;
}
- // ###################################################################
/**
- * Returns the lowercase version of the HTTP method (post or get)
- *
- * @return string HTTP method
- */
+ * Returns the lowercase version of the HTTP method (post or get)
+ *
+ * @return string HTTP method
+ */
public function getHttpMethod()
{
$method = strtolower($_SERVER['REQUEST_METHOD']);
return $method;
}
- // ###################################################################
/**
- * Checks to see if a POST refer is actually from us
- */
+ * Checks to see if a POST refer is actually from us
+ */
public function checkPostReferer()
{
if ($this->getHttpMethod() == 'post')
\*=====================================================================*/
/**
-* Installer creator (Install.php)
-*
-* @package ISSO
-*/
+ * Installer creator (Install.php)
+ *
+ * @package ISSO
+ */
/**
-* Installer
-*
-* Installer modules should extend this class. In the install module router,
-* instantiate the right module. Methods beginning with step*() will be executed
-* in numerical order.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Installer
+ *
+ * Installer modules should extend this class. In the install module router,
+ * instantiate the right module. Methods beginning with step*() will be executed
+ * in numerical order.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSInstaller
{
/**
- * All the method steps
- * @var array
- */
+ * All the method steps
+ * @var array
+ */
private $steps = array();
/**
- * The file name of this module
- * @var string
- */
+ * The file name of this module
+ * @var string
+ */
protected $fileName;
/**
- * Constructor: set up the steps
- *
- * @param string The file name for this module
- */
+ * Constructor: set up the steps
+ *
+ * @param string The file name for this module
+ */
public function __construct($fileName)
{
$this->fileName = $fileName;
$this->_runStep(BSApp::$input->inputClean('step', TYPE_UINT));
}
- // ###################################################################
/**
- * An abstract method that needs to be overridden by a subclass that
- * populates the page title
- *
- * @return string Returns the page title
- */
+ * An abstract method that needs to be overridden by a subclass that
+ * populates the page title
+ *
+ * @return string Returns the page title
+ */
protected abstract function _pageTitle();
- // ###################################################################
/**
- * Abstract method that will return link to the page after all the
- * steps are completed. This needs to provide it's own <a>
- *
- * @return string Final page link
- */
+ * Abstract method that will return link to the page after all the
+ * steps are completed. This needs to provide it's own <a>
+ *
+ * @return string Final page link
+ */
protected abstract function _finalLink();
- // ###################################################################
/**
- * Abstract method that prints out the first welcome screen that the
- * user sees when no step has been selected
- */
+ * Abstract method that prints out the first welcome screen that the
+ * user sees when no step has been selected
+ */
protected abstract function _welcomePage();
- // ###################################################################
/**
- * Prints out the page header... you really don't do this more than
- * once
- */
+ * Prints out the page header... you really don't do this more than
+ * once
+ */
protected function _setUp()
{
?>
<?php
}
- // ###################################################################
/**
- * Runs the specific step method; if it does not exist, it will throw
- * an error
- *
- * @param integer Step number
- */
+ * Runs the specific step method; if it does not exist, it will throw
+ * an error
+ *
+ * @param integer Step number
+ */
protected function _runStep($step)
{
if ($step == 0)
}
}
- // ###################################################################
/**
- * Prints out the footer part of the page, and the appropriate forwarding
- * action button
- *
- * @param integer Step number
- */
+ * Prints out the footer part of the page, and the appropriate forwarding
+ * action button
+ *
+ * @param integer Step number
+ */
protected function _setDown($step)
{
// this is the last step, print the final button
\*=====================================================================*/
/**
-* Mail Sender (mail.php)
-*
-* @package ISSO
-*/
+ * Mail Sender (mail.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Functions.php');
/**
-* Mail Sender
-*
-* This framework is a wrapper for the PHP mail function that properly
-* sends mail with full email headers.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Mail Sender
+ *
+ * This framework is a wrapper for the PHP mail function that properly
+ * sends mail with full email headers.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSMail
{
/**
- * The subject of the message
- * @var string
- */
+ * The subject of the message
+ * @var string
+ */
private $subject = '';
/**
- * Body plain-text of the message
- * @var string
- */
+ * Body plain-text of the message
+ * @var string
+ */
private $bodyText = '';
/**
- * HTML multi-part body of the message
- * @var string
- */
+ * HTML multi-part body of the message
+ * @var string
+ */
private $bodyHtml = '';
/**
- * The message sender's email address
- * @var string
- */
+ * The message sender's email address
+ * @var string
+ */
private $from = '';
/**
- * The message sender's display name
- * @var string
- */
+ * The message sender's display name
+ * @var string
+ */
private $fromName = '';
/**
- * Additional message headers
- * @var string
- */
+ * Additional message headers
+ * @var string
+ */
private $headers = '';
/**
- * The new line delimiter used in the message
- * @var string
- * @access private
- */
+ * The new line delimiter used in the message
+ * @var string
+ * @access private
+ */
private $delim = "\n";
/**
- * Character set used to send messages with
- * @var string
- * @access public
- */
+ * Character set used to send messages with
+ * @var string
+ * @access public
+ */
private $charset = 'utf-8'; // should we be using iso-8859-1 ?
/**
}
}
- // ###################################################################
/**
- * Sets the subject
- *
- * @param string Subject text
- */
+ * Sets the subject
+ *
+ * @param string Subject text
+ */
public function setSubject($subject)
{
$this->subject = $subject;
}
- // ###################################################################
/**
- * Sets the body text (required)
- *
- * @param string Body text
- */
+ * Sets the body text (required)
+ *
+ * @param string Body text
+ */
public function setBodyText($body)
{
$this->bodyText = $body;
}
- // ###################################################################
/**
- * Sets the HTML body (optional)
- *
- * @param string Body HTML
- */
+ * Sets the HTML body (optional)
+ *
+ * @param string Body HTML
+ */
public function setBodyHtml($body)
{
$this->bodyHtml = $body;
}
- // ###################################################################
/**
- * Sets the from address
- *
- * @param string Sending email address
- */
+ * Sets the from address
+ *
+ * @param string Sending email address
+ */
public function setFromAddress($address)
{
$this->from = $address;
}
- // ###################################################################
/**
- * Sets the from display name
- *
- * @param string From name
- */
+ * Sets the from display name
+ *
+ * @param string From name
+ */
public function setFromName($name)
{
$this->fromName = $name;
}
- // ###################################################################
/**
- * Sets any additional headers
- *
- * @param string Additional headers separated by a \n
- */
+ * Sets any additional headers
+ *
+ * @param string Additional headers separated by a \n
+ */
public function setHeaders($headers)
{
$this->headers = $headers;
}
- // ###################################################################
/**
- * Sets the character set to send the email in
- *
- * @param string Charset
- */
+ * Sets the character set to send the email in
+ *
+ * @param string Charset
+ */
public function setCharset($charset)
{
$this->charset = $charset;
}
- // ###################################################################
/**
- * Sends an email to the specified address with the specified
- * sender, subject, and body.
- *
- * @param string Email address to send to
- * @param string Name of the recipient
- * @param bool Send an HTML multipart (if HTML body specified)?
- *
- * @return bool Status of the message
- */
+ * Sends an email to the specified address with the specified
+ * sender, subject, and body.
+ *
+ * @param string Email address to send to
+ * @param string Name of the recipient
+ * @param bool Send an HTML multipart (if HTML body specified)?
+ *
+ * @return bool Status of the message
+ */
public function send($address, $name = null, $sendHtml = false)
{
if (empty($address))
}
}
- // ###################################################################
/**
- * Fetches the first line of a string
- *
- * @param string A string
- *
- * @return string The first line of the string
- */
+ * Fetches the first line of a string
+ *
+ * @param string A string
+ *
+ * @return string The first line of the string
+ */
private function _fetchFirstLine($string)
{
$string = BSFunctions::convert_line_breaks($string);
return $broken[0];
}
- // ###################################################################
/**
- * Encodes a header value (to name, fron name, subject, etc.) according
- * to RFC 2047
- *
- * @param string The text to encode
- *
- * @return string Encoded text
- */
+ * Encodes a header value (to name, fron name, subject, etc.) according
+ * to RFC 2047
+ *
+ * @param string The text to encode
+ *
+ * @return string Encoded text
+ */
function _encodeHeaderValue($text)
{
if (preg_match('#[^a-zA-Z0-9\+\-\*!/]#', $text) == 0)
\*=====================================================================*/
/**
-* Pagination System (Pagination.php)
-*
-* @package ISSO
-*/
+ * Pagination System (Pagination.php)
+ *
+ * @package ISSO
+ */
/**
-* Pagination System
-*
-* On many pages, it is necessary to limit the amount of records to display.
-* Using this class, you can set the maximum and minimum values to display,
-* and then the input variables for page number and perpage. This will
-* then create a page navigator and manage the SQL LIMIT statements.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Pagination System
+ *
+ * On many pages, it is necessary to limit the amount of records to display.
+ * Using this class, you can set the maximum and minimum values to display,
+ * and then the input variables for page number and perpage. This will
+ * then create a page navigator and manage the SQL LIMIT statements.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSPagination
{
/**
- * Current page number
- * @var integer
- */
+ * Current page number
+ * @var integer
+ */
protected $page;
/**
- * Per-page value
- * @var integer
- */
+ * Per-page value
+ * @var integer
+ */
protected $perpage;
/**
- * Number of page links
- * @var integer
- */
+ * Number of page links
+ * @var integer
+ */
protected $pagelinks;
/**
- * Total number of results
- * @var integer
- */
+ * Total number of results
+ * @var integer
+ */
protected $total;
/**
- * Total number of pages
- * @var integer
- */
+ * Total number of pages
+ * @var integer
+ */
protected $pagecount;
/**
- * Maximum number of per-page results
- * @var integer
- */
+ * Maximum number of per-page results
+ * @var integer
+ */
protected $maxperpage = 100;
/**
- * Default number of per-page results
- * @var integer
- */
+ * Default number of per-page results
+ * @var integer
+ */
protected $defaultperpage = 20;
- // ###################################################################
/**
* Callback public function for the processing of an indivdual page link
*
*/
protected abstract function _bitProcessor($baselink, $isCurrent, $pagenumber);
- // ###################################################################
/**
* Callback public function for the processing the entire page navigator
*
}
}
- // ###################################################################
/**
- * Returns the current page number
- *
- * @return integer Current page
- */
+ * Returns the current page number
+ *
+ * @return integer Current page
+ */
public function getPage()
{
return $this->page;
}
- // ###################################################################
/**
- * Returns the current perpage value
- *
- * @return integer Current perpage
- */
+ * Returns the current perpage value
+ *
+ * @return integer Current perpage
+ */
public function getPerPage()
{
return $this->perpage;
}
- // ###################################################################
/**
- * Sets total
- *
- * @param integer Total number
- */
+ * Sets total
+ *
+ * @param integer Total number
+ */
public function setTotal($total)
{
$this->total = $total;
}
- // ###################################################################
/**
- * Returns the number of pages to be in the navigator
- *
- * @param integer Number of pages
- */
+ * Returns the number of pages to be in the navigator
+ *
+ * @param integer Number of pages
+ */
public function getPageCount()
{
return $this->pagecount;
}
- // ###################################################################
/**
- * Takes all of the information from the set() functions and then
- * prepares all of the data through verification
- */
+ * Takes all of the information from the set() functions and then
+ * prepares all of the data through verification
+ */
public function processIncomingData()
{
$this->_setVariables();
$this->perpage = BSApp::$input->clean($this->perpage, TYPE_INT);
}
- // ###################################################################
/**
- * Takes the variables and splits up the pages
- */
+ * Takes the variables and splits up the pages
+ */
public function splitPages()
{
$this->pagecount = ceil($this->total / $this->perpage);
}
}
- // ###################################################################
/**
- * Returns the lower limit of the pages
- *
- * @param integer Page number
- *
- * @return integer Lower result limit
- */
+ * Returns the lower limit of the pages
+ *
+ * @param integer Page number
+ *
+ * @return integer Lower result limit
+ */
public function fetchLimit($page = null)
{
if ($page === null)
}
}
- // ###################################################################
/**
- * Constructs the page navigator
- *
- * @param string Base link path
- * @param bool Add a ? or a & to the path so it's link-friendly
- *
- * @return string Generated HTML page navigator
- */
+ * Constructs the page navigator
+ *
+ * @param string Base link path
+ * @param bool Add a ? or a & to the path so it's link-friendly
+ *
+ * @return string Generated HTML page navigator
+ */
public function constructPageNav($baselink, $addParam = true)
{
// handle base link
\*=====================================================================*/
/**
-* Printer System (printer.php)
-*
-* @package ISSO
-*/
+ * Printer System (printer.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterAbstract.php');
require_once(ISSO . '/PrinterElement.php');
require_once(ISSO . '/PrinterNavigation.php');
/**
-* Printer System
-*
-* This is the root static framework module for the HTML printer system that
-* works without templates. Here, you simply set the language and stylesheet
-* information and use the other classes to generate the code.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer System
+ *
+ * This is the root static framework module for the HTML printer system that
+ * works without templates. Here, you simply set the language and stylesheet
+ * information and use the other classes to generate the code.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinter
{
/**
- * Singleton instance
- * @var BSPrinter
- */
+ * Singleton instance
+ * @var BSPrinter
+ */
private static $instance;
/**
- * Language information for all printer elements with format array(langcode: en_US, direction: ltr/rtl, charset: utf-8)
- * @var string
- */
+ * Language information for all printer elements with format array(langcode: en_US, direction: ltr/rtl, charset: utf-8)
+ * @var string
+ */
private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8');
/**
- * CSS stylesheet to link to
- * @var string
- */
+ * CSS stylesheet to link to
+ * @var string
+ */
private $stylesheet;
/**
- * Realm; the extra bit added to the title
- * @var string
- */
+ * Realm; the extra bit added to the title
+ * @var string
+ */
private $realm = 'BSPrinterOutput';
/**
*/
private $copyright;
- // ###################################################################
/**
- * Constructor (private)
- */
+ * Constructor (private)
+ */
private function __construct() {}
- // ###################################################################
/**
- * Returns the singleton instance
- *
- * @return BSPrinter Singleton instance
- */
+ * Returns the singleton instance
+ *
+ * @return BSPrinter Singleton instance
+ */
private static function _instance()
{
if (!self::$instance)
self::_instance()->copyright = $copyright;
}
- // ###################################################################
/**
- * Returns the realm
- *
- * @return string Realm
- */
+ * Returns the realm
+ *
+ * @return string Realm
+ */
public static function get_realm()
{
return self::_instance()->realm;
}
- // ###################################################################
/**
- * Sets the realm
- *
- * @param string Realm
- */
+ * Sets the realm
+ *
+ * @param string Realm
+ */
public static function set_realm($realm)
{
self::_instance()->realm = $realm;
}
- // ###################################################################
/**
- * Returns the language array
- *
- * @return array Language array
- */
+ * Returns the language array
+ *
+ * @return array Language array
+ */
public static function get_language_information()
{
return self::_instance()->language;
}
- // ###################################################################
/**
- * Sets the language array information
- *
- * @param array Language array
- */
+ * Sets the language array information
+ *
+ * @param array Language array
+ */
public static function set_language_information($lang)
{
self::_instance()->language = $lang;
}
- // ###################################################################
/**
- * Returns the stylesheet URL
- *
- * @return string Stylesheet link
- */
+ * Returns the stylesheet URL
+ *
+ * @return string Stylesheet link
+ */
public static function get_stylesheet()
{
return self::_instance()->stylesheet;
}
- // ###################################################################
/**
- * Sets the path to the CSS style sheet
- *
- * @param string Path
- */
+ * Sets the path to the CSS style sheet
+ *
+ * @param string Path
+ */
public static function set_stylesheet($stylesheet)
{
self::_instance()->stylesheet = $stylesheet;
\*=====================================================================*/
/**
-* Printer Element Abstract Class (PrinterAbstract.php)
-*
-* @package ISSO
-*/
+ * Printer Element Abstract Class (PrinterAbstract.php)
+ *
+ * @package ISSO
+ */
/**
-* Printer Element
-*
-* This abstract class is used for all printer elements and describes
-* the basic functionality of an element.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Element
+ *
+ * This abstract class is used for all printer elements and describes
+ * the basic functionality of an element.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSPrinterAbstract
{
/**
- * Style information
- * @var array
- */
+ * Style information
+ * @var array
+ */
protected $style = array();
/**
- * The CSS class to use
- * @var string
- */
+ * The CSS class to use
+ * @var string
+ */
protected $cssClass = ':swap:';
/**
public abstract static function make();
/**
- * Tells the element to paint itself (and any children)
- */
+ * Tells the element to paint itself (and any children)
+ */
public abstract function paint();
- // ###################################################################
/**
- * Sets the CSS class to use. Use ":swap:" to alternate
- *
- * @param string CSS class
- *
- * @return fluent interface
- */
+ * Sets the CSS class to use. Use ":swap:" to alternate
+ *
+ * @param string CSS class
+ *
+ * @return fluent interface
+ */
public function setCssClass($class)
{
$this->cssClass = $class;
return $this;
}
- // ###################################################################
/**
- * Sets the style information
- *
- * @param array Style attributes
- *
- * @return fluent interface
- */
+ * Sets the style information
+ *
+ * @param array Style attributes
+ *
+ * @return fluent interface
+ */
public function setStyle(Array $attributes)
{
$this->style = $attributes;
return $this;
}
- // ###################################################################
/**
- * Returns a string of CSS style attributes
- *
- * @return string CSS attributes
- */
+ * Returns a string of CSS style attributes
+ *
+ * @return string CSS attributes
+ */
protected function _prepareStyle()
{
if (empty($this->style) && empty($this->cssClass))
\*=====================================================================*/
/**
-* Base Printer Element (PrinterElement.php)
-*
-* @package ISSO
-*/
+ * Base Printer Element (PrinterElement.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterAbstract.php');
/**
-* Base Printer Element
-*
-* This class represents the lowest level of printer elements:
-* buttons, input fields, etc. These cannot have children elements
-* and are only attached to a parent.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Base Printer Element
+ *
+ * This class represents the lowest level of printer elements:
+ * buttons, input fields, etc. These cannot have children elements
+ * and are only attached to a parent.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterElement extends BSPrinterAbstract
{
/**
- * The name of the element
- * @var string
- */
+ * The name of the element
+ * @var string
+ */
private $name;
/**
- * Type of element
- * @var string
- */
+ * Type of element
+ * @var string
+ */
private $type;
/**
- * The value of the element
- * @var string
- */
+ * The value of the element
+ * @var string
+ */
private $value;
/**
- * The checked/selected attribute (checkbox, radio, and option only)
- * @var boolean
- */
+ * The checked/selected attribute (checkbox, radio, and option only)
+ * @var boolean
+ */
private $active;
/**
- * The JavaScript onClick attribute
- * @var string
- */
+ * The JavaScript onClick attribute
+ * @var string
+ */
private $onClick;
/**
- * Accesskey attribute
- * @var string
- */
+ * Accesskey attribute
+ * @var string
+ */
private $accessKey;
/**
- * Constructor
- */
+ * Constructor
+ */
function __construct($type, $name, $value = '')
{
$this->type = $type;
return $obj->newInstanceArgs($args);
}
- // ###################################################################
/**
- * If the type is either checkbox, radio, or option then this will
- * set the selected/checked attribute
- *
- * @param boolean Active?
- *
- * @return fluent interface
- */
+ * If the type is either checkbox, radio, or option then this will
+ * set the selected/checked attribute
+ *
+ * @param boolean Active?
+ *
+ * @return fluent interface
+ */
public function setActive($active)
{
if (!in_array($this->type, array('checkbox', 'radio', 'option')))
return $this;
}
- // ###################################################################
/**
- * Sets the JavaScript onclick action
- *
- * @param string onClick attribute value
- *
- * @return fluent interface
- */
+ * Sets the JavaScript onclick action
+ *
+ * @param string onClick attribute value
+ *
+ * @return fluent interface
+ */
public function setOnClick($onClick)
{
$this->onClick = $onClick;
return $this;
}
- // ###################################################################
/**
- * Sets the accesskey attribute value
- *
- * @param string Access key
- *
- * @return fluent interface
- */
+ * Sets the accesskey attribute value
+ *
+ * @param string Access key
+ *
+ * @return fluent interface
+ */
public function setAccessKey($accessKey)
{
$this->accessKey = $accessKey;
return $this;
}
- // ###################################################################
/**
- * Returns the type
- *
- * @return string Element type
- */
+ * Returns the type
+ *
+ * @return string Element type
+ */
public function getType()
{
return $this->type;
}
- // ###################################################################
/**
- * Returns the name of the element
- *
- * @return string Name
- */
+ * Returns the name of the element
+ *
+ * @return string Name
+ */
public function getName()
{
return $this->name;
}
- // ###################################################################
/**
- * Sets the name of the element
- *
- * @param string A new name
- *
- * @return fluent interface
- */
+ * Sets the name of the element
+ *
+ * @param string A new name
+ *
+ * @return fluent interface
+ */
public function setName($name)
{
$this->name = $name;
return $this;
}
- // ###################################################################
/**
- * Returns the output HTML
- *
- * @return string Output HTML
- */
+ * Returns the output HTML
+ *
+ * @return string Output HTML
+ */
public function paint()
{
$name = ' name="' . $this->name . '"';
\*=====================================================================*/
/**
-* Printer Label Element (PrinterElementLabel.php)
-*
-* @package ISSO
-*/
+ * Printer Label Element (PrinterElementLabel.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterAbstract.php');
/**
-* Printer Label Element
-*
-* This element is a wrapper for a PHP string to be displayed in the
-* standard printer
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Label Element
+ *
+ * This element is a wrapper for a PHP string to be displayed in the
+ * standard printer
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterElementLabel extends BSPrinterAbstract
{
/**
- * The value to print
- * @var string
- */
+ * The value to print
+ * @var string
+ */
private $string = '';
- // ###################################################################
/**
- * Constructor
- *
- * @param string String to display
- */
+ * Constructor
+ *
+ * @param string String to display
+ */
function __construct($string)
{
$this->string = $string;
return $obj->newInstanceArgs($args);
}
- // ###################################################################
/**
- * Prints the string
- *
- * @return string The string; wrapped in a <span> if it has styling
- */
+ * Prints the string
+ *
+ * @return string The string; wrapped in a <span> if it has styling
+ */
public function paint()
{
if ($this->_prepareStyle())
\*=====================================================================*/
/**
-* Printer Table Element (PrinterElementTable.php)
-*
-* @package ISSO
-*/
+ * Printer Table Element (PrinterElementTable.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterRootTable.php');
require_once(ISSO . '/PrinterElement.php');
/**
-* Printer Table Element
-*
-* This represents a table row that holds elements.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Table Element
+ *
+ * This represents a table row that holds elements.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterElementTable extends BSPrinterAbstract
{
/**
- * Array of child nodes
- * @var array
- */
+ * Array of child nodes
+ * @var array
+ */
private $children = array();
/**
- * Number of columns to span
- * @var integer
- */
+ * Number of columns to span
+ * @var integer
+ */
private $colspan = 0;
- // ###################################################################
/**
- * Creates a table element; takes a variable number of arguments which
- * are added as children in the order passed
- *
- * @param BSPrinterElementTable... Variable number (or no) children
- */
+ * Creates a table element; takes a variable number of arguments which
+ * are added as children in the order passed
+ *
+ * @param BSPrinterElementTable... Variable number (or no) children
+ */
public function __construct()
{
$childs = func_get_args();
return $obj->newInstanceArgs($args);
}
- // ###################################################################
/**
- * Prints a simple row of text and text
- *
- * @param string Label (left side)
- * @param string Value (right side)
- *
- * @return BSPrinterElementTable Table row element
- */
+ * Prints a simple row of text and text
+ *
+ * @param string Label (left side)
+ * @param string Value (right side)
+ *
+ * @return BSPrinterElementTable Table row element
+ */
public static function row_label($label, $value)
{
$tr = new BSPrinterElementTable();
return $tr;
}
- // ###################################################################
/**
- * Creates an input[text/password] field row
- *
- * @param string Label
- * @param string Field name
- * @param mixed Default value
- * @param bool A password field?
- *
- * @return BPrinterElementTable Table row element
- */
+ * Creates an input[text/password] field row
+ *
+ * @param string Label
+ * @param string Field name
+ * @param mixed Default value
+ * @param bool A password field?
+ *
+ * @return BPrinterElementTable Table row element
+ */
public static function row_text($label, $name, $value = null, $password = false)
{
$tr = new BSPrinterElementTable();
return $tr;
}
- // ###################################################################
/**
- * Creates a submit row
- *
- * @param array Child elements to add before the buttons
- * @param string Save button text
- * @param string Reset button text
- *
- * @return BSPrinterElementTable Table row element
- */
+ * Creates a submit row
+ *
+ * @param array Child elements to add before the buttons
+ * @param string Save button text
+ * @param string Reset button text
+ *
+ * @return BSPrinterElementTable Table row element
+ */
public static function row_submit(Array $children = null, $save = ':submit:', $reset = ':reset:')
{
$build = '';
return $tr;
}
- // ###################################################################
/**
- * Constructs a <select> row from an array of BSPrinterElement's
- *
- * @param string Label
- * @param string Name
- * @param array Array of BSPrinterElement[option]'s
- *
- * @return BSPrinterElementTable Table row
- */
+ * Constructs a <select> row from an array of BSPrinterElement's
+ *
+ * @param string Label
+ * @param string Name
+ * @param array Array of BSPrinterElement[option]'s
+ *
+ * @return BSPrinterElementTable Table row
+ */
public static function row_list($label, $name, Array $options)
{
$build = '';
return $tr;
}
- // ###################################################################
/**
- * Constructs a row from an array of BSPrinterElement's of checkboxes
- *
- * @param string Label
- * @param string Name
- * @param array Array of BSPrinterElement[checkbox]'s that follow array(box label => BSPrinterElement)
- *
- * @return BSPrinterElementTable Table row
- */
+ * Constructs a row from an array of BSPrinterElement's of checkboxes
+ *
+ * @param string Label
+ * @param string Name
+ * @param array Array of BSPrinterElement[checkbox]'s that follow array(box label => BSPrinterElement)
+ *
+ * @return BSPrinterElementTable Table row
+ */
public static function row_checkbox($label, $name, Array $boxes)
{
$build = '';
return $tr;
}
- // ###################################################################
/**
- * Factory method to create an upload form element; requires that the
- * form this is attached to have the upload flag set
- *
- * @param string Label for the element
- * @param string Name of the <input>
- *
- * @return BSPrinterElementTable Upload form
- */
+ * Factory method to create an upload form element; requires that the
+ * form this is attached to have the upload flag set
+ *
+ * @param string Label for the element
+ * @param string Name of the <input>
+ *
+ * @return BSPrinterElementTable Upload form
+ */
public static function row_upload($label, $name)
{
$tr = new BSPrinterElementTable();
return $tr;
}
- // ###################################################################
/**
- * Creates a row with a radio select option for yes/no
- *
- * @param string Row label
- * @param string Name of the radio buttons
- * @param bool Yes is selected? (if false, No is selected)
- *
- * @return BSPrinterElementTable Yes-No row
- */
+ * Creates a row with a radio select option for yes/no
+ *
+ * @param string Row label
+ * @param string Name of the radio buttons
+ * @param bool Yes is selected? (if false, No is selected)
+ *
+ * @return BSPrinterElementTable Yes-No row
+ */
public static function row_yes_no($label, $name, $yes)
{
$elm = new BSPrinterElement('radio', $name, 1);
return $tr;
}
- // ###################################################################
/**
- * Prints a row with a textarea
- *
- * @param string Label
- * @param string Textarea name
- * @param string Value to fill with
- *
- * @return BSPrinterElementTable Table row
- */
+ * Prints a row with a textarea
+ *
+ * @param string Label
+ * @param string Textarea name
+ * @param string Value to fill with
+ *
+ * @return BSPrinterElementTable Table row
+ */
public static function row_textarea($label, $name, $value = null)
{
$tr = new BSPrinterElementTable();
return $tr;
}
- // ###################################################################
/**
- * Returns the number of columns in this element
- *
- * @return integer Column count
- */
+ * Returns the number of columns in this element
+ *
+ * @return integer Column count
+ */
public function numberOfColumns()
{
return sizeof($this->children);
}
- // ###################################################################
/**
- * Adds a child node to the element
- *
- * @param BSPrinterAbstract A child element
- *
- * @return fluent interface
- */
+ * Adds a child node to the element
+ *
+ * @param BSPrinterAbstract A child element
+ *
+ * @return fluent interface
+ */
public function addChild(BSPrinterAbstract $child)
{
$this->children[] = $child;
return $this;
}
- // ###################################################################
/**
- * Sets the number of columns this row should have and pads the <td>
- * elements accordingly
- *
- * @param integer Column count
- *
- * @return fluent interface
- */
+ * Sets the number of columns this row should have and pads the <td>
+ * elements accordingly
+ *
+ * @param integer Column count
+ *
+ * @return fluent interface
+ */
public function setColumnNumber($cols)
{
if ($cols < $this->numberOfColumns())
return $this;
}
- // ###################################################################
/**
- * Returns the HTML for all printed children elements
- *
- * @return string Printed HTML
- */
+ * Returns the HTML for all printed children elements
+ *
+ * @return string Printed HTML
+ */
protected function _paintChildren()
{
$builder = '';
return $builder;
}
- // ###################################################################
/**
- * Paints the entire table row
- *
- * @return string Table row HTML
- */
+ * Paints the entire table row
+ *
+ * @return string Table row HTML
+ */
public function paint()
{
return "\t<tr" . $this->_prepareStyle() . ">" . $this->_paintChildren() . "\n\t</tr>";
\*=====================================================================*/
/**
-* Printer: Navigation Generator (PrinterNavigation.php)
-*
-* @package ISSO
-*/
+ * Printer: Navigation Generator (PrinterNavigation.php)
+ *
+ * @package ISSO
+ */
/**
-* Printer: Navigation Generator
-*
-* This framework works in conjunction with BSPrinter to generate a page header
-* and sidebar to be used for navigation. You set the navigation array and then can
-* specify a given key to highlight elements. Elements are broken into three types:
-* tabs (top of the page), groups (blocks of link actions), and links
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer: Navigation Generator
+ *
+ * This framework works in conjunction with BSPrinter to generate a page header
+ * and sidebar to be used for navigation. You set the navigation array and then can
+ * specify a given key to highlight elements. Elements are broken into three types:
+ * tabs (top of the page), groups (blocks of link actions), and links
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterNavigation
{
/**
\*=====================================================================*/
/**
-* Printer Root Element (PrinterRootAbstract.php)
-*
-* @package ISSO
-*/
+ * Printer Root Element (PrinterRootAbstract.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterAbstract.php');
/**
-* Printer Root Element
-*
-* This is a root element class. That means that elements can be printed
-* directly into this and this can stand alone as a page. However, that
-* does not mean that all root elements produce valid XHTML.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Root Element
+ *
+ * This is a root element class. That means that elements can be printed
+ * directly into this and this can stand alone as a page. However, that
+ * does not mean that all root elements produce valid XHTML.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
abstract class BSPrinterRootAbstract extends BSPrinterAbstract
{
/**
- * Child elements
- * @var string
- */
+ * Child elements
+ * @var string
+ */
protected $children = array();
/**
- * Returns all of the children painted in the right order
- */
+ * Returns all of the children painted in the right order
+ */
protected abstract function _paintChildren();
- // ###################################################################
/**
- * Adds a child node to the element
- *
- * @param BSPrinterAbstract A child element
- *
- * @return fluent interface
- */
+ * Adds a child node to the element
+ *
+ * @param BSPrinterAbstract A child element
+ *
+ * @return fluent interface
+ */
public function addChild(BSPrinterAbstract $child)
{
$this->children[] = $child;
\*=====================================================================*/
/**
-* Printer Root Element: Form (PrinterRootForm.php)
-*
-* @package ISSO
-*/
+ * Printer Root Element: Form (PrinterRootForm.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterRootAbstract.php');
/**
-* Printer Root Element: Form
-*
-* Represents a <form> object. This can have a parent or not: if it does,
-* then it will be painted as a child, otherwise it will act as a root.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Root Element: Form
+ *
+ * Represents a <form> object. This can have a parent or not: if it does,
+ * then it will be painted as a child, otherwise it will act as a root.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterRootForm extends BSPrinterRootAbstract
{
/**
- * The form's action
- * @var string
- */
+ * The form's action
+ * @var string
+ */
private $action;
/**
- * "Do" parameter
- * @var string
- */
+ * "Do" parameter
+ * @var string
+ */
private $do;
/**
- * The form's name
- * @var string
- */
+ * The form's name
+ * @var string
+ */
private $name;
/**
- * This form is upload-ready
- * @var bool
- */
+ * This form is upload-ready
+ * @var bool
+ */
private $upload;
- // ###################################################################
/**
- * Constructor
- */
+ * Constructor
+ */
public function __construct($action, $do, $name = 'issoform')
{
$this->action = $action;
return $obj->newInstanceArgs($args);
}
- // ###################################################################
/**
- * Should this form be used for upload?
- *
- * @param bool Upload?
- *
- * @return fluent interface
- */
+ * Should this form be used for upload?
+ *
+ * @param bool Upload?
+ *
+ * @return fluent interface
+ */
public function setUpload($upload)
{
$this->upload = $upload;
return $this;
}
- // ###################################################################
/**
- * Adds a table row into the child list
- *
- * @param BSPrinterAbstract Table element
- *
- * @return fluent interface
- */
+ * Adds a table row into the child list
+ *
+ * @param BSPrinterAbstract Table element
+ *
+ * @return fluent interface
+ */
public function addChild(BSPrinterAbstract $tr)
{
$this->children[] = $tr;
return $this;
}
- // ###################################################################
/**
- * Returns the HTML for all printed children elements
- *
- * @return string Printed HTML
- */
+ * Returns the HTML for all printed children elements
+ *
+ * @return string Printed HTML
+ */
protected function _paintChildren()
{
$builder = '';
return $builder;
}
- // ###################################################################
/**
- * Paints the <table>
- *
- * @return string Table HTML code
- */
+ * Paints the <table>
+ *
+ * @return string Table HTML code
+ */
public function paint()
{
array_push($this->children, new BSPrinterElement('hidden', 'do', $this->do));
\*=====================================================================*/
/**
-* Printer Root Element: Page (PrinterRootPage.php)
-*
-* @package ISSO
-*/
+ * Printer Root Element: Page (PrinterRootPage.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterRootAbstract.php');
/**
-* Printer Root Element: Page
-*
-* This root element represents the entire page and is usually used for all
-* printer applications
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Root Element: Page
+ *
+ * This root element represents the entire page and is usually used for all
+ * printer applications
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterRootPage extends BSPrinterRootAbstract
{
/**
- * The page title
- * @var string
- */
+ * The page title
+ * @var string
+ */
private $title;
/**
*/
private $navigator;
- // ###################################################################
/**
- * Constructor
- *
- * @param string Page title
- */
+ * Constructor
+ *
+ * @param string Page title
+ */
function __construct($title)
{
$this->title = $title;
return $this->navigatior;
}
- // ###################################################################
/**
- * Creates a redirect to another page; constructs the header and footer
- * (therefore execution stops)
- *
- * @param string Location
- * @param string Redirect message to be shown
- * @param array An aray of POST variables to send through on the redirect
- */
+ * Creates a redirect to another page; constructs the header and footer
+ * (therefore execution stops)
+ *
+ * @param string Location
+ * @param string Redirect message to be shown
+ * @param array An aray of POST variables to send through on the redirect
+ */
public static function redirect($location, $message = null, $postvars = array())
{
if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
exit;
}
- // ###################################################################
/**
- * Prints a complete table message
- *
- * @param string Message title
- * @param string Message text
- *
- * @return BSPrinterRootTable A table
- */
+ * Prints a complete table message
+ *
+ * @param string Message title
+ * @param string Message text
+ *
+ * @return BSPrinterRootTable A table
+ */
public static function message($title, $message)
{
$table = new BSPrinterRootTable();
return $table;
}
- // ###################################################################
/**
- * Produces an entire page layout that asks the user whether or not
- * they want to perform X action and provides a link to the YES and NO
- * action
- *
- * @param string Message that asks if they want to do X
- * @param string Location to go to if the user confirms
- * @param string Form 'do' value
- * @param array Hidden parameters to pass to the next page
- */
+ * Produces an entire page layout that asks the user whether or not
+ * they want to perform X action and provides a link to the YES and NO
+ * action
+ *
+ * @param string Message that asks if they want to do X
+ * @param string Location to go to if the user confirms
+ * @param string Form 'do' value
+ * @param array Hidden parameters to pass to the next page
+ */
public static function confirm($message, $action, $do, $params)
{
if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
exit;
}
- // ###################################################################
/**
- * Throws a fatal error message
- *
- * @param string Error string
- */
+ * Throws a fatal error message
+ *
+ * @param string Error string
+ */
public static function error($message)
{
if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
exit;
}
- // ###################################################################
/**
- * Returns the HTML for all printed children elements
- *
- * @return string Printed HTML
- */
+ * Returns the HTML for all printed children elements
+ *
+ * @return string Printed HTML
+ */
protected function _paintChildren()
{
$builder = '';
return $builder;
}
- // ###################################################################
/**
- * Tells the element to paint itself (and any children)
- */
+ * Tells the element to paint itself (and any children)
+ */
public function paint()
{
$language = BSPrinter::get_language_information();
\*=====================================================================*/
/**
-* Printer Root Element: Table (PrinterRootTable.php)
-*
-* @package ISSO
-*/
+ * Printer Root Element: Table (PrinterRootTable.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/PrinterRootAbstract.php');
/**
-* Printer Root Element: Table
-*
-* Represents a <table> object. This can have a parent or not: if it does,
-* then it will be painted as a child, otherwise it will act as a root.
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * Printer Root Element: Table
+ *
+ * Represents a <table> object. This can have a parent or not: if it does,
+ * then it will be painted as a child, otherwise it will act as a root.
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSPrinterRootTable extends BSPrinterRootAbstract
{
/**
- * Maximum number of columns
- * @var integer
- */
+ * Maximum number of columns
+ * @var integer
+ */
private $colspan = 0;
/**
- * Heading child elements
- * @var array
- */
+ * Heading child elements
+ * @var array
+ */
private $headers = array();
/**
- * Width of the table
- * @var string
- */
+ * Width of the table
+ * @var string
+ */
private $width = '90%';
- // ###################################################################
/**
- * Constructor
- */
+ * Constructor
+ */
public function __construct()
{
$this->setCssClass('tborder');
return $obj->newInstanceArgs($args);
}
- // ###################################################################
/**
- * Adds a table row into the child list
- *
- * @param BSPrinterElementTable Table element
- *
- * @return fluent interface
- */
+ * Adds a table row into the child list
+ *
+ * @param BSPrinterElementTable Table element
+ *
+ * @return fluent interface
+ */
public function addChild(BSPrinterAbstract $tr)
{
if (!$tr instanceof BSPrinterElementTable)
return $this;
}
- // ###################################################################
/**
- * Adds a table element to be a heading of the table. This is still
- * considered a child, but it goes before all other child elemends
- *
- * @param BSPrinterElementTable Child element
- *
- * @return fluent interface
- */
+ * Adds a table element to be a heading of the table. This is still
+ * considered a child, but it goes before all other child elemends
+ *
+ * @param BSPrinterElementTable Child element
+ *
+ * @return fluent interface
+ */
public function addHeadingChild(BSPrinterElementTable $tr)
{
$this->headers[] = $tr;
return $this;
}
- // ###################################################################
/**
- * Sets the width of the table
- *
- * @param string Width value
- *
- * @return fluent interface
- */
+ * Sets the width of the table
+ *
+ * @param string Width value
+ *
+ * @return fluent interface
+ */
public function setWidth($width)
{
$this->width = $width;
return $this;
}
- // ###################################################################
/**
- * Calculates the number of columns to display based on the colspan
- * of children elements
- */
+ * Calculates the number of columns to display based on the colspan
+ * of children elements
+ */
private function _calculateColumnCount()
{
foreach ($this->children as $child)
}
}
- // ###################################################################
/**
- * Returns the HTML for all printed children elements
- *
- * @return string Printed HTML
- */
+ * Returns the HTML for all printed children elements
+ *
+ * @return string Printed HTML
+ */
protected function _paintChildren()
{
$builder = '';
return $builder;
}
- // ###################################################################
/**
- * Paints the <table>
- *
- * @return string Table HTML code
- */
+ * Paints the <table>
+ *
+ * @return string Table HTML code
+ */
public function paint()
{
return "<br />\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" align=\"center\" width=\"" . $this->width . "\"" . $this->_prepareStyle() . ">" . $this->_paintChildren() . "\n</table>";
\*=====================================================================*/
/**
-* Database-Driven Template System (template.php)
-*
-* @package ISSO
-*/
+ * Database-Driven Template System (template.php)
+ *
+ * @package ISSO
+ */
require_once(ISSO . '/Functions.php');
/**
-* File-Based Template System
-*
-* This framework merely replaces the template loading functions with
-* file-system based ones. It has an optional caching system in which
-* template data will remain stored in the database as long as the filesystem
-* file is modified. To do this, pass a table name to setDatabaseCache() and make sure
-* there's a DB module that has access to a table with this schema:
-*
-* CREATE TABLE template (filename VARCHAR (250) NOT NULL, template TEXT NOT NULL, timestamp INT NOT NULL);
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO
-*
-*/
+ * File-Based Template System
+ *
+ * This framework merely replaces the template loading functions with
+ * file-system based ones. It has an optional caching system in which
+ * template data will remain stored in the database as long as the filesystem
+ * file is modified. To do this, pass a table name to setDatabaseCache() and make sure
+ * there's a DB module that has access to a table with this schema:
+ *
+ * CREATE TABLE template (filename VARCHAR (250) NOT NULL, template TEXT NOT NULL, timestamp INT NOT NULL);
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO
+ *
+ */
class BSTemplate
{
/**
- * The path, from the path of the application, where templates are stored
- * @var string
- */
+ * The path, from the path of the application, where templates are stored
+ * @var string
+ */
private $templateDir = '';
/**
- * The extension all the template files have
- * @var string
- */
+ * The extension all the template files have
+ * @var string
+ */
private $extension = 'tpl';
/**
- * The database table name for the template cache
- * @var string
- */
+ * The database table name for the template cache
+ * @var string
+ */
private $dbCacheTable = null;
/**
- * The name of the function phrases are fetched with
- * @var string
- */
+ * The name of the function phrases are fetched with
+ * @var string
+ */
private $langcall = 'gettext';
/**
- * The name of the function phrases are sprintf() parsed with
- * @var string
- */
+ * The name of the function phrases are sprintf() parsed with
+ * @var string
+ */
private $langconst = 'sprintf';
/**
- * Array of pre-compiled templates that are stored to decrease server load
- * @var array
- */
+ * Array of pre-compiled templates that are stored to decrease server load
+ * @var array
+ */
protected $cache = array();
/**
- * A list of templates that weren't cached, but are still used
- * @var array
- */
+ * A list of templates that weren't cached, but are still used
+ * @var array
+ */
protected $uncached = array();
/**
- * Whether or not the page has been flush()'d already
- * @var bool
- */
+ * Whether or not the page has been flush()'d already
+ * @var bool
+ */
private $doneflush = false;
/**
- * The name of a function that is called before template parsing of phrases and conditionals occurs
- * @var string
- */
+ * The name of a function that is called before template parsing of phrases and conditionals occurs
+ * @var string
+ */
private $preParseHook = ':undefined:';
- // ###################################################################
/**
- * Sets the template directory name
- *
- * @param string Template directory name
- */
+ * Sets the template directory name
+ *
+ * @param string Template directory name
+ */
public function setTemplateDirectory($dir)
{
$this->templateDir = BSFunctions::fetch_source_path($dir);
}
- // ###################################################################
/**
- * Sets the file extension for the templates
- *
- * @param string File extension
- */
+ * Sets the file extension for the templates
+ *
+ * @param string File extension
+ */
public function setExtension($ext)
{
$this->extension = $ext;
}
- // ###################################################################
/**
- * Sets the name of the table to access for the datbase cache
- *
- * @param string DB table name
- */
+ * Sets the name of the table to access for the datbase cache
+ *
+ * @param string DB table name
+ */
public function setDatabaseCache($table)
{
$this->dbCacheTable = $table;
}
- // ###################################################################
/**
- * Sets the pre-parse hook method which is called before any other
- * processing is done on the template.
- *
- * @param string Method name
- */
+ * Sets the pre-parse hook method which is called before any other
+ * processing is done on the template.
+ *
+ * @param string Method name
+ */
public function setPreParseHook($hook)
{
$this->preParseHook = $hook;
}
- // ###################################################################
/**
- * Takes an array of template names, loads them, and then stores a
- * parsed version for optimum speed.
- *
- * @param array List of template names to be cached
- */
+ * Takes an array of template names, loads them, and then stores a
+ * parsed version for optimum speed.
+ *
+ * @param array List of template names to be cached
+ */
public function cache($namearray)
{
if (sizeof($this->cache) > 0)
}
}
- // ###################################################################
/**
- * Loads a template from the cache or the _load function and stores the
- * parsed version of it
- *
- * @param string The name of the template
- *
- * @return string A parsed and loaded template
- */
+ * Loads a template from the cache or the _load function and stores the
+ * parsed version of it
+ *
+ * @param string The name of the template
+ *
+ * @return string A parsed and loaded template
+ */
public function fetch($name)
{
if (isset($this->cache[$name]))
return $template;
}
- // ###################################################################
/**
- * Output a template fully compiled to the browser
- *
- * @param string Compiled and ready template
- */
+ * Output a template fully compiled to the browser
+ *
+ * @param string Compiled and ready template
+ */
public function flush($template)
{
ob_start();
print($template);
}
- // ###################################################################
/**
- * Loads an additional template from the database
- *
- * @param string The name of the template
- *
- * @return string Template data from the database
- */
+ * Loads an additional template from the database
+ *
+ * @param string The name of the template
+ *
+ * @return string Template data from the database
+ */
protected function _loadTemplate($name)
{
$path = $this->templateDir . $name . '.' . $this->extension;
}
}
- // ###################################################################
/**
- * A wrapper for all the parsing functions and compiling functins
- *
- * @param string Unparsed template data
- *
- * @return string Parsed template data
- */
+ * A wrapper for all the parsing functions and compiling functins
+ *
+ * @param string Unparsed template data
+ *
+ * @return string Parsed template data
+ */
protected function _parseTemplate($template)
{
$template = str_replace('"', '\"', $template);
return $template;
}
- // ###################################################################
/**
- * Parses anything with curly braces {} (including phrases)
- *
- * @param string Template data
- *
- * @return string Parsed template data
- */
+ * Parses anything with curly braces {} (including phrases)
+ *
+ * @param string Template data
+ *
+ * @return string Parsed template data
+ */
private function _parseBlocksAndTokens($template)
{
$stack = array();
}
}
- // ###################################################################
/**
- * Parses a curly brace token {}
- *
- * @param string Token
- *
- * @return string Parsed value
- */
+ * Parses a curly brace token {}
+ *
+ * @param string Token
+ *
+ * @return string Parsed value
+ */
private function _parseToken($token)
{
// knock of the braces
}
}
- // ###################################################################
/**
- * Prepares language and locale information inside templates
- *
- * @param string Template data to be processed
- *
- * @return string Language-ready template data
- */
+ * Prepares language and locale information inside templates
+ *
+ * @param string Template data to be processed
+ *
+ * @return string Language-ready template data
+ */
private function _parsePhrases($template)
{
$tagStart = '<lang ';
return $template;
}
- // ###################################################################
/**
- * Parser for in-line template conditionals
- *
- * @param string Template data awaiting processing
- *
- * @return string Parsed template data
- */
+ * Parser for in-line template conditionals
+ *
+ * @param string Template data awaiting processing
+ *
+ * @return string Parsed template data
+ */
private function _parseConditionals($template)
{
// tag data
/**
-* Application Test Suite
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO Tests
-*
-*/
+ * Application Test Suite
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO Tests
+ *
+ */
class AppTest extends PHPUnit_Framework_TestCase
{
public function setUp()
require_once 'PHPUnit/Framework.php';
/**
-* DateTest
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO Tests
-*
-*/
+ * DateTest
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO Tests
+ *
+ */
class DateTest extends PHPUnit_Framework_TestCase
{
private $fixture;
require_once 'PHPUnit/Framework.php';
/**
-* Functions Test Suite
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO Tests
-*
-*/
+ * Functions Test Suite
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO Tests
+ *
+ */
class FunctionsTest extends PHPUnit_Framework_TestCase
{
public function setUp()
require_once 'PHPUnit/Framework.php';
/**
-* InputTest
-*
-* @author Blue Static
-* @copyright Copyright (c)2005 - 2008, Blue Static
-* @package ISSO Tests
-*
-*/
+ * InputTest
+ *
+ * @author Blue Static
+ * @copyright Copyright (c)2005 - 2008, Blue Static
+ * @package ISSO Tests
+ *
+ */
class InputTest extends PHPUnit_Framework_TestCase
{
private $fixture;