proxitok/app/Controllers/TagController.php

36 lines
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;
2022-11-04 15:08:19 -04:00
use App\Helpers\UrlBuilder;
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();
Wrappers::latte('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();
2022-11-04 15:08:19 -04:00
Misc::rss($name);
Wrappers::latte('rss', new RSSTemplate($name, $data->info->detail->desc, UrlBuilder::tag($name), $data->feed->items));
2022-01-30 18:02:52 -05:00
}
}
}