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, strip_tags(BBCode::convert($this->msg))); } /** * 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 { if ($name != '') { $pos = strpos($message, $name); } else { $pos = false; } if ($pos !== false) { $message = substr_replace($message, '{0}', $pos, strlen($name)); } return $message; } }