diff --git a/app/class/Servicepostprocess.php b/app/class/Servicepostprocess.php index e8068262..6dacc412 100644 --- a/app/class/Servicepostprocess.php +++ b/app/class/Servicepostprocess.php @@ -2,6 +2,7 @@ namespace Wcms; +use FTP\Connection; use JsonException; /** @@ -20,12 +21,16 @@ class Servicepostprocess public const VISIT_COUNT = '%VISITCOUNT%'; public const EDIT_COUNT = '%EDITCOUNT%'; - public const AFF_COUNT = '%DISPLAYCOUNT%'; + public const DISPLAY_COUNT = '%DISPLAYCOUNT%'; + public const CONNECT = '%CONNECT%'; + public const USER = '%USER%'; - public const COUNTERS = [ + public const POST_PROCESS_CODES = [ self::VISIT_COUNT, self::EDIT_COUNT, - self::AFF_COUNT, + self::DISPLAY_COUNT, + self::CONNECT, + self::USER, ]; public function __construct(Page $page, User $user) @@ -71,14 +76,19 @@ private function replace(string $text): string $displaycount = $this->page->displaycount(); $replacements = [ - self::VISIT_COUNT => "$visitcount", - self::EDIT_COUNT => "$editcount", - self::AFF_COUNT => "$displaycount", + self::VISIT_COUNT => "$visitcount", + self::EDIT_COUNT => "$editcount", + self::DISPLAY_COUNT => "$displaycount", + self::CONNECT => $this->connect(), + self::USER => $this->user->name(), ]; return strtr($text, $replacements); } /** + * Datas about given page and user in JSON + * To be printed with every pages, so it can be used in JS + * * @return string JSON encoded w global, pages and user datas * @throws JsonException If JSON encoding failed */ @@ -101,4 +111,30 @@ private function wobj(Page $page, User $user): string ]; return json_encode($wdatas, JSON_THROW_ON_ERROR); } + + + + /** + * Generate a login or logout form + * + * @return string HTML code + */ + protected function connect(): string + { + + $form = "
'; + return $form; + } } diff --git a/app/class/Servicerender.php b/app/class/Servicerender.php index c377a038..b6dedf69 100644 --- a/app/class/Servicerender.php +++ b/app/class/Servicerender.php @@ -289,7 +289,6 @@ protected function winclusions($text) $text = $this->pageoptmap($text); $text = $this->randomopt($text); $text = $this->authors($text); - $text = $this->authenticate($text); return $text; } @@ -851,7 +850,7 @@ protected function authors(string $text): string */ protected function checkpostprocessaction(string $text): bool { - $counterpaterns = Servicepostprocess::COUNTERS; + $counterpaterns = Servicepostprocess::POST_PROCESS_CODES; $pattern = implode('|', $counterpaterns); return boolval(preg_match("#($pattern)#", $text)); } @@ -872,33 +871,6 @@ protected function everylink(string $text, int $limit): string return $text; } - - - /** - * @param string $text content to analyse and replace - * - * @return string text ouput - */ - protected function authenticate(string $text): string - { - $id = $this->page->id(); - $regex = '~\%CONNECT(\?dir=([a-zA-Z0-9-_]+))?\%~'; - $text = preg_replace_callback($regex, function ($matches) use ($id) { - if (isset($matches[2])) { - $id = $matches[2]; - } - $form = ''; - return $form; - }, $text); - return $text; - } - /** * Render an user as a HTML element * A HTML link is added inside if user have a specified URL property