<?php require_once __DIR__ . '/BasePage.php'; require_once __DIR__ . '/../render/TagRenderer.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 '<table class="tag-table">'; echo '<thead>'; echo '<tr>'; echo '<th>Name</th>'; echo '<th>Message</th>'; echo '<th>Author</th>'; echo '<th class="tag-age-header">Age</th>'; echo '<th class="tag-commit-header">Commit</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; $tags = []; $this->git->eachTag( function( Tag $tag ) use ( &$tags ) { $tags[] = $tag; } ); usort( $tags, function( Tag $a, Tag $b ) { return $a->compare( $b ); } ); $renderer = new HtmlTagRenderer( $this->currentRepo['safe_name'] ); if( empty( $tags ) ) { echo '<tr><td colspan="5"><div class="empty-state">' . '<p>No tags found.</p></div></td></tr>'; } else { foreach( $tags as $tag ) { $tag->render( $renderer ); } } echo '</tbody>'; echo '</table>'; }, $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>'; } }