Added some more comments and type hints.
This commit is contained in:
parent
9707c1f7ce
commit
5af54bb9e0
3 changed files with 38 additions and 5 deletions
|
@ -106,8 +106,10 @@ class Image {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for an array of images
|
* Search for an array of images
|
||||||
|
*
|
||||||
|
* @retval Array
|
||||||
*/
|
*/
|
||||||
public static function find_images($start, $limit, $tags=array()) {
|
public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) {
|
||||||
assert(is_numeric($start));
|
assert(is_numeric($start));
|
||||||
assert(is_numeric($limit));
|
assert(is_numeric($limit));
|
||||||
assert(is_array($tags));
|
assert(is_array($tags));
|
||||||
|
@ -383,7 +385,7 @@ class Image {
|
||||||
/**
|
/**
|
||||||
* Set the image's source URL
|
* Set the image's source URL
|
||||||
*/
|
*/
|
||||||
public function set_source($source) {
|
public function set_source(/*string*/ $source) {
|
||||||
global $database;
|
global $database;
|
||||||
if(empty($source)) $source = null;
|
if(empty($source)) $source = null;
|
||||||
if($source != $this->source) {
|
if($source != $this->source) {
|
||||||
|
@ -392,7 +394,10 @@ class Image {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the image is locked.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
public function is_locked() {
|
public function is_locked() {
|
||||||
return ($this->locked === true || $this->locked == "Y" || $this->locked == "t");
|
return ($this->locked === true || $this->locked == "Y" || $this->locked == "t");
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ class User {
|
||||||
/**
|
/**
|
||||||
* Get a snippet of HTML which will render the user's avatar, be that
|
* Get a snippet of HTML which will render the user's avatar, be that
|
||||||
* a local file, a remote file, a gravatar, a something else, etc
|
* a local file, a remote file, a gravatar, a something else, etc
|
||||||
|
* @retval String of HTML
|
||||||
*/
|
*/
|
||||||
public function get_avatar_html() {
|
public function get_avatar_html() {
|
||||||
// FIXME: configurable
|
// FIXME: configurable
|
||||||
|
@ -242,6 +243,8 @@ class User {
|
||||||
* authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that
|
* authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that
|
||||||
* the form was generated within the session. Salted and re-hashed so that
|
* the form was generated within the session. Salted and re-hashed so that
|
||||||
* reading a web page from the user's cache doesn't give access to the session key
|
* reading a web page from the user's cache doesn't give access to the session key
|
||||||
|
*
|
||||||
|
* @retval String containing auth token (MD5sum)
|
||||||
*/
|
*/
|
||||||
public function get_auth_token() {
|
public function get_auth_token() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
|
@ -190,12 +190,26 @@ function undb_bool($val) {
|
||||||
if($val === false || $val == 'N' || $val == 'n' || $val == 'F' || $val == 'f' || $val === 0) return false;
|
if($val === false || $val == 'N' || $val == 'n' || $val == 'F' || $val == 'f' || $val === 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startsWith($haystack, $needle) {
|
/**
|
||||||
|
* Checks if a given string contains another at the beginning.
|
||||||
|
*
|
||||||
|
* @param $haystack String to examine.
|
||||||
|
* @param $needle String to look for.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
|
function startsWith(/*string*/ $haystack, /*string*/ $needle) {
|
||||||
$length = strlen($needle);
|
$length = strlen($needle);
|
||||||
return (substr($haystack, 0, $length) === $needle);
|
return (substr($haystack, 0, $length) === $needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
function endsWith($haystack, $needle) {
|
/**
|
||||||
|
* Checks if a given string contains another at the end.
|
||||||
|
*
|
||||||
|
* @param $haystack String to examine.
|
||||||
|
* @param $needle String to look for.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
|
function endsWith(/*string*/ $haystack, /*string*/ $needle) {
|
||||||
$length = strlen($needle);
|
$length = strlen($needle);
|
||||||
$start = $length * -1; //negative
|
$start = $length * -1; //negative
|
||||||
return (substr($haystack, $start) === $needle);
|
return (substr($haystack, $start) === $needle);
|
||||||
|
@ -621,6 +635,7 @@ function log_msg($section, $priority, $message) {
|
||||||
send_event(new LogEvent($section, $priority, $message));
|
send_event(new LogEvent($section, $priority, $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// More shorthand ways of logging
|
||||||
function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
|
function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
|
||||||
function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);}
|
function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);}
|
||||||
function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
|
function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
|
||||||
|
@ -847,6 +862,13 @@ function send_event(Event $event) {
|
||||||
// string representation of a number, it's two numbers separated by a space.
|
// string representation of a number, it's two numbers separated by a space.
|
||||||
// What the fuck were the PHP developers smoking.
|
// What the fuck were the PHP developers smoking.
|
||||||
$_load_start = microtime(true);
|
$_load_start = microtime(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects some debug information (execution time, memory usage, queries, etc)
|
||||||
|
* and formats it to stick in the footer of the page.
|
||||||
|
*
|
||||||
|
* @retval String of debug info to add to the page.
|
||||||
|
*/
|
||||||
function get_debug_info() {
|
function get_debug_info() {
|
||||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||||
|
|
||||||
|
@ -1051,6 +1073,9 @@ function _load_extensions() {
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to display fatal errors to the web user.
|
||||||
|
*/
|
||||||
function _fatal_error(Exception $e) {
|
function _fatal_error(Exception $e) {
|
||||||
$version = VERSION;
|
$version = VERSION;
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
|
Reference in a new issue