Compare commits

...

2 commits

Author SHA1 Message Date
mrilyew
74e998add4 fix(wall): attempt to fix invisible post betwee...
...n page 1 and 2 with pinned post on wall
2024-11-23 13:20:21 +03:00
mrilyew
2af8447a0f feat(rss): new fields 2024-11-23 13:16:55 +03:00
5 changed files with 65 additions and 11 deletions

View file

@ -383,34 +383,70 @@ class Post extends Postable
{ {
$domain = ovk_scheme(true).$_SERVER["HTTP_HOST"]; $domain = ovk_scheme(true).$_SERVER["HTTP_HOST"];
$description = $this->getText(false); $description = $this->getText(false);
$title = str_replace("\n", "", ovk_proc_strtr($description, 79));
$description_html = $description; $description_html = $description;
$url = $domain."/wall".$this->getPrettyId(); $url = $domain."/wall".$this->getPrettyId();
if($this->isUpdateAvatarMessage())
$title = tr('upd_in_general');
if($this->isDeactivationMessage())
$title = tr('post_deact_in_general');
$author = $this->getOwner(); $author = $this->getOwner();
$author_name = htmlspecialchars($author->getCanonicalName(), ENT_DISALLOWED | ENT_XHTML); $target_wall = $this->getWallOwner();
$author_name = escape_html($author->getCanonicalName());
if($this->isExplicit()) if($this->isExplicit())
$description_html .= "<br /><b>".tr('contains_nsfw').".</b><br />"; $title = 'NSFW: ' . $title;
foreach($this->getChildren() as $child) { foreach($this->getChildren() as $child) {
if($child instanceof Photo) { if($child instanceof Photo) {
$child_page = $domain.$child->getPageURL(); $child_page = $domain.$child->getPageURL();
$child_url = $child->getURLBySizeId('large'); $child_url = $child->getURL();
$description_html .= "<br /><a href='$child_page'><img src='$child_url'></a>"; $description_html .= "<br /><a href='$child_page'><img src='$child_url'></a><br />";
} elseif($child instanceof Video) { } elseif($child instanceof Video) {
$child_page = $domain.'/video'.$child->getPrettyId(); $child_page = $domain.'/video'.$child->getPrettyId();
$description_html .= "<br /><a href='$child_page'>Video</a>";
if($child->getType() != 1) {
$description_html .= "".
"<br />".
"<video width=\"320\" height=\"240\" controls><source src=\"".$child->getURL()."\" type=\"video/mp4\"></video><br />".
"<b>".escape_html($child->getName())."</b><br />";
} else {
$description_html .= "".
"<br />".
"<a href=\"".$child->getVideoDriver()->getURL()."\"><b>".escape_html($child->getName())."</b></a><br />";
}
} elseif($child instanceof Audio) { } elseif($child instanceof Audio) {
$description_html .= "<br />Audio"; if(!$child->isWithdrawn()) {
$description_html .= "<br />"
."<b>".escape_html($child->getName())."</b>:"
."<br />"
."<audio controls>"
."<source src=\"".$child->getOriginalURL()."\" type=\"audio/mpeg\"></audio>"
."<br />";
}
} elseif($child instanceof Poll) {
$description_html .= "<br />".tr('poll').": ".escape_html($child->getTitle());
} elseif($child instanceof Note) {
$description_html .= "<br />".tr('note').": ".escape_html($child->getName());
} }
} }
$description_html .= "<br />".tr('author').": <img width='15px' src='".$author->getAvatarURL()."'><a href='".$author->getURL()."'>" . $author_name . "</a>"; $description_html .= "<br />".tr('author').": <img width='15px' src='".$author->getAvatarURL()."'><a href='".$author->getURL()."'>" . $author_name . "</a>";
if($this->hasSource()) {
$description_html .= "<br />".tr('source').": ".htmlspecialchars($this->getSource(), ENT_DISALLOWED | ENT_XHTML); if($target_wall->getRealId() != $author->getRealId())
$description_html .= "<br />".tr('on_wall').": <img width='15px' src='".$target_wall->getAvatarURL()."'><a href='".$target_wall->getURL()."'>" . escape_html($target_wall->getCanonicalName()) . "</a>";
if($this->isSigned()) {
$signer = $this->getOwner(false);
$description_html .= "<br />".tr('sign_short').": <img width='15px' src='".$signer->getAvatarURL()."'><a href='".$signer->getURL()."'>" . escape_html($signer->getCanonicalName()) . "</a>";
} }
if($this->hasSource())
$description_html .= "<br />".tr('source').": ".escape_html($this->getSource());
$item = new \Bhaktaraz\RSSGenerator\Item(); $item = new \Bhaktaraz\RSSGenerator\Item();
$item->title(str_replace("\n", "", ovk_proc_strtr($description, 79))) $item->title($title)
->url($url) ->url($url)
->guid($url) ->guid($url)
->creator($author_name) ->creator($author_name)

View file

@ -53,9 +53,9 @@ class Posts
$offset--; $offset--;
} }
} }
} /*else if(!is_null($offset)) { } else if(!is_null($offset) && $pinPost) {
$offset--; $offset--;
}*/ }
$sel = $this->posts->where([ $sel = $this->posts->where([
"wall" => $user, "wall" => $user,

View file

@ -366,6 +366,11 @@ function check_copyright_link(string $link = ''): bool
return true; return true;
} }
function escape_html(string $unsafe): string
{
return htmlspecialchars($unsafe, ENT_DISALLOWED | ENT_XHTML);
}
return (function() { return (function() {
_ovk_check_environment(); _ovk_check_environment();
require __DIR__ . "/vendor/autoload.php"; require __DIR__ . "/vendor/autoload.php";

View file

@ -2236,3 +2236,10 @@
"roll_back" = "rollback"; "roll_back" = "rollback";
"roll_backed" = "rollbacked"; "roll_backed" = "rollbacked";
/* RSS */
"post_deact_in_general" = "Page deletion";
"upd_in_general" = "Avatar update";
"on_wall" = "On wall";
"sign_short" = "Sign";

View file

@ -2127,3 +2127,9 @@
"roll_back" = "откатить"; "roll_back" = "откатить";
"roll_backed" = "откачено"; "roll_backed" = "откачено";
/* RSS */
"post_deact_in_general" = "Удаление страницы";
"upd_in_general" = "Обновление фотографии страницы";
"on_wall" = "На стене";
"sign_short" = "Подпись";