title = new title;
$this->license = new license;
}
function load($id = 0) {
if ($id != 0) $this->id = $id;
else $id = $this->id;
$conn = &dbconnect();
list($this->release, $this->title->id, $this->title->title,
$this->license->id, $this->license->name, $this->attributes) =
$conn->GetRow("select release, titleid, title, licenseid, licensename, atts from game_view where gameId = $id");
$this->title->gameid = $id;
$series = &$conn->GetRow("select series.seriesid, series.name, gameseries.index from series, gameseries where gameseries.gameid = $this->id and gameseries.seriesid = series.seriesid");
if ($series) {
$this->series = new series;
list($this->series->id, $this->series->name, $this->seriesindex) =
$series;
} else {
$this->series = 0;
$this->seriesindex = "";
}
}
function store() {
$conn = &dbconnect();
if (!$this->license->id)
$this->license->store;
$licenseid = $this->license->id;
$release = escape($this->release);
if (empty($this->id)) {
$result = &$conn->execute("insert into games (release, licenseid) values ($release, $licenseid)");
// Postgres-specific
$oid = $conn->Insert_ID();
$this->id = $conn->GetOne("select gameid from games where oid = $oid");
}
$this->title->gameid = $this->id;
$this->title->store();
$titleid = $this->title->id;
$conn->execute("update games set release=$release, licenseid=$licenseid, titleid=$titleid where gameid = $this->id");
$conn->execute("delete from gameseries where gameid = $this->id");
if ($this->series) {
$seriesid = $this->series->id;
$seriesindex = (empty($this->seriesindex))? "null" : $this->seriesindex;
$conn->execute("insert into gameseries (gameid, seriesid, index) values ($this->id, $seriesid, $seriesindex)");
}
}
function linkto() {
$this->title->linkto();
}
function describe() {
global $tables;
if ($tables) {
$left = "
";
$mid = "
";
$right = "
";
} else {
$left = " ";
$mid = " ";
$right = "\n";
}
// The parts
// s series
// t alternate titles
// p persons
// c companies
// g genres
// d release date
// l license
// a attributes
// P platforms
// R reviews
// A awards
// i ifiction.org links
// L links
// D downloads
// S see also
$parts = getparts();
showhead($this->title->getName());
if ($this->series && $parts['s']) {
echo "
Part of ";
$this->series->linkto();
echo "
\n";
}
findRoles();
global $roles;
if ($tables)
echo "
";
if ($parts['t']) {
$this->getAltTitles();
if (!empty($this->alttitles)) {
echo $left, "Alternate Titles:", $mid;
for ($alt = reset($this->alttitles); $alt;
$alt = current($this->alttitles)) {
echo "";
$alt->describe();
echo "";
if (next($this->alttitles)) echo ", ";
}
if ($tables) echo " \n";
echo $right;
}
}
if ($parts['p']) {
$this->getPersons();
if (empty($this->persons)) {
if ($tables) echo $left, "Author:", $mid;
echo "Anonymous", $right;
} else {
reset($this->persons);
while (list($roleid, $stuff) = each($this->persons)) {
echo $left;
echo ucwords($roles[$roleid]->name);
if (count($stuff)>1) echo "s";
echo ":", $mid;
listnames($stuff);
echo $right;
}
}
}
if ($parts['c']) {
$this->getCompanies();
if (!empty($this->companies)) {
reset($this->companies);
while (list($roleid, $stuff) = each($this->companies)) {
echo $left;
echo ucwords($roles[$roleid]->name);
if (count($stuff)>1) echo "s";
echo ":", $mid;
for (reset($stuff); $company = current($stuff); ) {
$company->linkto();
if (next($stuff)) echo ", ";
}
echo $right;
}
}
}
if ($parts['g']) {
$gens = getGenres();
$this->getGenres();
if (!empty($this->genres)) {
echo $left, "Genre";
if (count($this->genres)>1) echo "s";
echo ":", $mid;
for ($gen = reset($this->genres); $gen; ) {
$gens[$gen]->fullname(1);
$gen = next($this->genres);
if ($gen) {
if ($tables) echo " \n";
else echo ", ";
}
}
echo $right;
}
}
if (!empty($this->release) && $parts['d']) {
if ($tables)
echo $left, "Released:", $mid;
else echo " ";
echo $this->release;
echo $right;
}
if ($this->license->id != 1 && $parts['l']) {
if ($tables)
echo $left, "License:", $mid;
echo $this->license->name;
echo $right;
}
if ($parts['P']) {
$this->getPlatforms();
if (!empty($this->platform)) {
echo $left, "Platform";
if (count($this->platform)>1) echo "s";
echo ":", $mid;
listPlatforms($this->platform,1);
echo $right;
}
}
if ($parts['a']) {
echo $left, "Attributes:", $mid;
listatts($this->attributes);
echo $right;
}
if ($parts['R']) {
$this->getReviews();
for ($r = reset($this->reviews); $r; $r = next($this->reviews)) {
echo $left, "Review:", $mid;
$r->describe();
echo $right;
}
}
if ($parts['A']) {
$this->getAwards();
if (!empty($this->awards)) {
global $up;
if ($tables) echo $left, "Competitions/ Awards:", $mid;
else echo $left, "Competition/Awards:", $mid, " \n";
foreach ($this->awards as $a) {
if ($a->category) echo htmlentities($a->category), ", ";
else if ($a->place) echo ordinal($a->place), " place, ";
else echo "Entered in ";
if ($a->division) echo $a->division, ", ";
echo "compgroupid#$a->compid>";
if ($a->compname) echo $a->compname;
else {
echo $a->name;
if ($a->number) echo " ", $a->number;
}
echo " \n";
}
echo $right;
}
}
if ($parts['i']) {
$this->getIfictions();
if (!empty($this->ifictions)) {
if ($tables) echo $left, "Play Online:", $mid;
for ($ific = reset($this->ifictions); $ific; $ific = next($this->ifictions)) {
$ific->describe();
echo " \n";
}
echo $right;
}
}
if ($parts['L']) {
$this->getLinks();
if (!empty($this->links)) {
echo $left, "Related Links:", $mid;
if (!$tables) echo " ";
for ($link = reset($this->links); $link; $link = next($this->links)) {
$link->describe();
echo " \n";
}
echo $right;
}
}
if ($parts['D']) {
global $showdates;
$this->getContents();
echo $left, "Downloads:", $mid, "
";
while (list($fileid, $stuff) = each($this->contents)) {
$file = new iffile;
$file->load($fileid);
echo "