From 9b0f531f0eb7611bf8b8211349f16934ecd44bdd Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Fri, 8 Jan 2016 10:52:38 -0500 Subject: [PATCH] Add systems and stations. --- lib/header.php | 2 +- lib/station.php | 74 ++++++++++++++++++++++++++++++ lib/system.php | 43 +++++++++++++++++ propel/build/classes/buckyball/Station.php | 31 +++++++++++++ propel/schema.xml | 2 + 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 lib/station.php create mode 100644 lib/system.php create mode 100644 propel/build/classes/buckyball/Station.php diff --git a/lib/header.php b/lib/header.php index 8788241..f17ad4e 100644 --- a/lib/header.php +++ b/lib/header.php @@ -5,7 +5,7 @@ Buckyball Racing Club"; - foreach (array("competitor", "hull", "ship", "system", "race", "raikogram", "entry") as $what) { + foreach (array("competitor", "hull", "ship", "system", "station", "race", "raikogram", "entry") as $what) { $title = preg_replace('/y$/', 'ie', $what); echo " | " . ucfirst($title) . "s"; } diff --git a/lib/station.php b/lib/station.php new file mode 100644 index 0000000..caf5b68 --- /dev/null +++ b/lib/station.php @@ -0,0 +1,74 @@ +

Stations

+Missing station name!

\n"; + return false; + } + $orbital = 0 + (! ($type & Station::OrbitalFlag())); + $large_pad = 0 + (! ($type & Station::LargePadFlag())); + + $station = new Station; + $station->setSystemId($system_id); + $station->setOrbital($orbital); + $station->setLargePad($large_pad); + $station->setName($name); + try { + $station->save(); + return true; + } + catch (Exception $e) { + echo "

Error adding station: " . $e->getMessage() . "

\n"; + } + return false; + } + + function module_station($action) { + if ($_POST['add_station']) { + if (add_station($_POST["system_id"], $_POST["type"], $_POST["name"])) unset($_POST); + } + + $q = new StationQuery; + $q->joinWith('Station.System'); + $stations = $q->orderBy('System.Name')->orderByName()->find(); + foreach ($stations as $station) { + $station_name = $station->getName(); + $system_name = $station->getSystem()->getName(); + $type = $station->getType(); + echo "

$station_name $type in $system_name

\n"; + } + + echo "
\n"; + $sq = new SystemQuery; + $systems = $sq->orderByName()->find(); + if (! count($systems)) { + echo "

Add systems before adding stations.

\n"; + return; + } + form(); + echo "

Add a new station: "; + echo "System: \n"; + echo "type: \n"; + input("name", $_POST["name"]); + echo "\n"; + + submit("add_station", "Add"); + echo "

\n"; + end_form(); + } +?> + diff --git a/lib/system.php b/lib/system.php new file mode 100644 index 0000000..57027f1 --- /dev/null +++ b/lib/system.php @@ -0,0 +1,43 @@ +

Systems

+Missing system name!

\n"; + return false; + } + $system = new System; + $system->setName($system_name); + try { + $system->save(); + return true; + } + catch (Exception $e) { + echo "

Error adding system: " . $e->getMessage() . "

\n"; + } + return false; + } + + function module_system($action) { + if ($_POST['add_system']) { + if (add_system($_POST["system_name"])) unset($_POST); + } + + $q = new SystemQuery; + $systems = $q->orderByName()->find(); + if (! count($systems)) echo "

No systems

\n"; + foreach ($systems as $system) { + $system_name = $system->getName(); + echo "

$system_name

\n"; + } + + echo "
\n"; + form(); + echo "

Add a new system: "; + input("system_name", $_POST['system_name']); + submit("add_system", "Add"); + echo "

\n"; + end_form(); + } + +?> diff --git a/propel/build/classes/buckyball/Station.php b/propel/build/classes/buckyball/Station.php new file mode 100644 index 0000000..c9c4571 --- /dev/null +++ b/propel/build/classes/buckyball/Station.php @@ -0,0 +1,31 @@ +getOrbital()) { + if ($this->getLargePad()) return "Starport"; + else return "Outpost"; + } + else { + if ($this->getLargePad()) return "Base"; + else return "Settlement"; + } + } +} diff --git a/propel/schema.xml b/propel/schema.xml index 23b8ffc..510b77c 100644 --- a/propel/schema.xml +++ b/propel/schema.xml @@ -73,6 +73,8 @@ + + -- 2.7.4