proxitok/app/Controllers/TagController.php

36 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-30 18:02:52 -05:00
<?php
namespace App\Controllers;
use App\Helpers\ErrorHandler;
use App\Helpers\Misc;
use App\Helpers\Wrappers;
2022-05-24 08:10:41 -04:00
use App\Models\FullTemplate;
use App\Models\RSSTemplate;
2022-01-30 18:02:52 -05:00
class TagController {
static public function get(string $name) {
$cursor = Misc::getCursor();
$api = Wrappers::api();
2022-05-24 08:10:41 -04:00
$hashtag = $api->hashtag($name);
$hashtag->feed($cursor);
if ($hashtag->ok()) {
$data = $hashtag->getFull();
$latte = Wrappers::latte();
2022-09-25 13:53:00 -04:00
$latte->render(Misc::getView('tag'), new FullTemplate($data->info->detail->title, $data));
2022-01-30 18:02:52 -05:00
} else {
2022-09-03 08:01:03 -04:00
ErrorHandler::showMeta($hashtag->error());
2022-01-30 18:02:52 -05:00
}
}
static public function rss(string $name) {
$api = Wrappers::api();
2022-05-24 08:10:41 -04:00
$hashtag = $api->hashtag($name);
$hashtag->feed();
if ($hashtag->ok()) {
$data = $hashtag->getFull();
$latte = Wrappers::latte();
2022-05-24 08:10:41 -04:00
$latte->render(Misc::getView('rss'), new RSSTemplate($name, $data->info->detail->desc, "/tag/{$name}", $data->feed->items));
2022-01-30 18:02:52 -05:00
}
}
}