Fixing/Cleaning more PHP Doc related issues.

This commit is contained in:
jgen 2014-04-28 00:56:19 -04:00
parent 8a2eb4b121
commit 76fd27f87c
3 changed files with 171 additions and 122 deletions

View File

@ -6,15 +6,29 @@
*/ */
class MP3FileHandler extends DataHandlerExtension { class MP3FileHandler extends DataHandlerExtension {
/**
* @param string $hash
* @return bool
*/
protected function create_thumb($hash) { protected function create_thumb($hash) {
copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash)); copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash));
return true;
} }
/**
* @param string $ext
* @return bool
*/
protected function supported_ext($ext) { protected function supported_ext($ext) {
$exts = array("mp3"); $exts = array("mp3");
return in_array(strtolower($ext), $exts); return in_array(strtolower($ext), $exts);
} }
/**
* @param string $filename
* @param array $metadata
* @return Image|null
*/
protected function create_image_from_data($filename, $metadata) { protected function create_image_from_data($filename, $metadata) {
global $config; global $config;
@ -47,6 +61,10 @@ class MP3FileHandler extends DataHandlerExtension {
return $image; return $image;
} }
/**
* @param $file
* @return bool
*/
protected function check_contents($file) { protected function check_contents($file) {
if (file_exists($file)) { if (file_exists($file)) {
require_once('lib/getid3/getid3/getid3.php'); require_once('lib/getid3/getid3/getid3.php');

View File

@ -238,8 +238,11 @@ class Notes extends Extension {
} }
/* /**
* HERE WE GET ALL NOTES FOR DISPLAYED IMAGE * HERE WE GET ALL NOTES FOR DISPLAYED IMAGE.
*
* @param int $imageID
* @return array
*/ */
private function get_notes($imageID) { private function get_notes($imageID) {
global $database; global $database;
@ -347,7 +350,6 @@ class Notes extends Extension {
} }
/* /*
* HERE WE DELETE THE NOTE * HERE WE DELETE THE NOTE
*/ */
@ -400,13 +402,15 @@ class Notes extends Extension {
log_info("notes", "Requests deleted from {$image_id} by {$user->name}"); log_info("notes", "Requests deleted from {$image_id} by {$user->name}");
} }
/**
/*
* HERE WE ALL IMAGES THAT HAVE NOTES * HERE WE ALL IMAGES THAT HAVE NOTES
* @param PageRequestEvent $event
*/ */
private function get_notes_list($event) { private function get_notes_list(PageRequestEvent $event) {
global $database, $config;
$pageNumber = $event->get_arg(1); $pageNumber = $event->get_arg(1);
if(is_null($pageNumber) || !is_numeric($pageNumber)) if(is_null($pageNumber) || !is_numeric($pageNumber))
$pageNumber = 0; $pageNumber = 0;
else if ($pageNumber <= 0) else if ($pageNumber <= 0)
@ -414,13 +418,10 @@ class Notes extends Extension {
else else
$pageNumber--; $pageNumber--;
global $config;
$notesPerPage = $config->get_int('notesNotesPerPage'); $notesPerPage = $config->get_int('notesNotesPerPage');
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID)); //$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
global $database;
$get_notes = " $get_notes = "
SELECT DISTINCT image_id ". SELECT DISTINCT image_id ".
"FROM notes ". "FROM notes ".
@ -441,13 +442,15 @@ class Notes extends Extension {
$this->theme->display_note_list($images, $pageNumber + 1, $totalPages); $this->theme->display_note_list($images, $pageNumber + 1, $totalPages);
} }
/**
/*
* HERE WE GET ALL NOTE REQUESTS * HERE WE GET ALL NOTE REQUESTS
* @param PageRequestEvent $event
*/ */
private function get_notes_requests($event) { private function get_notes_requests(PageRequestEvent $event) {
global $config;
$pageNumber = $event->get_arg(1); $pageNumber = $event->get_arg(1);
if(is_null($pageNumber) || !is_numeric($pageNumber)) if(is_null($pageNumber) || !is_numeric($pageNumber))
$pageNumber = 0; $pageNumber = 0;
else if ($pageNumber <= 0) else if ($pageNumber <= 0)
@ -455,8 +458,6 @@ class Notes extends Extension {
else else
$pageNumber--; $pageNumber--;
global $config;
$requestsPerPage = $config->get_int('notesRequestsPerPage'); $requestsPerPage = $config->get_int('notesRequestsPerPage');
@ -503,11 +504,11 @@ class Notes extends Extension {
} }
/**
/*
* HERE WE GET ALL HISTORIES. * HERE WE GET ALL HISTORIES.
* @param PageRequestEvent $event
*/ */
private function get_histories($event){ private function get_histories(PageRequestEvent $event){
$pageNumber = $event->get_arg(1); $pageNumber = $event->get_arg(1);
if(is_null($pageNumber) || !is_numeric($pageNumber)) if(is_null($pageNumber) || !is_numeric($pageNumber))
$pageNumber = 0; $pageNumber = 0;
@ -535,11 +536,11 @@ class Notes extends Extension {
} }
/**
/*
* HERE WE THE HISTORY FOR A SPECIFIC NOTE. * HERE WE THE HISTORY FOR A SPECIFIC NOTE.
* @param PageRequestEvent $event
*/ */
private function get_history($event){ private function get_history(PageRequestEvent $event){
$noteID = $event->get_arg(1); $noteID = $event->get_arg(1);
$pageNumber = $event->get_arg(2); $pageNumber = $event->get_arg(2);
if(is_null($pageNumber) || !is_numeric($pageNumber)) if(is_null($pageNumber) || !is_numeric($pageNumber))
@ -567,13 +568,13 @@ class Notes extends Extension {
$this->theme->display_history($histories, $pageNumber + 1, $totalPages); $this->theme->display_history($histories, $pageNumber + 1, $totalPages);
} }
/**
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE RE-ADD IT.
/* * @param int $noteID
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE READD IT. * @param int $reviewID
*/ */
private function revert_history($noteID, $reviewID){ private function revert_history($noteID, $reviewID){
global $user, $database; global $database;
$history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?",array($noteID, $reviewID)); $history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?",array($noteID, $reviewID));
@ -596,7 +597,6 @@ class Notes extends Extension {
"WHERE image_id = ? AND id = ?", array(1, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID)); "WHERE image_id = ? AND id = ?", array(1, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID));
$this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText); $this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
} }
} }

View File

@ -13,8 +13,12 @@
* This class is just a wrapper around SCoreException. * This class is just a wrapper around SCoreException.
*/ */
class PoolCreationException extends SCoreException { class PoolCreationException extends SCoreException {
var $error; /** @var string */
public $error;
/**
* @param string $error
*/
public function __construct($error) { public function __construct($error) {
$this->error = $error; $this->error = $error;
} }
@ -92,7 +96,7 @@ class Pools extends Extension {
} }
public function onPageRequest(PageRequestEvent $event) { public function onPageRequest(PageRequestEvent $event) {
global $config, $page, $user; global $page, $user;
if ($event->page_matches("pool")) { if ($event->page_matches("pool")) {
@ -249,7 +253,7 @@ class Pools extends Extension {
* to the Next image in the pool. * to the Next image in the pool.
*/ */
public function onDisplayingImage(DisplayingImageEvent $event) { public function onDisplayingImage(DisplayingImageEvent $event) {
global $config, $database, $page; global $config;
if($config->get_bool("poolsInfoOnViewImage")) { if($config->get_bool("poolsInfoOnViewImage")) {
$imageID = $event->image->id; $imageID = $event->image->id;
@ -341,7 +345,11 @@ class Pools extends Extension {
/** /**
* Check if the given user has permission to edit/change the pool. * Check if the given user has permission to edit/change the pool.
*
* TODO: Should the user variable be global? * TODO: Should the user variable be global?
*
* @param \User $user
* @param $pool
* @return bool * @return bool
*/ */
private function have_permission($user, $pool) { private function have_permission($user, $pool) {
@ -357,7 +365,7 @@ class Pools extends Extension {
/** /**
* HERE WE GET THE LIST OF POOLS. * HERE WE GET THE LIST OF POOLS.
* *
* @param Page $page * @param \Page $page
* @param int $pageNumber * @param int $pageNumber
*/ */
private function list_pools(Page $page, /*int*/ $pageNumber) { private function list_pools(Page $page, /*int*/ $pageNumber) {
@ -437,8 +445,11 @@ class Pools extends Extension {
/** /**
* Retrieve information about pools given multiple pool IDs. * Retrieve information about pools given multiple pool IDs.
*
* TODO: What is the difference between this and get_single_pool() other than the db query?
*
* @param int $poolID Array of integers * @param int $poolID Array of integers
* @return 2D Array * @return array
*/ */
private function get_pool(/*int*/ $poolID) { private function get_pool(/*int*/ $poolID) {
global $database; global $database;
@ -448,7 +459,7 @@ class Pools extends Extension {
/** /**
* Retrieve information about a pool given a pool ID. * Retrieve information about a pool given a pool ID.
* @param int $poolID the pool id * @param int $poolID the pool id
* @return 2D array (with only 1 element in the one dimension) * @return array Array with only 1 element in the one dimension
*/ */
private function get_single_pool(/*int*/ $poolID) { private function get_single_pool(/*int*/ $poolID) {
global $database; global $database;
@ -457,8 +468,8 @@ class Pools extends Extension {
/** /**
* Retrieve information about a pool given a pool title. * Retrieve information about a pool given a pool title.
* @param $poolTitle Integer * @param string $poolTitle
* @return 2D array (with only 1 element in the one dimension) * @return array Array (with only 1 element in the one dimension)
*/ */
private function get_single_pool_from_title(/*string*/ $poolTitle) { private function get_single_pool_from_title(/*string*/ $poolTitle) {
global $database; global $database;
@ -467,20 +478,20 @@ class Pools extends Extension {
/** /**
* Get all of the pool IDs that an image is in, given an image ID. * Get all of the pool IDs that an image is in, given an image ID.
* @param $imageID Integer * @param int $imageID Integer ID for the image
* @return 2D array * @return array
*/ */
private function get_pool_id(/*int*/ $imageID) { private function get_pool_id(/*int*/ $imageID) {
global $database; global $database;
return $database->get_all("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID)); return $database->get_all("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID));
} }
/**
/*
* HERE WE GET THE IMAGES FROM THE TAG ON IMPORT * HERE WE GET THE IMAGES FROM THE TAG ON IMPORT
* @param int $pool_id
*/ */
private function import_posts(/*int*/ $pool_id) { private function import_posts(/*int*/ $pool_id) {
global $page, $config, $database; global $page, $config;
$poolsMaxResults = $config->get_int("poolsMaxImportResults", 1000); $poolsMaxResults = $config->get_int("poolsMaxImportResults", 1000);
@ -489,10 +500,12 @@ class Pools extends Extension {
} }
/* /**
* HERE WE ADD CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY * HERE WE ADD CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY
* *
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function. * TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
*
* @return int
*/ */
private function add_posts() { private function add_posts() {
global $database; global $database;
@ -526,8 +539,9 @@ class Pools extends Extension {
return $poolID; return $poolID;
} }
/* /**
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function. * TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
* @return int
*/ */
private function order_posts() { private function order_posts() {
global $database; global $database;
@ -547,11 +561,12 @@ class Pools extends Extension {
return $poolID; return $poolID;
} }
/**
/*
* HERE WE REMOVE CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY * HERE WE REMOVE CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY
* *
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function. * TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
*
* @return int
*/ */
private function remove_posts() { private function remove_posts() {
global $database; global $database;
@ -569,8 +584,9 @@ class Pools extends Extension {
return $poolID; return $poolID;
} }
/* /**
* Allows editing of pool description. * Allows editing of pool description.
* @return int
*/ */
private function edit_description() { private function edit_description() {
global $database; global $database;
@ -586,8 +602,8 @@ class Pools extends Extension {
* Used by add_posts() * Used by add_posts()
* *
* @see add_posts() * @see add_posts()
* @param $poolID integer * @param int $poolID
* @param $imageID integer * @param int $imageID
* @return bool * @return bool
*/ */
private function check_post(/*int*/ $poolID, /*int*/ $imageID) { private function check_post(/*int*/ $poolID, /*int*/ $imageID) {
@ -599,9 +615,9 @@ class Pools extends Extension {
/** /**
* Gets the next successive image from a pool, given a pool ID and an image ID. * Gets the next successive image from a pool, given a pool ID and an image ID.
* *
* @param $pool Array for the given pool * @param array $pool Array for the given pool
* @param $imageID Integer * @param int $imageID Integer
* @return Integer which is the next Image ID or NULL if none. * @return int Integer which is the next Image ID or NULL if none.
*/ */
private function get_next_post(/*array*/ $pool, /*int*/ $imageID) { private function get_next_post(/*array*/ $pool, /*int*/ $imageID) {
global $database; global $database;
@ -627,6 +643,9 @@ class Pools extends Extension {
/** /**
* Retrieve all the images in a pool, given a pool ID. * Retrieve all the images in a pool, given a pool ID.
*
* @param PageRequestEvent $event
* @param int $poolID
*/ */
private function get_posts($event, /*int*/ $poolID) { private function get_posts($event, /*int*/ $poolID) {
global $config, $user, $database; global $config, $user, $database;
@ -690,8 +709,8 @@ class Pools extends Extension {
/** /**
* This function gets the current order of images from a given pool. * This function gets the current order of images from a given pool.
* @param $poolID integer * @param int $poolID
* @return Array of image objects. * @return \Image[] Array of image objects.
*/ */
private function edit_posts(/*int*/ $poolID) { private function edit_posts(/*int*/ $poolID) {
global $database; global $database;
@ -708,8 +727,11 @@ class Pools extends Extension {
} }
/* /**
* WE GET THE ORDER OF THE IMAGES BUT HERE WE SEND KEYS ADDED IN ARRAY TO GET THE ORDER IN THE INPUT VALUE * WE GET THE ORDER OF THE IMAGES BUT HERE WE SEND KEYS ADDED IN ARRAY TO GET THE ORDER IN THE INPUT VALUE.
*
* @param int $poolID
* @return \Image[]
*/ */
private function edit_order(/*int*/ $poolID) { private function edit_order(/*int*/ $poolID) {
global $database; global $database;
@ -732,8 +754,10 @@ class Pools extends Extension {
} }
/* /**
* HERE WE NUKE ENTIRE POOL. WE REMOVE POOLS AND POSTS FROM REMOVED POOL AND HISTORIES ENTRIES FROM REMOVED POOL * HERE WE NUKE ENTIRE POOL. WE REMOVE POOLS AND POSTS FROM REMOVED POOL AND HISTORIES ENTRIES FROM REMOVED POOL.
*
* @param int $poolID
*/ */
private function nuke_pool(/*int*/ $poolID) { private function nuke_pool(/*int*/ $poolID) {
global $user, $database; global $user, $database;
@ -765,8 +789,9 @@ class Pools extends Extension {
} }
/* /**
* HERE WE GET THE HISTORY LIST * HERE WE GET THE HISTORY LIST.
* @param int $pageNumber
*/ */
private function get_history(/*int*/ $pageNumber) { private function get_history(/*int*/ $pageNumber) {
global $config, $database; global $config, $database;
@ -778,7 +803,6 @@ class Pools extends Extension {
else else
$pageNumber--; $pageNumber--;
$historiesPerPage = $config->get_int("poolsUpdatedPerPage"); $historiesPerPage = $config->get_int("poolsUpdatedPerPage");
$history = $database->get_all(" $history = $database->get_all("
@ -799,9 +823,9 @@ class Pools extends Extension {
} }
/**
/* * HERE GO BACK IN HISTORY AND ADD OR REMOVE POSTS TO POOL.
* HERE GO BACK IN HISTORY AND ADD OR REMOVE POSTS TO POOL * @param int $historyID
*/ */
private function revert_history(/*int*/ $historyID) { private function revert_history(/*int*/ $historyID) {
global $database; global $database;
@ -846,9 +870,13 @@ class Pools extends Extension {
/* /**
* HERE WE ADD A SIMPLE POST FROM POOL * HERE WE ADD A SIMPLE POST FROM POOL.
* USED WITH FOREACH IN revert_history() & onTagTermParse() * USED WITH FOREACH IN revert_history() & onTagTermParse().
*
* @param int $poolID
* @param int $imageID
* @param bool $history
*/ */
private function add_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) { private function add_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) {
global $database; global $database;
@ -869,10 +897,13 @@ class Pools extends Extension {
} }
/**
/* * HERE WE REMOVE A SIMPLE POST FROM POOL.
* HERE WE REMOVE A SIMPLE POST FROM POOL * USED WITH FOREACH IN revert_history() & onTagTermParse().
* USED WITH FOREACH IN revert_history() & onTagTermParse() *
* @param int $poolID
* @param int $imageID
* @param bool $history
*/ */
private function delete_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) { private function delete_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) {
global $database; global $database;