From e59c28d45443968c2d7333e5179e307df0c8bf3d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 28 Feb 2008 15:49:05 -0500 Subject: [PATCH] Update the comment formatting to not use the pound bar anymore and to put a space in front of the PHPdoc comments --- Api.php | 252 ++++++++++------------ App.php | 82 ++++--- Date.php | 77 ++++--- Db.php | 430 ++++++++++++++++++------------------- DbMySql.php | 132 +++++------- DbMySqlI.php | 121 +++++------ DbPostgreSql.php | 131 +++++------ Functions.php | 355 ++++++++++++++---------------- Input.php | 252 ++++++++++------------ Installer.php | 108 +++++----- Mail.php | 190 ++++++++-------- Pagination.php | 152 ++++++------- Printer.php | 122 +++++------ PrinterAbstract.php | 79 ++++--- PrinterElement.php | 151 +++++++------ PrinterElementLabel.php | 52 +++-- PrinterElementTable.php | 240 ++++++++++----------- PrinterNavigation.php | 32 +-- PrinterRootAbstract.php | 53 +++-- PrinterRootForm.php | 101 +++++---- PrinterRootPage.php | 115 +++++----- PrinterRootTable.php | 117 +++++----- Template.php | 243 ++++++++++----------- UnitTest/AppTest.php | 14 +- UnitTest/DateTest.php | 14 +- UnitTest/FunctionsTest.php | 14 +- UnitTest/InputTest.php | 14 +- 27 files changed, 1708 insertions(+), 1935 deletions(-) diff --git a/Api.php b/Api.php index 27d6ad7..3f5d860 100644 --- a/Api.php +++ b/Api.php @@ -20,69 +20,69 @@ \*=====================================================================*/ /** -* 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(); } 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(); } 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(); /** @@ -98,39 +98,39 @@ abstract class BSApi 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; /** @@ -148,12 +148,11 @@ abstract class BSApi } } - // ################################################################### /** - * 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) @@ -163,11 +162,10 @@ abstract class BSApi $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) @@ -176,15 +174,14 @@ abstract class BSApi } } - // ################################################################### /** - * 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"])) @@ -202,13 +199,12 @@ abstract class BSApi } } - // ################################################################### /** - * 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) @@ -252,15 +248,14 @@ abstract class BSApi } } - // ################################################################### /** - * 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) @@ -286,13 +281,12 @@ abstract class BSApi 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(); @@ -330,13 +324,12 @@ abstract class BSApi $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) @@ -359,13 +352,12 @@ abstract class BSApi $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) @@ -382,10 +374,9 @@ abstract class BSApi $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) @@ -404,13 +395,12 @@ abstract class BSApi } } - // ################################################################### /** - * 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)) @@ -421,15 +411,14 @@ abstract class BSApi $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]; @@ -452,10 +441,9 @@ abstract class BSApi } } - // ################################################################### /** - * Verify field: not a zero value - */ + * Verify field: not a zero value + */ protected function _verifyIsNotZero($field) { if ($this->values[$field] == 0) @@ -467,10 +455,9 @@ abstract class BSApi return true; } - // ################################################################### /** - * Verify field: not empty - */ + * Verify field: not empty + */ protected function _verifyIsNotEmpty($field) { if (empty($this->values[$field])) @@ -482,10 +469,9 @@ abstract class BSApi 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})")); @@ -518,7 +504,6 @@ class ApiException extends Exception */ private $exceptions = array(); - // ################################################################### /** * Constructor */ @@ -527,7 +512,6 @@ class ApiException extends Exception parent::__construct(_('An error occurred while processing the API data.')); } - // ################################################################### /** * Adds an exception to the collection * @@ -538,7 +522,6 @@ class ApiException extends Exception $this->exceptions[] = $e; } - // ################################################################### /** * Returns an array of all the exceptions in the collection * @@ -557,7 +540,6 @@ class ApiException extends Exception * * @author rsesek * @copyright Copyright (c)2005 - 2008, Blue Static - * @version $Id$ * @package ISSO * */ @@ -569,7 +551,6 @@ class FieldException extends Exception */ private $field; - // ################################################################### /** * Constructor: create a new exception */ @@ -579,7 +560,6 @@ class FieldException extends Exception parent::__construct($error); } - // ################################################################### /** * Returns the name of the field the exception is for * diff --git a/App.php b/App.php index bfbfb25..7318fcc 100644 --- a/App.php +++ b/App.php @@ -20,10 +20,10 @@ \*=====================================================================*/ /** -* 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')) @@ -54,30 +54,30 @@ if ((bool)ini_get('register_globals') === true) 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(); /** @@ -86,35 +86,32 @@ class BSApp 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) @@ -123,12 +120,11 @@ class BSApp } } - // ################################################################### /** - * Returns a menu of all the debug notices + * + * @return string Debug list + */ public static function get_debug_list() { $output = ' 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 - * - * @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 + * + * @return BSPrinterElementTable Upload form + */ public static function row_upload($label, $name) { $tr = new BSPrinterElementTable(); @@ -255,16 +248,15 @@ class BSPrinterElementTable extends BSPrinterAbstract 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); @@ -283,16 +275,15 @@ class BSPrinterElementTable extends BSPrinterAbstract 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(); @@ -303,40 +294,37 @@ class BSPrinterElementTable extends BSPrinterAbstract 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 - * elements accordingly - * - * @param integer Column count - * - * @return fluent interface - */ + * Sets the number of columns this row should have and pads the + * elements accordingly + * + * @param integer Column count + * + * @return fluent interface + */ public function setColumnNumber($cols) { if ($cols < $this->numberOfColumns()) @@ -347,12 +335,11 @@ class BSPrinterElementTable extends BSPrinterAbstract 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 = ''; @@ -382,12 +369,11 @@ class BSPrinterElementTable extends BSPrinterAbstract 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_prepareStyle() . ">" . $this->_paintChildren() . "\n\t"; diff --git a/PrinterNavigation.php b/PrinterNavigation.php index ee0fb1a..2de0cce 100644 --- a/PrinterNavigation.php +++ b/PrinterNavigation.php @@ -20,24 +20,24 @@ \*=====================================================================*/ /** -* 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 { /** diff --git a/PrinterRootAbstract.php b/PrinterRootAbstract.php index 0f45699..ab6ca2a 100644 --- a/PrinterRootAbstract.php +++ b/PrinterRootAbstract.php @@ -20,46 +20,45 @@ \*=====================================================================*/ /** -* 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; diff --git a/PrinterRootForm.php b/PrinterRootForm.php index 8c0deb8..f5f42a5 100644 --- a/PrinterRootForm.php +++ b/PrinterRootForm.php @@ -20,54 +20,53 @@ \*=====================================================================*/ /** -* 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
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 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; @@ -87,40 +86,37 @@ class BSPrinterRootForm extends BSPrinterRootAbstract 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 = ''; @@ -133,12 +129,11 @@ class BSPrinterRootForm extends BSPrinterRootAbstract return $builder; } - // ################################################################### /** - * Paints the - * - * @return string Table HTML code - */ + * Paints the
+ * + * @return string Table HTML code + */ public function paint() { array_push($this->children, new BSPrinterElement('hidden', 'do', $this->do)); diff --git a/PrinterRootPage.php b/PrinterRootPage.php index ed54f95..2724239 100644 --- a/PrinterRootPage.php +++ b/PrinterRootPage.php @@ -20,30 +20,30 @@ \*=====================================================================*/ /** -* 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; /** @@ -52,12 +52,11 @@ class BSPrinterRootPage extends BSPrinterRootAbstract */ private $navigator; - // ################################################################### /** - * Constructor - * - * @param string Page title - */ + * Constructor + * + * @param string Page title + */ function __construct($title) { $this->title = $title; @@ -98,15 +97,14 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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')) @@ -168,15 +166,14 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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(); @@ -193,17 +190,16 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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')) @@ -239,12 +235,11 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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')) @@ -259,12 +254,11 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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 = ''; @@ -277,10 +271,9 @@ class BSPrinterRootPage extends BSPrinterRootAbstract 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(); diff --git a/PrinterRootTable.php b/PrinterRootTable.php index 395b0f8..108f58b 100644 --- a/PrinterRootTable.php +++ b/PrinterRootTable.php @@ -20,48 +20,47 @@ \*=====================================================================*/ /** -* 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
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
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'); @@ -79,14 +78,13 @@ class BSPrinterRootTable extends BSPrinterRootAbstract 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) @@ -97,40 +95,37 @@ class BSPrinterRootTable extends BSPrinterRootAbstract 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) @@ -142,12 +137,11 @@ class BSPrinterRootTable extends BSPrinterRootAbstract } } - // ################################################################### /** - * 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 = ''; @@ -166,12 +160,11 @@ class BSPrinterRootTable extends BSPrinterRootAbstract return $builder; } - // ################################################################### /** - * Paints the
- * - * @return string Table HTML code - */ + * Paints the
+ * + * @return string Table HTML code + */ public function paint() { return "
\n
width . "\"" . $this->_prepareStyle() . ">" . $this->_paintChildren() . "\n
"; diff --git a/Template.php b/Template.php index b15d749..5e13566 100644 --- a/Template.php +++ b/Template.php @@ -20,137 +20,132 @@ \*=====================================================================*/ /** -* 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) @@ -201,15 +196,14 @@ class BSTemplate } } - // ################################################################### /** - * 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])) @@ -227,12 +221,11 @@ class BSTemplate 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(); @@ -284,14 +277,13 @@ class BSTemplate 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; @@ -305,14 +297,13 @@ class BSTemplate } } - // ################################################################### /** - * 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); @@ -328,14 +319,13 @@ class BSTemplate 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(); @@ -384,14 +374,13 @@ class BSTemplate } } - // ################################################################### /** - * 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 @@ -409,14 +398,13 @@ class BSTemplate } } - // ################################################################### /** - * 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 = '