2022-01-05 23:11:00 +00:00
|
|
|
<?php
|
2022-01-30 23:02:52 +00:00
|
|
|
namespace App\Helpers;
|
2022-01-13 15:51:45 +00:00
|
|
|
|
2022-01-05 23:11:00 +00:00
|
|
|
class Misc {
|
2022-01-30 23:02:52 +00:00
|
|
|
static public function getCursor(): int {
|
|
|
|
return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0;
|
|
|
|
}
|
|
|
|
|
2022-03-11 22:24:13 +00:00
|
|
|
static public function getTtwid(): string {
|
2022-05-24 14:03:43 +00:00
|
|
|
return isset($_GET['cursor']) ? $_GET['cursor'] : '';
|
2022-03-11 22:24:13 +00:00
|
|
|
}
|
|
|
|
|
2022-03-29 17:30:31 +00:00
|
|
|
static public function url(string $endpoint = ''): string {
|
2022-03-29 17:37:57 +00:00
|
|
|
return self::env('APP_URL', '') . $endpoint;
|
2022-01-30 23:02:52 +00:00
|
|
|
}
|
|
|
|
|
2022-02-20 15:25:15 +00:00
|
|
|
static public function env(string $key, $default_value) {
|
2022-02-15 12:55:36 +00:00
|
|
|
return $_ENV[$key] ?? $default_value;
|
2022-01-05 23:11:00 +00:00
|
|
|
}
|
|
|
|
|
2022-01-28 14:54:09 +00:00
|
|
|
/**
|
|
|
|
* Returns absolute path for view
|
|
|
|
*/
|
2022-01-05 23:11:00 +00:00
|
|
|
static public function getView(string $template): string {
|
2022-11-04 17:02:57 +00:00
|
|
|
return __DIR__ . "/../../templates/views/{$template}.latte";
|
2022-01-05 23:11:00 +00:00
|
|
|
}
|
2022-11-04 19:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Common method for rss feeds
|
|
|
|
*/
|
|
|
|
static public function rss(string $title) {
|
|
|
|
header('Content-Disposition: attachment; filename="' . $title . '.rss' . '"');
|
|
|
|
}
|
2022-01-05 23:11:00 +00:00
|
|
|
}
|