|
|
@ -1,6 +1,7 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
require_once 'php/servers/servers-rooms.php';
|
|
|
|
require_once 'php/servers/servers-rooms.php';
|
|
|
|
require_once 'php/utils/utils.php';
|
|
|
|
require_once 'php/utils/utils.php';
|
|
|
|
|
|
|
|
require_once 'php/servers/room-listings-api.php';
|
|
|
|
|
|
|
|
|
|
|
|
class RoomSieve {
|
|
|
|
class RoomSieve {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -34,18 +35,18 @@
|
|
|
|
public function saveStickies() {
|
|
|
|
public function saveStickies() {
|
|
|
|
$stickied = CommunityRoom::get_stickied_rooms($this->rooms, $rest);
|
|
|
|
$stickied = CommunityRoom::get_stickied_rooms($this->rooms, $rest);
|
|
|
|
$rooms = $rest;
|
|
|
|
$rooms = $rest;
|
|
|
|
return new RoomSieve($rooms, $stickied);
|
|
|
|
return $this->cloneWith($rooms, $stickied);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param CommunityRoom[] $rooms
|
|
|
|
* @param CommunityRoom[] $rooms
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function addRooms(array $rooms) {
|
|
|
|
public function addRooms(array $rooms) {
|
|
|
|
return new RoomSieve(array_merge($this->rooms, $rooms), $this->stickies);
|
|
|
|
return $this->cloneWith(array_merge($this->rooms, $rooms));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function apply(Closure $filter) {
|
|
|
|
public function apply(Closure $filter) {
|
|
|
|
return new RoomSieve($filter($this->rooms), $this->stickies);
|
|
|
|
return $this->cloneWith($filter($this->rooms));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getWithStickies() {
|
|
|
|
public function getWithStickies() {
|
|
|
@ -62,13 +63,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
public function onlyTop(int $count = RoomSieve::TOP_DEFAULT) {
|
|
|
|
public function onlyTop(int $count = RoomSieve::TOP_DEFAULT) {
|
|
|
|
$rooms = $this->rooms;
|
|
|
|
$rooms = $this->rooms;
|
|
|
|
return new RoomSieve(array_slice(array_reverse($rooms), 0, $count), $this->stickies);
|
|
|
|
return $this->cloneWith(array_slice(array_reverse($rooms), 0, $count));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function exceptTop(int $count = RoomSieve::TOP_DEFAULT) {
|
|
|
|
public function exceptTop(int $count = RoomSieve::TOP_DEFAULT) {
|
|
|
|
$rooms = $this->rooms;
|
|
|
|
$rooms = $this->rooms;
|
|
|
|
CommunityRoom::sort_rooms_num($rooms, 'active_users');
|
|
|
|
CommunityRoom::sort_rooms_num($rooms, 'active_users');
|
|
|
|
return new RoomSieve(array_slice(array_reverse($rooms), $count), $this->stickies);
|
|
|
|
return $this->cloneWith(array_slice(array_reverse($rooms), $count));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static function isIndexApproved(CommunityRoom $room): bool {
|
|
|
|
private static function isIndexApproved(CommunityRoom $room): bool {
|
|
|
@ -112,5 +113,14 @@
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
return new RoomSieve($rooms, $this->stickies);
|
|
|
|
return new RoomSieve($rooms, $this->stickies);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function clone(): self {
|
|
|
|
|
|
|
|
return $this->cloneWith();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function cloneWith($rooms = null, $stickies = null): self {
|
|
|
|
|
|
|
|
$clone = new RoomSieve($rooms ?? $this->rooms, $stickies ?? $this->stickies);
|
|
|
|
|
|
|
|
return $clone;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|