Global: Make code more consistent with code style

This commit is contained in:
Maxim Leshchenko 2022-05-08 12:06:26 +02:00
parent aef369ac58
commit fe2010560a
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
31 changed files with 97 additions and 97 deletions

View file

@ -13,9 +13,9 @@ final class Account extends VKAPIRequestHandler
"last_name" => $this->getUser()->getLastName(), "last_name" => $this->getUser()->getLastName(),
"home_town" => $this->getUser()->getHometown(), "home_town" => $this->getUser()->getHometown(),
"status" => $this->getUser()->getStatus(), "status" => $this->getUser()->getStatus(),
"bdate" => "1.1.1970", // TODO "bdate" => "1.1.1970", # TODO
"bdate_visibility" => 0, // TODO "bdate_visibility" => 0, # TODO
"phone" => "+420 ** *** 228", // TODO "phone" => "+420 ** *** 228", # TODO
"relation" => $this->getUser()->getMaritalStatus(), "relation" => $this->getUser()->getMaritalStatus(),
"sex" => $this->getUser()->isFemale() ? 1 : 2 "sex" => $this->getUser()->isFemale() ? 1 : 2
]; ];
@ -25,12 +25,12 @@ final class Account extends VKAPIRequestHandler
{ {
$this->requireUser(); $this->requireUser();
// Цiй метод є заглушка # Цiй метод є заглушка
return (object) [ return (object) [
"2fa_required" => 0, "2fa_required" => 0,
"country" => "CZ", // TODO "country" => "CZ", # TODO
"eu_user" => false, // TODO "eu_user" => false, # TODO
"https_required" => 1, "https_required" => 1,
"intro" => 0, "intro" => 0,
"community_comments" => false, "community_comments" => false,
@ -55,7 +55,7 @@ final class Account extends VKAPIRequestHandler
{ {
$this->requireUser(); $this->requireUser();
// Цiй метод є заглушка # Цiй метод є заглушка
return 1; return 1;
} }
@ -73,6 +73,6 @@ final class Account extends VKAPIRequestHandler
"messages" => $this->getUser()->getUnreadMessagesCount() "messages" => $this->getUser()->getUnreadMessagesCount()
]; ];
// TODO: Filter # TODO: Filter
} }
} }

View file

@ -25,7 +25,7 @@ final class Friends extends VKAPIRequestHandler
$usersApi = new Users($this->getUser()); $usersApi = new Users($this->getUser());
if (!is_null($fields)) { if (!is_null($fields)) {
$response = $usersApi->get(implode(',', $friends), $fields, 0, $count); // FIXME $response = $usersApi->get(implode(',', $friends), $fields, 0, $count); # FIXME
} }
return (object) [ return (object) [

View file

@ -48,7 +48,7 @@ final class Groups extends VKAPIRequestHandler
"name" => "DELETED", "name" => "DELETED",
"deactivated" => "deleted" "deactivated" => "deleted"
]; ];
}else if($clbs[$i] == null){ }else if($clbs[$i] == NULL){
}else{ }else{
$rClubs[$i] = (object)[ $rClubs[$i] = (object)[
@ -95,10 +95,10 @@ final class Groups extends VKAPIRequestHandler
$clubs = new ClubsRepo; $clubs = new ClubsRepo;
if ($group_ids == null && $group_id != null) if ($group_ids == NULL && $group_id != NULL)
$group_ids = $group_id; $group_ids = $group_id;
if ($group_ids == null && $group_id == null) if ($group_ids == NULL && $group_id == NULL)
$this->fail(100, "One of the parameters specified was missing or invalid: group_ids is undefined"); $this->fail(100, "One of the parameters specified was missing or invalid: group_ids is undefined");
$clbs = explode(',', $group_ids); $clbs = explode(',', $group_ids);
@ -123,7 +123,7 @@ final class Groups extends VKAPIRequestHandler
"type" => "group", "type" => "group",
"description" => "This group was deleted or it doesn't exist" "description" => "This group was deleted or it doesn't exist"
]; ];
}else if($clbs[$i] == null){ }else if($clbs[$i] == NULL){
}else{ }else{
$response[$i] = (object)[ $response[$i] = (object)[

View file

@ -63,7 +63,7 @@ final class Likes extends VKAPIRequestHandler
return (object)[ return (object)[
"liked" => (int) $post->hasLikeFrom($user), "liked" => (int) $post->hasLikeFrom($user),
"copied" => 0 // TODO: handle this "copied" => 0 # TODO: handle this
]; ];
break; break;
default: default:

View file

@ -7,9 +7,9 @@ final class Users extends VKAPIRequestHandler
{ {
function get(string $user_ids = "0", string $fields = "", int $offset = 0, int $count = 100, User $authuser = null /* костыль(( */): array function get(string $user_ids = "0", string $fields = "", int $offset = 0, int $count = 100, User $authuser = null /* костыль(( */): array
{ {
// $this->requireUser(); # $this->requireUser();
if($authuser == null) $authuser = $this->getUser(); if($authuser == NULL) $authuser = $this->getUser();
$users = new UsersRepo; $users = new UsersRepo;
if($user_ids == "0") if($user_ids == "0")
@ -34,7 +34,7 @@ final class Users extends VKAPIRequestHandler
"last_name" => "", "last_name" => "",
"deactivated" => "deleted" "deactivated" => "deleted"
]; ];
}else if($usrs[$i] == null){ }else if($usrs[$i] == NULL){
}else{ }else{
$response[$i] = (object)[ $response[$i] = (object)[
@ -73,21 +73,21 @@ final class Users extends VKAPIRequestHandler
case 'photo_200': case 'photo_200':
$response[$i]->photo_50 = $usr->getAvatarURL("normal"); $response[$i]->photo_50 = $usr->getAvatarURL("normal");
break; break;
case 'photo_200_orig': // вообще не ебу к чему эта строка ну пусть будет кек case 'photo_200_orig': # вообще не ебу к чему эта строка ну пусть будет кек
$response[$i]->photo_50 = $usr->getAvatarURL("normal"); $response[$i]->photo_50 = $usr->getAvatarURL("normal");
break; break;
case 'photo_400_orig': case 'photo_400_orig':
$response[$i]->photo_50 = $usr->getAvatarURL("normal"); $response[$i]->photo_50 = $usr->getAvatarURL("normal");
break; break;
// Она хочет быть выебанной видя матан # Она хочет быть выебанной видя матан
// Покайфу когда ты Виет а вокруг лишь дискриминант # Покайфу когда ты Виет а вокруг лишь дискриминант
case 'status': case 'status':
if($usr->getStatus() != null) if($usr->getStatus() != NULL)
$response[$i]->status = $usr->getStatus(); $response[$i]->status = $usr->getStatus();
break; break;
case 'screen_name': case 'screen_name':
if($usr->getShortCode() != null) if($usr->getShortCode() != NULL)
$response[$i]->screen_name = $usr->getShortCode(); $response[$i]->screen_name = $usr->getShortCode();
break; break;
case 'friend_status': case 'friend_status':

View file

@ -32,7 +32,7 @@ final class Wall extends VKAPIRequestHandler
$attachments[] = [ $attachments[] = [
"type" => "photo", "type" => "photo",
"photo" => [ "photo" => [
"album_id" => $attachment->getAlbum() ? $attachment->getAlbum()->getId() : null, "album_id" => $attachment->getAlbum() ? $attachment->getAlbum()->getId() : NULL,
"date" => $attachment->getPublicationTime()->timestamp(), "date" => $attachment->getPublicationTime()->timestamp(),
"id" => $attachment->getVirtualId(), "id" => $attachment->getVirtualId(),
"owner_id" => $attachment->getOwner()->getId(), "owner_id" => $attachment->getOwner()->getId(),
@ -51,10 +51,10 @@ final class Wall extends VKAPIRequestHandler
"date" => $post->getPublicationTime()->timestamp(), "date" => $post->getPublicationTime()->timestamp(),
"post_type" => "post", "post_type" => "post",
"text" => $post->getText(), "text" => $post->getText(),
"can_edit" => 0, // TODO "can_edit" => 0, # TODO
"can_delete" => $post->canBeDeletedBy($this->getUser()), "can_delete" => $post->canBeDeletedBy($this->getUser()),
"can_pin" => $post->canBePinnedBy($this->getUser()), "can_pin" => $post->canBePinnedBy($this->getUser()),
"can_archive" => false, // TODO MAYBE "can_archive" => false, # TODO MAYBE
"is_archived" => false, "is_archived" => false,
"is_pinned" => $post->isPinned(), "is_pinned" => $post->isPinned(),
"attachments" => $attachments, "attachments" => $attachments,
@ -80,7 +80,7 @@ final class Wall extends VKAPIRequestHandler
else else
$groups[] = $from_id * -1; $groups[] = $from_id * -1;
$attachments = null; // free attachments so it will not clone everythingg $attachments = NULL; # free attachments so it will not clone everythingg
} }
if($extended == 1) if($extended == 1)
@ -135,9 +135,9 @@ final class Wall extends VKAPIRequestHandler
]; ];
} }
function getById(string $posts, int $extended = 0, string $fields = "", User $user = null) function getById(string $posts, int $extended = 0, string $fields = "", User $user = NULL)
{ {
if($user == null) $user = $this->getUser(); // костыли костыли крылышки if($user == NULL) $user = $this->getUser(); # костыли костыли крылышки
$items = []; $items = [];
$profiles = []; $profiles = [];
@ -160,7 +160,7 @@ final class Wall extends VKAPIRequestHandler
$attachments[] = [ $attachments[] = [
"type" => "photo", "type" => "photo",
"photo" => [ "photo" => [
"album_id" => $attachment->getAlbum() ? $attachment->getAlbum()->getId() : null, "album_id" => $attachment->getAlbum() ? $attachment->getAlbum()->getId() : NULL,
"date" => $attachment->getPublicationTime()->timestamp(), "date" => $attachment->getPublicationTime()->timestamp(),
"id" => $attachment->getVirtualId(), "id" => $attachment->getVirtualId(),
"owner_id" => $attachment->getOwner()->getId(), "owner_id" => $attachment->getOwner()->getId(),
@ -196,7 +196,7 @@ final class Wall extends VKAPIRequestHandler
"width" => 1280, "width" => 1280,
], ],
[ [
"height" => 75, // Для временного компросима оставляю статическое число. Если каждый раз обращаться к файлу за количеством пикселов, то наступает пuпuська полная с производительностью, так что пока так "height" => 75, # Для временного компросима оставляю статическое число. Если каждый раз обращаться к файлу за количеством пикселов, то наступает пuпuська полная с производительностью, так что пока так
"url" => $attachment->getURLBySizeId("miniscule"), "url" => $attachment->getURLBySizeId("miniscule"),
"type" => "s", "type" => "s",
"width" => 75, "width" => 75,
@ -215,10 +215,10 @@ final class Wall extends VKAPIRequestHandler
"date" => $post->getPublicationTime()->timestamp(), "date" => $post->getPublicationTime()->timestamp(),
"post_type" => "post", "post_type" => "post",
"text" => $post->getText(), "text" => $post->getText(),
"can_edit" => 0, // TODO "can_edit" => 0, # TODO
"can_delete" => $post->canBeDeletedBy($user), "can_delete" => $post->canBeDeletedBy($user),
"can_pin" => $post->canBePinnedBy($user), "can_pin" => $post->canBePinnedBy($user),
"can_archive" => false, // TODO MAYBE "can_archive" => false, # TODO MAYBE
"is_archived" => false, "is_archived" => false,
"is_pinned" => $post->isPinned(), "is_pinned" => $post->isPinned(),
"post_source" => (object)["type" => "vk"], "post_source" => (object)["type" => "vk"],
@ -244,7 +244,7 @@ final class Wall extends VKAPIRequestHandler
else else
$groups[] = $from_id * -1; $groups[] = $from_id * -1;
$attachments = null; // free attachments so it will not clone everythingg $attachments = NULL; # free attachments so it will not clone everythingg
} }
} }
@ -335,12 +335,12 @@ final class Wall extends VKAPIRequestHandler
if($signed == 1) if($signed == 1)
$flags |= 0b01000000; $flags |= 0b01000000;
// TODO: Compatible implementation of this # TODO: Compatible implementation of this
try { try {
$photo = null; $photo = NULL;
$video = null; $video = NULL;
if($_FILES["photo"]["error"] === UPLOAD_ERR_OK) { if($_FILES["photo"]["error"] === UPLOAD_ERR_OK) {
$album = null; $album = NULL;
if(!$anon && $owner_id > 0 && $owner_id === $this->getUser()->getId()) if(!$anon && $owner_id > 0 && $owner_id === $this->getUser()->getId())
$album = (new AlbumsRepo)->getUserWallAlbum($wallOwner); $album = (new AlbumsRepo)->getUserWallAlbum($wallOwner);

View file

@ -302,8 +302,8 @@ class Club extends RowModel
{ {
$manager = (new Managers)->getByUserAndClub($user->getId(), $this->getId()); $manager = (new Managers)->getByUserAndClub($user->getId(), $this->getId());
if ($ignoreHidden && $manager !== null && $manager->isHidden()) if ($ignoreHidden && $manager !== NULL && $manager->isHidden())
return null; return NULL;
return $manager; return $manager;
} }

View file

@ -131,7 +131,7 @@ class Correspondence
*/ */
function getPreviewMessage(): ?Message function getPreviewMessage(): ?Message
{ {
$messages = $this->getMessages(1, null, 1); $messages = $this->getMessages(1, NULL, 1);
return $messages[0] ?? NULL; return $messages[0] ?? NULL;
} }

View file

@ -126,7 +126,7 @@ class Message extends RowModel
], ],
"timing" => [ "timing" => [
"sent" => (string) $this->getSendTime()->format("%e %B %G" . tr("time_at_sp") . "%X"), "sent" => (string) $this->getSendTime()->format("%e %B %G" . tr("time_at_sp") . "%X"),
"edited" => is_null($this->getEditTime()) ? null : (string) $this->getEditTime(), "edited" => is_null($this->getEditTime()) ? NULL : (string) $this->getEditTime(),
], ],
"text" => $this->getText(), "text" => $this->getText(),
"read" => !$this->isUnread(), "read" => !$this->isUnread(),

View file

@ -87,7 +87,7 @@ abstract class Postable extends Attachable
])); ]));
} }
// TODO add pagination # TODO add pagination
function getLikers(): \Traversable function getLikers(): \Traversable
{ {
$sel = DB::i()->getContext()->table("likes")->where([ $sel = DB::i()->getContext()->table("likes")->where([

View file

@ -939,7 +939,7 @@ class User extends RowModel
return $this->getRecord()->website; return $this->getRecord()->website;
} }
// ты устрица # ты устрица
function isActivated(): bool function isActivated(): bool
{ {
return (bool) $this->getRecord()->activated; return (bool) $this->getRecord()->activated;

View file

@ -63,7 +63,7 @@ class Video extends Media
if(!file_exists($this->getFileName())) { if(!file_exists($this->getFileName())) {
if((time() - $this->getRecord()->last_checked) > 3600) { if((time() - $this->getRecord()->last_checked) > 3600) {
// TODO notify that video processor is probably dead # TODO notify that video processor is probably dead
} }
return false; return false;

View file

@ -39,7 +39,7 @@ class Notes
if(!is_null($note)) if(!is_null($note))
return new Note($note); return new Note($note);
else else
return null; return NULL;
} }
function getUserNotesCount(User $user): int function getUserNotesCount(User $user): int

View file

@ -96,7 +96,7 @@ class Posts
if(!is_null($post)) if(!is_null($post))
return new Post($post); return new Post($post);
else else
return null; return NULL;
} }

View file

@ -1,8 +1,8 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace openvk\Web\Models\Repositories; namespace openvk\Web\Models\Repositories;
// use openvk\Web\Models\Entities\Ticket; # use openvk\Web\Models\Entities\Ticket;
// use openvk\Web\Models\Entities\User; # use openvk\Web\Models\Entities\User;
// use openvk\Web\Models\Repositories\Users; # use openvk\Web\Models\Repositories\Users;
use openvk\Web\Models\Entities\TicketComment; use openvk\Web\Models\Entities\TicketComment;
use Chandler\Database\DatabaseConnection; use Chandler\Database\DatabaseConnection;
@ -22,31 +22,31 @@ class TicketComments
foreach($this->comments->where(['ticket_id' => $ticket_id, 'deleted' => 0]) as $comment) yield new TicketComment($comment); foreach($this->comments->where(['ticket_id' => $ticket_id, 'deleted' => 0]) as $comment) yield new TicketComment($comment);
} }
// private function toTicket(?ActiveRow $ar): ?Ticket # private function toTicket(?ActiveRow $ar): ?Ticket
// { # {
// return is_null($ar) ? NULL : new Ticket($ar); # return is_null($ar) ? NULL : new Ticket($ar);
// } # }
// function getTicketsByuId(int $user_id): \Traversable # function getTicketsByuId(int $user_id): \Traversable
// { # {
// foreach($this->tickets->where(['user_id' => $user_id, 'deleted' => 0]) as $ticket) yield new Ticket($ticket); # foreach($this->tickets->where(['user_id' => $user_id, 'deleted' => 0]) as $ticket) yield new Ticket($ticket);
// } # }
// function getRequestById(int $req_id): ?Ticket # function getRequestById(int $req_id): ?Ticket
// { # {
// $requests = $this->tickets->where(['id' => $req_id])->fetch(); # $requests = $this->tickets->where(['id' => $req_id])->fetch();
// if(!is_null($requests)) # if(!is_null($requests))
// return new Req($requests); # return new Req($requests);
// else # else
// return null; # return null;
// } # }
// function get(int $id): ?Ticket # function get(int $id): ?Ticket
// { # {
// return $this->toTicket($this->tickets->get($id)); # return $this->toTicket($this->tickets->get($id));
// } # }
function get(int $id): ?TicketComment function get(int $id): ?TicketComment
{ {

View file

@ -50,7 +50,7 @@ class Tickets
if(!is_null($requests)) if(!is_null($requests))
return new Req($requests); return new Req($requests);
else else
return null; return NULL;
} }

View file

@ -35,7 +35,7 @@ class Topics
{ {
$perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE; $perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE;
// Get pinned topics first # Get pinned topics first
$query = "SELECT `id` FROM `topics` WHERE `pinned` = 1 AND `group` = ? AND `deleted` = 0 UNION SELECT `id` FROM `topics` WHERE `pinned` = 0 AND `group` = ? AND `deleted` = 0"; $query = "SELECT `id` FROM `topics` WHERE `pinned` = 1 AND `group` = ? AND `deleted` = 0 UNION SELECT `id` FROM `topics` WHERE `pinned` = 0 AND `group` = ? AND `deleted` = 0";
$query .= " LIMIT " . $perPage . " OFFSET " . ($page - 1) * $perPage; $query .= " LIMIT " . $perPage . " OFFSET " . ($page - 1) * $perPage;

View file

@ -85,7 +85,7 @@ final class AboutPresenter extends OpenVKPresenter
if(is_null($lg)) if(is_null($lg))
$this->throwError(404, "Not found", "Language is not found"); $this->throwError(404, "Not found", "Language is not found");
header("Content-Type: application/javascript"); header("Content-Type: application/javascript");
echo "window.lang = " . json_encode($localizer->export($lang)) . ";"; // привет хардкод :DDD echo "window.lang = " . json_encode($localizer->export($lang)) . ";"; # привет хардкод :DDD
exit; exit;
} }
@ -120,7 +120,7 @@ final class AboutPresenter extends OpenVKPresenter
function renderHumansTxt(): void function renderHumansTxt(): void
{ {
// :D # :D
header("HTTP/1.1 302 Found"); header("HTTP/1.1 302 Found");
header("Location: https://github.com/openvk/openvk#readme"); header("Location: https://github.com/openvk/openvk#readme");

View file

@ -60,7 +60,7 @@ final class CommentPresenter extends OpenVKPresenter
} }
} }
// TODO move to trait # TODO move to trait
try { try {
$photo = NULL; $photo = NULL;
$video = NULL; $video = NULL;

View file

@ -89,7 +89,7 @@ final class GroupPresenter extends OpenVKPresenter
$this->template->club = $this->clubs->get($id); $this->template->club = $this->clubs->get($id);
$this->template->onlyShowManagers = $this->queryParam("onlyAdmins") == "1"; $this->template->onlyShowManagers = $this->queryParam("onlyAdmins") == "1";
if($this->template->onlyShowManagers) { if($this->template->onlyShowManagers) {
$this->template->followers = null; $this->template->followers = NULL;
$this->template->managers = $this->template->club->getManagers((int) ($this->queryParam("p") ?? 1), !$this->template->club->canBeModifiedBy($this->user->identity)); $this->template->managers = $this->template->club->getManagers((int) ($this->queryParam("p") ?? 1), !$this->template->club->canBeModifiedBy($this->user->identity));
if($this->template->club->canBeModifiedBy($this->user->identity) || !$this->template->club->isOwnerHidden()) { if($this->template->club->canBeModifiedBy($this->user->identity) || !$this->template->club->isOwnerHidden()) {
@ -99,7 +99,7 @@ final class GroupPresenter extends OpenVKPresenter
$this->template->count = $this->template->club->getManagersCount(); $this->template->count = $this->template->club->getManagersCount();
} else { } else {
$this->template->followers = $this->template->club->getFollowers((int) ($this->queryParam("p") ?? 1)); $this->template->followers = $this->template->club->getFollowers((int) ($this->queryParam("p") ?? 1));
$this->template->managers = null; $this->template->managers = NULL;
$this->template->count = $this->template->club->getFollowersCount(); $this->template->count = $this->template->club->getFollowersCount();
} }
@ -116,7 +116,7 @@ final class GroupPresenter extends OpenVKPresenter
$user = is_null($this->queryParam("user")) ? $this->postParam("user") : $this->queryParam("user"); $user = is_null($this->queryParam("user")) ? $this->postParam("user") : $this->queryParam("user");
$comment = $this->postParam("comment"); $comment = $this->postParam("comment");
$removeComment = $this->postParam("removeComment") === "1"; $removeComment = $this->postParam("removeComment") === "1";
$hidden = ["0" => false, "1" => true][$this->queryParam("hidden")] ?? null; $hidden = ["0" => false, "1" => true][$this->queryParam("hidden")] ?? NULL;
//$index = $this->queryParam("index"); //$index = $this->queryParam("index");
if(!$user) if(!$user)
$this->badRequest(); $this->badRequest();

View file

@ -80,11 +80,11 @@ final class InternalAPIPresenter extends OpenVKPresenter
if ($postTZ != $sessionOffset || $sessionOffset == null) { if ($postTZ != $sessionOffset || $sessionOffset == null) {
Session::i()->set("_timezoneOffset", $postTZ ? $postTZ : 3 * MINUTE ); Session::i()->set("_timezoneOffset", $postTZ ? $postTZ : 3 * MINUTE );
$this->returnJson([ $this->returnJson([
"success" => 1 // If it's new value "success" => 1 # If it's new value
]); ]);
} else { } else {
$this->returnJson([ $this->returnJson([
"success" => 2 // If it's the same value (if for some reason server will call this func) "success" => 2 # If it's the same value (if for some reason server will call this func)
]); ]);
} }
} else { } else {

View file

@ -106,7 +106,7 @@ final class MessengerPresenter extends OpenVKPresenter
$messages = []; $messages = [];
$correspondence = new Correspondence($this->user->identity, $correspondent); $correspondence = new Correspondence($this->user->identity, $correspondent);
foreach($correspondence->getMessages(1, $lastMsg === 0 ? null : $lastMsg) as $message) foreach($correspondence->getMessages(1, $lastMsg === 0 ? NULL : $lastMsg) as $message)
$messages[] = $message->simplify(); $messages[] = $message->simplify();
header("Content-Type: application/json"); header("Content-Type: application/json");

View file

@ -118,7 +118,7 @@ abstract class OpenVKPresenter extends SimplePresenter
return ($action === "register" || $action === "login"); return ($action === "register" || $action === "login");
} }
return (bool) $this->user->raw->can($action)->model($model)->whichBelongsTo($context === -1 ? null : $context); return (bool) $this->user->raw->can($action)->model($model)->whichBelongsTo($context === -1 ? NULL : $context);
} }
protected function assertPermission(string $model, string $action, int $context, bool $throw = false): void protected function assertPermission(string $model, string $action, int $context, bool $throw = false): void
@ -252,7 +252,7 @@ abstract class OpenVKPresenter extends SimplePresenter
exit; exit;
} }
// ето для емейл уже надо (и по хорошему надо бы избавится от повторяющегося кода мда) # ето для емейл уже надо (и по хорошему надо бы избавится от повторяющегося кода мда)
if(!$this->user->identity->isActivated() && !$this->activationTolerant) { if(!$this->user->identity->isActivated() && !$this->activationTolerant) {
header("HTTP/1.1 403 Forbidden"); header("HTTP/1.1 403 Forbidden");
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@email.xml", [ $this->getTemplatingEngine()->render(__DIR__ . "/templates/@email.xml", [
@ -288,7 +288,7 @@ abstract class OpenVKPresenter extends SimplePresenter
$whichbrowser = new WhichBrowser\Parser(getallheaders()); $whichbrowser = new WhichBrowser\Parser(getallheaders());
$mobiletheme = OPENVK_ROOT_CONF["openvk"]["preferences"]["defaultMobileTheme"]; $mobiletheme = OPENVK_ROOT_CONF["openvk"]["preferences"]["defaultMobileTheme"];
if($mobiletheme && $whichbrowser->isType('mobile') && Session::i()->get("_tempTheme") == null) if($mobiletheme && $whichbrowser->isType('mobile') && Session::i()->get("_tempTheme") == NULL)
$this->setSessionTheme($mobiletheme); $this->setSessionTheme($mobiletheme);
$theme = NULL; $theme = NULL;
@ -299,7 +299,7 @@ abstract class OpenVKPresenter extends SimplePresenter
$theme = Themepacks::i()[Session::i()->get("_sessionTheme", "ovk")]; $theme = Themepacks::i()[Session::i()->get("_sessionTheme", "ovk")];
} else if($this->requestParam("themePreview")) { } else if($this->requestParam("themePreview")) {
$theme = Themepacks::i()[$this->requestParam("themePreview")]; $theme = Themepacks::i()[$this->requestParam("themePreview")];
} else if($this->user->identity !== null && $this->user->identity->getTheme()) { } else if($this->user->identity !== NULL && $this->user->identity->getTheme()) {
$theme = $this->user->identity->getTheme(); $theme = $this->user->identity->getTheme();
} }

View file

@ -29,7 +29,7 @@ final class SearchPresenter extends OpenVKPresenter
if($query != "") if($query != "")
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
// https://youtu.be/pSAWM5YuXx8 # https://youtu.be/pSAWM5YuXx8
$repos = [ "groups" => "clubs", "users" => "users" ]; $repos = [ "groups" => "clubs", "users" => "users" ];
$repo = $repos[$type] or $this->throwError(400, "Bad Request", "Invalid search entity $type."); $repo = $repos[$type] or $this->throwError(400, "Bad Request", "Invalid search entity $type.");

View file

@ -91,7 +91,7 @@ final class TopicsPresenter extends OpenVKPresenter
$topic->setFlags($flags); $topic->setFlags($flags);
$topic->save(); $topic->save();
// TODO move to trait # TODO move to trait
try { try {
$photo = NULL; $photo = NULL;
$video = NULL; $video = NULL;

View file

@ -495,7 +495,7 @@ final class UserPresenter extends OpenVKPresenter
$this->template->secret = $secret; $this->template->secret = $secret;
} }
// Why are these crutch? For some reason, the QR code is not displayed if you just pass the render output to the view # Why are these crutch? For some reason, the QR code is not displayed if you just pass the render output to the view
$issuer = OPENVK_ROOT_CONF["openvk"]["appearance"]["name"]; $issuer = OPENVK_ROOT_CONF["openvk"]["appearance"]["name"];
$email = $this->user->identity->getEmail(); $email = $this->user->identity->getEmail();

View file

@ -414,7 +414,7 @@ final class WallPresenter extends OpenVKPresenter
$post->unpin(); $post->unpin();
} }
// TODO localize message based on language and ?act=(un)pin # TODO localize message based on language and ?act=(un)pin
$this->flashFail("succ", tr("information_-1"), tr("changes_saved_comment")); $this->flashFail("succ", tr("information_-1"), tr("changes_saved_comment"));
} }
} }

View file

@ -17,7 +17,7 @@
{script "js/l10n.js"} {script "js/l10n.js"}
{script "js/openvk.cls.js"} {script "js/openvk.cls.js"}
{if $isTimezoned == null} {if $isTimezoned == NULL}
{script "js/timezone.js"} {script "js/timezone.js"}
{/if} {/if}
@ -26,7 +26,7 @@
{css "css/nsfw-posts.css"} {css "css/nsfw-posts.css"}
{/if} {/if}
{if $theme !== null} {if $theme !== NULL}
{if $theme->inheritDefault()} {if $theme->inheritDefault()}
{css "css/style.css"} {css "css/style.css"}
{css "css/dialog.css"} {css "css/dialog.css"}

View file

@ -2,7 +2,7 @@
{var $comments = $post->getLastComments(3)} {var $comments = $post->getLastComments(3)}
{var $commentsCount = $post->getCommentsCount()} {var $commentsCount = $post->getCommentsCount()}
{var $commentTextAreaId = $post === null ? rand(1,300) : $post->getId()} {var $commentTextAreaId = $post === NULL ? rand(1,300) : $post->getId()}
<table border="0" style="font-size: 11px;" n:class="post, !$compact ? post-divider, $post->isExplicit() ? post-nsfw"> <table border="0" style="font-size: 11px;" n:class="post, !$compact ? post-divider, $post->isExplicit() ? post-nsfw">
<tbody> <tbody>

View file

@ -1,5 +1,5 @@
{php if(!isset($GLOBALS["textAreaCtr"])) $GLOBALS["textAreaCtr"] = 10;} {php if(!isset($GLOBALS["textAreaCtr"])) $GLOBALS["textAreaCtr"] = 10;}
{var $textAreaId = ($post ?? NULL) === null ? (++$GLOBALS["textAreaCtr"]) : $post->getId()} {var $textAreaId = ($post ?? NULL) === NULL ? (++$GLOBALS["textAreaCtr"]) : $post->getId()}
<div id="write" style="padding: 5px 0;" onfocusin="expand_wall_textarea({$textAreaId});"> <div id="write" style="padding: 5px 0;" onfocusin="expand_wall_textarea({$textAreaId});">
<form action="{$route}" method="post" enctype="multipart/form-data" style="margin:0;"> <form action="{$route}" method="post" enctype="multipart/form-data" style="margin:0;">

View file

@ -136,7 +136,7 @@ function isLanguageAvailable($lg): bool
function getBrowsersLanguage(): array function getBrowsersLanguage(): array
{ {
if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] != null) return mb_split(",", mb_split(";", $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]); if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] != NULL) return mb_split(",", mb_split(";", $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]);
else return array(); else return array();
} }
@ -144,7 +144,7 @@ function eventdb(): ?DatabaseConnection
{ {
$conf = OPENVK_ROOT_CONF["openvk"]["credentials"]["eventDB"]; $conf = OPENVK_ROOT_CONF["openvk"]["credentials"]["eventDB"];
if(!$conf["enable"]) if(!$conf["enable"])
return null; return NULL;
$db = (object) $conf["database"]; $db = (object) $conf["database"];
return DatabaseConnection::connect([ return DatabaseConnection::connect([
@ -216,8 +216,8 @@ return (function() {
setlocale(LC_TIME, "POSIX"); setlocale(LC_TIME, "POSIX");
// TODO: Default language in config # TODO: Default language in config
if(Session::i()->get("lang") == null) { if(Session::i()->get("lang") == NULL) {
$languages = array_reverse(getBrowsersLanguage()); $languages = array_reverse(getBrowsersLanguage());
foreach($languages as $lg) { foreach($languages as $lg) {
if(isLanguageAvailable($lg)) setLanguage($lg); if(isLanguageAvailable($lg)) setLanguage($lg);
@ -233,7 +233,7 @@ return (function() {
else else
$ver = "Public Technical Preview 3"; $ver = "Public Technical Preview 3";
// Unix time constants # Unix time constants
define('MINUTE', 60); define('MINUTE', 60);
define('HOUR', 60 * MINUTE); define('HOUR', 60 * MINUTE);
define('DAY', 24 * HOUR); define('DAY', 24 * HOUR);