PHPDoc all the things!

This commit is contained in:
jgen 2014-04-28 18:22:57 -04:00
parent 2a9f76d2f0
commit b3f9925839
8 changed files with 191 additions and 47 deletions

View file

@ -349,7 +349,7 @@ class Pools extends Extension {
* TODO: Should the user variable be global?
*
* @param \User $user
* @param $pool
* @param array $pool
* @return bool
*/
private function have_permission($user, $pool) {
@ -522,11 +522,10 @@ class Pools extends Extension {
$images .= " ".$imageID;
}
}
if(!strlen($images) == 0) {
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", array("pid"=>$poolID));
$count = int_escape($database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", array("pid"=>$poolID)));
$this->add_history($poolID, 1, $images, $count);
}
@ -774,10 +773,13 @@ class Pools extends Extension {
}
}
/*
* HERE WE ADD A HISTORY ENTRY
* FOR $action 1 (one) MEANS ADDED, 0 (zero) MEANS REMOVED
/**
* HERE WE ADD A HISTORY ENTRY.
*
* @param int $poolID
* @param int $action Action=1 (one) MEANS ADDED, Action=0 (zero) MEANS REMOVED
* @param string $images
* @param int $count
*/
private function add_history(/*int*/ $poolID, $action, $images, $count) {
global $user, $database;
@ -788,7 +790,6 @@ class Pools extends Extension {
array("pid"=>$poolID, "uid"=>$user->id, "act"=>$action, "img"=>$images, "count"=>$count));
}
/**
* HERE WE GET THE HISTORY LIST.
* @param int $pageNumber
@ -822,7 +823,6 @@ class Pools extends Extension {
$this->theme->show_history($history, $pageNumber + 1, $totalPages);
}
/**
* HERE GO BACK IN HISTORY AND ADD OR REMOVE POSTS TO POOL.
* @param int $historyID
@ -868,8 +868,6 @@ class Pools extends Extension {
}
}
/**
* HERE WE ADD A SIMPLE POST FROM POOL.
* USED WITH FOREACH IN revert_history() & onTagTermParse().
@ -896,7 +894,6 @@ class Pools extends Extension {
}
}
/**
* HERE WE REMOVE A SIMPLE POST FROM POOL.
* USED WITH FOREACH IN revert_history() & onTagTermParse().

View file

@ -11,6 +11,11 @@ class PoolsTheme extends Themelet {
}
}
/**
* @param Image $image
* @param array $pools
* @return string
*/
public function get_adder_html(Image $image, /*array*/ $pools) {
$h = "";
foreach($pools as $pool) {
@ -27,9 +32,13 @@ class PoolsTheme extends Themelet {
return $editor;
}
/*
* HERE WE SHOWS THE LIST OF POOLS
/**
* HERE WE SHOWS THE LIST OF POOLS.
*
* @param Page $page
* @param array $pools
* @param int $pageNumber
* @param int $totalPages
*/
public function list_pools(Page $page, /*array*/ $pools, /*int*/ $pageNumber, /*int*/ $totalPages) {
global $user;
@ -105,7 +114,11 @@ class PoolsTheme extends Themelet {
$page->add_block(new Block("Create Pool", $create_html, "main", 20));
}
/**
* @param array $pools
* @param string $heading
* @param bool $check_all
*/
private function display_top(/*array*/ $pools, /*string*/ $heading, $check_all=false) {
global $page, $user;
@ -150,8 +163,13 @@ class PoolsTheme extends Themelet {
}
/*
* HERE WE DISPLAY THE POOL WITH TITLE DESCRIPTION AND IMAGES WITH PAGINATION
/**
* HERE WE DISPLAY THE POOL WITH TITLE DESCRIPTION AND IMAGES WITH PAGINATION.
*
* @param array $pools
* @param array $images
* @param int $pageNumber
* @param int $totalPages
*/
public function view_pool(/*array*/ $pools, /*array*/ $images, /*int*/ $pageNumber, /*int*/ $totalPages) {
global $user, $page;
@ -176,8 +194,12 @@ class PoolsTheme extends Themelet {
}
/*
* HERE WE DISPLAY THE POOL OPTIONS ON SIDEBAR BUT WE HIDE REMOVE OPTION IF THE USER IS NOT THE OWNER OR ADMIN
/**
* HERE WE DISPLAY THE POOL OPTIONS ON SIDEBAR BUT WE HIDE REMOVE OPTION IF THE USER IS NOT THE OWNER OR ADMIN.
*
* @param Page $page
* @param array $pool
* @param bool $check_all
*/
public function sidebar_options(Page $page, $pool, /*bool*/ $check_all) {
global $user;
@ -240,8 +262,12 @@ class PoolsTheme extends Themelet {
}
/*
* HERE WE DISPLAY THE RESULT OF THE SEARCH ON IMPORT
/**
* HERE WE DISPLAY THE RESULT OF THE SEARCH ON IMPORT.
*
* @param Page $page
* @param array $images
* @param int $pool_id
*/
public function pool_result(Page $page, /*array*/ $images, /*int*/ $pool_id) {
// TODO: this could / should be done using jQuery
@ -289,9 +315,13 @@ class PoolsTheme extends Themelet {
}
/*
* HERE WE DISPLAY THE POOL ORDERER
/**
* HERE WE DISPLAY THE POOL ORDERER.
* WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH A TEXT INPUT TO SET A NUMBER AND CHANGE THE ORDER
*
* @param Page $page
* @param array $pools
* @param array $images
*/
public function edit_order(Page $page, /*array*/ $pools, /*array*/ $images) {
global $user;
@ -318,16 +348,19 @@ class PoolsTheme extends Themelet {
$page->add_block(new Block("Sorting Posts", $pool_images, "main", 30));
}
/*
* HERE WE DISPLAY THE POOL EDITOR
/**
* HERE WE DISPLAY THE POOL EDITOR.
*
* WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH
* A CHECKBOX TO SELECT WHICH IMAGE WE WANT TO REMOVE
*
* @param Page $page
* @param array $pools
* @param array $images
*/
public function edit_pool(Page $page, /*array*/ $pools, /*array*/ $images) {
global $user;
/* EDIT POOL DESCRIPTION */
$desc_html = "
".make_form(make_link("pool/edit_description"))."
@ -362,8 +395,12 @@ class PoolsTheme extends Themelet {
}
/*
* HERE WE DISPLAY THE HISTORY LIST
/**
* HERE WE DISPLAY THE HISTORY LIST.
*
* @param array $histories
* @param int $pageNumber
* @param int $totalPages
*/
public function show_history($histories, /*int*/ $pageNumber, /*int*/ $totalPages) {
global $page;
@ -393,7 +430,7 @@ class PoolsTheme extends Themelet {
$images = explode(" ", $images);
$image_link = "";
foreach ($images as $image) {
foreach ($images as $image) {
$image_link .= "<a href='".make_link("post/view/".$image)."'>".$prefix.$image." </a>";
}

View file

@ -139,6 +139,10 @@ class ReportImage extends Extension {
}
}
/**
* @param Image $image
* @return array
*/
public function get_reporters(Image $image) {
global $database;
@ -150,6 +154,9 @@ class ReportImage extends Extension {
", array("image_id" => $image->id));
}
/**
* @return array
*/
public function get_reported_images() {
global $database;
@ -174,6 +181,9 @@ class ReportImage extends Extension {
return $reports;
}
/**
* @return mixed
*/
public function count_reported_images() {
global $database;

View file

@ -11,6 +11,10 @@
*/
class ReportImageTheme extends Themelet {
/**
* @param Page $page
* @param array $reports
*/
public function display_reported_images(Page $page, $reports) {
global $config;

View file

@ -153,7 +153,11 @@ class XMLSitemap extends Extension
$page->set_data($xml);
}
// returns true if a new sitemap is needed
/**
* Returns true if a new sitemap is needed.
*
* @return bool
*/
private function new_sitemap_needed()
{
$sitemap_generation_interval = 86400; // allow new site map every day

View file

@ -37,6 +37,9 @@ class UploadTheme extends Themelet {
}
}
/**
* @return string
*/
protected function h_upload_list_1() {
global $config;
$upload_list = "";
@ -83,6 +86,9 @@ class UploadTheme extends Themelet {
return $upload_list;
}
/**
* @return string
*/
protected function h_upload_List_2() {
global $config;
@ -180,6 +186,9 @@ class UploadTheme extends Themelet {
return $upload_list;
}
/**
* @return string
*/
protected function h_bookmarklets() {
global $config;
$link = make_http(make_link("upload"));
@ -306,6 +315,9 @@ class UploadTheme extends Themelet {
$page->add_block(new Block($title, $message));
}
/**
* @return string
*/
protected function build_upload_block() {
global $config;

View file

@ -6,8 +6,14 @@
*/
class UserBlockBuildingEvent extends Event {
var $parts = array();
/** @var array */
public $parts = array();
/**
* @param string $name
* @param string $link
* @param int $position
*/
public function add_link($name, $link, $position=50) {
while(isset($this->parts[$position])) $position++;
$this->parts[$position] = array("name" => $name, "link" => $link);
@ -15,24 +21,41 @@ class UserBlockBuildingEvent extends Event {
}
class UserPageBuildingEvent extends Event {
var $display_user;
var $stats = array();
/** @var \User */
public $display_user;
/** @var array */
public $stats = array();
/**
* @param User $display_user
*/
public function __construct(User $display_user) {
$this->display_user = $display_user;
}
/**
* @param string $html
* @param int $position
*/
public function add_stats($html, $position=50) {
while(isset($this->stats[$position])) $position++;
while(isset($this->stats[$position])) { $position++; }
$this->stats[$position] = $html;
}
}
class UserCreationEvent extends Event {
var $username;
var $password;
var $email;
/** @var string */
public $username;
/** @var string */
public $password;
/** @var string */
public $email;
/**
* @param string $name
* @param string $pass
* @param string $email
*/
public function __construct($name, $pass, $email) {
$this->username = $name;
$this->password = $pass;
@ -41,8 +64,12 @@ class UserCreationEvent extends Event {
}
class UserDeletionEvent extends Event {
var $id;
/** @var int */
public $id;
/**
* @param int $id
*/
public function __construct($id) {
$this->id = $id;
}
@ -221,8 +248,11 @@ class UserPage extends Extension {
}
}
/**
* @param UserPageBuildingEvent $event
*/
public function onUserPageBuilding(UserPageBuildingEvent $event) {
global $page, $user, $config;
global $user, $config;
$h_join_date = autodate($event->display_user->join_date);
if($event->display_user->can("hellbanned")) {
@ -251,6 +281,9 @@ class UserPage extends Extension {
}
}
/**
* @param UserPageBuildingEvent $event
*/
private function display_stats(UserPageBuildingEvent $event) {
global $user, $page, $config;
@ -273,6 +306,9 @@ class UserPage extends Extension {
}
}
/**
* @param SetupBuildingEvent $event
*/
public function onSetupBuilding(SetupBuildingEvent $event) {
global $config;
@ -300,24 +336,33 @@ class UserPage extends Extension {
array('G'=>'g', 'PG'=>'pg', 'R'=>'r', 'X'=>'x'),
"<br>Rating: ");
}
$sb->add_choice_option("user_loginshowprofile", array(
"return to previous page" => 0, // 0 is default
"send to user profile" => 1),
"<br>When user logs in/out");
$sb->add_choice_option("user_loginshowprofile", array(
"return to previous page" => 0, // 0 is default
"send to user profile" => 1),
"<br>When user logs in/out");
$event->panel->add_block($sb);
}
/**
* @param UserBlockBuildingEvent $event
*/
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
$event->add_link("My Profile", make_link("user"));
$event->add_link("Log Out", make_link("user_admin/logout"), 99);
}
/**
* @param UserCreationEvent $event
*/
public function onUserCreation(UserCreationEvent $event) {
$this->check_user_creation($event);
$this->create_user($event);
}
/**
* @param SearchTermParseEvent $event
*/
public function onSearchTermParse(SearchTermParseEvent $event) {
global $user;
@ -343,6 +388,9 @@ class UserPage extends Extension {
}
// }}}
// Things done *with* the user {{{
/**
* @param Page $page
*/
private function login(Page $page) {
global $user, $config;
@ -378,6 +426,10 @@ class UserPage extends Extension {
}
}
/**
* @param UserCreationEvent $event
* @throws UserCreationException
*/
private function check_user_creation(UserCreationEvent $event)
{
global $database;
@ -435,6 +487,11 @@ class UserPage extends Extension {
}
//}}}
// Things done *to* the user {{{
/**
* @param User $a
* @param User $b
* @return bool
*/
private function user_can_edit_user(User $a, User $b) {
if($a->is_anonymous()) {
$this->theme->display_error(401, "Error", "You aren't logged in");
@ -474,6 +531,11 @@ class UserPage extends Extension {
}
}
/**
* @param User $duser
* @param string $pass1
* @param string $pass2
*/
private function change_password_wrapper(User $duser, $pass1, $pass2) {
global $user;
@ -495,6 +557,10 @@ class UserPage extends Extension {
}
}
/**
* @param User $duser
* @param string $address
*/
private function change_email_wrapper(User $duser, /*string(email)*/ $address) {
global $user;
@ -506,6 +572,11 @@ class UserPage extends Extension {
}
}
/**
* @param User $duser
* @param string $class
* @throws NullUserException
*/
private function change_class_wrapper(User $duser, /*string(class)*/ $class) {
global $user;
@ -522,6 +593,10 @@ class UserPage extends Extension {
}
// }}}
// ips {{{
/**
* @param User $duser
* @return array
*/
private function count_upload_ips(User $duser) {
global $database;
$rows = $database->get_pairs("
@ -535,6 +610,11 @@ class UserPage extends Extension {
ORDER BY most_recent DESC", array("id"=>$duser->id));
return $rows;
}
/**
* @param User $duser
* @return array
*/
private function count_comment_ips(User $duser) {
global $database;
$rows = $database->get_pairs("

View file

@ -66,7 +66,7 @@ class ShimmieInstallerTest extends WebTestCase {
$this->clickSubmit("Go!");
if (!$this->assertText("Installation Succeeded!")) {
print "ERROR --- '" + $db + "'";
print "ERROR --- '" . $db . "'";
$this->showSource();
}
}