diff --git a/ext/random_image/main.php b/ext/random_image/main.php
index 1d2d194a..f2ed58a7 100644
--- a/ext/random_image/main.php
+++ b/ext/random_image/main.php
@@ -22,7 +22,8 @@
class RandomImage extends Extension {
public function onPageRequest(PageRequestEvent $event) {
- global $config, $database, $page, $user;
+ global $page;
+
if($event->page_matches("random_image")) {
$action = '';
if($event->count_args() == 1) {
@@ -34,7 +35,7 @@ class RandomImage extends Extension {
$search_terms = explode(' ', $event->get_arg(1));
}
else {
- # FIXME: throw exception
+ throw new SCoreException("Error: too many arguments.");
}
$image = Image::by_random($search_terms);
diff --git a/ext/random_image/theme.php b/ext/random_image/theme.php
index 1210959e..457a06a0 100644
--- a/ext/random_image/theme.php
+++ b/ext/random_image/theme.php
@@ -5,23 +5,24 @@ class RandomImageTheme extends Themelet {
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
}
- public function build_random_html(Image $image, $query=null) {
- global $config;
- $i_id = int_escape($image->id);
- $h_view_link = make_link("post/view/$i_id", $query);
- $h_thumb_link = $image->get_thumb_link();
- $h_tip = html_escape($image->get_tooltip());
- $tsize = get_thumbnail_size($image->width, $image->height);
+ public function build_random_html(Image $image, $query=null)
+ {
- return "
-
+ $i_id = int_escape($image->id);
+ $h_view_link = make_link("post/view/$i_id", $query);
+ $h_thumb_link = $image->get_thumb_link();
+ $h_tip = html_escape($image->get_tooltip());
+ $tsize = get_thumbnail_size($image->width, $image->height);
-
-
-
+ return "
+
-
- ";
+
+
+
+
+
+ ";
}
}
diff --git a/ext/random_list/theme.php b/ext/random_list/theme.php
index bbfbff5c..b3baf1ad 100644
--- a/ext/random_list/theme.php
+++ b/ext/random_list/theme.php
@@ -1,4 +1,4 @@
\ No newline at end of file
+
diff --git a/ext/rating/main.php b/ext/rating/main.php
index c9f3c8aa..b9e0c933 100644
--- a/ext/rating/main.php
+++ b/ext/rating/main.php
@@ -20,10 +20,18 @@
*/
class RatingSetEvent extends Event {
- var $image, $rating;
+ /** @var \Image */
+ public $image;
+ /** @var string */
+ public $rating;
+ /**
+ * @param Image $image
+ * @param string $rating
+ */
public function __construct(Image $image, /*char*/ $rating) {
assert(in_array($rating, array("s", "q", "e", "u")));
+
$this->image = $image;
$this->rating = $rating;
}
@@ -31,6 +39,9 @@ class RatingSetEvent extends Event {
class Ratings extends Extension {
+ /**
+ * @return int
+ */
public function get_priority() {return 50;}
public function onInitExt(InitExtEvent $event) {
@@ -69,7 +80,7 @@ class Ratings extends Extension {
public function onDisplayingImage(DisplayingImageEvent $event) {
- global $user, $database, $page;
+ global $user, $page;
/**
* Deny images upon insufficient permissions.
**/
@@ -97,8 +108,6 @@ class Ratings extends Extension {
}
public function onImageInfoSet(ImageInfoSetEvent $event) {
- global $user;
-
if($this->can_rate() && isset($_POST["rating"])) {
send_event(new RatingSetEvent($event->image, $_POST['rating']));
}
@@ -125,11 +134,11 @@ class Ratings extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
- global $database, $user, $page;
+ global $user, $page;
if ($event->page_matches("admin/bulk_rate")) {
if(!$user->is_admin()) {
- throw PermissionDeniedException();
+ throw new PermissionDeniedException();
}
else {
$n = 0;
@@ -154,9 +163,14 @@ class Ratings extends Extension {
}
}
}
-
- public static function get_user_privs($user) {
+
+ /**
+ * @param \User $user
+ * @return null|string
+ */
+ public static function get_user_privs(User $user) {
global $config;
+
if($user->is_anonymous()) {
$sqes = $config->get_string("ext_rating_anon_privs");
}
@@ -169,6 +183,10 @@ class Ratings extends Extension {
return $sqes;
}
+ /**
+ * @param string $sqes
+ * @return string
+ */
public static function privs_to_sql(/*string*/ $sqes) {
$arr = array();
$length = strlen($sqes);
@@ -179,6 +197,10 @@ class Ratings extends Extension {
return $set;
}
+ /**
+ * @param string $rating
+ * @return string
+ */
public static function rating_to_human(/*string*/ $rating) {
switch($rating) {
case "s": return "Safe";
@@ -188,7 +210,11 @@ class Ratings extends Extension {
}
}
- // FIXME: this is a bit ugly and guessey, should have proper options
+ /**
+ * FIXME: this is a bit ugly and guessey, should have proper options
+ *
+ * @return bool
+ */
private function can_rate() {
global $config, $user;
if($user->is_anonymous() && $config->get_string("ext_rating_anon_privs") == "sqeu") return false;
@@ -197,6 +223,10 @@ class Ratings extends Extension {
return false;
}
+ /**
+ * @param $context
+ * @return bool
+ */
private function no_rating_query($context) {
foreach($context as $term) {
if(preg_match("/^rating[=|:]/", $term)) {
@@ -207,8 +237,7 @@ class Ratings extends Extension {
}
private function install() {
- global $database;
- global $config;
+ global $database, $config;
if($config->get_int("ext_ratings2_version") < 1) {
$database->Execute("ALTER TABLE images ADD COLUMN rating CHAR(1) NOT NULL DEFAULT 'u'");
@@ -227,6 +256,11 @@ class Ratings extends Extension {
}
}
+ /**
+ * @param int $image_id
+ * @param string $rating
+ * @param string $old_rating
+ */
private function set_rating(/*int*/ $image_id, /*string*/ $rating, /*string*/ $old_rating) {
global $database;
if($old_rating != $rating){
diff --git a/ext/rating/theme.php b/ext/rating/theme.php
index 4fde8274..6fc58f3d 100644
--- a/ext/rating/theme.php
+++ b/ext/rating/theme.php
@@ -1,6 +1,11 @@
add_block(new Block("List Controls", $html, "left"));
}
+ /**
+ * @param string $rating
+ * @return string
+ */
public function rating_to_name(/*string*/ $rating) {
switch($rating) {
case 's': return "Safe";
diff --git a/ext/report_image/main.php b/ext/report_image/main.php
index b99f7030..6f5dfd5a 100644
--- a/ext/report_image/main.php
+++ b/ext/report_image/main.php
@@ -10,18 +10,30 @@
*/
class RemoveReportedImageEvent extends Event {
- var $id;
+ /** @var int */
+ public $id;
+ /**
+ * @param int $id
+ */
public function __construct($id) {
$this->id = $id;
}
}
class AddReportedImageEvent extends Event {
- var $reporter_id;
- var $image_id;
- var $reason;
+ /** @var int */
+ public $reporter_id;
+ /** @var int */
+ public $image_id;
+ /** @var string */
+ public $reason;
+ /**
+ * @param int $image_id
+ * @param int $reporter_id
+ * @param string $reason
+ */
public function __construct($image_id, $reporter_id, $reason) {
$this->reporter_id = $reporter_id;
$this->image_id = $image_id;
@@ -89,7 +101,7 @@ class ReportImage extends Extension {
}
public function onDisplayingImage(DisplayingImageEvent $event) {
- global $config, $user, $page;
+ global $user, $page;
if($user->can('create_image_report')) {
$reps = $this->get_reporters($event->image);
$this->theme->display_image_banner($event->image, $reps);
@@ -112,8 +124,8 @@ class ReportImage extends Extension {
}
protected function install() {
- global $database;
- global $config;
+ global $database, $config;
+
if($config->get_int("ext_report_image_version") < 1) {
$database->create_table("image_reports", "
id SCORE_AIPK,
@@ -129,6 +141,7 @@ class ReportImage extends Extension {
public function get_reporters(Image $image) {
global $database;
+
return $database->get_col("
SELECT users.name
FROM image_reports
@@ -138,7 +151,8 @@ class ReportImage extends Extension {
}
public function get_reported_images() {
- global $config, $database;
+ global $database;
+
$all_reports = $database->get_all("
SELECT image_reports.*, users.name AS reporter_name
FROM image_reports
diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php
index 35aca30f..1bc59d61 100644
--- a/ext/report_image/theme.php
+++ b/ext/report_image/theme.php
@@ -57,11 +57,14 @@ class ReportImageTheme extends Themelet {
$page->set_heading("Reported Images");
$page->add_block(new NavBlock());
$page->add_block(new Block("Reported Images", $html));
-
}
+ /**
+ * @param Image $image
+ * @param array $reporters
+ */
public function display_image_banner(Image $image, /*array*/ $reporters) {
- global $config, $page;
+ global $page;
$i_image = int_escape($image->id);
$html = "";