proxitok/app/Controllers/TagController.php

37 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;
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 {
2023-04-27 14:23:23 -04:00
public static function get(string $name) {
2022-01-30 18:02:52 -05:00
$cursor = Misc::getCursor();
$api = Wrappers::api();
2022-05-24 08:10:41 -04:00
$hashtag = $api->hashtag($name);
$hashtag->feed($cursor);
if ($hashtag->ok()) {
2022-11-26 17:51:45 -05:00
$info = $hashtag->getInfo();
$feed = $hashtag->getFeed();
Wrappers::latte('tag', new FullTemplate($info->detail->title, $info, $feed));
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
}
}
2023-04-27 14:23:23 -04:00
public static 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
}
}
}