Lots of linting again.
This commit is contained in:
parent
158819cb28
commit
b56e390676
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
class RandomImage extends Extension {
|
class RandomImage extends Extension {
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $database, $page, $user;
|
global $page;
|
||||||
|
|
||||||
if($event->page_matches("random_image")) {
|
if($event->page_matches("random_image")) {
|
||||||
$action = '';
|
$action = '';
|
||||||
if($event->count_args() == 1) {
|
if($event->count_args() == 1) {
|
||||||
@ -34,7 +35,7 @@ class RandomImage extends Extension {
|
|||||||
$search_terms = explode(' ', $event->get_arg(1));
|
$search_terms = explode(' ', $event->get_arg(1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# FIXME: throw exception
|
throw new SCoreException("Error: too many arguments.");
|
||||||
}
|
}
|
||||||
$image = Image::by_random($search_terms);
|
$image = Image::by_random($search_terms);
|
||||||
|
|
||||||
|
@ -5,23 +5,24 @@ class RandomImageTheme extends Themelet {
|
|||||||
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
|
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build_random_html(Image $image, $query=null) {
|
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);
|
|
||||||
|
|
||||||
return "
|
$i_id = int_escape($image->id);
|
||||||
<center><div>
|
$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);
|
||||||
|
|
||||||
<a href='$h_view_link' style='position: relative; height: {$tsize[1]}px; width: {$tsize[0]}px;'>
|
return "
|
||||||
<img id='thumb_rand_$i_id' title='$h_tip' alt='$h_tip' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'>
|
<center><div>
|
||||||
</a>
|
|
||||||
|
|
||||||
</div></center>
|
<a href='$h_view_link' style='position: relative; height: {$tsize[1]}px; width: {$tsize[0]}px;'>
|
||||||
";
|
<img id='thumb_rand_$i_id' title='$h_tip' alt='$h_tip' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div></center>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/* needed for access to build_thumb_html */
|
/* needed for access to build_thumb_html */
|
||||||
class RandomListTheme extends Themelet {}
|
class RandomListTheme extends Themelet {}
|
||||||
?>
|
|
||||||
|
@ -20,10 +20,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class RatingSetEvent extends Event {
|
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) {
|
public function __construct(Image $image, /*char*/ $rating) {
|
||||||
assert(in_array($rating, array("s", "q", "e", "u")));
|
assert(in_array($rating, array("s", "q", "e", "u")));
|
||||||
|
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
$this->rating = $rating;
|
$this->rating = $rating;
|
||||||
}
|
}
|
||||||
@ -31,6 +39,9 @@ class RatingSetEvent extends Event {
|
|||||||
|
|
||||||
class Ratings extends Extension {
|
class Ratings extends Extension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function get_priority() {return 50;}
|
public function get_priority() {return 50;}
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
@ -69,7 +80,7 @@ class Ratings extends Extension {
|
|||||||
|
|
||||||
|
|
||||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
global $user, $database, $page;
|
global $user, $page;
|
||||||
/**
|
/**
|
||||||
* Deny images upon insufficient permissions.
|
* Deny images upon insufficient permissions.
|
||||||
**/
|
**/
|
||||||
@ -97,8 +108,6 @@ class Ratings extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onImageInfoSet(ImageInfoSetEvent $event) {
|
public function onImageInfoSet(ImageInfoSetEvent $event) {
|
||||||
global $user;
|
|
||||||
|
|
||||||
if($this->can_rate() && isset($_POST["rating"])) {
|
if($this->can_rate() && isset($_POST["rating"])) {
|
||||||
send_event(new RatingSetEvent($event->image, $_POST['rating']));
|
send_event(new RatingSetEvent($event->image, $_POST['rating']));
|
||||||
}
|
}
|
||||||
@ -125,11 +134,11 @@ class Ratings extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $database, $user, $page;
|
global $user, $page;
|
||||||
|
|
||||||
if ($event->page_matches("admin/bulk_rate")) {
|
if ($event->page_matches("admin/bulk_rate")) {
|
||||||
if(!$user->is_admin()) {
|
if(!$user->is_admin()) {
|
||||||
throw PermissionDeniedException();
|
throw new PermissionDeniedException();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$n = 0;
|
$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;
|
global $config;
|
||||||
|
|
||||||
if($user->is_anonymous()) {
|
if($user->is_anonymous()) {
|
||||||
$sqes = $config->get_string("ext_rating_anon_privs");
|
$sqes = $config->get_string("ext_rating_anon_privs");
|
||||||
}
|
}
|
||||||
@ -169,6 +183,10 @@ class Ratings extends Extension {
|
|||||||
return $sqes;
|
return $sqes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sqes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function privs_to_sql(/*string*/ $sqes) {
|
public static function privs_to_sql(/*string*/ $sqes) {
|
||||||
$arr = array();
|
$arr = array();
|
||||||
$length = strlen($sqes);
|
$length = strlen($sqes);
|
||||||
@ -179,6 +197,10 @@ class Ratings extends Extension {
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $rating
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function rating_to_human(/*string*/ $rating) {
|
public static function rating_to_human(/*string*/ $rating) {
|
||||||
switch($rating) {
|
switch($rating) {
|
||||||
case "s": return "Safe";
|
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() {
|
private function can_rate() {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
if($user->is_anonymous() && $config->get_string("ext_rating_anon_privs") == "sqeu") return false;
|
if($user->is_anonymous() && $config->get_string("ext_rating_anon_privs") == "sqeu") return false;
|
||||||
@ -197,6 +223,10 @@ class Ratings extends Extension {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $context
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
private function no_rating_query($context) {
|
private function no_rating_query($context) {
|
||||||
foreach($context as $term) {
|
foreach($context as $term) {
|
||||||
if(preg_match("/^rating[=|:]/", $term)) {
|
if(preg_match("/^rating[=|:]/", $term)) {
|
||||||
@ -207,8 +237,7 @@ class Ratings extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function install() {
|
private function install() {
|
||||||
global $database;
|
global $database, $config;
|
||||||
global $config;
|
|
||||||
|
|
||||||
if($config->get_int("ext_ratings2_version") < 1) {
|
if($config->get_int("ext_ratings2_version") < 1) {
|
||||||
$database->Execute("ALTER TABLE images ADD COLUMN rating CHAR(1) NOT NULL DEFAULT 'u'");
|
$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) {
|
private function set_rating(/*int*/ $image_id, /*string*/ $rating, /*string*/ $old_rating) {
|
||||||
global $database;
|
global $database;
|
||||||
if($old_rating != $rating){
|
if($old_rating != $rating){
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class RatingsTheme extends Themelet {
|
class RatingsTheme extends Themelet {
|
||||||
|
/**
|
||||||
|
* @param int $image_id
|
||||||
|
* @param string $rating
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function get_rater_html(/*int*/ $image_id, /*string*/ $rating) {
|
public function get_rater_html(/*int*/ $image_id, /*string*/ $rating) {
|
||||||
$s_checked = $rating == 's' ? " checked" : "";
|
$s_checked = $rating == 's' ? " checked" : "";
|
||||||
$q_checked = $rating == 'q' ? " checked" : "";
|
$q_checked = $rating == 'q' ? " checked" : "";
|
||||||
@ -35,6 +40,10 @@ class RatingsTheme extends Themelet {
|
|||||||
$page->add_block(new Block("List Controls", $html, "left"));
|
$page->add_block(new Block("List Controls", $html, "left"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $rating
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function rating_to_name(/*string*/ $rating) {
|
public function rating_to_name(/*string*/ $rating) {
|
||||||
switch($rating) {
|
switch($rating) {
|
||||||
case 's': return "Safe";
|
case 's': return "Safe";
|
||||||
|
@ -10,18 +10,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class RemoveReportedImageEvent extends Event {
|
class RemoveReportedImageEvent extends Event {
|
||||||
var $id;
|
/** @var int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
public function __construct($id) {
|
public function __construct($id) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddReportedImageEvent extends Event {
|
class AddReportedImageEvent extends Event {
|
||||||
var $reporter_id;
|
/** @var int */
|
||||||
var $image_id;
|
public $reporter_id;
|
||||||
var $reason;
|
/** @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) {
|
public function __construct($image_id, $reporter_id, $reason) {
|
||||||
$this->reporter_id = $reporter_id;
|
$this->reporter_id = $reporter_id;
|
||||||
$this->image_id = $image_id;
|
$this->image_id = $image_id;
|
||||||
@ -89,7 +101,7 @@ class ReportImage extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
global $config, $user, $page;
|
global $user, $page;
|
||||||
if($user->can('create_image_report')) {
|
if($user->can('create_image_report')) {
|
||||||
$reps = $this->get_reporters($event->image);
|
$reps = $this->get_reporters($event->image);
|
||||||
$this->theme->display_image_banner($event->image, $reps);
|
$this->theme->display_image_banner($event->image, $reps);
|
||||||
@ -112,8 +124,8 @@ class ReportImage extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function install() {
|
protected function install() {
|
||||||
global $database;
|
global $database, $config;
|
||||||
global $config;
|
|
||||||
if($config->get_int("ext_report_image_version") < 1) {
|
if($config->get_int("ext_report_image_version") < 1) {
|
||||||
$database->create_table("image_reports", "
|
$database->create_table("image_reports", "
|
||||||
id SCORE_AIPK,
|
id SCORE_AIPK,
|
||||||
@ -129,6 +141,7 @@ class ReportImage extends Extension {
|
|||||||
|
|
||||||
public function get_reporters(Image $image) {
|
public function get_reporters(Image $image) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
return $database->get_col("
|
return $database->get_col("
|
||||||
SELECT users.name
|
SELECT users.name
|
||||||
FROM image_reports
|
FROM image_reports
|
||||||
@ -138,7 +151,8 @@ class ReportImage extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_reported_images() {
|
public function get_reported_images() {
|
||||||
global $config, $database;
|
global $database;
|
||||||
|
|
||||||
$all_reports = $database->get_all("
|
$all_reports = $database->get_all("
|
||||||
SELECT image_reports.*, users.name AS reporter_name
|
SELECT image_reports.*, users.name AS reporter_name
|
||||||
FROM image_reports
|
FROM image_reports
|
||||||
|
@ -57,11 +57,14 @@ class ReportImageTheme extends Themelet {
|
|||||||
$page->set_heading("Reported Images");
|
$page->set_heading("Reported Images");
|
||||||
$page->add_block(new NavBlock());
|
$page->add_block(new NavBlock());
|
||||||
$page->add_block(new Block("Reported Images", $html));
|
$page->add_block(new Block("Reported Images", $html));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Image $image
|
||||||
|
* @param array $reporters
|
||||||
|
*/
|
||||||
public function display_image_banner(Image $image, /*array*/ $reporters) {
|
public function display_image_banner(Image $image, /*array*/ $reporters) {
|
||||||
global $config, $page;
|
global $page;
|
||||||
|
|
||||||
$i_image = int_escape($image->id);
|
$i_image = int_escape($image->id);
|
||||||
$html = "";
|
$html = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user