2024-03-14 19:39:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
class RenderService
|
|
|
|
{
|
2024-03-14 23:58:11 +01:00
|
|
|
private $sort;
|
|
|
|
private $settings;
|
|
|
|
private $pageInfo;
|
|
|
|
private $menu;
|
|
|
|
private $background;
|
|
|
|
|
|
|
|
public function __construct(SortingService $sortingService, SettingsService $settingsService)
|
|
|
|
{
|
|
|
|
$this->sort = $sortingService;
|
|
|
|
$this->settings = $settingsService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tag()
|
2024-03-14 19:39:43 +01:00
|
|
|
{
|
2024-03-14 23:58:11 +01:00
|
|
|
$list = $this->sort->tags();
|
|
|
|
foreach ($list as $item) {
|
|
|
|
$template = 'tags.twig';
|
|
|
|
$pageOptions = [
|
|
|
|
'title' => 'Pages Tagged as ' . $item['tag_name'],
|
|
|
|
'background' => $this->pageInfo['image'],
|
|
|
|
'tag_list' => $item['pages'],
|
|
|
|
'info' => $this->pageInfo,
|
|
|
|
'menu' => $this->menu,
|
|
|
|
'media' => [['file' => $this->pageInfo['image'], 'type' => trim(pathinfo($this->pageInfo['image'], PATHINFO_EXTENSION))]],
|
|
|
|
];
|
|
|
|
|
|
|
|
$html = $this->twig->render($template, $pageOptions);
|
|
|
|
|
|
|
|
$location = '../public/tags/' . $item['slug'] . '.html';
|
|
|
|
|
|
|
|
//if tags folder doesn't exist, make it
|
|
|
|
if (!is_dir('../public/tags')) {
|
|
|
|
mkdir('../public/tags', 0755, true);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_file($location)) {
|
|
|
|
file_put_contents($location, $html);
|
|
|
|
} else {
|
|
|
|
($new = fopen($location, 'w')) or die('Unable to open file!');
|
|
|
|
fwrite($new, $html);
|
|
|
|
fclose($new);
|
|
|
|
}
|
|
|
|
}
|
2024-03-14 19:39:43 +01:00
|
|
|
}
|
|
|
|
}
|