<?php namespace DDD; require_once "TemuRepo.php"; echo "<a href='generuoti.php'>Generuoti duomenis</a>"; $temuRepo = new TemuRepo(); $res = $temuRepo->getAll(true); if ($res['status'] == 'failed') { echo "<h1>Sorry, something went wrong</h1>"; echo "<p>Message: " . $res['message'] . "</p>"; return; } $temos = $res['data']; //isvesk temas echo "<table width='100%' border='1'>\n <tr>\n <th align='left'>Data</th>\n <th align='left'>Pavadinimas</th>\n <th align='left'>komentaru skaicius</th>\n <th align='left'>komentarai</th>\n </tr>\n"; foreach ($temos as $tema) { echo "<tr>\n <td>" . $tema->getData() . "</td>\n <td>" . $tema->getPavadinimas() . "</td>\n <td>" . $tema->getKomentaruSkaicius() . "</td>\n <td>"; foreach ($tema->getKomentarai() as $komentaras) { echo $komentaras->getData() . ' ' . $komentaras->getKomentaras() . ' ' . $komentaras->getAutorius() . "<br />"; } echo "</td>\n </tr>\n "; } echo "</table>";
<?php namespace DDD; require_once "KomentaruRepo.php"; require_once "TemuRepo.php"; $action = isset($_GET['action']) ? $_GET['action'] : null; if (empty($action)) { echo "<a href='?action=gentem'><h1>Generuoti temas</h1></a>"; echo "<a href='?action=genkom'><h1>Generuoti komentarus</h1></a>"; } if ($action == 'gentem') { $temuRepo = new TemuRepo(); $generuok = $temuRepo->generateEntries(); if ($generuok['status'] == 'success') { echo "<h1>Jūs sėkmingai sugeneravote temas</h1>"; } else { echo "<h1>Klaida</h1>"; echo "<p>" . $generuok['message'] . "</p>"; } } elseif ($action == 'genkom') { $komentaruRepo = new KomentaruRepo(); $generuok = $komentaruRepo->generateEntries(); if ($generuok['status'] == 'success') { echo "<h1>Jūs sėkmingai sugeneravote komentarus</h1>"; } else { echo "<h1>Klaida</h1>"; echo "<p>" . $generuok['message'] . "</p>"; } } if (!empty($action)) {