forked from Cavemanon/cavepaintings
use strict types
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
class NumericScoreInfo extends ExtensionInfo
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
class NumericScoreSetEvent extends Event
|
||||
{
|
||||
@@ -8,6 +8,7 @@ class NumericScoreSetEvent extends Event
|
||||
|
||||
public function __construct(int $image_id, User $user, int $score)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->image_id = $image_id;
|
||||
$this->user = $user;
|
||||
$this->score = $score;
|
||||
@@ -46,8 +47,8 @@ class NumericScore extends Extension
|
||||
if ($event->page_matches("numeric_score_votes")) {
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
$x = $database->get_all(
|
||||
"SELECT users.name as username, user_id, score
|
||||
FROM numeric_score_votes
|
||||
"SELECT users.name as username, user_id, score
|
||||
FROM numeric_score_votes
|
||||
JOIN users ON numeric_score_votes.user_id=users.id
|
||||
WHERE image_id=:image_id",
|
||||
['image_id'=>$image_id]
|
||||
@@ -222,6 +223,8 @@ class NumericScore extends Extension
|
||||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^score([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(-?\d+)$/i", $event->term, $matches)) {
|
||||
$cmp = ltrim($matches[1], ":") ?: "=";
|
||||
@@ -298,7 +301,6 @@ class NumericScore extends Extension
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
if ($this->get_version("ext_numeric_score_version") < 1) {
|
||||
$database->execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0");
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
class NumericScoreTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testNumericScore()
|
||||
|
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
class NumericScoreTheme extends Themelet
|
||||
{
|
||||
public function get_voter(Image $image)
|
||||
{
|
||||
global $user, $page;
|
||||
$i_image_id = int_escape($image->id);
|
||||
$i_score = int_escape($image->numeric_score);
|
||||
$i_image_id = $image->id;
|
||||
if(is_string($image->numeric_score)) $image->numeric_score = (int)$image->numeric_score;
|
||||
$i_score = $image->numeric_score;
|
||||
|
||||
$html = "
|
||||
Current Score: $i_score
|
||||
@@ -99,7 +100,7 @@ class NumericScoreTheme extends Themelet
|
||||
<div class="command_example">
|
||||
<pre>score=1</pre>
|
||||
<p>Returns images with a score of 1.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="command_example">
|
||||
<pre>score>0</pre>
|
||||
<p>Returns images with a score of 1 or more.</p>
|
||||
|
Reference in New Issue
Block a user