proxitok/app/Controllers/TagController.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-30 23:02:52 +00:00
<?php
namespace App\Controllers;
use App\Helpers\ErrorHandler;
use App\Helpers\Misc;
2022-11-04 19:08:19 +00:00
use App\Helpers\UrlBuilder;
use App\Helpers\Wrappers;
2022-05-24 12:10:41 +00:00
use App\Models\FullTemplate;
use App\Models\RSSTemplate;
2022-01-30 23:02:52 +00:00
class TagController {
2023-04-27 18:23:23 +00:00
public static function get(string $name) {
2022-01-30 23:02:52 +00:00
$cursor = Misc::getCursor();
$api = Wrappers::api();
2022-05-24 12:10:41 +00:00
$hashtag = $api->hashtag($name);
$hashtag->feed($cursor);
if ($hashtag->ok()) {
2022-11-26 22:51:45 +00:00
$info = $hashtag->getInfo();
$feed = $hashtag->getFeed();
Wrappers::latte('tag', new FullTemplate($info->detail->title, $info, $feed));
2022-01-30 23:02:52 +00:00
} else {
2022-09-03 12:01:03 +00:00
ErrorHandler::showMeta($hashtag->error());
2022-01-30 23:02:52 +00:00
}
}
2023-04-27 18:23:23 +00:00
public static function rss(string $name) {
$api = Wrappers::api();
2022-05-24 12:10:41 +00:00
$hashtag = $api->hashtag($name);
$hashtag->feed();
if ($hashtag->ok()) {
$data = $hashtag->getFull();
2022-11-04 19:08:19 +00:00
Misc::rss($name);
Wrappers::latte('rss', new RSSTemplate($name, $data->info->detail->desc, UrlBuilder::tag($name), $data->feed->items));
2022-01-30 23:02:52 +00:00
}
}
}