| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * Unit view page file.
- *
- * Provides a class with all the properties and methods to display the page.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
- require_once(PATH::PAGE . "Page.php");
- require_once(PATH::ENTITY . "Unit.php");
- /**
- * Unit view page model.
- *
- * @category Page
- */
- class Unit_Page extends Page{
- /**
- * @var Unit Selected Unit.
- */
- private $unit;
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param string $id Selected unit id
- */
- public function __construct($id){
- parent::__construct();
- $this->set_public(true);
- $this->set_view("unit.php");
- $this->unit = new Unit($id, true);
- if ($this->unit == null || $this->unit->get_id() == null){
- $this->set_code(404);
- $this->set_message("Unit not found");
- }
- else{
- $this->set_code(200);
- $this->set_message("OK");
- }
- $this->set_title($this->unit->get_title());
- $this->set_description(get_context()->get_player()->get_name() . "'s " . $this->unit->get_title());
- $this->set_canonical(get_context()->get_player()->get_id() . "/unit/" . $this->unit->get_id());
- $this->add_css("unit.css");
-
- }
- /**
- * Retrieves the selected unit.
- *
- * @return Unit Selected unit.
- */
- public function get_unit(){
- return $this->unit;
- }
- }
|