mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
55 lines
No EOL
1.6 KiB
PHP
55 lines
No EOL
1.6 KiB
PHP
<?php
|
|
|
|
class BountyActions extends Actions
|
|
{
|
|
const URL_BOUNTY_LIST = '/bounty';
|
|
|
|
public static function executeList()
|
|
{
|
|
$allBounties = Post::find(ROOT_DIR . '/posts/bounty');
|
|
|
|
$allCategories = ['' => ''] + Post::collectMetadata($allBounties, 'category');
|
|
$allStatuses = ['' => ''] + Post::collectMetadata($allBounties, 'status');
|
|
|
|
$selectedStatus = static::param('status');
|
|
$selectedCategory = static::param('category');
|
|
|
|
$filters = array_filter([
|
|
'category' => $selectedCategory && isset($allCategories[$selectedCategory]) ? $selectedCategory : null,
|
|
'status' => $selectedStatus && isset($allStatuses[$selectedStatus]) ? $selectedStatus : null
|
|
]);
|
|
|
|
$bounties = $filters ? Post::filter($allBounties, $filters) : $allBounties;
|
|
|
|
uasort($bounties, function($postA, $postB) {
|
|
$metadataA = $postA->getMetadata();
|
|
$metadataB = $postB->getMetadata();
|
|
if ($metadataA['award'] != $metadataB['award'])
|
|
{
|
|
return $metadataA['award'] > $metadataB['award'] ? -1 : 1;
|
|
}
|
|
return $metadataA['title'] < $metadataB['title'] ? -1 : 1;
|
|
});
|
|
|
|
return ['bounty/list', [
|
|
'bounties' => $bounties,
|
|
'categories' => $allCategories,
|
|
'statuses' => $allStatuses,
|
|
'selectedCategory' => $selectedCategory,
|
|
'selectedStatus' => $selectedStatus
|
|
]];
|
|
}
|
|
|
|
public static function executeShow($relativeUri)
|
|
{
|
|
list($metadata, $postHtml) = View::parseMarkdown(ROOT_DIR . '/posts/' . $relativeUri . '.md');
|
|
if (!$postHtml)
|
|
{
|
|
return ['page/404', []];
|
|
}
|
|
return ['bounty/show', [
|
|
'postHtml' => $postHtml,
|
|
'metadata' => $metadata
|
|
]];
|
|
}
|
|
} |