diff --git a/Web/Models/Entities/Postable.php b/Web/Models/Entities/Postable.php
index 75d774b5..b9309c45 100644
--- a/Web/Models/Entities/Postable.php
+++ b/Web/Models/Entities/Postable.php
@@ -75,9 +75,9 @@ abstract class Postable extends Attachable
return new DateTime($edited);
}
- public function getComments(int $page, ?int $perPage = null): \Traversable
+ public function getComments(int $page, ?int $perPage = null, string $sort = "ASC"): \Traversable
{
- return (new Comments())->getCommentsByTarget($this, $page, $perPage);
+ return (new Comments())->getCommentsByTarget($this, $page, $perPage, $sort);
}
public function getCommentsCount(): int
diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php
index f4a8e898..0add4c0c 100644
--- a/Web/Presenters/WallPresenter.php
+++ b/Web/Presenters/WallPresenter.php
@@ -469,7 +469,11 @@ final class WallPresenter extends OpenVKPresenter
}
$this->template->cCount = $post->getCommentsCount();
$this->template->cPage = (int) ($_GET["p"] ?? 1);
- $this->template->comments = iterator_to_array($post->getComments($this->template->cPage));
+ $this->template->sort = $this->queryParam("sort") ?? "asc";
+
+ $input_sort = $this->template->sort == "asc" ? "ASC" : "DESC";
+
+ $this->template->comments = iterator_to_array($post->getComments($this->template->cPage, null, $input_sort));
}
public function renderLike(int $wall, int $post_id): void
diff --git a/Web/Presenters/templates/Wall/Post.xml b/Web/Presenters/templates/Wall/Post.xml
index e7146044..ee526065 100644
--- a/Web/Presenters/templates/Wall/Post.xml
+++ b/Web/Presenters/templates/Wall/Post.xml
@@ -36,7 +36,8 @@
count => $cCount,
page => $cPage,
model => "posts",
- parent => $post }
+ parent => $post,
+ sort => $sort}
{_actions}
diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml
index 53253b5f..3c9a858e 100644
--- a/Web/Presenters/templates/components/comments.xml
+++ b/Web/Presenters/templates/components/comments.xml
@@ -1,5 +1,18 @@
-
{_comments} ({$count})
+
{var $commentsURL = "/al_comments/create/$model/" . $parent->getId()}
{var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club}
diff --git a/Web/static/css/main.css b/Web/static/css/main.css
index 389134a1..8dd47fd7 100644
--- a/Web/static/css/main.css
+++ b/Web/static/css/main.css
@@ -4314,3 +4314,23 @@ hr {
.deleted_mark_average {
padding: 5px 61px;
}
+
+.sort_link {
+ padding: 5px 2px;
+ display: inline-block;
+}
+
+.sort_link_icon {
+ background: url(/assets/packages/static/openvk/img/wall.png?v=3) no-repeat;
+ display: inline-block;
+ height: 11px;
+ width: 9px;
+}
+
+.sort_link_icon_desc {
+ background-position: 0px -15px;
+}
+
+.sort_link_icon_asc {
+ background-position: -11px -15px;
+}
diff --git a/Web/static/img/wall.png b/Web/static/img/wall.png
index 197dca8d..e8577b9c 100644
Binary files a/Web/static/img/wall.png and b/Web/static/img/wall.png differ
diff --git a/locales/en.strings b/locales/en.strings
index 7e5b0425..4c3c4595 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -868,6 +868,9 @@
"sort_up" = "Sort by ID up";
"sort_down" = "Sort by ID down";
+"new_first" = "New frist";
+"old_first" = "Old first";
+
/* Videos */
"videos" = "Videos";
diff --git a/locales/ru.strings b/locales/ru.strings
index 6bfb2527..16a44e02 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -826,6 +826,9 @@
"sort_up" = "Сортировать по дате создания вверх";
"sort_down" = "Сортировать по дате создания вниз";
+"new_first" = "Сначала новые";
+"old_first" = "Сначала старые";
+
/* Videos */
"videos" = "Видеозаписи";