Animarr/web/titles.php

55 lines
1.4 KiB
PHP

<?php
include "common.php";
use Animarr\Release\Release;
use Animarr\Torrent\Torrent;
$aid = 0;
if(isset($_GET["aid"])){
$aid = intval($_GET["aid"]);
}
$info = $aniDB->getAnime($aid);
if($info === null){
header("Location: index.php");
die();
}
if(isset($_POST) and isset($_POST["title"])){
$database->addAlternateTitle($aid, $_POST["language"], $_POST["title"], $_POST["type"]);
}
printHeader($info["title"]);
echo "<h1>".$info["title"]." <a href=\"https://anidb.net/perl-bin/animedb.pl?show=anime&aid=$aid\" target=\"_blank\">[anidb-$aid]</a></h1>";
echo "<table class=\"table table-striped table-hover\">";
echo "<tr><th>Title</th><th>Language</th><th>Type</th></tr>";
$types = [
1 => "Main",
2 => "Synonym",
3 => "Short",
4 => "Official",
0 => "(Special)"
];
$typeSelect = "";
foreach($types as $i => $n){
$typeSelect .= "<option value=\"$i\">$n</option>";
}
foreach ($database->getAlternateTitles($aid) as $t) {
echo "<tr><td>".htmlentities($t["title"])."</td><td>".htmlentities($t["language"])."</td><td>".$types[$t["type"]]."</td></tr>";
}
echo "<form action=\"titles.php?aid=$aid\" method=\"post\">";
echo "<tr><td><input type=\"text\" name=\"title\"/></td><td><select name=\"language\"><option>x-jat</option><option>en</option></select></td><td><select name=\"type\">$typeSelect</td></tr>";
echo "<tr><td colspan=3><input type=\"submit\" value=\"add new title\"\></td></tr>";
echo "</form>";
echo "</table>";
printFooter();