type = $type; $this->name = $name; $this->url = $url; $this->photo = $photo; $this->date = $date; $this->msg = $msg; $this->uid = $uid; $this->link = $link; $this->itemId = $itemId; $this->parent = $parent; $this->seen = $seen; $this->verb = $verb; $this->otype = $otype; $this->name_cache = $name_cache; $this->msg_cache = $msg_cache; $this->uriId = $uriId; $this->parentUriId = $parentUriId; $this->id = $id; } public function setSeen() { $this->seen = true; } public function updateMsgFromPreamble($epreamble) { $this->msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $this->link->__toString()]); $this->msg_cache = self::formatMessage($this->name_cache ?? $this->name, BBCode::toPlaintext($this->msg, false)); } /** * Formats a notification message with the notification author * * Replace the name with {0} but ensure to make that only once. The {0} is used * later and prints the name in bold. * * @param string $name * @param string $message * * @return string Formatted message */ public static function formatMessage(string $name, string $message): string { return str_replace('{0}', '' . htmlspecialchars(BBCode::toPlaintext($name, false)) . '', htmlspecialchars($message)); } }