Updating/Fixing/Adding more comments with the PHP Doc style.
This commit is contained in:
		
							parent
							
								
									4f51e942be
								
							
						
					
					
						commit
						03b3cdcbd2
					
				| @ -11,7 +11,7 @@ class Block { | |||||||
| 	public $header; | 	public $header; | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * The content for the block. | 	 * The content of the block. | ||||||
| 	 * | 	 * | ||||||
| 	 * @var string | 	 * @var string | ||||||
| 	 */ | 	 */ | ||||||
|  | |||||||
| @ -2,28 +2,44 @@ | |||||||
| /** @privatesection */ | /** @privatesection */ | ||||||
| // Querylet {{{
 | // Querylet {{{
 | ||||||
| class Querylet { | class Querylet { | ||||||
| 	var $sql; | 	/** @var string */ | ||||||
| 	var $variables; | 	public $sql; | ||||||
|  | 	/** @var array */ | ||||||
|  | 	public $variables; | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $sql | ||||||
|  | 	 * @param array $variables | ||||||
|  | 	 */ | ||||||
| 	public function __construct($sql, $variables=array()) { | 	public function __construct($sql, $variables=array()) { | ||||||
| 		$this->sql = $sql; | 		$this->sql = $sql; | ||||||
| 		$this->variables = $variables; | 		$this->variables = $variables; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param \Querylet $querylet | ||||||
|  | 	 */ | ||||||
| 	public function append($querylet) { | 	public function append($querylet) { | ||||||
| 		assert(!is_null($querylet)); | 		assert(!is_null($querylet)); | ||||||
| 		$this->sql .= $querylet->sql; | 		$this->sql .= $querylet->sql; | ||||||
| 		$this->variables = array_merge($this->variables, $querylet->variables); | 		$this->variables = array_merge($this->variables, $querylet->variables); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $sql | ||||||
|  | 	 */ | ||||||
| 	public function append_sql($sql) { | 	public function append_sql($sql) { | ||||||
| 		$this->sql .= $sql; | 		$this->sql .= $sql; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param mixed $var | ||||||
|  | 	 */ | ||||||
| 	public function add_variable($var) { | 	public function add_variable($var) { | ||||||
| 		$this->variables[] = $var; | 		$this->variables[] = $var; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
| class TagQuerylet { | class TagQuerylet { | ||||||
| 	var $tag; | 	var $tag; | ||||||
| 	var $positive; | 	var $positive; | ||||||
| @ -33,6 +49,7 @@ class TagQuerylet { | |||||||
| 		$this->positive = $positive; | 		$this->positive = $positive; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
| class ImgQuerylet { | class ImgQuerylet { | ||||||
| 	var $qlet; | 	var $qlet; | ||||||
| 	var $positive; | 	var $positive; | ||||||
| @ -45,25 +62,40 @@ class ImgQuerylet { | |||||||
| // }}}
 | // }}}
 | ||||||
| // {{{ db engines
 | // {{{ db engines
 | ||||||
| class DBEngine { | class DBEngine { | ||||||
|  | 	/** @var null|string */ | ||||||
| 	public $name = null; | 	public $name = null; | ||||||
| 
 | 
 | ||||||
| 	public function init($db) {} | 	public function init($db) {} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $scoreql | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function scoreql_to_sql($scoreql) { | 	public function scoreql_to_sql($scoreql) { | ||||||
| 		return $scoreql; | 		return $scoreql; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function create_table_sql($name, $data) { | 	public function create_table_sql($name, $data) { | ||||||
| 		return 'CREATE TABLE '.$name.' ('.$data.')'; | 		return 'CREATE TABLE '.$name.' ('.$data.')'; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| class MySQL extends DBEngine { | class MySQL extends DBEngine { | ||||||
|  | 	/** @var string */ | ||||||
| 	public $name = "mysql"; | 	public $name = "mysql"; | ||||||
| 
 | 
 | ||||||
| 	public function init($db) { | 	public function init($db) { | ||||||
| 		$db->exec("SET NAMES utf8;"); | 		$db->exec("SET NAMES utf8;"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function scoreql_to_sql($data) { | 	public function scoreql_to_sql($data) { | ||||||
| 		$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY auto_increment", $data); | 		$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY auto_increment", $data); | ||||||
| 		$data = str_replace("SCORE_INET", "VARCHAR(45)", $data); | 		$data = str_replace("SCORE_INET", "VARCHAR(45)", $data); | ||||||
| @ -77,6 +109,11 @@ class MySQL extends DBEngine { | |||||||
| 		return $data; | 		return $data; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function create_table_sql($name, $data) { | 	public function create_table_sql($name, $data) { | ||||||
| 		$data = $this->scoreql_to_sql($data); | 		$data = $this->scoreql_to_sql($data); | ||||||
| 		$ctes = "ENGINE=InnoDB DEFAULT CHARSET='utf8'"; | 		$ctes = "ENGINE=InnoDB DEFAULT CHARSET='utf8'"; | ||||||
| @ -84,12 +121,17 @@ class MySQL extends DBEngine { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| class PostgreSQL extends DBEngine { | class PostgreSQL extends DBEngine { | ||||||
|  | 	/** @var string */ | ||||||
| 	public $name = "pgsql"; | 	public $name = "pgsql"; | ||||||
| 
 | 
 | ||||||
| 	public function init($db) { | 	public function init($db) { | ||||||
| 		$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); | 		$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function scoreql_to_sql($data) { | 	public function scoreql_to_sql($data) { | ||||||
| 		$data = str_replace("SCORE_AIPK", "SERIAL PRIMARY KEY", $data); | 		$data = str_replace("SCORE_AIPK", "SERIAL PRIMARY KEY", $data); | ||||||
| 		$data = str_replace("SCORE_INET", "INET", $data); | 		$data = str_replace("SCORE_INET", "INET", $data); | ||||||
| @ -103,6 +145,11 @@ class PostgreSQL extends DBEngine { | |||||||
| 		return $data; | 		return $data; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function create_table_sql($name, $data) { | 	public function create_table_sql($name, $data) { | ||||||
| 		$data = $this->scoreql_to_sql($data); | 		$data = $this->scoreql_to_sql($data); | ||||||
| 		return 'CREATE TABLE '.$name.' ('.$data.')'; | 		return 'CREATE TABLE '.$name.' ('.$data.')'; | ||||||
| @ -123,6 +170,7 @@ function _concat($a, $b) { return $a . $b; } | |||||||
| function _lower($a) { return strtolower($a); } | function _lower($a) { return strtolower($a); } | ||||||
| 
 | 
 | ||||||
| class SQLite extends DBEngine { | class SQLite extends DBEngine { | ||||||
|  | 	/** @var string  */ | ||||||
| 	public $name = "sqlite"; | 	public $name = "sqlite"; | ||||||
| 
 | 
 | ||||||
| 	public function init($db) { | 	public function init($db) { | ||||||
| @ -138,6 +186,10 @@ class SQLite extends DBEngine { | |||||||
| 		$db->sqliteCreateFunction('lower', '_lower', 1); | 		$db->sqliteCreateFunction('lower', '_lower', 1); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function scoreql_to_sql($data) { | 	public function scoreql_to_sql($data) { | ||||||
| 		$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY", $data); | 		$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY", $data); | ||||||
| 		$data = str_replace("SCORE_INET", "VARCHAR(45)", $data); | 		$data = str_replace("SCORE_INET", "VARCHAR(45)", $data); | ||||||
| @ -150,6 +202,11 @@ class SQLite extends DBEngine { | |||||||
| 		return $data; | 		return $data; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param string $data | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function create_table_sql($name, $data) { | 	public function create_table_sql($name, $data) { | ||||||
| 		$data = $this->scoreql_to_sql($data); | 		$data = $this->scoreql_to_sql($data); | ||||||
| 		$cols = array(); | 		$cols = array(); | ||||||
| @ -187,8 +244,16 @@ class NoCache implements CacheEngine { | |||||||
| 	public function get_misses() {return 0;} | 	public function get_misses() {return 0;} | ||||||
| } | } | ||||||
| class MemcacheCache implements CacheEngine { | class MemcacheCache implements CacheEngine { | ||||||
| 	var $memcache=null, $hits=0, $misses=0; | 	/** @var \Memcache|null */ | ||||||
|  | 	public $memcache=null; | ||||||
|  | 	/** @var int */ | ||||||
|  | 	private $hits=0; | ||||||
|  | 	/** @var int */ | ||||||
|  | 	private $misses=0; | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $args | ||||||
|  | 	 */ | ||||||
| 	public function __construct($args) { | 	public function __construct($args) { | ||||||
| 		$hp = explode(":", $args); | 		$hp = explode(":", $args); | ||||||
| 		if(class_exists("Memcache")) { | 		if(class_exists("Memcache")) { | ||||||
| @ -197,6 +262,10 @@ class MemcacheCache implements CacheEngine { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $key | ||||||
|  | 	 * @return array|bool|string | ||||||
|  | 	 */ | ||||||
| 	public function get($key) { | 	public function get($key) { | ||||||
| 		assert(!is_null($key)); | 		assert(!is_null($key)); | ||||||
| 		if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) { | 		if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) { | ||||||
| @ -213,19 +282,35 @@ class MemcacheCache implements CacheEngine { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $key | ||||||
|  | 	 * @param mixed $val | ||||||
|  | 	 * @param int $time | ||||||
|  | 	 */ | ||||||
| 	public function set($key, $val, $time=0) { | 	public function set($key, $val, $time=0) { | ||||||
| 		assert(!is_null($key)); | 		assert(!is_null($key)); | ||||||
| 		$this->memcache->set($key, $val, false, $time); | 		$this->memcache->set($key, $val, false, $time); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $key | ||||||
|  | 	 */ | ||||||
| 	public function delete($key) { | 	public function delete($key) { | ||||||
| 		assert(!is_null($key)); | 		assert(!is_null($key)); | ||||||
| 		$this->memcache->delete($key); | 		$this->memcache->delete($key); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
| 	public function get_hits() {return $this->hits;} | 	public function get_hits() {return $this->hits;} | ||||||
|  | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @return int | ||||||
|  | 	 */ | ||||||
| 	public function get_misses() {return $this->misses;} | 	public function get_misses() {return $this->misses;} | ||||||
| } | } | ||||||
|  | 
 | ||||||
| class APCCache implements CacheEngine { | class APCCache implements CacheEngine { | ||||||
| 	var $hits=0, $misses=0; | 	var $hits=0, $misses=0; | ||||||
| 
 | 
 | ||||||
| @ -267,25 +352,28 @@ class APCCache implements CacheEngine { | |||||||
|  */ |  */ | ||||||
| class Database { | class Database { | ||||||
| 	/** | 	/** | ||||||
| 	 * The PDO database connection object, for anyone who wants direct access | 	 * The PDO database connection object, for anyone who wants direct access. | ||||||
|  | 	 * @var null|PDO | ||||||
| 	 */ | 	 */ | ||||||
| 	private $db = null; | 	private $db = null; | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Meta info about the database engine | 	 * Meta info about the database engine. | ||||||
| 	 * @var DBEngine | 	 * @var DBEngine|null | ||||||
| 	 */ | 	 */ | ||||||
| 	private $engine = null; | 	private $engine = null; | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * The currently active cache engine | 	 * The currently active cache engine. | ||||||
| 	 * @var CacheEngine | 	 * @var CacheEngine|null | ||||||
| 	 */ | 	 */ | ||||||
| 	public $cache = null; | 	public $cache = null; | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * A boolean flag to track if we already have an active transaction. | 	 * A boolean flag to track if we already have an active transaction. | ||||||
| 	 * (ie: True if beginTransaction() already called) | 	 * (ie: True if beginTransaction() already called) | ||||||
|  | 	 * | ||||||
|  | 	 * @var bool | ||||||
| 	 */ | 	 */ | ||||||
| 	public $transaction = false; | 	public $transaction = false; | ||||||
| 
 | 
 | ||||||
| @ -364,6 +452,10 @@ class Database { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @return bool | ||||||
|  | 	 * @throws SCoreException | ||||||
|  | 	 */ | ||||||
| 	public function commit() { | 	public function commit() { | ||||||
| 		if(!is_null($this->db)) { | 		if(!is_null($this->db)) { | ||||||
| 			if ($this->transaction === true) { | 			if ($this->transaction === true) { | ||||||
| @ -376,6 +468,10 @@ class Database { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @return bool | ||||||
|  | 	 * @throws SCoreException | ||||||
|  | 	 */ | ||||||
| 	public function rollback() { | 	public function rollback() { | ||||||
| 		if(!is_null($this->db)) { | 		if(!is_null($this->db)) { | ||||||
| 			if ($this->transaction === true) { | 			if ($this->transaction === true) { | ||||||
| @ -388,23 +484,39 @@ class Database { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $input | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function escape($input) { | 	public function escape($input) { | ||||||
| 		if(is_null($this->db)) $this->connect_db(); | 		if(is_null($this->db)) $this->connect_db(); | ||||||
| 		return $this->db->Quote($input); | 		return $this->db->Quote($input); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $input | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
| 	public function scoreql_to_sql($input) { | 	public function scoreql_to_sql($input) { | ||||||
| 		if(is_null($this->engine)) $this->connect_engine(); | 		if(is_null($this->engine)) $this->connect_engine(); | ||||||
| 		return $this->engine->scoreql_to_sql($input); | 		return $this->engine->scoreql_to_sql($input); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @return null|string | ||||||
|  | 	 */ | ||||||
| 	public function get_driver_name() { | 	public function get_driver_name() { | ||||||
| 		if(is_null($this->engine)) $this->connect_engine(); | 		if(is_null($this->engine)) $this->connect_engine(); | ||||||
| 		return $this->engine->name; | 		return $this->engine->name; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return an PDO resultset | 	 * Execute an SQL query and return an PDO result-set. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return PDOStatement | ||||||
|  | 	 * @throws SCoreException | ||||||
| 	 */ | 	 */ | ||||||
| 	public function execute($query, $args=array()) { | 	public function execute($query, $args=array()) { | ||||||
| 		try { | 		try { | ||||||
| @ -433,14 +545,22 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return a 2D array | 	 * Execute an SQL query and return a 2D array. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_all($query, $args=array()) { | 	public function get_all($query, $args=array()) { | ||||||
| 		return $this->execute($query, $args)->fetchAll(); | 		return $this->execute($query, $args)->fetchAll(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return a single row | 	 * Execute an SQL query and return a single row. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return mixed|null | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_row($query, $args=array()) { | 	public function get_row($query, $args=array()) { | ||||||
| 		$row = $this->execute($query, $args)->fetch(); | 		$row = $this->execute($query, $args)->fetch(); | ||||||
| @ -448,7 +568,11 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return the first column of each row | 	 * Execute an SQL query and return the first column of each row. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_col($query, $args=array()) { | 	public function get_col($query, $args=array()) { | ||||||
| 		$stmt = $this->execute($query, $args); | 		$stmt = $this->execute($query, $args); | ||||||
| @ -460,7 +584,11 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return the the first row => the second rown | 	 * Execute an SQL query and return the the first row => the second rown. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return array | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_pairs($query, $args=array()) { | 	public function get_pairs($query, $args=array()) { | ||||||
| 		$stmt = $this->execute($query, $args); | 		$stmt = $this->execute($query, $args); | ||||||
| @ -472,7 +600,11 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Execute an SQL query and return a single value | 	 * Execute an SQL query and return a single value. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $args | ||||||
|  | 	 * @return mixed | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_one($query, $args=array()) { | 	public function get_one($query, $args=array()) { | ||||||
| 		$row = $this->execute($query, $args)->fetch(); | 		$row = $this->execute($query, $args)->fetch(); | ||||||
| @ -480,7 +612,10 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * get the ID of the last inserted row | 	 * Get the ID of the last inserted row. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string|null $seq | ||||||
|  | 	 * @return string | ||||||
| 	 */ | 	 */ | ||||||
| 	public function get_last_insert_id($seq) { | 	public function get_last_insert_id($seq) { | ||||||
| 		if($this->engine->name == "pgsql") { | 		if($this->engine->name == "pgsql") { | ||||||
| @ -492,15 +627,20 @@ class Database { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Create a table from pseudo-SQL | 	 * Create a table from pseudo-SQL. | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param string $data | ||||||
| 	 */ | 	 */ | ||||||
| 	public function create_table($name, $data) { | 	public function create_table($name, $data) { | ||||||
| 		if(is_null($this->engine)) $this->connect_engine(); | 		if(is_null($this->engine)) { $this->connect_engine(); } | ||||||
| 		$this->execute($this->engine->create_table_sql($name, $data)); | 		$this->execute($this->engine->create_table_sql($name, $data)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * Returns the number of tables present in the current database. | 	 * Returns the number of tables present in the current database. | ||||||
|  | 	 * | ||||||
|  | 	 * @return int|null | ||||||
| 	 */ | 	 */ | ||||||
| 	public function count_tables() { | 	public function count_tables() { | ||||||
| 		if(is_null($this->db) || is_null($this->engine)) $this->connect_db(); | 		if(is_null($this->db) || is_null($this->engine)) $this->connect_db(); | ||||||
| @ -525,14 +665,26 @@ class Database { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class MockDatabase extends Database { | class MockDatabase extends Database { | ||||||
|  | 	/** @var int */ | ||||||
| 	var $query_id = 0; | 	var $query_id = 0; | ||||||
|  | 	/** @var array */ | ||||||
| 	var $responses = array(); | 	var $responses = array(); | ||||||
|  | 	/** @var \NoCache|null  */ | ||||||
| 	var $cache = null; | 	var $cache = null; | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param array $responses | ||||||
|  | 	 */ | ||||||
| 	public function __construct($responses = array()) { | 	public function __construct($responses = array()) { | ||||||
| 		$this->cache = new NoCache(); | 		$this->cache = new NoCache(); | ||||||
| 		$this->responses = $responses; | 		$this->responses = $responses; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $query | ||||||
|  | 	 * @param array $params | ||||||
|  | 	 * @return PDOStatement | ||||||
|  | 	 */ | ||||||
| 	public function execute($query, $params=array()) { | 	public function execute($query, $params=array()) { | ||||||
| 		log_debug("mock-database", | 		log_debug("mock-database", | ||||||
| 			"QUERY: " . $query . | 			"QUERY: " . $query . | ||||||
|  | |||||||
| @ -1,21 +1,38 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| class Email { |  | ||||||
| /** | /** | ||||||
|  * A generic email. |  * A generic email. | ||||||
|  */ |  */ | ||||||
|  | class Email { | ||||||
|  | 	/** @var string */ | ||||||
| 	public $to; | 	public $to; | ||||||
|  | 	/** @var string  */ | ||||||
| 	public $subject; | 	public $subject; | ||||||
|  | 	/** @var string  */ | ||||||
| 	public $header; | 	public $header; | ||||||
|  | 	/** @var null|string  */ | ||||||
| 	public $style; | 	public $style; | ||||||
|  | 	/** @var null|string  */ | ||||||
| 	public $header_img; | 	public $header_img; | ||||||
|  | 	/** @var null|string  */ | ||||||
| 	public $sitename; | 	public $sitename; | ||||||
|  | 	/** @var null|string  */ | ||||||
| 	public $sitedomain; | 	public $sitedomain; | ||||||
|  | 	/** @var null|string */ | ||||||
| 	public $siteemail; | 	public $siteemail; | ||||||
|  | 	/** @var string */ | ||||||
| 	public $date; | 	public $date; | ||||||
|  | 	/** @var string */ | ||||||
| 	public $body; | 	public $body; | ||||||
|  | 	/** @var null|string */ | ||||||
| 	public $footer; | 	public $footer; | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $to | ||||||
|  | 	 * @param string $subject | ||||||
|  | 	 * @param string $header | ||||||
|  | 	 * @param string $body | ||||||
|  | 	 */ | ||||||
| 	public function __construct($to, $subject, $header, $body) { | 	public function __construct($to, $subject, $header, $body) { | ||||||
| 		global $config; | 		global $config; | ||||||
| 		$this->to = $to; | 		$this->to = $to; | ||||||
|  | |||||||
| @ -66,7 +66,8 @@ class Image { | |||||||
| 	/** | 	/** | ||||||
| 	 * One will very rarely construct an image directly, more common | 	 * One will very rarely construct an image directly, more common | ||||||
| 	 * would be to use Image::by_id, Image::by_hash, etc. | 	 * would be to use Image::by_id, Image::by_hash, etc. | ||||||
| 	 * @param mixed $row | 	 * | ||||||
|  | 	 * @param null|mixed $row | ||||||
| 	 */ | 	 */ | ||||||
| 	public function __construct($row=null) { | 	public function __construct($row=null) { | ||||||
| 		if(!is_null($row)) { | 		if(!is_null($row)) { | ||||||
|  | |||||||
| @ -1,17 +1,18 @@ | |||||||
| <?php | <?php | ||||||
| /** | /** | ||||||
|  * @global UserClass[] |  * @global UserClass[] $_user_classes | ||||||
|  */ |  */ | ||||||
| $_user_classes = array(); | $_user_classes = array(); | ||||||
| 
 | 
 | ||||||
| class UserClass { | class UserClass { | ||||||
|  | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * @var null|string | 	 * @var null|string | ||||||
| 	 */ | 	 */ | ||||||
| 	public $name = null; | 	public $name = null; | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * @var mixed | 	 * @var null|string | ||||||
| 	 */ | 	 */ | ||||||
| 	public $parent = null; | 	public $parent = null; | ||||||
| 
 | 
 | ||||||
| @ -20,6 +21,11 @@ class UserClass { | |||||||
| 	 */ | 	 */ | ||||||
| 	public $abilities = array(); | 	public $abilities = array(); | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param string $name | ||||||
|  | 	 * @param null|string $parent | ||||||
|  | 	 * @param array $abilities | ||||||
|  | 	 */ | ||||||
| 	public function __construct($name, $parent=null, $abilities=array()) { | 	public function __construct($name, $parent=null, $abilities=array()) { | ||||||
| 		global $_user_classes; | 		global $_user_classes; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user