| | +<?php |
| | +class TagsPage extends BasePage { |
| | + private $currentRepo; |
| | + private $git; |
| | + |
| | + public function __construct(array $repositories, array $currentRepo, Git $git) { |
| | + parent::__construct($repositories); |
| | + $this->currentRepo = $currentRepo; |
| | + $this->git = $git; |
| | + $this->title = $currentRepo['name'] . ' - Tags'; |
| | + } |
| | + |
| | + public function render() { |
| | + $this->renderLayout(function() { |
| | + $this->renderBreadcrumbs(); |
| | + |
| | + echo '<h2>Tags</h2>'; |
| | + echo '<div class="refs-list">'; |
| | + |
| | + $hasTags = false; |
| | + $repoParam = '&repo=' . urlencode($this->currentRepo['safe_name']); |
| | + |
| | + $this->git->eachTag(function($name, $sha) use ($repoParam, &$hasTags) { |
| | + $hasTags = true; |
| | + $url = '?hash=' . $sha . $repoParam; |
| | + |
| | + echo '<div class="ref-item">'; |
| | + echo '<span class="ref-type tag">Tag</span>'; |
| | + echo '<a href="' . $url . '" class="ref-name">' . htmlspecialchars($name) . '</a>'; |
| | + echo '<span class="commit-hash" style="margin-left: auto;">' . substr($sha, 0, 7) . '</span>'; |
| | + echo '</div>'; |
| | + }); |
| | + |
| | + if (!$hasTags) { |
| | + echo '<div class="empty-state"><p>No tags found.</p></div>'; |
| | + } |
| | + |
| | + echo '</div>'; // end refs-list |
| | + }, $this->currentRepo); |
| | + } |
| | + |
| | + private function renderBreadcrumbs() { |
| | + $repoUrl = '?repo=' . urlencode($this->currentRepo['safe_name']); |
| | + |
| | + $crumbs = [ |
| | + '<a href="?">Repositories</a>', |
| | + '<a href="' . $repoUrl . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>', |
| | + 'Tags' |
| | + ]; |
| | + |
| | + echo '<div class="breadcrumb">' . implode(' / ', $crumbs) . '</div>'; |
| | + } |
| | +} |
| | |