root/trunk/wifidog-auth/wifidog/classes/MainUI.php @ 599

Revision 597, 11.8 KB (checked in by fproulx, 8 years ago)

2005-04-28 Fran�ois Proulx <francois.proulx@…>

  • More translations in .PO
  • 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 * This program is free software; you can redistribute it and/or    *
4 * modify it under the terms of the GNU General Public License as   *
5 * published by the Free Software Foundation; either version 2 of   *
6 * the License, or (at your option) any later version.              *
7 *                                                                  *
8 * This program is distributed in the hope that it will be useful,  *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
11 * GNU General Public License for more details.                     *
12 *                                                                  *
13 * You should have received a copy of the GNU General Public License*
14 * along with this program; if not, contact:                        *
15 *                                                                  *
16 * Free Software Foundation           Voice:  +1-617-542-5942       *
17 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
18 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
19 *                                                                  *
20 \********************************************************************/
21/**@file MainUI.php
22 * @author Copyright (C) 2005 Technologies Coeus inc.
23 */
24require_once BASEPATH.'include/common.php';
25require_once BASEPATH.'include/common_interface.php';
26/** Style contains functions managing headers, footers, stylesheet, etc.
27 */
28class MainUI
29{
30        private $main_content; /**<Content to be displayed in the main pane */
31        private $tool_content; /**<Content to be displayed in the tool pane */
32        private $smarty;
33        private $title;
34        function __construct()
35        {
36                $this->smarty = new SmartyWifidog();
37                $this->title = Network :: getCurrentNetwork()->getName().' '._("authentication server"); //Default title
38        }
39
40        /** Set the content to be displayed in the main pane */
41        public function setMainContent($html)
42        {
43                $this->main_content = $html;
44        }
45        /** Set the title of the page */
46        public function setTitle($title_string)
47        {
48                $this->title = $title_string;
49        }
50        /** Set the section to be displayed in the tool pane */
51        public function setToolSection($section)
52        {
53                if ($section == 'ADMIN')
54                {
55                        $current_user = User :: getCurrentUser();
56                        $html = '';
57                        $html .= "<ul>\n";
58           
59            if($current_user->isSuperAdmin())
60            {
61                        $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n";
62                        $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n";
63                        $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n";
64                        $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n";
65                        $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n";
66                        $html .= "<li><a href='hotspot.php'>"._("Hotspot creation and configuration")."</a> - Beta</li>\n";
67                        $html .= "<li><a href='owner_sendfiles.php'>"._("Hotspot owner administration")."</a> - Beta</li>\n";
68            }
69
70                        /* Node admin */
71                        $html .= "<div class='admin_section_container'>\n";
72                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">';
73                        $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n";
74
75                        $html .= "<div class='admin_section_data'>\n";
76                        $html .= "<input type='hidden' name='action' value='edit'>\n";
77                        $html .= "<input type='hidden' name='object_class' value='Node'><br>\n";
78
79                        if ($current_user->isSuperAdmin())
80                        {
81                                $sql_additional_where = '';
82                        }
83                        else
84                        {
85                                $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')";
86                        }
87            $html .= "<div id='NodeSelector'>\n";
88                        $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where);
89            $html .= "</div>\n";
90                        $html .= "</div>\n";
91                        $html .= "<div class='admin_section_tools'>\n";
92
93                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
94                        $html .= "</div>\n";
95                        $html .= '</form>';
96                        $html .= "</div>\n";
97
98                        /* Network admin */
99            if($current_user->isSuperAdmin())
100            {
101                        $html .= "<div class='admin_section_container'>\n";
102                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">';
103                        $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n";
104   
105                        $html .= "<div class='admin_section_data'>\n";
106                        $html .= "<input type='hidden' name='action' value='edit'>\n";
107                        $html .= "<input type='hidden' name='object_class' value='Network'><br>\n";
108                        $html .= Network :: getSelectNetworkUI('object_id');
109                        $html .= "</div>\n";
110                        $html .= "<div class='admin_section_tools'>\n";
111   
112                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
113                        $html .= "</div>\n";
114                        $html .= '</form>';
115                        $html .= "</div>\n";
116            }
117
118                        $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n";
119                        $html .= "</ul>\n";
120
121                }
122                else
123                {
124                        $html .= "<p class='errormsg'>"._("Unknown section:")." $section</p>\n";
125
126                }
127                $this->tool_content = $html;
128        }
129
130        /** Set the content to be displayed in the tool pane */
131        public function setToolContent($html)
132        {
133                $this->tool_content = $html;
134        }
135
136        /** Get the content to be displayed in the tool pane
137         * @param section, one of:  START, LOGIN,
138         * @return HTML markup */
139        private function getToolContent($section = 'START')
140        {
141        global $session;
142                $html = '';
143                if ($section = 'START')
144                {
145                        $html .= '<div id="tool_section">'."\n";
146                        $html .= '<div class="tool_user_info">'."\n";
147                        $html .= '<span class="tool_user_info">'."\n";
148                        $user = User :: getCurrentUser();
149                        if ($user != null)
150                        {
151                                $html .= '<p>'._("Logged in as:").' '.$user->getUsername().'</p>'."\n";
152                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'?content=myprofile"><img class="administration" src="/images/profile.gif" border="0"> '._("My profile").'</a>'."\n";
153               
154                $gw_id = $session->get(SESS_GW_ID_VAR);
155                $gw_address = $session->get(SESS_GW_ADDRESS_VAR);
156                $gw_port = $session->get(SESS_GW_PORT_VAR);
157               
158                if($gw_id && $gw_address && $gw_port)
159                    $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'login/?logout=true&gw_id='.$gw_id.'&gw_address='.$gw_address.'&gw_port='.$gw_port.'"><img class="administration" src="/images/logout.gif" border="0"> '._("Logout").'</a>'."\n";
160                else
161                                    $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'login/?logout=true"><img class="administration" src="/images/logout.gif" border="0"> '._("Logout").'</a>'."\n";
162
163                        }
164                        else
165                        {
166                // If the user connects physically ( through a gateway don't show the confusing login message )
167                if(empty($_REQUEST['gw_id']) || empty($_REQUEST['gw_address']) || empty($_REQUEST['gw_port'])) 
168                    $html .= '<p>'._("NOT logged in.").' <a href="'.BASE_SSL_PATH.'login/">'. ("Login?").'</a></p>'."\n";
169                                $html .= '<a class="administration" HREF="'.Network :: getCurrentNetwork()->getHomepageURL().'"><img class="administration" src="/images/lien_ext.gif"> '.Network :: getCurrentNetwork()->getName().'</a>'."\n";
170                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'faq.php"><img class="administration" src="/images/where.gif"> '._("Where am I?").'</a>'."\n";
171                        }
172
173                        $html .= "</span>"."\n"; //End tool_user_info
174                        $html .= "</div>"."\n"; //End tool_user_info
175
176                        $html .= '<div class="navigation">'."\n";
177                        /*
178                        $html .= '<a href="index.php" class="navigation">'._("Start").'</a>'."\n";
179                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
180                        $html .= '<a href="users.php" class="navigation">'._("Users Online").'</a>'."\n";
181                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
182                        $html .= '<a href="news.php" class="navigation">'._("News").'</a>'."\n";
183                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
184                        $html .= '<a href="hotspots.php" class="navigation">'._("Hotspots").'</a>'."\n";
185                        */
186                        $html .= '<span class="navigation">';
187                        $html .= Network :: getCurrentNetwork()->getName()." "._("Building your wireless community");
188                        $html .= '</span>';
189                        $html .= "</div>"."\n"; //End navigation
190
191                        $html .= '<div class="language">'."\n";
192                        $html .= '<form class="language" name="lang_form" method="post" action="'.$_SERVER['REQUEST_URI'].'">'."\n";
193                        $html .= _("Language:")."\n";
194                        $html .= "<select name='lang' onChange='javascript: document.lang_form.submit();'>"."\n";
195                        global $AVAIL_LOCALE_ARRAY; //From config file
196                        foreach ($AVAIL_LOCALE_ARRAY as $lang_ids => $lang_names)
197                        {
198                                if (Locale :: getCurrentLocale()->getId() == $lang_ids)
199                                {
200                                        $selected = "SELECTED";
201                                }
202                                else
203                                {
204                                        $selected = '';
205                                }
206                                $html .= '<option label="'.$lang_names.'" value="'.$lang_ids.'" '.$selected.'>'.$lang_names.'</option>'."\n";
207                        }
208                        $html .= "</select>"."\n";
209                        $html .= "</form>"."\n";
210
211                        $html .= "</div>"."\n"; //End language
212
213                        $html .= "<div class='tool_content'>"."\n";
214                        /******************************/
215                        $html .= $this->tool_content;
216                        /******************************/
217                        $html .= "</div>"."\n"; //End tool_content
218                        $html .= '<div class="avis">'."\n";
219                        $html .= '<span class="avis">'."\n";
220                        $html .= sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName());
221                        $html .= _("Please inform us of any problem or service interruption at:");
222                        $tech_support_email = Network :: getCurrentNetwork()->getTechSupportEmail();
223                        $html .= '<a href="mailto:'.$tech_support_email.'">'.$tech_support_email.'</a>'."\n";
224                        $html .= "</span>"."\n"; //End avis
225                        $html .= "</div>"."\n"; //End avis
226                        $html .= "</div>"."\n"; //End tool_section
227
228                }
229                else
230                        if ($section = 'LOGIN')
231                        {
232
233                        }
234                        else
235                        {
236                                $html .= '<p class="errmsg">MainUI::getToolContent(): Unknown section!</p>'."\n";
237                        }
238                return $html;
239        }
240
241        /** Display the page */
242        public function display()
243        {
244                $html = '';
245                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html");
246
247                /**** Headers ****/
248                $html .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'."\n";
249                $html .= '<html>'."\n";
250                $html .= '<head>'."\n";
251                $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n";
252                $html .= '<meta http-equiv="Pragma" CONTENT="no-cache">'."\n";
253                $html .= '<meta http-equiv="Expires" CONTENT="-1">'."\n";
254                $html .= "<html>\n";
255                $html .= "<head>\n";
256                $html .= "<title>{$this->title}</title>\n";
257                $html .= "<style type='text/css'>\n";
258                if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
259                {
260                        $stylesheet_file = NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
261                }
262                else
263                {
264                        $stylesheet_file = DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
265                }
266                $html .= $this->smarty->fetch($stylesheet_file);
267                $html .= "</style>\n";
268                $html .= "</head>\n";
269
270                $html .= "<body>"."\n";
271                $html .= '<div class="outer_container">'."\n";
272       
273        /**** Tools ******/
274        $html .= $this->getToolContent();
275       
276                /**** Main section ****/
277                $html .= "<div id='main_section'>"."\n";
278                $html .= $this->main_content;
279                $html .= "</div>"."\n"; //End main_section
280       
281                $html .= '</div>'."\n"; //End outer_container
282                $html .= "</body>"."\n";
283                $html .= "</html>"."\n";
284                echo $html;
285
286                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
287        }
288   
289    function displayError($errmsg)
290    {
291        $html = "<p>$errmsg</p>\n";
292        $html .= "<p>"._("Please get in touch with ")."<a href='{TECH_SUPPORT_EMAIL}'>{TECH_SUPPORT_EMAIL}</a></p>";
293        $this->setMainContent($html);
294        $this->display();   
295    }
296   
297} //End class
298?>
Note: See TracBrowser for help on using the browser.