Skip to content

Commit

Permalink
bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Nov 11, 2023
1 parent 8487970 commit fd1bb21
Show file tree
Hide file tree
Showing 235 changed files with 1,552 additions and 1,592 deletions.
536 changes: 248 additions & 288 deletions composer.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions core/basepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function send_headers(): void
*/
public function display(): void
{
if ($this->mode!=PageMode::MANUAL) {
if ($this->mode != PageMode::MANUAL) {
$this->send_headers();
}

Expand Down Expand Up @@ -474,14 +474,14 @@ protected function get_nav_links(): array
$active_link = null;
// To save on event calls, we check if one of the top-level links has already been marked as active
foreach ($nav_links as $link) {
if ($link->active===true) {
if ($link->active === true) {
$active_link = $link;
break;
}
}
$sub_links = null;
// If one is, we just query for sub-menu options under that one tab
if ($active_link!==null) {
if ($active_link !== null) {
$psnbe = send_event(new PageSubNavBuildingEvent($active_link->name));
$sub_links = $psnbe->links;
} else {
Expand All @@ -491,20 +491,20 @@ protected function get_nav_links(): array

// Now we check for a current link so we can identify the sub-links to show
foreach ($psnbe->links as $sub_link) {
if ($sub_link->active===true) {
if ($sub_link->active === true) {
$sub_links = $psnbe->links;
break;
}
}
// If the active link has been detected, we break out
if ($sub_links!==null) {
if ($sub_links !== null) {
$link->active = true;
break;
}
}
}

$sub_links = $sub_links??[];
$sub_links = $sub_links ?? [];
usort($nav_links, "Shimmie2\sort_nav_links");
usort($sub_links, "Shimmie2\sort_nav_links");

Expand Down Expand Up @@ -628,7 +628,7 @@ class PageSubNavBuildingEvent extends Event
public function __construct(string $parent)
{
parent::__construct();
$this->parent= $parent;
$this->parent = $parent;
}

public function add_nav_link(string $name, Link $link, string|HTMLElement $desc, ?bool $active = null, int $order = 50)
Expand All @@ -653,7 +653,7 @@ public function __construct(string $name, Link $link, string|HTMLElement $descri
$this->link = $link;
$this->description = $description;
$this->order = $order;
if ($active==null) {
if ($active == null) {
$query = ltrim(_get_query(), "/");
if ($query === "") {
// This indicates the front page, so we check what's set as the front page
Expand All @@ -664,7 +664,7 @@ public function __construct(string $name, Link $link, string|HTMLElement $descri
} else {
$this->active = self::is_active([$link->page], $front_page);
}
} elseif ($query===$link->page) {
} elseif ($query === $link->page) {
$this->active = true;
} else {
$this->active = self::is_active([$link->page]);
Expand All @@ -679,18 +679,18 @@ public static function is_active(array $pages_matched, string $url = null): bool
/**
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
*/
$url = $url??ltrim(_get_query(), "/");
$url = $url ?? ltrim(_get_query(), "/");

$re1='.*?';
$re2='((?:[a-z][a-z_]+))';
$re1 = '.*?';
$re2 = '((?:[a-z][a-z_]+))';

if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) {
$url=$matches[1][0];
$url = $matches[1][0];
}

$count_pages_matched = count($pages_matched);

for ($i=0; $i < $count_pages_matched; $i++) {
for ($i = 0; $i < $count_pages_matched; $i++) {
if ($url == $pages_matched[$i]) {
return true;
}
Expand Down
34 changes: 17 additions & 17 deletions core/basethemelet.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ public function build_thumb_html(Image $image): HTMLElement

return A(
[
"href"=>$view_link,
"class"=>"thumb shm-thumb shm-thumb-link $custom_classes",
"data-tags"=>$tags,
"data-height"=>$image->height,
"data-width"=>$image->width,
"data-mime"=>$image->get_mime(),
"data-post-id"=>$id,
"href" => $view_link,
"class" => "thumb shm-thumb shm-thumb-link $custom_classes",
"data-tags" => $tags,
"data-height" => $image->height,
"data-width" => $image->width,
"data-mime" => $image->get_mime(),
"data-post-id" => $id,
],
IMG(
[
"id"=>"thumb_$id",
"title"=>$tip,
"alt"=>$tip,
"height"=>$tsize[1],
"width"=>$tsize[0],
"src"=>$thumb_link,
"id" => "thumb_$id",
"title" => $tip,
"alt" => $tip,
"height" => $tsize[1],
"width" => $tsize[0],
"src" => $thumb_link,
]
)
);
Expand All @@ -112,18 +112,18 @@ public function display_paginator(Page $page, string $base, ?string $query, int

$page->add_html_header("<link rel='first' href='".make_http(make_link($base.'/1', $query))."'>");
if ($page_number < $total_pages) {
$page->add_html_header("<link rel='prefetch' href='".make_http(make_link($base.'/'.($page_number+1), $query))."'>");
$page->add_html_header("<link rel='next' href='".make_http(make_link($base.'/'.($page_number+1), $query))."'>");
$page->add_html_header("<link rel='prefetch' href='".make_http(make_link($base.'/'.($page_number + 1), $query))."'>");
$page->add_html_header("<link rel='next' href='".make_http(make_link($base.'/'.($page_number + 1), $query))."'>");
}
if ($page_number > 1) {
$page->add_html_header("<link rel='previous' href='".make_http(make_link($base.'/'.($page_number-1), $query))."'>");
$page->add_html_header("<link rel='previous' href='".make_http(make_link($base.'/'.($page_number - 1), $query))."'>");
}
$page->add_html_header("<link rel='last' href='".make_http(make_link($base.'/'.$total_pages, $query))."'>");
}

private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement
{
return A(["href"=>make_link($base_url.'/'.$page, $query)], $name);
return A(["href" => make_link($base_url.'/'.$page, $query)], $name);
}

private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement
Expand Down
4 changes: 2 additions & 2 deletions core/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Block
*/
public bool $is_content = true;

public function __construct(string $header=null, string|\MicroHTML\HTMLElement $body=null, string $section="main", int $position=50, string $id=null)
public function __construct(string $header = null, string|\MicroHTML\HTMLElement $body = null, string $section = "main", int $position = 50, string $id = null)
{
$this->header = $header;
$this->body = (string)$body;
Expand All @@ -63,7 +63,7 @@ public function __construct(string $header=null, string|\MicroHTML\HTMLElement $
/**
* Get the HTML for this block.
*/
public function get_html(bool $hidable=false): string
public function get_html(bool $hidable = false): string
{
$h = $this->header;
$b = $this->body;
Expand Down
18 changes: 9 additions & 9 deletions core/cacheengine.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class EventTracingCache implements CacheInterface
{
private CacheInterface $engine;
private \EventTracer $tracer;
private int $hits=0;
private int $misses=0;
private int $hits = 0;
private int $misses = 0;

public function __construct(CacheInterface $engine, \EventTracer $tracer)
{
$this->engine = $engine;
$this->tracer = $tracer;
}

public function get($key, $default=null)
public function get($key, $default = null)
{
if ($key === "__etc_cache_hits") {
return $this->hits;
Expand All @@ -29,7 +29,7 @@ public function get($key, $default=null)
}

$sentinel = "__etc_sentinel";
$this->tracer->begin("Cache Get", ["key"=>$key]);
$this->tracer->begin("Cache Get", ["key" => $key]);
$val = $this->engine->get($key, $sentinel);
if ($val != $sentinel) {
$res = "hit";
Expand All @@ -39,21 +39,21 @@ public function get($key, $default=null)
$val = $default;
$this->misses++;
}
$this->tracer->end(null, ["result"=>$res]);
$this->tracer->end(null, ["result" => $res]);
return $val;
}

public function set($key, $value, $ttl = null)
{
$this->tracer->begin("Cache Set", ["key"=>$key, "ttl"=>$ttl]);
$this->tracer->begin("Cache Set", ["key" => $key, "ttl" => $ttl]);
$val = $this->engine->set($key, $value, $ttl);
$this->tracer->end();
return $val;
}

public function delete($key)
{
$this->tracer->begin("Cache Delete", ["key"=>$key]);
$this->tracer->begin("Cache Delete", ["key" => $key]);
$val = $this->engine->delete($key);
$this->tracer->end();
return $val;
Expand Down Expand Up @@ -93,9 +93,9 @@ public function deleteMultiple($keys)

public function has($key)
{
$this->tracer->begin("Cache Has", ["key"=>$key]);
$this->tracer->begin("Cache Has", ["key" => $key]);
$val = $this->engine->has($key);
$this->tracer->end(null, ["exists"=>$val]);
$this->tracer->end(null, ["exists" => $val]);
return $val;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/command_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function execute(bool $fail_on_non_zero_return = false): int

log_debug('command_builder', "Command `$cmd` returned $ret and outputted $output");

if ($fail_on_non_zero_return&&(int)$ret!==(int)0) {
if ($fail_on_non_zero_return && (int)$ret !== (int)0) {
throw new SCoreException("Command `$cmd` failed, returning $ret and outputting $output");
}
return $ret;
Expand Down
36 changes: 18 additions & 18 deletions core/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Config
* so that the next time a page is loaded it will use the new
* configuration.
*/
public function save(string $name=null): void;
public function save(string $name = null): void;

//@{ /*--------------------------------- SET ------------------------------------------------------*/
/**
Expand Down Expand Up @@ -101,27 +101,27 @@ public function set_default_array(string $name, array $value): void;
/**
* Pick a value out of the table by name, cast to the appropriate data type.
*/
public function get_int(string $name, ?int $default=null): ?int;
public function get_int(string $name, ?int $default = null): ?int;

/**
* Pick a value out of the table by name, cast to the appropriate data type.
*/
public function get_float(string $name, ?float $default=null): ?float;
public function get_float(string $name, ?float $default = null): ?float;

/**
* Pick a value out of the table by name, cast to the appropriate data type.
*/
public function get_string(string $name, ?string $default=null): ?string;
public function get_string(string $name, ?string $default = null): ?string;

/**
* Pick a value out of the table by name, cast to the appropriate data type.
*/
public function get_bool(string $name, ?bool $default=null): ?bool;
public function get_bool(string $name, ?bool $default = null): ?bool;

/**
* Pick a value out of the table by name, cast to the appropriate data type.
*/
public function get_array(string $name, ?array $default=[]): ?array;
public function get_array(string $name, ?array $default = []): ?array;
//@} /*--------------------------------------------------------------------------------------------*/
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public function set_bool(string $name, ?bool $value): void

public function set_array(string $name, ?array $value): void
{
if ($value!=null) {
if ($value != null) {
$this->values[$name] = implode(",", $value);
} else {
$this->values[$name] = null;
Expand Down Expand Up @@ -205,17 +205,17 @@ public function set_default_array(string $name, array $value): void
}
}

public function get_int(string $name, ?int $default=null): ?int
public function get_int(string $name, ?int $default = null): ?int
{
return (int)($this->get($name, $default));
}

public function get_float(string $name, ?float $default=null): ?float
public function get_float(string $name, ?float $default = null): ?float
{
return (float)($this->get($name, $default));
}

public function get_string(string $name, ?string $default=null): ?string
public function get_string(string $name, ?string $default = null): ?string
{
$val = $this->get($name, $default);
if (!is_string($val) && !is_null($val)) {
Expand All @@ -224,17 +224,17 @@ public function get_string(string $name, ?string $default=null): ?string
return $val;
}

public function get_bool(string $name, ?bool $default=null): ?bool
public function get_bool(string $name, ?bool $default = null): ?bool
{
return bool_escape($this->get($name, $default));
}

public function get_array(string $name, ?array $default=[]): ?array
public function get_array(string $name, ?array $default = []): ?array
{
return explode(",", $this->get($name, ""));
}

private function get(string $name, $default=null)
private function get(string $name, $default = null)
{
if (isset($this->values[$name])) {
return $this->values[$name];
Expand Down Expand Up @@ -289,7 +289,7 @@ public function __construct(
$query = "SELECT name, value FROM {$this->table_name}";
$args = [];

if (!empty($sub_column)&&!empty($sub_value)) {
if (!empty($sub_column) && !empty($sub_value)) {
$query .= " WHERE $sub_column = :sub_value";
$args["sub_value"] = $sub_value;
}
Expand All @@ -301,7 +301,7 @@ public function __construct(
}
}

public function save(string $name=null): void
public function save(string $name = null): void
{
global $cache;

Expand All @@ -312,10 +312,10 @@ public function save(string $name=null): void
}
} else {
$query = "DELETE FROM {$this->table_name} WHERE name = :name";
$args = ["name"=>$name];
$args = ["name" => $name];
$cols = ["name","value"];
$params = [":name",":value"];
if (!empty($this->sub_column)&&!empty($this->sub_value)) {
if (!empty($this->sub_column) && !empty($this->sub_value)) {
$query .= " AND $this->sub_column = :sub_value";
$args["sub_value"] = $this->sub_value;
$cols[] = $this->sub_column;
Expand All @@ -324,7 +324,7 @@ public function save(string $name=null): void

$this->database->execute($query, $args);

$args["value"] =$this->values[$name];
$args["value"] = $this->values[$name];
$this->database->execute(
"INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")",
$args
Expand Down
Loading

0 comments on commit fd1bb21

Please sign in to comment.