From 1a09d905ff69c0fa72b6bf6ebb51314edd5b2ff9 Mon Sep 17 00:00:00 2001 From: Kevin Abel <kevin.abel.0@gmail.com> Date: Fri, 23 May 2014 17:27:53 -0500 Subject: [PATCH] Add support for building code aliases and hide aliased buildings --- data/php/building_aliases.inc.php | 24 +++++++++++++++++++ data/php/hidden_buildings.inc.php | 21 ++++++++++++---- src/UNL/TourMap/BuildingData.php | 12 ++++++++++ src/UNL/TourMap/MarkerList/Buildings.php | 5 ++++ .../html/UNL/TourMap/GoogleMap.tpl.php | 9 +++++++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 data/php/building_aliases.inc.php diff --git a/data/php/building_aliases.inc.php b/data/php/building_aliases.inc.php new file mode 100644 index 00000000..e705a888 --- /dev/null +++ b/data/php/building_aliases.inc.php @@ -0,0 +1,24 @@ +<?php +return array( + + // EAST CAMPUS + + // CITY CAMPUS + + 'HEPP' => 'NRC', + 'PIPH' => 'NRC', + 'RAYH' => 'NRC', + 'LOVH' => 'NRC', + 'SELD' => 'SELQ', + 'SELE' => 'SELQ', + 'SELF' => 'SELQ', + 'SELG' => 'SELQ', + 'SELH' => 'SELQ', + 'SELJ' => 'SELQ', + 'SELK' => 'SELQ', + 'SELL' => 'SELQ', + 'STE' => 'MEMS', + 'STNO' => 'MEMS', + 'STSO' => 'MEMS', + 'STW' => 'MEMS', +); diff --git a/data/php/hidden_buildings.inc.php b/data/php/hidden_buildings.inc.php index 52294dfd..7af66dd9 100644 --- a/data/php/hidden_buildings.inc.php +++ b/data/php/hidden_buildings.inc.php @@ -46,7 +46,6 @@ return array( 'SVC', 'UTPE', 'W1', - 'W2', 'WAST', 'WEED', @@ -55,6 +54,7 @@ return array( '2', '1631', '1740', + '1820', // Demo'd 'ARCL', 'ARCW', 'BOAT', @@ -66,22 +66,35 @@ return array( 'FMF', 'GE', 'HAY', + 'HEPP', // Aliased to unofficial 'HZM', 'HZMC', + 'LOVH', // Aliased to unofficial 'LSMB', 'LSS', 'LSCS', 'MAIN', 'MSTO', + 'PIPH', // Aliased to unofficial + 'RAYH', // Aliased to unofficial 'REUN', + 'SELD', // Aliased to unofficial + 'SELE', // Aliased to unofficial + 'SELF', // Aliased to unofficial + 'SELG', // Aliased to unofficial + 'SELH', // Aliased to unofficial + 'SELJ', // Aliased to unofficial + 'SELK', // Aliased to unofficial + 'SELL', 'SPCW', 'STSB', 'STS', 'STSC', - 'STNO', - 'STSO', + 'STE', // Aliased to unofficial + 'STNO', // Aliased to unofficial + 'STSO', // Aliased to unofficial 'SSTD', - 'STW', + 'STW', // Aliased to unofficial 'STNC', 'STN', 'SYF', diff --git a/src/UNL/TourMap/BuildingData.php b/src/UNL/TourMap/BuildingData.php index fed7f5ad..bf39dc01 100644 --- a/src/UNL/TourMap/BuildingData.php +++ b/src/UNL/TourMap/BuildingData.php @@ -11,10 +11,13 @@ class UNL_TourMap_BuildingData { protected $db; + protected $codeAliases; + public function __construct(Adapter $db) { $this->db = $db; $this->checkDb(); + $this->codeAliases = require UNL_TourMap::getDataDir() . '/php/building_aliases.inc.php'; } public function checkDb() @@ -140,9 +143,18 @@ class UNL_TourMap_BuildingData public function getByCode($code) { + if (isset($this->codeAliases[$code])) { + $code = $this->codeAliases[$code]; + } + return $this->executeSelect(array('code' => $code)); } + public function getAliases() + { + return $this->codeAliases; + } + public function getAllBuildings() { return $this->executeSelect(array('location' => array( diff --git a/src/UNL/TourMap/MarkerList/Buildings.php b/src/UNL/TourMap/MarkerList/Buildings.php index 58572acf..dc0ea764 100644 --- a/src/UNL/TourMap/MarkerList/Buildings.php +++ b/src/UNL/TourMap/MarkerList/Buildings.php @@ -48,4 +48,9 @@ class UNL_TourMap_MarkerList_Buildings extends FilterIterator implements UNL_Tou { return new UNL_TourMap_Marker_Building(parent::current()); } + + public function getAliases() + { + return $this->buildingDriver->getAliases(); + } } \ No newline at end of file diff --git a/www/templates/html/UNL/TourMap/GoogleMap.tpl.php b/www/templates/html/UNL/TourMap/GoogleMap.tpl.php index d6164fd5..85859657 100644 --- a/www/templates/html/UNL/TourMap/GoogleMap.tpl.php +++ b/www/templates/html/UNL/TourMap/GoogleMap.tpl.php @@ -85,6 +85,15 @@ WDN.loadCSS('<?php echo UNL_TourMap::getURL(); ?>css/map.css'); UNLTourMap.initialize(); <?php endif; ?> + <?php + if ($context->getRaw('markers') instanceof UNL_TourMap_MarkerList_Buildings) { + $buildings = $context->getRaw('markers'); + } else { + $buildings = new UNL_TourMap_MarkerList_Buildings(); + } + ?> + UNLTourMap.setBuildingAliases(<?php echo json_encode($buildings->getAliases()) ?>); + <?php if ($context->getRawObject() instanceof UNL_TourMap_GoogleMap_DynamicCenter) : ?> UNLTourMap.openBuildingInfo("<?php echo $context->getRawObject()->options['code']; ?>", true); <?php endif; ?> -- GitLab