PhotoMosaic: reorder methods to be alphabetically ordered
This commit is contained in:
parent
aeaff887ca
commit
8e0e642d34
@ -8,10 +8,9 @@
|
||||
|
||||
class PhotoMosaic
|
||||
{
|
||||
private $queue = [];
|
||||
|
||||
const NUM_DAYS_CUTOFF = 7;
|
||||
private AssetIterator $iterator;
|
||||
private $queue = [];
|
||||
|
||||
public function __construct(AssetIterator $iterator)
|
||||
{
|
||||
@ -23,21 +22,9 @@ class PhotoMosaic
|
||||
$this->iterator->clean();
|
||||
}
|
||||
|
||||
public static function getRecentPhotos()
|
||||
private static function daysApart(Image $a, Image $b)
|
||||
{
|
||||
return new self(AssetIterator::getByOptions([
|
||||
'tag' => 'photo',
|
||||
'order' => 'date_captured',
|
||||
'direction' => 'desc',
|
||||
'limit' => 15, // worst case: 3 rows * (portrait + 4 thumbs)
|
||||
]));
|
||||
}
|
||||
|
||||
private static function matchTypeMask(Image $image, $type_mask)
|
||||
{
|
||||
return ($type_mask & Image::TYPE_PANORAMA) && $image->isPanorama() ||
|
||||
($type_mask & Image::TYPE_LANDSCAPE) && $image->isLandscape() ||
|
||||
($type_mask & Image::TYPE_PORTRAIT) && $image->isPortrait();
|
||||
return $a->getDateCaptured()->diff($b->getDateCaptured())->days;
|
||||
}
|
||||
|
||||
private function fetchImage($desired_type = Image::TYPE_PORTRAIT | Image::TYPE_LANDSCAPE | Image::TYPE_PANORAMA, Image $refDateImage = null)
|
||||
@ -66,25 +53,14 @@ class PhotoMosaic
|
||||
return false;
|
||||
}
|
||||
|
||||
private function pushToQueue(Image $image)
|
||||
public static function getRecentPhotos()
|
||||
{
|
||||
$this->queue[] = $image;
|
||||
}
|
||||
|
||||
private static function orderPhotos(Image $a, Image $b)
|
||||
{
|
||||
// Show images of highest priority first.
|
||||
$priority_diff = $a->getPriority() - $b->getPriority();
|
||||
if ($priority_diff !== 0)
|
||||
return -$priority_diff;
|
||||
|
||||
// In other cases, we'll just show the newest first.
|
||||
return $a->getDateCaptured() <=> $b->getDateCaptured();
|
||||
}
|
||||
|
||||
private static function daysApart(Image $a, Image $b)
|
||||
{
|
||||
return $a->getDateCaptured()->diff($b->getDateCaptured())->days;
|
||||
return new self(AssetIterator::getByOptions([
|
||||
'tag' => 'photo',
|
||||
'order' => 'date_captured',
|
||||
'direction' => 'desc',
|
||||
'limit' => 15, // worst case: 3 rows * (portrait + 4 thumbs)
|
||||
]));
|
||||
}
|
||||
|
||||
public function getRow()
|
||||
@ -102,13 +78,13 @@ class PhotoMosaic
|
||||
|
||||
// Alright, let's initalise a proper row, then.
|
||||
$photos = [$image];
|
||||
$num_portrait = $image->isPortrait() ? 1 : 0;
|
||||
$num_portrait = $image->isPortrait() ? 1 : 0;
|
||||
$num_landscape = $image->isLandscape() ? 1 : 0;
|
||||
|
||||
// Get an initial batch of non-panorama images to work with.
|
||||
for ($i = 1; $i < 3 && ($image = $this->fetchImage(Image::TYPE_LANDSCAPE | Image::TYPE_PORTRAIT, $image)); $i++)
|
||||
{
|
||||
$num_portrait += $image->isPortrait() ? 1 : 0;
|
||||
$num_portrait += $image->isPortrait() ? 1 : 0;
|
||||
$num_landscape += $image->isLandscape() ? 1 : 0;
|
||||
$photos[] = $image;
|
||||
}
|
||||
@ -171,4 +147,27 @@ class PhotoMosaic
|
||||
else
|
||||
return [$photos, 'landscapes'];
|
||||
}
|
||||
|
||||
private static function matchTypeMask(Image $image, $type_mask)
|
||||
{
|
||||
return ($type_mask & Image::TYPE_PANORAMA) && $image->isPanorama() ||
|
||||
($type_mask & Image::TYPE_LANDSCAPE) && $image->isLandscape() ||
|
||||
($type_mask & Image::TYPE_PORTRAIT) && $image->isPortrait();
|
||||
}
|
||||
|
||||
private static function orderPhotos(Image $a, Image $b)
|
||||
{
|
||||
// Show images of highest priority first.
|
||||
$priority_diff = $a->getPriority() - $b->getPriority();
|
||||
if ($priority_diff !== 0)
|
||||
return -$priority_diff;
|
||||
|
||||
// In other cases, we'll just show the newest first.
|
||||
return $a->getDateCaptured() <=> $b->getDateCaptured();
|
||||
}
|
||||
|
||||
private function pushToQueue(Image $image)
|
||||
{
|
||||
$this->queue[] = $image;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user