format
This commit is contained in:
parent
60dda96fd2
commit
3631084afd
25 changed files with 105 additions and 55 deletions
|
@ -27,7 +27,7 @@ class Image
|
|||
/** @var string */
|
||||
public $hash;
|
||||
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
public $filesize;
|
||||
|
||||
/** @var string */
|
||||
|
@ -78,13 +78,11 @@ class Image
|
|||
$name = str_replace("images.", "", $name);
|
||||
|
||||
// hax, this is likely the cause of much scrutinizer-ci complaints.
|
||||
if(in_array($name, ["locked", "lossless", "video", "audio"])) {
|
||||
if (in_array($name, ["locked", "lossless", "video", "audio"])) {
|
||||
$this->$name = bool_escape($value);
|
||||
}
|
||||
elseif(in_array($name, ["id", "owner_id", "height", "width", "filesize", "length"])) {
|
||||
} elseif (in_array($name, ["id", "owner_id", "height", "width", "filesize", "length"])) {
|
||||
$this->$name = int_escape($value);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -699,7 +699,8 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false,
|
|||
);
|
||||
}
|
||||
|
||||
function SHM_SIMPLE_FORM($target, ...$children) {
|
||||
function SHM_SIMPLE_FORM($target, ...$children)
|
||||
{
|
||||
$form = SHM_FORM($target);
|
||||
$form->appendChild(emptyHTML(...$children));
|
||||
return $form;
|
||||
|
|
|
@ -129,7 +129,9 @@ class Approval extends Extension
|
|||
$event->add_querylet(new Querylet($database->scoreql_to_sql("approved = SCORE_BOOL_Y ")));
|
||||
}
|
||||
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) {
|
||||
if ($user->can(Permissions::APPROVE_IMAGE) && $matches[1] == "no") {
|
||||
$event->add_querylet(new Querylet($database->scoreql_to_sql("approved = SCORE_BOOL_N ")));
|
||||
|
|
|
@ -42,7 +42,9 @@ class Artists extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^(author|artist)[=|:](.*)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\{TABLE,TR,TH,TD,INPUT,TEXTAREA,rawHTML,SELECT,OPTION};
|
||||
use function MicroHTML\TABLE;
|
||||
use function MicroHTML\TR;
|
||||
use function MicroHTML\TH;
|
||||
use function MicroHTML\TD;
|
||||
use function MicroHTML\INPUT;
|
||||
use function MicroHTML\TEXTAREA;
|
||||
use function MicroHTML\rawHTML;
|
||||
use function MicroHTML\SELECT;
|
||||
use function MicroHTML\OPTION;
|
||||
|
||||
class BlocksTheme extends Themelet
|
||||
{
|
||||
|
@ -13,11 +21,16 @@ class BlocksTheme extends Themelet
|
|||
make_link("blocks/update"),
|
||||
TR(
|
||||
INPUT(["type"=>"hidden", "name"=>"id", "value"=>$block['id']]),
|
||||
TH("Title"), TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])),
|
||||
TH("Area"), TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])),
|
||||
TH("Priority"), TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])),
|
||||
TH("Pages"), TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])),
|
||||
TH("Delete"), TD(INPUT(["type"=>"checkbox", "name"=>"delete"])),
|
||||
TH("Title"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])),
|
||||
TH("Area"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])),
|
||||
TH("Priority"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])),
|
||||
TH("Pages"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])),
|
||||
TH("Delete"),
|
||||
TD(INPUT(["type"=>"checkbox", "name"=>"delete"])),
|
||||
TD(INPUT(["type"=>"submit", "value"=>"Save"]))
|
||||
),
|
||||
TR(
|
||||
|
@ -32,10 +45,14 @@ class BlocksTheme extends Themelet
|
|||
$html->appendChild(SHM_SIMPLE_FORM(
|
||||
make_link("blocks/add"),
|
||||
TR(
|
||||
TH("Title"), TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])),
|
||||
TH("Area"), TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main"))),
|
||||
TH("Priority"), TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])),
|
||||
TH("Pages"), TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])),
|
||||
TH("Title"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])),
|
||||
TH("Area"),
|
||||
TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main"))),
|
||||
TH("Priority"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])),
|
||||
TH("Pages"),
|
||||
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])),
|
||||
TD(["colspan"=>'3'], INPUT(["type"=>"submit", "value"=>"Add"]))
|
||||
),
|
||||
TR(
|
||||
|
|
|
@ -342,7 +342,9 @@ class CommentList extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^comments([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -55,12 +55,13 @@ class CustomHtmlHeaders extends Extension
|
|||
$sitename_in_title = $config->get_string("sitename_in_title");
|
||||
|
||||
// sitename is already in title (can occur on index & other pages)
|
||||
if(strstr($page->title, $site_title)) return;
|
||||
if (strstr($page->title, $site_title)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($sitename_in_title == "prefix") {
|
||||
$page->title = "$site_title - $page->title";
|
||||
}
|
||||
elseif ($sitename_in_title == "suffix") {
|
||||
} elseif ($sitename_in_title == "suffix") {
|
||||
$page->title = "$page->title - $site_title";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,9 @@ class Favorites extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^favorites([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -164,7 +164,9 @@ class Index extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
// check for tags first as tag based searches are more common.
|
||||
|
|
|
@ -44,13 +44,13 @@ and of course start organising your images :-)
|
|||
|
||||
if (count($images) > 0) {
|
||||
$this->display_page_images($page, $images);
|
||||
if($this->page_number < $this->total_pages) {
|
||||
$next = $this->page_number + 1;
|
||||
$u_tags = url_escape(Tag::implode($this->search_terms));
|
||||
$query = empty($u_tags) ? "" : '/'.$u_tags;
|
||||
$next = make_link('post/list'.$query.'/'.$next);
|
||||
$page->add_html_header("<link rel='prefetch' href='$next'>");
|
||||
}
|
||||
if ($this->page_number < $this->total_pages) {
|
||||
$next = $this->page_number + 1;
|
||||
$u_tags = url_escape(Tag::implode($this->search_terms));
|
||||
$query = empty($u_tags) ? "" : '/'.$u_tags;
|
||||
$next = make_link('post/list'.$query.'/'.$next);
|
||||
$page->add_html_header("<link rel='prefetch' href='$next'>");
|
||||
}
|
||||
} else {
|
||||
$this->display_error(404, "No Images Found", "No images were found to match the search criteria");
|
||||
}
|
||||
|
|
|
@ -257,7 +257,9 @@ class Media extends Extension
|
|||
{
|
||||
global $database;
|
||||
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match(self::CONTENT_SEARCH_TERM_REGEX, $event->term, $matches)) {
|
||||
|
|
|
@ -188,7 +188,9 @@ class Notes extends Extension
|
|||
*/
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^note[=|:](.*)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -223,7 +223,9 @@ class NumericScore extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^score([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(-?\d+)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -6,7 +6,9 @@ class NumericScoreTheme extends Themelet
|
|||
{
|
||||
global $user, $page;
|
||||
$i_image_id = $image->id;
|
||||
if(is_string($image->numeric_score)) $image->numeric_score = (int)$image->numeric_score;
|
||||
if (is_string($image->numeric_score)) {
|
||||
$image->numeric_score = (int)$image->numeric_score;
|
||||
}
|
||||
$i_score = $image->numeric_score;
|
||||
|
||||
$html = "
|
||||
|
|
|
@ -378,7 +378,9 @@ class Pools extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^pool[=|:]([0-9]+|any|none)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -250,7 +250,9 @@ class Ratings extends Extension
|
|||
{
|
||||
global $user;
|
||||
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (is_null($event->term) && $this->no_rating_query($event->context)) {
|
||||
|
|
|
@ -56,7 +56,9 @@ class Relationships extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^parent[=|:]([0-9]+|any|none)$/", $event->term, $matches)) {
|
||||
|
|
|
@ -223,10 +223,9 @@ class SetupBlock extends Block
|
|||
public function add_choice_option(string $name, array $options, string $label=null, bool $table_row = false)
|
||||
{
|
||||
global $config;
|
||||
if(is_int(array_values($options)[0])) {
|
||||
if (is_int(array_values($options)[0])) {
|
||||
$current = $config->get_int($name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$current = $config->get_string($name);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ class SetupTheme extends Themelet
|
|||
$h_rows = "";
|
||||
ksort($options);
|
||||
foreach ($options as $name => $value) {
|
||||
if(is_null($value)) $value = '';
|
||||
if (is_null($value)) {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$h_name = html_escape($name);
|
||||
$h_value = html_escape((string)$value);
|
||||
|
|
|
@ -66,7 +66,9 @@ class TagCategories extends Extension
|
|||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^(.+)tags([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])([0-9]+)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\{DIV,FORM,INPUT};
|
||||
use function MicroHTML\DIV;
|
||||
use function MicroHTML\FORM;
|
||||
use function MicroHTML\INPUT;
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Tagger - Advanced Tagging v2 *
|
||||
|
|
|
@ -73,7 +73,9 @@ class Trash extends Extension
|
|||
$event->add_querylet(new Querylet($database->scoreql_to_sql("trash = SCORE_BOOL_N ")));
|
||||
}
|
||||
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) {
|
||||
if ($user->can(Permissions::VIEW_TRASH)) {
|
||||
$event->add_querylet(new Querylet($database->scoreql_to_sql("trash = SCORE_BOOL_Y ")));
|
||||
|
|
|
@ -109,13 +109,13 @@ class Upload extends Extension
|
|||
$min_free_space = $config->get_int("upload_min_free_space");
|
||||
if ($min_free_space > 0) {
|
||||
// SHIT: fucking PHP "security" measures -_-;;;
|
||||
$img_path = realpath("./images/");
|
||||
if($img_path) {
|
||||
$free_num = @disk_free_space($img_path);
|
||||
if ($free_num !== false) {
|
||||
$this->is_full = $free_num < $min_free_space;
|
||||
}
|
||||
}
|
||||
$img_path = realpath("./images/");
|
||||
if ($img_path) {
|
||||
$free_num = @disk_free_space($img_path);
|
||||
if ($free_num !== false) {
|
||||
$this->is_full = $free_num < $min_free_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,9 @@ class UserPage extends Extension
|
|||
{
|
||||
global $user;
|
||||
|
||||
if(is_null($event->term)) return;
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (preg_match("/^(?:poster|user)[=|:](.*)$/i", $event->term, $matches)) {
|
||||
|
|
|
@ -64,7 +64,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
|
|||
if (!$args) {
|
||||
$args = [];
|
||||
}
|
||||
foreach($args as $k=>$v) {
|
||||
foreach ($args as $k=>$v) {
|
||||
$args[$k] = (string)$v;
|
||||
}
|
||||
$_GET = [];
|
||||
|
|
Reference in a new issue