root/trunk/wifidog-auth/wifidog/hotspots_map.php @ 1034

Revision 1034, 7.3 KB (checked in by fproulx, 7 years ago)

2006-05-10 François Proulx <francois.proulx@…>

  • Fixed Google Maps script path to images.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5// +-------------------------------------------------------------------+
6// | WiFiDog Authentication Server                                     |
7// | =============================                                     |
8// |                                                                   |
9// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10// | portal suite.                                                     |
11// +-------------------------------------------------------------------+
12// | PHP version 5 required.                                           |
13// +-------------------------------------------------------------------+
14// | Homepage:     http://www.wifidog.org/                             |
15// | Source Forge: http://sourceforge.net/projects/wifidog/            |
16// +-------------------------------------------------------------------+
17// | This program is free software; you can redistribute it and/or     |
18// | modify it under the terms of the GNU General Public License as    |
19// | published by the Free Software Foundation; either version 2 of    |
20// | the License, or (at your option) any later version.               |
21// |                                                                   |
22// | This program is distributed in the hope that it will be useful,   |
23// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25// | GNU General Public License for more details.                      |
26// |                                                                   |
27// | You should have received a copy of the GNU General Public License |
28// | along with this program; if not, contact:                         |
29// |                                                                   |
30// | Free Software Foundation           Voice:  +1-617-542-5942        |
31// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33// |                                                                   |
34// +-------------------------------------------------------------------+
35
36/**
37 * Network map/status page.
38 *
39 * @package    WiFiDogAuthServer
40 * @author     Francois Proulx <francois.proulx@gmail.com>
41 * @author     Max Horvath <max.horvath@maxspot.de>
42 * @copyright  2005-2006 Francois Proulx, Technologies Coeus inc.
43 * @copyright  2006 Max Horvath, maxspot GmbH
44 * @version    Subversion $Id$
45 * @link       http://www.wifidog.org/
46 */
47
48/**
49 * Load required files
50 */
51require_once(dirname(__FILE__) . '/include/common.php');
52
53require_once('include/common_interface.php');
54require_once('classes/MainUI.php');
55require_once('classes/Network.php');
56require_once('classes/Node.php');
57require_once('classes/User.php');
58require_once('classes/Server.php');
59
60// Get information about user
61$currentUser = User::getCurrentUser();
62
63// Check if Google maps support has been enabled
64if (!defined("GMAPS_HOTSPOTS_MAP_ENABLED") || (defined("GMAPS_HOTSPOTS_MAP_ENABLED") && GMAPS_HOTSPOTS_MAP_ENABLED === false)) {
65    header("Location: hotspot_status.php");
66    exit();
67}
68
69// Check if user is at a Hotspot and if he is authenticated
70if (!is_null(Node::getCurrentRealNode()) && !$currentUser) {
71    header("Location: hotspot_status.php");
72    exit();
73}
74
75// Init ALL smarty SWITCH values
76$smarty->assign('sectionTOOLCONTENT', false);
77$smarty->assign('sectionMAINCONTENT', false);
78
79// Init ALL smarty values
80$smarty->assign('isSuperAdmin', false);
81$smarty->assign('isOwner', false);
82$smarty->assign('selectNetworkUI', null);
83
84/**
85 * Define user security levels for the template
86 *
87 * These values are used in the default template of WiFoDog but could be used
88 * in a customized template to restrict certain links to specific user
89 * access levels.
90 */
91$smarty->assign('isSuperAdmin', $currentUser && $currentUser->isSuperAdmin());
92$smarty->assign('isOwner', $currentUser && $currentUser->isOwner());
93
94/*
95 * Header JavaScripts
96 */
97
98// Add Google Maps JavaScript (must set config values)
99$html_headers  = "<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;&key=" . Server::getCurrentServer()->getGoogleAPIKey() . "' type='text/javascript'></script>";
100$html_headers .= "<script src='js/hotspots_status_map.js' type='text/javascript'></script>";
101
102/*
103 * Tool content
104 */
105
106// Set section of Smarty template
107$smarty->assign('sectionTOOLCONTENT', true);
108
109// Compile HTML code
110$html = $smarty->fetch("templates/sites/hotspots_map.tpl");
111
112/*
113 * Main content
114 */
115
116// Reset ALL smarty SWITCH values
117$smarty->assign('sectionTOOLCONTENT', false);
118$smarty->assign('sectionMAINCONTENT', false);
119
120// Set section of Smarty template
121$smarty->assign('sectionMAINCONTENT', true);
122
123// Set network selector
124$smarty->assign('selectNetworkUI', Network::getSelectNetworkUI('network_map', (!empty($_REQUEST['network_map']) ? Network::getObject($_REQUEST['network_map']) : Network::getCurrentNetwork())) . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : ""));
125
126// Compile HTML code
127$html_body = $smarty->fetch("templates/sites/hotspots_map.tpl");
128
129/*
130 * Footer JavaScripts
131 */
132
133// Get GIS data to set
134if (!empty($_REQUEST['network_map'])) {
135    $network = Network::getObject($_REQUEST['network_map']);
136} else {
137    $network = Network::getCurrentNetwork();
138}
139
140$gis_data = $network->getGisLocation();
141
142// The onLoad code should only be called once all DIV are created.
143$script  = "<script type=\"text/javascript\"><!--\n";
144$script .= "    function toggleOverlay(name)\n";
145$script .= "    {\n";
146$script .= "        o = document.getElementById('map_postalcode_overlay');\n";
147$script .= "        if (o != undefined) {\n";
148$script .= "            if (o.style.display == 'block') {\n";
149$script .= "                o.style.display = 'none';\n";
150$script .= "            } else {\n";
151$script .= "                o.style.display = 'block';\n";
152$script .= "            }\n";
153$script .= "        }\n";
154$script .= "    }\n";
155$script .= "    translations = new HotspotsMapTranslations('" . addcslashes(_("Sorry, your browser does not support Google Maps."), "'") . "', '" . addcslashes(_("Homepage"), "'") . "', '" . addcslashes(_("Show me on the map"), "'") . "', '" . addcslashes(_("Loading, please wait..."), "'") . "');\n";
156$script .= "    hotspots_map = new HotspotsMap('map_frame', 'hotspots_map', translations, '" . COMMON_IMAGES_URL . "');\n";
157$script .= "    hotspots_map.setXmlSourceUrl('" . GMAPS_XML_SOURCE_URL . "');\n";
158$script .= "    hotspots_map.setHotspotsInfoList('map_hotspots_list');\n";
159$script .= "    hotspots_map.setInitialPosition(" . $gis_data->getLatitude() . ", " . $gis_data->getLongitude() . ", " . $gis_data->getAltitude() . ");\n";
160$script .= "    hotspots_map.setMapType(" . $network->getGisMapType() . ");\n";
161$script .= "    hotspots_map.redraw();\n";
162$script .= "//-->\n";
163$script .= "</script>\n";
164
165/*
166 * Render output
167 */
168$ui = new MainUI();
169$ui->setTitle(_("Hotspots status map"));
170$ui->setHtmlHeader($html_headers);
171$ui->addContent('left_area_middle', $html);
172$ui->addContent('main_area_middle', $html_body);
173$ui->addFooterScript($script);
174$ui->display();
175
176/*
177 * Local variables:
178 * tab-width: 4
179 * c-basic-offset: 4
180 * c-hanging-comment-ender-p: nil
181 * End:
182 */
183
184?>
Note: See TracBrowser for help on using the browser.