restore video&audio piker
|
@ -11,7 +11,7 @@ use openvk\Web\Models\Repositories\Comments as CommentsRepo;
|
|||
|
||||
final class Video extends VKAPIRequestHandler
|
||||
{
|
||||
function get(int $owner_id, string $videos = "", int $offset = 0, int $count = 30, int $extended = 0): object
|
||||
function get(int $owner_id, string $videos = "", string $fields = "", int $offset = 0, int $count = 30, int $extended = 0): object
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
|
@ -46,12 +46,46 @@ final class Video extends VKAPIRequestHandler
|
|||
if(!$user->getPrivacyPermission('videos.read', $this->getUser()))
|
||||
$this->fail(21, "This user chose to hide his videos.");
|
||||
|
||||
$videos = (new VideosRepo)->getByUser($user, $offset + 1, $count);
|
||||
$videos = (new VideosRepo)->getByUserLimit($user, $offset, $count);
|
||||
$videosCount = (new VideosRepo)->getUserVideosCount($user);
|
||||
|
||||
$items = [];
|
||||
foreach ($videos as $video) {
|
||||
$items[] = $video->getApiStructure($this->getUser());
|
||||
$profiles = [];
|
||||
$groups = [];
|
||||
foreach($videos as $video) {
|
||||
$video = $video->getApiStructure($this->getUser())->video;
|
||||
$items[] = $video;
|
||||
if($video['owner_id']) {
|
||||
if($video['owner_id'] > 0)
|
||||
$profiles[] = $video['owner_id'];
|
||||
else
|
||||
$groups[] = abs($video['owner_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if($extended == 1) {
|
||||
$profiles = array_unique($profiles);
|
||||
$groups = array_unique($groups);
|
||||
|
||||
$profilesFormatted = [];
|
||||
$groupsFormatted = [];
|
||||
|
||||
foreach($profiles as $prof) {
|
||||
$profile = (new UsersRepo)->get($prof);
|
||||
$profilesFormatted[] = $profile->toVkApiStruct($this->getUser(), $fields);
|
||||
}
|
||||
|
||||
foreach($groups as $gr) {
|
||||
$group = (new ClubsRepo)->get($gr);
|
||||
$groupsFormatted[] = $group->toVkApiStruct($this->getUser(), $fields);
|
||||
}
|
||||
|
||||
return (object) [
|
||||
"count" => $videosCount,
|
||||
"items" => $items,
|
||||
"profiles" => $profilesFormatted,
|
||||
"groups" => $groupsFormatted,
|
||||
];
|
||||
}
|
||||
|
||||
return (object) [
|
||||
|
|
|
@ -473,7 +473,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
];
|
||||
}
|
||||
|
||||
function post(string $owner_id, string $message = "", int $from_group = 0, int $signed = 0, string $attachments = "", int $post_id = 0): object
|
||||
function post(string $owner_id, string $message = "", string $copyright = "", int $from_group = 0, int $signed = 0, string $attachments = "", int $post_id = 0): object
|
||||
{
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
@ -551,7 +551,17 @@ final class Wall extends VKAPIRequestHandler
|
|||
if($signed == 1)
|
||||
$flags |= 0b01000000;
|
||||
|
||||
if(empty($message) && empty($attachments))
|
||||
$parsed_attachments = parseAttachments($attachments, ['photo', 'video', 'note', 'poll', 'audio']);
|
||||
$final_attachments = [];
|
||||
$should_be_suggested = $owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2;
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
if($attachment && !$attachment->isDeleted() && $attachment->canBeViewedBy($this->getUser()) &&
|
||||
!(method_exists($attachment, 'getVoters') && $attachment->getOwner()->getId() != $this->getUser()->getId())) {
|
||||
$final_attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
if((empty($message) && (empty($attachments) || sizeof($final_attachments) < 1)))
|
||||
$this->fail(100, "Required parameter 'message' missing.");
|
||||
|
||||
try {
|
||||
|
@ -569,7 +579,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
} catch(\Throwable) {}
|
||||
}
|
||||
|
||||
if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2)
|
||||
if($should_be_suggested)
|
||||
$post->setSuggested(1);
|
||||
|
||||
$post->save();
|
||||
|
@ -577,90 +587,14 @@ final class Wall extends VKAPIRequestHandler
|
|||
$this->fail(100, "One of the parameters specified was missing or invalid");
|
||||
}
|
||||
|
||||
# TODO use parseAttachments
|
||||
if(!empty($attachments)) {
|
||||
$attachmentsArr = explode(",", $attachments);
|
||||
# Аттачи такого вида: [тип][id владельца]_[id вложения]
|
||||
# Пример: photo1_1
|
||||
|
||||
if(sizeof($attachmentsArr) > 10)
|
||||
$this->fail(50, "Too many attachments");
|
||||
|
||||
preg_match_all("/poll/m", $attachments, $matches, PREG_SET_ORDER, 0);
|
||||
if(sizeof($matches) > 1)
|
||||
$this->fail(85, "Too many polls");
|
||||
|
||||
foreach($attachmentsArr as $attac) {
|
||||
$attachmentType = NULL;
|
||||
|
||||
if(str_contains($attac, "photo"))
|
||||
$attachmentType = "photo";
|
||||
elseif(str_contains($attac, "video"))
|
||||
$attachmentType = "video";
|
||||
elseif(str_contains($attac, "note"))
|
||||
$attachmentType = "note";
|
||||
elseif(str_contains($attac, "poll"))
|
||||
$attachmentType = "poll";
|
||||
elseif(str_contains($attac, "audio"))
|
||||
$attachmentType = "audio";
|
||||
|
||||
else
|
||||
$this->fail(205, "Unknown attachment type");
|
||||
|
||||
$attachment = str_replace($attachmentType, "", $attac);
|
||||
|
||||
$attachmentOwner = (int)explode("_", $attachment)[0];
|
||||
$attachmentId = (int)end(explode("_", $attachment));
|
||||
|
||||
$attacc = NULL;
|
||||
|
||||
if($attachmentType == "photo") {
|
||||
$attacc = (new PhotosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Invalid photo");
|
||||
if(!$attacc->getOwner()->getPrivacyPermission('photos.read', $this->getUser()))
|
||||
$this->fail(43, "Access to photo denied");
|
||||
|
||||
$post->attach($attacc);
|
||||
} elseif($attachmentType == "video") {
|
||||
$attacc = (new VideosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Video does not exists");
|
||||
if(!$attacc->getOwner()->getPrivacyPermission('videos.read', $this->getUser()))
|
||||
$this->fail(43, "Access to video denied");
|
||||
|
||||
$post->attach($attacc);
|
||||
} elseif($attachmentType == "note") {
|
||||
$attacc = (new NotesRepo)->getNoteById($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Note does not exist");
|
||||
if(!$attacc->getOwner()->getPrivacyPermission('notes.read', $this->getUser()))
|
||||
$this->fail(11, "Access to note denied");
|
||||
|
||||
$post->attach($attacc);
|
||||
} elseif($attachmentType == "poll") {
|
||||
$attacc = (new PollsRepo)->get($attachmentId);
|
||||
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Poll does not exist");
|
||||
if($attacc->getOwner()->getId() != $this->getUser()->getId())
|
||||
$this->fail(43, "You do not have access to this poll");
|
||||
|
||||
$post->attach($attacc);
|
||||
} elseif($attachmentType == "audio") {
|
||||
$attacc = (new AudiosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Audio does not exist");
|
||||
|
||||
$post->attach($attacc);
|
||||
}
|
||||
}
|
||||
foreach($final_attachments as $attachment) {
|
||||
$post->attach($attachment);
|
||||
}
|
||||
|
||||
if($wall > 0 && $wall !== $this->user->identity->getId())
|
||||
(new WallPostNotification($wallOwner, $post, $this->user->identity))->emit();
|
||||
|
||||
if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2) {
|
||||
if($should_be_suggested) {
|
||||
return (object)["post_id" => "on_view"];
|
||||
}
|
||||
|
||||
|
@ -675,6 +609,15 @@ final class Wall extends VKAPIRequestHandler
|
|||
if(preg_match('/wall((?:-?)[0-9]+)_([0-9]+)/', $object, $postArray) == 0)
|
||||
$this->fail(100, "One of the parameters specified was missing or invalid: object is incorrect");
|
||||
|
||||
$parsed_attachments = parseAttachments($attachments, ['photo', 'video', 'note', 'audio']);
|
||||
$final_attachments = [];
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
if($attachment && !$attachment->isDeleted() && $attachment->canBeViewedBy($this->getUser()) &&
|
||||
!(method_exists($attachment, 'getVoters') && $attachment->getOwner()->getId() != $this->getUser()->getId())) {
|
||||
$final_attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
$post = (new PostsRepo)->getPostById((int) $postArray[1], (int) $postArray[2]);
|
||||
if(!$post || $post->isDeleted()) $this->fail(100, "One of the parameters specified was missing or invalid");
|
||||
|
||||
|
@ -710,12 +653,8 @@ final class Wall extends VKAPIRequestHandler
|
|||
$nPost->save();
|
||||
|
||||
$nPost->attach($post);
|
||||
$attachments_arr = parseAttachments($attachments, ['photo', 'video', 'audio']);
|
||||
foreach($attachments_arr as $attachment) {
|
||||
if(!$attachment || $attachment->isDeleted() || !$attachment->canBeViewedBy($this->getUser())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
$nPost->attach($attachment);
|
||||
}
|
||||
|
||||
|
@ -905,7 +844,16 @@ final class Wall extends VKAPIRequestHandler
|
|||
if($post->getTargetWall() < 0)
|
||||
$club = (new ClubsRepo)->get(abs($post->getTargetWall()));
|
||||
|
||||
if(empty($message) && empty($attachments)) {
|
||||
$parsed_attachments = parseAttachments($attachments, ['photo', 'video', 'note', 'audio']);
|
||||
$final_attachments = [];
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
if($attachment && !$attachment->isDeleted() && $attachment->canBeViewedBy($this->getUser()) &&
|
||||
!(method_exists($attachment, 'getVoters') && $attachment->getOwner()->getId() != $this->getUser()->getId())) {
|
||||
$final_attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
if((empty($message) && (empty($attachments) || sizeof($final_attachments) < 1))) {
|
||||
$this->fail(100, "Required parameter 'message' missing.");
|
||||
}
|
||||
|
||||
|
@ -926,55 +874,8 @@ final class Wall extends VKAPIRequestHandler
|
|||
$this->fail(1, "ошибка про то что коммент большой слишком");
|
||||
}
|
||||
|
||||
if(!empty($attachments)) {
|
||||
$attachmentsArr = explode(",", $attachments);
|
||||
|
||||
if(sizeof($attachmentsArr) > 10)
|
||||
$this->fail(50, "Error: too many attachments");
|
||||
|
||||
foreach($attachmentsArr as $attac) {
|
||||
$attachmentType = NULL;
|
||||
|
||||
if(str_contains($attac, "photo"))
|
||||
$attachmentType = "photo";
|
||||
elseif(str_contains($attac, "video"))
|
||||
$attachmentType = "video";
|
||||
elseif(str_contains($attac, "audio"))
|
||||
$attachmentType = "audio";
|
||||
else
|
||||
$this->fail(205, "Unknown attachment type");
|
||||
|
||||
$attachment = str_replace($attachmentType, "", $attac);
|
||||
|
||||
$attachmentOwner = (int)explode("_", $attachment)[0];
|
||||
$attachmentId = (int)end(explode("_", $attachment));
|
||||
|
||||
$attacc = NULL;
|
||||
|
||||
if($attachmentType == "photo") {
|
||||
$attacc = (new PhotosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Photo does not exists");
|
||||
if(!$attacc->getOwner()->getPrivacyPermission('photos.read', $this->getUser()))
|
||||
$this->fail(11, "Access to photo denied");
|
||||
|
||||
$comment->attach($attacc);
|
||||
} elseif($attachmentType == "video") {
|
||||
$attacc = (new VideosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Video does not exists");
|
||||
if(!$attacc->getOwner()->getPrivacyPermission('videos.read', $this->getUser()))
|
||||
$this->fail(11, "Access to video denied");
|
||||
|
||||
$comment->attach($attacc);
|
||||
} elseif($attachmentType == "audio") {
|
||||
$attacc = (new AudiosRepo)->getByOwnerAndVID($attachmentOwner, $attachmentId);
|
||||
if(!$attacc || $attacc->isDeleted())
|
||||
$this->fail(100, "Audio does not exist");
|
||||
|
||||
$comment->attach($attacc);
|
||||
}
|
||||
}
|
||||
foreach($final_attachments as $attachment) {
|
||||
$comment->attach($attachment);
|
||||
}
|
||||
|
||||
if($post->getOwner()->getId() !== $this->user->getId())
|
||||
|
@ -1049,24 +950,19 @@ final class Wall extends VKAPIRequestHandler
|
|||
|
||||
$post->save(true);
|
||||
|
||||
# todo добавить такое в веб версию
|
||||
if(!empty($attachments)) {
|
||||
$attachs = parseAttachments($attachments);
|
||||
$newAttachmentsCount = sizeof($attachs);
|
||||
$parsed_attachments = parseAttachments($attachments, ['photo', 'video', 'note', 'audio']);
|
||||
$final_attachments = [];
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
if($attachment && !$attachment->isDeleted() && $attachment->canBeViewedBy($this->getUser()) &&
|
||||
!(method_exists($attachment, 'getVoters') && $attachment->getOwner()->getId() != $this->getUser()->getId())) {
|
||||
$final_attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
$postsAttachments = iterator_to_array($post->getChildren());
|
||||
|
||||
if(sizeof($postsAttachments) >= 10)
|
||||
$this->fail(15, "Post have too many attachments");
|
||||
|
||||
if(($newAttachmentsCount + sizeof($postsAttachments)) > 10)
|
||||
$this->fail(158, "Post will have too many attachments");
|
||||
|
||||
foreach($attachs as $attach) {
|
||||
if($attach && !$attach->isDeleted())
|
||||
$post->attach($attach);
|
||||
else
|
||||
$this->fail(52, "One of the attachments is invalid");
|
||||
if(sizeof($final_attachments) > 0) {
|
||||
$post->unwire();
|
||||
foreach($final_attachments as $attachment) {
|
||||
$post->attach($attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1094,23 +990,19 @@ final class Wall extends VKAPIRequestHandler
|
|||
$comment->setEdited(time());
|
||||
$comment->save(true);
|
||||
|
||||
if(!empty($attachments)) {
|
||||
$attachs = parseAttachments($attachments);
|
||||
$newAttachmentsCount = sizeof($attachs);
|
||||
$parsed_attachments = parseAttachments($attachments, ['photo', 'video', 'note', 'audio']);
|
||||
$final_attachments = [];
|
||||
foreach($parsed_attachments as $attachment) {
|
||||
if($attachment && !$attachment->isDeleted() && $attachment->canBeViewedBy($this->getUser()) &&
|
||||
!(method_exists($attachment, 'getVoters') && $attachment->getOwner()->getId() != $this->getUser()->getId())) {
|
||||
$final_attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
$postsAttachments = iterator_to_array($comment->getChildren());
|
||||
|
||||
if(sizeof($postsAttachments) >= 10)
|
||||
$this->fail(15, "Post have too many attachments");
|
||||
|
||||
if(($newAttachmentsCount + sizeof($postsAttachments)) > 10)
|
||||
$this->fail(158, "Post will have too many attachments");
|
||||
|
||||
foreach($attachs as $attach) {
|
||||
if($attach && !$attach->isDeleted())
|
||||
$comment->attach($attach);
|
||||
else
|
||||
$this->fail(52, "One of the attachments is invalid");
|
||||
if(sizeof($final_attachments) > 0) {
|
||||
$comment->unwire();
|
||||
foreach($final_attachments as $attachment) {
|
||||
$comment->attach($attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,13 @@ class Videos
|
|||
yield new Video($video);
|
||||
}
|
||||
|
||||
function getByUserLimit(User $user, int $offset = 0, int $limit = 10): \Traversable
|
||||
{
|
||||
$perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE;
|
||||
foreach($this->videos->where("owner", $user->getId())->where(["deleted" => 0, "unlisted" => 0])->limit($limit, $offset)->order("created DESC") as $video)
|
||||
yield new Video($video);
|
||||
}
|
||||
|
||||
function getUserVideosCount(User $user): int
|
||||
{
|
||||
return sizeof($this->videos->where("owner", $user->getId())->where(["deleted" => 0, "unlisted" => 0]));
|
||||
|
|
|
@ -79,15 +79,15 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
$horizontal_attachments = [];
|
||||
$vertical_attachments = [];
|
||||
if(!empty($this->postParam("horizontal_attachments"))) {
|
||||
$horizontal_attachments_array = explode(",", $this->postParam("horizontal_attachments"));
|
||||
if(sizeof($horizontal_attachments_array) <= OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]) {
|
||||
$horizontal_attachments_array = array_slice(explode(",", $this->postParam("horizontal_attachments")), 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]);
|
||||
if(sizeof($horizontal_attachments_array) > 0) {
|
||||
$horizontal_attachments = parseAttachments($horizontal_attachments_array, ['photo', 'video']);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($this->postParam("vertical_attachments"))) {
|
||||
$vertical_attachments_array = explode(",", $this->postParam("vertical_attachments"));
|
||||
if(sizeof($vertical_attachments_array) <= OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]) {
|
||||
$vertical_attachments_array = array_slice(explode(",", $this->postParam("vertical_attachments")), 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]);
|
||||
if(sizeof($vertical_attachments_array) > 0) {
|
||||
$vertical_attachments = parseAttachments($vertical_attachments_array, ['audio', 'note']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,15 +275,15 @@ final class WallPresenter extends OpenVKPresenter
|
|||
$horizontal_attachments = [];
|
||||
$vertical_attachments = [];
|
||||
if(!empty($this->postParam("horizontal_attachments"))) {
|
||||
$horizontal_attachments_array = explode(",", $this->postParam("horizontal_attachments"));
|
||||
if(sizeof($horizontal_attachments_array) <= OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]) {
|
||||
$horizontal_attachments_array = array_slice(explode(",", $this->postParam("horizontal_attachments")), 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]);
|
||||
if(sizeof($horizontal_attachments_array) > 0) {
|
||||
$horizontal_attachments = parseAttachments($horizontal_attachments_array, ['photo', 'video']);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($this->postParam("vertical_attachments"))) {
|
||||
$vertical_attachments_array = explode(",", $this->postParam("vertical_attachments"));
|
||||
if(sizeof($vertical_attachments_array) <= OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]) {
|
||||
$vertical_attachments_array = array_slice(explode(",", $this->postParam("vertical_attachments")), 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]);
|
||||
if(sizeof($vertical_attachments_array) > 0) {
|
||||
$vertical_attachments = parseAttachments($vertical_attachments_array, ['audio', 'note']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
<div id="audioEmbed-{$id}" data-realid="{$audio->getId()}" {if $hideButtons}data-prettyid="{$audio->getPrettyId()}" data-name="{$audio->getName()}"{/if} data-genre="{$audio->getGenre()}" class="audioEmbed {if !$isAvailable}processed{/if} {if $isWithdrawn}withdrawn{/if}" data-length="{$audio->getLength()}" data-keys="{json_encode($audio->getKeys())}" data-url="{$audio->getURL()}">
|
||||
<audio class="audio" />
|
||||
|
||||
<div id="miniplayer" class="audioEntry" style="min-height: 39px;">
|
||||
<div style="display: flex;">
|
||||
<div id="miniplayer" class="audioEntry">
|
||||
<div class='audioEntryWrapper' style="display: flex;" draggable='true'>
|
||||
<div class="playerButton">
|
||||
<div class="playIcon"></div>
|
||||
</div>
|
||||
|
||||
<div class="status" style="margin-top: 12px;">
|
||||
<div class="status">
|
||||
<div class="mediaInfo noOverflow">
|
||||
<div class="info">
|
||||
<strong class="performer">
|
||||
<a href="/search?query=§ion=audios&order=listens&only_performers=on&q={$audio->getPerformer()}">{$audio->getPerformer()}</a>
|
||||
<a draggable='false' href="/search?section=audios&order=listens&only_performers=on&q={$audio->getPerformer()}">{$audio->getPerformer()}</a>
|
||||
</strong>
|
||||
—
|
||||
<span class="title {if !empty($audio->getLyrics())}withLyrics{/if}">{$audio->getTitle()}</span>
|
||||
|
@ -27,8 +27,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="volume" style="display: flex; flex-direction: column;width:14%;">
|
||||
<span class="nobold {if !$hideButtons}hideOnHover{/if}" data-unformatted="{$audio->getLength()}" style="text-align: center;margin-top: 12px;">{$audio->getFormattedLength()}</span>
|
||||
<div class="volume">
|
||||
<span class="nobold {if !$hideButtons}hideOnHover{/if}" data-unformatted="{$audio->getLength()}">{$audio->getFormattedLength()}</span>
|
||||
<div class="buttons">
|
||||
{php $hasAudio = isset($thisUser) && $audio->isInLibraryOf($thisUser)}
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="subTracks">
|
||||
<div class="subTracks" draggable='false'>
|
||||
<div class="lengthTrackWrapper">
|
||||
<div class="track lengthTrack">
|
||||
<div class="selectableTrack" n:attr="style => $isWithdrawn ? 'display: none;' : ''">
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
<input type="checkbox" name="as_group" /> {_comment_as_group}
|
||||
</label>
|
||||
</div>
|
||||
<input type="text" name="horizontal_attachments" value="" />
|
||||
<input type="text" name="vertical_attachments" value="" />
|
||||
<input type="hidden" name="horizontal_attachments" value="" />
|
||||
<input type="hidden" name="vertical_attachments" value="" />
|
||||
<input type="hidden" name="poll" value="none" />
|
||||
<input type="hidden" id="source" name="source" value="none" />
|
||||
<input type="hidden" name="type" value="1" />
|
||||
|
@ -75,11 +75,11 @@
|
|||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-x-egon.png" />
|
||||
{_photo}
|
||||
</a>
|
||||
<a id="videoAttachment">
|
||||
<a id="__videoAttachment">
|
||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-vnd.rn-realmedia.png" />
|
||||
{_video}
|
||||
</a>
|
||||
<a id="_audioAttachment">
|
||||
<a id="__audioAttachment">
|
||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/audio-ac3.png" />
|
||||
{_audio}
|
||||
</a>
|
||||
|
|
|
@ -267,6 +267,17 @@
|
|||
color: white;
|
||||
}
|
||||
|
||||
.audioEntry .volume {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 14%;
|
||||
}
|
||||
|
||||
.audioEntry .nobold {
|
||||
text-align: center;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.audioEntry.nowPlaying .volume .nobold {
|
||||
color: white !important;
|
||||
}
|
||||
|
@ -303,6 +314,7 @@
|
|||
height: 100%;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 39px;
|
||||
}
|
||||
|
||||
.audioEntry .playerButton {
|
||||
|
@ -341,6 +353,7 @@
|
|||
grid-template-columns: 1fr;
|
||||
width: 85%;
|
||||
height: 23px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.audioEntry .status .mediaInfo {
|
||||
|
@ -588,7 +601,6 @@
|
|||
}
|
||||
|
||||
.attachAudio {
|
||||
float: left;
|
||||
width: 28%;
|
||||
height: 26px;
|
||||
padding-top: 11px;
|
||||
|
|
|
@ -1490,7 +1490,7 @@ body.scrolled .toTop:hover {
|
|||
color: #3c3c3c;
|
||||
}
|
||||
|
||||
.post-source #remove_source_button {
|
||||
.post-source #remove_source_button, #small_remove_button {
|
||||
display: inline-block;
|
||||
background-repeat: no-repeat;
|
||||
background: url('/assets/packages/static/openvk/img/arrows.png?v=2');
|
||||
|
@ -1504,7 +1504,7 @@ body.scrolled .toTop:hover {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.post-source #remove_source_button:hover {
|
||||
.post-source #remove_source_button:hover, #small_remove_button:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
|
@ -2413,8 +2413,8 @@ a.poll-retract-vote {
|
|||
}
|
||||
}
|
||||
|
||||
.post-horizontal {
|
||||
margin-top: 8px;
|
||||
.post-horizontal, .post-vertical {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.post-horizontal {
|
||||
|
@ -2424,19 +2424,46 @@ a.poll-retract-vote {
|
|||
gap: 3px;
|
||||
}
|
||||
|
||||
.post-vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.post-horizontal .upload-item {
|
||||
/*width: 75px;
|
||||
height: 60px;*/
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.post-horizontal .upload-item.dragged {
|
||||
.post-horizontal .upload-item .play-button {
|
||||
position: absolute;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.post-horizontal .upload-item .play-button .play-button-ico {
|
||||
background: url(/assets/packages/static/openvk/img/wall.png) no-repeat 1px 0;
|
||||
display: inline-block;
|
||||
height: 15px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.upload-item.dragged {
|
||||
filter: contrast(0.5);
|
||||
}
|
||||
|
||||
.upload-item .upload-delete {
|
||||
.post-horizontal .upload-item .upload-delete {
|
||||
position: absolute;
|
||||
background: rgba(0,0,0,0.5);
|
||||
padding: 2px 5px;
|
||||
|
@ -2444,6 +2471,7 @@ a.poll-retract-vote {
|
|||
color: #fff;
|
||||
font-size: 11px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
opacity: 0;
|
||||
transition: 0.25s;
|
||||
}
|
||||
|
@ -2452,13 +2480,60 @@ a.poll-retract-vote {
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.upload-item img {
|
||||
.post-horizontal .upload-item img {
|
||||
width: 100%;
|
||||
max-height: 60px;
|
||||
object-fit: cover;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 0fr;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment:first-of-type {
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry {
|
||||
max-height: 28px;
|
||||
min-height: 18px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry .playerButton {
|
||||
padding: 0px 3px 0px 3px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry .status {
|
||||
margin-top: 1px;
|
||||
margin-left: 2px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry .nobold {
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry .subTracks {
|
||||
padding-bottom: 2px;
|
||||
padding-left: 3px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .audioEntry .audioEntryWrapper {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .vertical-attachment-content {
|
||||
max-height: 27px;
|
||||
}
|
||||
|
||||
.post-vertical .vertical-attachment .vertical-attachment-content .overflowedName {
|
||||
position: initial;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* https://imgur.com/a/ihB3JZ4 */
|
||||
|
||||
.ovk-photo-view-dimmer {
|
||||
|
@ -3169,6 +3244,10 @@ body.article .floating_sidebar, body.article .page_content {
|
|||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.attachment_selector .topGrayBlock #video_query {
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
.attachment_selector .topGrayBlock #albumSelect {
|
||||
width: 150px;
|
||||
}
|
||||
|
@ -3216,6 +3295,22 @@ body.article .floating_sidebar, body.article .page_content {
|
|||
margin: unset;
|
||||
}
|
||||
|
||||
.attachment_selector #attachment_insert .videosInsert .video_list .video-preview {
|
||||
height: 75px;
|
||||
width: 133px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.attachment_selector #attachment_insert .videosInsert .video_list .video-preview img {
|
||||
max-width: 133px;
|
||||
height: 75px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.attachment_selector #attachment_insert .videosInsert .video_list .action_links {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.edited {
|
||||
color: #9b9b9b;
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 932 B |
Before Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 153 B |
|
@ -1 +0,0 @@
|
|||
<svg id="note" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 40"><defs><style>.cls-1{fill:#a0a0a0;}</style></defs><title>note</title><polygon class="cls-1" points="0 0 0 40 35 40 35 20 17.5 20 17.5 0 0 0"/><polygon id="block" class="cls-1" points="20.26 1 35 18 20.26 18 20.26 1"/></svg>
|
Before Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 510 B |
BIN
Web/static/img/wall.png
Normal file
After Width: | Height: | Size: 2 KiB |
|
@ -1315,8 +1315,8 @@ $(document).on("click", "#_deletePlaylist", (e) => {
|
|||
}, Function.noop])
|
||||
})
|
||||
|
||||
$(document).on("click", "#_audioAttachment", (e) => {
|
||||
let form = e.currentTarget.closest("form")
|
||||
$(document).on("click", "#__audioAttachment", (e) => {
|
||||
const form = e.target.closest("form")
|
||||
let body = `
|
||||
<div class="searchBox">
|
||||
<input name="query" type="text" maxlength="50" placeholder="${tr("header_search")}">
|
||||
|
@ -1328,7 +1328,7 @@ $(document).on("click", "#_audioAttachment", (e) => {
|
|||
|
||||
<div class="audiosInsert"></div>
|
||||
`
|
||||
MessageBox(tr("select_audio"), body, [tr("ok")], [Function.noop])
|
||||
MessageBox(tr("select_audio"), body, [tr("close")], [Function.noop])
|
||||
|
||||
document.querySelector(".ovk-diag-body").style.padding = "0"
|
||||
document.querySelector(".ovk-diag-cont").style.width = "580px"
|
||||
|
@ -1349,23 +1349,24 @@ $(document).on("click", "#_audioAttachment", (e) => {
|
|||
|
||||
result.querySelectorAll(".audioEmbed").forEach(el => {
|
||||
let id = el.dataset.prettyid
|
||||
let name = el.dataset.name
|
||||
let isAttached = (form.querySelector("input[name='audios']").value.includes(`${id},`))
|
||||
const is_attached = (u(form).find(`.post-vertical .vertical-attachment[data-id='${id}']`)).length > 0
|
||||
|
||||
document.querySelector(".audiosInsert").insertAdjacentHTML("beforeend", `
|
||||
<div style="display: table;width: 100%;clear: both;">
|
||||
<div style="width: 72%;float: left;">${el.outerHTML}</div>
|
||||
<div class="attachAudio" data-attachmentdata="${id}" data-name="${name}">
|
||||
<span>${isAttached ? tr("detach_audio") : tr("attach_audio")}</span>
|
||||
<div class='audio_attachment_header' style="display: flex;width: 100%;">
|
||||
<div class='player_part' style="width: 72%;">${el.outerHTML}</div>
|
||||
<div class="attachAudio" data-attachmentdata="${id}">
|
||||
<span>${is_attached ? tr("detach_audio") : tr("attach_audio")}</span>
|
||||
</div>
|
||||
</div>
|
||||
`)
|
||||
})
|
||||
|
||||
u("#loader").remove()
|
||||
u('#show_more').remove()
|
||||
|
||||
if(thisc.page < pagesCount) {
|
||||
document.querySelector(".audiosInsert").insertAdjacentHTML("beforeend", `
|
||||
<div id="showMoreAudios" data-pagesCount="${pagesCount}" data-page="${thisc.page + 1}" class="showMore">
|
||||
<div id="show_more" data-pagesCount="${pagesCount}" data-page="${thisc.page + 1}" class="showMore">
|
||||
<span>${tr("show_more_audios")}</span>
|
||||
</div>`)
|
||||
}
|
||||
|
@ -1385,14 +1386,12 @@ $(document).on("click", "#_audioAttachment", (e) => {
|
|||
|
||||
searcher.movePage(1)
|
||||
|
||||
$(".audiosInsert").on("click", "#showMoreAudios", (e) => {
|
||||
u(e.currentTarget).remove()
|
||||
u(".audiosInsert").on("click", "#show_more", async (e) => {
|
||||
u(e.target).closest('#show_more').addClass('lagged')
|
||||
searcher.movePage(Number(e.currentTarget.dataset.page))
|
||||
})
|
||||
|
||||
$(".searchBox input").on("change", async (e) => {
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
|
||||
if(e.currentTarget.value === document.querySelector(".searchBox input").value) {
|
||||
searcher.clearContainer()
|
||||
|
||||
|
@ -1423,44 +1422,34 @@ $(document).on("click", "#_audioAttachment", (e) => {
|
|||
return;
|
||||
})
|
||||
|
||||
function insertAttachment(id) {
|
||||
let audios = form.querySelector("input[name='audios']")
|
||||
u(".audiosInsert").on("click", ".attachAudio", (ev) => {
|
||||
const id = ev.currentTarget.dataset.attachmentdata
|
||||
const is_attached = u(form).find(`.post-vertical .vertical-attachment[data-id='${id}']`).length > 0
|
||||
|
||||
if(!audios.value.includes(id + ",")) {
|
||||
if(audios.value.split(",").length > 10) {
|
||||
NewNotification(tr("error"), tr("max_attached_audios"))
|
||||
return false
|
||||
// 04.11.2024 19:03
|
||||
if(is_attached) {
|
||||
u(form).find(`.post-vertical .vertical-attachment[data-id='${id}']`).remove()
|
||||
u(ev.currentTarget).find("span").html(tr("attach_audio"))
|
||||
} else {
|
||||
if(u(form).find(`.vertical-attachment`).length > window.openvk.max_attachments) {
|
||||
makeError(tr('too_many_attachments'), 'Red', 10000, 1)
|
||||
return
|
||||
}
|
||||
|
||||
form.querySelector("input[name='audios']").value += (id + ",")
|
||||
u(ev.currentTarget).find("span").html(tr("detach_audio"))
|
||||
|
||||
return true
|
||||
} else {
|
||||
form.querySelector("input[name='audios']").value = form.querySelector("input[name='audios']").value.replace(id + ",", "")
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
$(".audiosInsert").on("click", ".attachAudio", (ev) => {
|
||||
if(!insertAttachment(ev.currentTarget.dataset.attachmentdata)) {
|
||||
u(`.post-has-audios .post-has-audio[data-id='${ev.currentTarget.dataset.attachmentdata}']`).remove()
|
||||
ev.currentTarget.querySelector("span").innerHTML = tr("attach_audio")
|
||||
} else {
|
||||
ev.currentTarget.querySelector("span").innerHTML = tr("detach_audio")
|
||||
|
||||
form.querySelector(".post-has-audios").insertAdjacentHTML("beforeend", `
|
||||
<div class="post-has-audio" id="unattachAudio" data-id="${ev.currentTarget.dataset.attachmentdata}">
|
||||
<span>${ovk_proc_strtr(escapeHtml(ev.currentTarget.dataset.name), 40)}</span>
|
||||
const header = u(ev.currentTarget).closest('.audio_attachment_header')
|
||||
const player = header.find('.player_part')
|
||||
u(form).find(".post-vertical").append(`
|
||||
<div class="vertical-attachment upload-item" data-type='audio' data-id="${ev.currentTarget.dataset.attachmentdata}">
|
||||
<div class='vertical-attachment-content'>
|
||||
${player.html()}
|
||||
</div>
|
||||
<div class='vertical-attachment-remove'>
|
||||
<div id='small_remove_button'></div>
|
||||
</div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
u(`#unattachAudio[data-id='${ev.currentTarget.dataset.attachmentdata}']`).on("click", (e) => {
|
||||
let id = ev.currentTarget.dataset.attachmentdata
|
||||
form.querySelector("input[name='audios']").value = form.querySelector("input[name='audios']").value.replace(id + ",", "")
|
||||
|
||||
u(e.currentTarget).remove()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -512,14 +512,10 @@ async function __appendToTextarea(attachment_obj, textareaNode) {
|
|||
indicator.append(`
|
||||
<a draggable="true" href='/${attachment_obj.type}${attachment_obj.id}' class="upload-item" data-type='${attachment_obj.type}' data-id="${attachment_obj.id}">
|
||||
<span class="upload-delete">×</span>
|
||||
${attachment_obj.type == 'video' ? `<div class='play-button'><div class='play-button-ico'></div></div>` : ''}
|
||||
<img draggable="false" src="${attachment_obj.preview}" alt='...'>
|
||||
</a>
|
||||
`)
|
||||
|
||||
u(document).on('click', `.post-horizontal .upload-item[data-id='${attachment_obj.id}'] .upload-delete`, (e) => {
|
||||
e.preventDefault()
|
||||
indicator.find(`.upload-item[data-id='${attachment_obj.id}']`).remove()
|
||||
})
|
||||
}
|
||||
|
||||
// ajax не буде работать
|
||||
|
@ -531,13 +527,14 @@ u('#write .small-textarea').on('paste', (e) => {
|
|||
}
|
||||
})
|
||||
|
||||
u('#write').on('dragstart', '.post-horizontal .upload-item', (e) => {
|
||||
u('#write').on('dragstart', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => {
|
||||
//e.preventDefault()
|
||||
u(e.target).addClass('currently_dragging')
|
||||
//console.log(e)
|
||||
u(e.target).closest('.upload-item').addClass('currently_dragging')
|
||||
return
|
||||
})
|
||||
|
||||
u('#write').on('dragover', '.post-horizontal .upload-item', (e) => {
|
||||
u('#write').on('dragover', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
const target = u(e.target).closest('.upload-item')
|
||||
|
@ -550,23 +547,31 @@ u('#write').on('dragover', '.post-horizontal .upload-item', (e) => {
|
|||
return
|
||||
})
|
||||
|
||||
u('#write').on('dragleave dragend', '.post-horizontal .upload-item', (e) => {
|
||||
u('#write').on('dragleave dragend', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => {
|
||||
//console.log(e)
|
||||
u(e.target).closest('.upload-item').removeClass('dragged')
|
||||
return
|
||||
})
|
||||
|
||||
u('#write').on("drop", function(e) {
|
||||
e.preventDefault()
|
||||
|
||||
const current = u('.upload-item.currently_dragging')
|
||||
|
||||
//console.log(e)
|
||||
if(e.dataTransfer.types.includes('Files')) {
|
||||
e.preventDefault()
|
||||
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
__uploadToTextarea(e.dataTransfer.files[0], u(e.target).closest('#write'))
|
||||
} else {
|
||||
} else if(e.dataTransfer.types.length < 1 || e.dataTransfer.types.includes('text/uri-list')) {
|
||||
e.preventDefault()
|
||||
|
||||
const target = u(e.target).closest('.upload-item')
|
||||
target.removeClass('dragged')
|
||||
u('.dragged').removeClass('dragged')
|
||||
current.removeClass('currently_dragging')
|
||||
//console.log(target)
|
||||
if(!current.closest('.vertical-attachment').length < 1 && target.closest('.vertical-attachment').length < 1
|
||||
|| current.closest('.vertical-attachment').length < 1 && !target.closest('.vertical-attachment').length < 1) {
|
||||
return
|
||||
}
|
||||
|
||||
const first_html = target.nodes[0].outerHTML
|
||||
const second_html = current.nodes[0].outerHTML
|
||||
|
@ -581,14 +586,14 @@ u('#write > form').on('submit', (e) => {
|
|||
const horizontal_array = []
|
||||
const horizontal_input = target.find(`input[name='horizontal_attachments']`)
|
||||
const horizontal_attachments = target.find(`.post-horizontal > a`)
|
||||
horizontal_attachments.nodes.slice(0, window.openvk.max_attachments).forEach(_node => {
|
||||
horizontal_attachments.nodes.forEach(_node => {
|
||||
horizontal_array.push(`${_node.dataset.type}${_node.dataset.id}`)
|
||||
})
|
||||
horizontal_input.nodes[0].value = horizontal_array.join(',')
|
||||
|
||||
const vertical_array = []
|
||||
const vertical_input = target.find(`input[name='vertical_attachments']`)
|
||||
const vertical_attachments = target.find(`.post-vertical > a`)
|
||||
const vertical_attachments = target.find(`.post-vertical > .vertical-attachment`)
|
||||
vertical_attachments.nodes.forEach(_node => {
|
||||
vertical_array.push(`${_node.dataset.type}${_node.dataset.id}`)
|
||||
})
|
||||
|
@ -732,6 +737,171 @@ u(document).on("click", "#__photoAttachment", async (e) => {
|
|||
})
|
||||
})
|
||||
|
||||
u(document).on('click', '#__videoAttachment', async (e) => {
|
||||
const per_page = 10
|
||||
const form = u(e.target).closest('form')
|
||||
const msg = new CMessageBox({
|
||||
title: tr('selecting_video'),
|
||||
body: `
|
||||
<div class='attachment_selector'>
|
||||
<div class="topGrayBlock display_flex_row">
|
||||
<a href="/videos/upload">${tr("upload_new_video")}</a>
|
||||
|
||||
<input type="search" id="video_query" maxlength="20" placeholder="${tr("header_search")}">
|
||||
</div>
|
||||
<div id='attachment_insert'>
|
||||
<div class="videosInsert"></div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
buttons: [tr('close')],
|
||||
callbacks: [Function.noop]
|
||||
})
|
||||
|
||||
msg.getNode().attr('style', 'width: 630px;')
|
||||
msg.getNode().find('.ovk-diag-body').attr('style', 'height:335px;padding:0px;')
|
||||
|
||||
async function __recieveVideos(page, query = '') {
|
||||
u('#gif_loader').remove()
|
||||
u('#attachment_insert').append(`<div id='gif_loader'></div>`)
|
||||
const insert_place = u('#attachment_insert .videosInsert')
|
||||
let videos = null
|
||||
|
||||
try {
|
||||
if(query == '') {
|
||||
videos = await window.OVKAPI.call('video.get', {'owner_id': window.openvk.current_id, 'extended': 1, 'count': per_page, 'offset': page * per_page})
|
||||
} else {
|
||||
videos = await window.OVKAPI.call('video.search', {'q': escapeHtml(query), 'extended': 1, 'count': per_page, 'offset': page * per_page})
|
||||
}
|
||||
} catch(e) {
|
||||
u("#gif_loader").remove()
|
||||
insert_place.html("Err")
|
||||
return
|
||||
}
|
||||
|
||||
u("#gif_loader").remove()
|
||||
const pages_count = Math.ceil(Number(videos.count) / per_page)
|
||||
videos.items.forEach(video => {
|
||||
const pretty_id = `${video.owner_id}_${video.id}`
|
||||
const is_attached = (form.find(`.upload-item[data-type='video'][data-id='${video.owner_id}_${video.id}']`)).length > 0
|
||||
let author_name = ''
|
||||
|
||||
const profiles = videos.profiles
|
||||
const groups = videos.groups
|
||||
|
||||
if(video['owner_id'] > 0) {
|
||||
const profile = profiles.find(prof => prof.id == video['owner_id'])
|
||||
if(profile) {
|
||||
author_name = profile['first_name'] + ' ' + profile['last_name']
|
||||
}
|
||||
} else {
|
||||
const group = groups.find(grou => grou.id == Math.abs(video['owner_id']))
|
||||
if(group) {
|
||||
author_name = group['name']
|
||||
}
|
||||
}
|
||||
|
||||
insert_place.append(`
|
||||
<div class="content video_list" style="padding: unset;" data-preview='${video.image[0].url}' data-attachmentdata="${pretty_id}">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<a href="/video${pretty_id}">
|
||||
<div class="video-preview">
|
||||
<img src="${video.image[0].url}" alt="${escapeHtml(video.title)}">
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
<td valign="top" style="width: 100%">
|
||||
<a href="/video${pretty_id}">
|
||||
<b class='video-name'>
|
||||
${ovk_proc_strtr(escapeHtml(video.title), 50)}
|
||||
</b>
|
||||
</a>
|
||||
<br>
|
||||
<p>
|
||||
<span class='video-desc'>${ovk_proc_strtr(escapeHtml(video.description ?? ""), 140)}</span>
|
||||
</p>
|
||||
<span><a href="/id${video.owner_id}" target="_blank">${ovk_proc_strtr(escapeHtml(author_name ?? ""), 100)}</a></span>
|
||||
</td>
|
||||
<td valign="top" class="action_links">
|
||||
<a class="profile_link" id="__attach_vid">${!is_attached ? tr("attach") : tr("detach")}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`)
|
||||
})
|
||||
|
||||
if(page < pages_count - 1) {
|
||||
insert_place.append(`
|
||||
<div id="show_more" data-pagesCount="${pages_count}" data-page="${page + 1}">
|
||||
<span>${tr('show_more')}</span>
|
||||
</div>`)
|
||||
}
|
||||
|
||||
if(query != '') {
|
||||
highlightText(query, '.videosInsert', ['.video-name', '.video-desc'])
|
||||
}
|
||||
}
|
||||
|
||||
u(".ovk-diag-body #video_query").on('change', (ev) => {
|
||||
if(ev.target.value == u(".ovk-diag-body #video_query").nodes[0].value) {
|
||||
u('#attachment_insert .videosInsert').html('')
|
||||
__recieveVideos(0, u(".ovk-diag-body #video_query").nodes[0].value)
|
||||
}
|
||||
})
|
||||
|
||||
// next page
|
||||
u(".ovk-diag-body .attachment_selector").on("click", "#show_more", async (ev) => {
|
||||
const target = u(ev.target).closest('#show_more')
|
||||
target.addClass('lagged')
|
||||
await __recieveVideos(Number(target.nodes[0].dataset.page), u(".topGrayBlock #video_query").nodes[0].value)
|
||||
target.remove()
|
||||
})
|
||||
|
||||
// add video
|
||||
u(".ovk-diag-body .attachment_selector").on("click", "#__attach_vid", async (ev) => {
|
||||
ev.preventDefault()
|
||||
|
||||
const target = u(ev.target).closest('.content')
|
||||
const button = target.find('#__attach_vid')
|
||||
const dataset = target.nodes[0].dataset
|
||||
const is_attached = (form.find(`.upload-item[data-type='video'][data-id='${dataset.attachmentdata}']`)).length > 0
|
||||
if(is_attached) {
|
||||
(form.find(`.upload-item[data-type='video'][data-id='${dataset.attachmentdata}']`)).remove()
|
||||
button.html(tr('attach'))
|
||||
} else {
|
||||
if(form.find(`.upload-item`).length + 1 > window.openvk.max_attachments) {
|
||||
makeError(tr('too_many_attachments'), 'Red', 10000, 1)
|
||||
return
|
||||
}
|
||||
|
||||
button.html(tr('detach'))
|
||||
__appendToTextarea({
|
||||
'type': 'video',
|
||||
'preview': dataset.preview,
|
||||
'id': dataset.attachmentdata,
|
||||
'fullsize_url': dataset.preview,
|
||||
}, form)
|
||||
}
|
||||
})
|
||||
|
||||
__recieveVideos(0)
|
||||
})
|
||||
|
||||
u(document).on('click', `.post-horizontal .upload-item .upload-delete`, (e) => {
|
||||
e.preventDefault()
|
||||
u(e.target).closest('.upload-item').remove()
|
||||
})
|
||||
|
||||
u(document).on('click', `.post-vertical .vertical-attachment #small_remove_button`, (e) => {
|
||||
e.preventDefault()
|
||||
u(e.target).closest('.vertical-attachment').remove()
|
||||
})
|
||||
|
||||
u(document).on('click', '.post-buttons .upload-item', (e) => {
|
||||
e.preventDefault()
|
||||
})
|
||||
|
|
|
@ -28,7 +28,7 @@ function highlightText(searchText, container_selector, selectors = []) {
|
|||
node.parentNode.insertBefore(tempDiv.firstChild, node)
|
||||
}
|
||||
node.parentNode.removeChild(node)
|
||||
} else if(node.nodeType === 1 && node.tagName !== 'SCRIPT' && node.tagName !== 'BR' && node.tagName !== 'STYLE') {
|
||||
} else if(node.nodeType === 1 && node.tagName !== 'SCRIPT' && node.tagName !== 'BR' && node.tagName !== 'STYLE' && !node.classList.contains('highlight')) {
|
||||
Array.from(node.childNodes).forEach(highlightNode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ function ovk_is_ssl(): bool
|
|||
function parseAttachments($attachments, array $allow_types = ['photo', 'video', 'note', 'audio']): array
|
||||
{
|
||||
$exploded_attachments = is_array($attachments) ? $attachments : explode(",", $attachments);
|
||||
$exploded_attachments = array_slice($exploded_attachments, 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]);
|
||||
$imploded_types = implode('|', $allow_types);
|
||||
$output_attachments = [];
|
||||
$repositories = [
|
||||
|
@ -254,21 +255,37 @@ function parseAttachments($attachments, array $allow_types = ['photo', 'video',
|
|||
'repo' => 'openvk\Web\Models\Repositories\Notes',
|
||||
'method' => 'getNoteById',
|
||||
],
|
||||
'poll' => [
|
||||
'repo' => 'openvk\Web\Models\Repositories\Polls',
|
||||
'method' => 'get',
|
||||
'onlyId' => true,
|
||||
],
|
||||
];
|
||||
|
||||
foreach($exploded_attachments as $attachment_string) {
|
||||
if(preg_match("/$imploded_types/", $attachment_string, $matches) == 1) {
|
||||
$attachment_type = $matches[0];
|
||||
if(!$repositories[$attachment_type])
|
||||
continue;
|
||||
try {
|
||||
$attachment_type = $matches[0];
|
||||
if(!$repositories[$attachment_type])
|
||||
continue;
|
||||
|
||||
$attachment_ids = str_replace($attachment_type, '', $attachment_string);
|
||||
[$attachment_owner, $attachment_id] = array_map('intval', explode('_', $attachment_ids));
|
||||
$attachment_ids = str_replace($attachment_type, '', $attachment_string);
|
||||
if($repositories[$attachment_type]['onlyId']) {
|
||||
[$attachment_id] = array_map('intval', explode('_', $attachment_ids));
|
||||
|
||||
$repository_class = $repositories[$attachment_type]['repo'];
|
||||
if(!$repository_class) continue;
|
||||
$attachment_model = (new $repository_class)->{$repositories[$attachment_type]['method']}($attachment_owner, $attachment_id);
|
||||
$output_attachments[] = $attachment_model;
|
||||
$repository_class = $repositories[$attachment_type]['repo'];
|
||||
if(!$repository_class) continue;
|
||||
$attachment_model = (new $repository_class)->{$repositories[$attachment_type]['method']}($attachment_id);
|
||||
$output_attachments[] = $attachment_model;
|
||||
} else {
|
||||
[$attachment_owner, $attachment_id] = array_map('intval', explode('_', $attachment_ids));
|
||||
|
||||
$repository_class = $repositories[$attachment_type]['repo'];
|
||||
if(!$repository_class) continue;
|
||||
$attachment_model = (new $repository_class)->{$repositories[$attachment_type]['method']}($attachment_owner, $attachment_id);
|
||||
$output_attachments[] = $attachment_model;
|
||||
}
|
||||
} catch(\Throwable) {continue;}
|
||||
}
|
||||
}
|
||||
|
||||
|
|