diff --git a/Web/Models/Entities/Message.php b/Web/Models/Entities/Message.php index de840606..97f3cf69 100644 --- a/Web/Models/Entities/Message.php +++ b/Web/Models/Entities/Message.php @@ -60,6 +60,17 @@ class Message extends RowModel { return new DateTime($this->getRecord()->created); } + + function getSendTimeHumanized(): string + { + $dateTime = new DateTime($this->getRecord()->created); + + if($dateTime->format("%d.%m.%y") == ovk_strftime_safe("%d.%m.%y", time())) { + return $dateTime->format("%T %p"); + } else { + return $dateTime->format("%d.%m.%y"); + } + } /** * Get date of last edit, if any edits were made, otherwise null. @@ -125,7 +136,7 @@ class Message extends RowModel "name" => $author->getFirstName().$unreadmsg, ], "timing" => [ - "sent" => (string) $this->getSendTime()->format("%e %B %G" . tr("time_at_sp") . "%X"), + "sent" => (string) $this->getSendTimeHumanized(), "edited" => is_null($this->getEditTime()) ? NULL : (string) $this->getEditTime(), ], "text" => $this->getText(), diff --git a/Web/Models/Repositories/Messages.php b/Web/Models/Repositories/Messages.php index ba95d6d0..4c870806 100644 --- a/Web/Models/Repositories/Messages.php +++ b/Web/Models/Repositories/Messages.php @@ -44,4 +44,15 @@ class Messages yield new Correspondence($correspondent, $anotherCorrespondent); } } + + function getCorrespondenciesCount(RowModel $correspondent): ?int + { + $id = $correspondent->getId(); + $class = get_class($correspondent); + $query = file_get_contents(__DIR__ . "/../sql/get-correspondencies-count.tsql"); + DatabaseConnection::i()->getConnection()->query(file_get_contents(__DIR__ . "/../sql/mysql-msg-fix.tsql")); + $count = DatabaseConnection::i()->getConnection()->query($query, $id, $class, $id, $class)->fetch()->cnt; + bdump($count); + return $count; + } } diff --git a/Web/Models/sql/get-correspondencies-count.tsql b/Web/Models/sql/get-correspondencies-count.tsql new file mode 100644 index 00000000..b24390b9 --- /dev/null +++ b/Web/Models/sql/get-correspondencies-count.tsql @@ -0,0 +1,20 @@ +SELECT COUNT(id) AS cnt FROM +( + ( + SELECT + recipient_id AS id + FROM messages + WHERE + sender_id = ? + AND + sender_type = ? + ) UNION ( + SELECT + sender_id AS id + FROM messages + WHERE + recipient_id = ? + AND + recipient_type = ? + ) +) dt \ No newline at end of file diff --git a/Web/Presenters/MessengerPresenter.php b/Web/Presenters/MessengerPresenter.php index 968c1936..cea440ba 100644 --- a/Web/Presenters/MessengerPresenter.php +++ b/Web/Presenters/MessengerPresenter.php @@ -34,10 +34,18 @@ final class MessengerPresenter extends OpenVKPresenter if(isset($_GET["sel"])) $this->pass("openvk!Messenger->app", $_GET["sel"]); - $page = $_GET["p"] ?? 1; + $page = (int) ($_GET["p"] ?? 1); $correspondences = iterator_to_array($this->messages->getCorrespondencies($this->user->identity, $page)); - + + // #КакаоПрокакалось + $this->template->corresps = $correspondences; + $this->template->paginatorConf = (object) [ + "count" => $this->messages->getCorrespondenciesCount($this->user->identity), + "page" => (int) ($_GET["p"] ?? 1), + "amount" => sizeof($this->template->corresps), + "perPage" => OPENVK_DEFAULT_PER_PAGE, + ]; } function renderApp(int $sel): void diff --git a/Web/Presenters/templates/@listView.xml b/Web/Presenters/templates/@listView.xml index 811f8724..8ea93728 100644 --- a/Web/Presenters/templates/@listView.xml +++ b/Web/Presenters/templates/@listView.xml @@ -4,7 +4,7 @@
-
+
{include tabs}
diff --git a/Web/Presenters/templates/Messenger/Index.xml b/Web/Presenters/templates/Messenger/Index.xml index 5397fde4..db2b90e1 100644 --- a/Web/Presenters/templates/Messenger/Index.xml +++ b/Web/Presenters/templates/Messenger/Index.xml @@ -30,7 +30,7 @@
{var $_author = $lastMsg->getSender()} @@ -45,6 +45,9 @@
+
+ {include "../components/paginator.xml", conf => $paginatorConf} +
{else}

diff --git a/Web/Presenters/templates/Search/Index.xml b/Web/Presenters/templates/Search/Index.xml index 1814f6b7..6b943e5c 100644 --- a/Web/Presenters/templates/Search/Index.xml +++ b/Web/Presenters/templates/Search/Index.xml @@ -33,16 +33,17 @@ {_groups}
+ +
+ + + +
-
- - - -
- -

- {tr("results", $count)} -

+

+ {tr("results", $count)} +

+
{/block} {block link|strip|stripHtml} diff --git a/Web/static/css/style.css b/Web/static/css/style.css index 20163a6a..0a7ee69b 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -798,6 +798,13 @@ table.User { .tabs { border-bottom: 1px solid #707070; padding: 0 10px; + margin-left: -10px; + width: 607px; +} + +.tabs.stupid-fix { + margin-left: 0; + width: auto; } #activetabs { @@ -913,11 +920,19 @@ table.User { } .crp-entry--info { - width: 190px; + width: 130px; + margin-top: 2%; +} + +.crp-entry--message{ + padding: 3px; + width: 395px; + border-radius: 3px; } .crp-entry--image>img { - max-width: 64px; + max-width: 50px; + border-radius: 3px; } .crp-entry--info span { @@ -929,15 +944,14 @@ table.User { } .crp-entry--message.unread { - background-color: #ededed; - padding: 5px; - width: 346px; + padding: 3px; + width: 395px; + background: #e6e6e6; + border-radius: 3px; } .messenger-app--messages---message.unread { background-color: #ededed; - padding: 5px; - margin: -5px; padding-bottom: 1.2rem; margin-bottom: 0; } @@ -955,20 +969,27 @@ table.User { } .crp-entry--message---av img { - max-width: 42px; + max-width: 32px; + border-radius: 3px; + margin-top: 20%; + margin-left: 10%; } .crp-entry--message---av, .crp-entry--message---text { display: inline-block; vertical-align: top; + max-width: 50px; + border-radius: 3px; } .crp-entry--message---text { - max-height: 45px; - max-width: 260px; + max-height: 40px; + max-width: 310px; overflow: hidden; text-overflow: ellipsis; + /* white-space: nowrap; */ /* myslivets: а как........... */ + margin-left: 3%; } .crp-entry--message---text, @@ -976,14 +997,14 @@ table.User { color: #404036; } -.messenger-app--messages, .messenger-app--input { - padding: 10px 70px; + padding: 10px 60px; } .messenger-app--messages { height: 360px; overflow-y: auto; + padding: 10px 60px; } .messenger-app--messages---message, @@ -994,20 +1015,31 @@ table.User { } .messenger-app--messages---message { - margin-bottom: 1.2rem; + margin-bottom: 3px; + padding: 10px; } -.messenger-app--messages---message .ava, .messenger-app--input>.ava { width: 52px; height: 52px; + object-fit: cover; + border-radius: 3px; +} + +.messenger-app--messages---message .ava { + width: 37px; + height: 37px; + object-fit: cover; + border-radius: 3px; } .messenger-app--messages---message ._content { - padding-left: 20px; - width: 300px; + width: 310px; + line-height: 13.2pt; } + + .messenger-app--messages---message ._content span, .messenger-app--messages---message ._content>a { display: block;