proper support for html in usernav
This commit is contained in:
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Shimmie2;
|
namespace Shimmie2;
|
||||||
|
|
||||||
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
require_once "core/event.php";
|
require_once "core/event.php";
|
||||||
|
|
||||||
enum PageMode: string
|
enum PageMode: string
|
||||||
@ -604,7 +606,7 @@ class PageSubNavBuildingEvent extends Event
|
|||||||
$this->parent= $parent;
|
$this->parent= $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50)
|
public function add_nav_link(string $name, Link $link, string|HTMLElement $desc, ?bool $active = null, int $order = 50)
|
||||||
{
|
{
|
||||||
$this->links[] = new NavLink($name, $link, $desc, $active, $order);
|
$this->links[] = new NavLink($name, $link, $desc, $active, $order);
|
||||||
}
|
}
|
||||||
@ -614,11 +616,11 @@ class NavLink
|
|||||||
{
|
{
|
||||||
public string $name;
|
public string $name;
|
||||||
public Link $link;
|
public Link $link;
|
||||||
public string $description;
|
public string|HTMLElement $description;
|
||||||
public int $order;
|
public int $order;
|
||||||
public bool $active = false;
|
public bool $active = false;
|
||||||
|
|
||||||
public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
|
public function __construct(string $name, Link $link, string|HTMLElement $description, ?bool $active = null, int $order = 50)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ use GQLA\Field;
|
|||||||
use GQLA\Query;
|
use GQLA\Query;
|
||||||
use GQLA\Mutation;
|
use GQLA\Mutation;
|
||||||
|
|
||||||
|
use function MicroHTML\{emptyHTML, SPAN};
|
||||||
|
|
||||||
class SendPMEvent extends Event
|
class SendPMEvent extends Event
|
||||||
{
|
{
|
||||||
public PM $pm;
|
public PM $pm;
|
||||||
@ -185,8 +187,8 @@ class PrivMsg extends Extension
|
|||||||
if ($event->parent==="user") {
|
if ($event->parent==="user") {
|
||||||
if ($user->can(Permissions::READ_PM)) {
|
if ($user->can(Permissions::READ_PM)) {
|
||||||
$count = $this->count_pms($user);
|
$count = $this->count_pms($user);
|
||||||
$h_count = $count > 0 ? " <span class='unread'>($count)</span>" : "";
|
$h_count = $count > 0 ? SPAN(["class"=>'unread'], "($count)") : "";
|
||||||
$event->add_nav_link("pm", new Link('user#private-messages'), "Private Messages$h_count");
|
$event->add_nav_link("pm", new Link('user#private-messages'), emptyHTML("Private Messages", $h_count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,8 +198,8 @@ class PrivMsg extends Extension
|
|||||||
global $user;
|
global $user;
|
||||||
if ($user->can(Permissions::READ_PM)) {
|
if ($user->can(Permissions::READ_PM)) {
|
||||||
$count = $this->count_pms($user);
|
$count = $this->count_pms($user);
|
||||||
$h_count = $count > 0 ? " <span class='unread'>($count)</span>" : "";
|
$h_count = $count > 0 ? SPAN(["class"=>'unread'], "($count)") : "";
|
||||||
$event->add_link("Private Messages$h_count", make_link("user", null, "private-messages"));
|
$event->add_link(emptyHTML("Private Messages", $h_count), make_link("user", null, "private-messages"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Shimmie2;
|
namespace Shimmie2;
|
||||||
|
|
||||||
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
class UserBlockBuildingEvent extends Event
|
class UserBlockBuildingEvent extends Event
|
||||||
{
|
{
|
||||||
public array $parts = [];
|
public array $parts = [];
|
||||||
|
|
||||||
public function add_link(string $name, string $link, int $position=50): void
|
public function add_link(string|HTMLElement $name, string $link, int $position=50): void
|
||||||
{
|
{
|
||||||
while (isset($this->parts[$position])) {
|
while (isset($this->parts[$position])) {
|
||||||
$position++;
|
$position++;
|
||||||
|
Reference in New Issue
Block a user