Skip to content

Commit 0c8bc42

Browse files
committed
Add getURI function to news, packet, document too
1 parent 4a09391 commit 0c8bc42

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

src/libraries/Document.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ public function getTitle() {
202202
return $this->title;
203203
}
204204

205+
public function getURI() {
206+
return Common::relativeUrlToAbsolute(
207+
"/document/" . $this->getId() . "/" . Common::sanitizeForUrl(
208+
$this->getTitle(), true
209+
)
210+
);
211+
}
212+
205213
public function getUser() {
206214
if (is_null($this->user_id)) return null;
207215
return new User($this->user_id);

src/libraries/NewsPost.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ public function getTitle() {
248248
return $this->title;
249249
}
250250

251+
public function getURI() {
252+
return Common::relativeUrlToAbsolute(
253+
"/news/" . $this->getId() . "/" . Common::sanitizeForUrl(
254+
$this->getTitle(), true
255+
)
256+
);
257+
}
258+
251259
public function getUser() {
252260
if (is_null($this->user_id)) return null;
253261
return new User($this->user_id);

src/libraries/Packet.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function getCreatedDateTime() {
147147
public function getEditedCount() {
148148
return $this->edited_count;
149149
}
150-
150+
151151
public function getEditedDateTime() {
152152
if (is_null($this->edited_datetime)) {
153153
return $this->edited_datetime;
@@ -211,7 +211,7 @@ public function getPacketId($format = false) {
211211
if (!$format) return $this->packet_id;
212212
return "0x" . strtoupper(substr("0" . dechex($this->packet_id), -2));
213213
}
214-
214+
215215
public function getPacketRemarks($prepare) {
216216
if (!$prepare) {
217217
return $this->packet_remarks;
@@ -283,6 +283,14 @@ public function getPublishedDateTime() {
283283
}
284284
}
285285

286+
public function getURI() {
287+
return Common::relativeUrlToAbsolute(
288+
"/packet/" . $this->getId() . "/" . Common::sanitizeForUrl(
289+
$this->getPacketName(), true
290+
)
291+
);
292+
}
293+
286294
public function getUsedBy() {
287295
$ckey = "bnetdocs-packetusedby-" . $this->id;
288296
$cval = Common::$cache->get($ckey);
@@ -340,7 +348,7 @@ protected static function normalize(StdClass &$data) {
340348
if (!is_null($data->edited_datetime))
341349
$data->edited_datetime = $data->edited_datetime;
342350

343-
if (!is_null($data->user_id))
351+
if (!is_null($data->user_id))
344352
$data->user_id = $data->user_id;
345353

346354
return true;

src/templates/User/View.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $this->opengraph->attach(new Pair("type", "profile"));
1616

1717
if ($object) {
1818
$this->opengraph->attach(new Pair("profile:username", $object->getName()));
19-
19+
2020
$gravatar = new Gravatar($object->getEmail());
2121
$this->opengraph->attach(new Pair("image", "https:" . $gravatar->getUrl(null, "identicon")));
2222

0 commit comments

Comments
 (0)