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

Revision 573, 10.4 KB (checked in by fproulx, 8 years ago)

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

  • Much better stylesheet
  • 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                        $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n";
59                        $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n";
60                        $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n";
61                        $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n";
62                        $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n";
63                        $html .= "<li><a href='hotspot.php'>"._("Hotspot creation and configuration")."</a> - Beta</li>\n";
64                        $html .= "<li><a href='owner_sendfiles.php'>"._("Hotspot owner administration")."</a> - Beta</li>\n";
65
66                        /* Node admin */
67                        $html .= "<div class='admin_section_container'>\n";
68                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">';
69                        $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n";
70
71                        $html .= "<div class='admin_section_data'>\n";
72                        $html .= "<input type='hidden' name='action' value='edit'>\n";
73                        $html .= "<input type='hidden' name='object_class' value='Node'><br>\n";
74
75                        if ($current_user->isSuperAdmin())
76                        {
77                                $sql_additional_where = '';
78                        }
79                        else
80                        {
81                                $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')";
82                        }
83                        $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where);
84                        $html .= "</div>\n";
85                        $html .= "<div class='admin_section_tools'>\n";
86
87                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
88                        $html .= "</div>\n";
89                        $html .= '</form>';
90                        $html .= "</div>\n";
91
92                        /* Network admin */
93                        $html .= "<div class='admin_section_container'>\n";
94                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">';
95                        $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n";
96
97                        $html .= "<div class='admin_section_data'>\n";
98                        $html .= "<input type='hidden' name='action' value='edit'>\n";
99                        $html .= "<input type='hidden' name='object_class' value='Network'><br>\n";
100                        $html .= Network :: getSelectNetworkUI('object_id');
101                        $html .= "</div>\n";
102                        $html .= "<div class='admin_section_tools'>\n";
103
104                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
105                        $html .= "</div>\n";
106                        $html .= '</form>';
107                        $html .= "</div>\n";
108
109                        $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n";
110                        $html .= "</ul>\n";
111
112                }
113                else
114                {
115                        $html .= "<p class='errormsg'>"._("Unknown section:")." $section</p>\n";
116
117                }
118                $this->tool_content = $html;
119        }
120
121        /** Set the content to be displayed in the tool pane */
122        public function setToolContent($html)
123        {
124                $this->tool_content = $html;
125        }
126
127        /** Get the content to be displayed in the tool pane
128         * @param section, one of:  START, LOGIN,
129         * @return HTML markup */
130        private function getToolContent($section = 'START')
131        {
132                $html = '';
133                if ($section = 'START')
134                {
135                        $html .= '<div id="tool_section">'."\n";
136                        $html .= '<div class="tool_user_info">'."\n";
137                        $html .= '<span class="tool_user_info">'."\n";
138                        $user = User :: getCurrentUser();
139                        if ($user != null)
140                        {
141                                $html .= '<p>'._("Logged in as:").' '.$user->getUsername().'</p>'."\n";
142                                $html .= '<a class="administration" HREF="?content=myprofile"><img class="administration" src="/images/profile.gif" border="0"> My profile</a>'."\n";
143                                $html .= '<a class="administration" HREF="/login/?logout=true"><img class="administration" src="/images/logout.gif" border="0"> Logout</a>'."\n";
144
145                        }
146                        else
147                        {
148                                $html .= '<p>'._("NOT logged in.").' <a href="'.BASE_SSL_PATH.'login/">'. ("Login?").'</a></p>'."\n";
149                                $html .= '<a class="administration" HREF="'.Network :: getCurrentNetwork()->getHomepageURL().'"><img class="administration" src="/images/lien_ext.gif"> '.Network :: getCurrentNetwork()->getName().'</a>'."\n";
150                                $html .= '<a class="administration" HREF="'.BASE_NON_SSL_PATH.'/faq.php"><img class="administration" src="'.BASE_NON_SSL_PATH.'/images/where.gif"> '._("Where am I?").'</a>'."\n";
151                        }
152
153                        $html .= "</span>"."\n"; //End tool_user_info
154                        $html .= "</div>"."\n"; //End tool_user_info
155
156                        $html .= '<div class="navigation">'."\n";
157                        /*
158                        $html .= '<a href="index.php" class="navigation">'._("Start").'</a>'."\n";
159                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
160                        $html .= '<a href="users.php" class="navigation">'._("Users Online").'</a>'."\n";
161                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
162                        $html .= '<a href="news.php" class="navigation">'._("News").'</a>'."\n";
163                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
164                        $html .= '<a href="hotspots.php" class="navigation">'._("Hotspots").'</a>'."\n";
165                        */
166                        $html .= '<span class="navigation">';
167                        $html .= Network :: getCurrentNetwork()->getName().". Building your wireless community";
168                        $html .= '</span>';
169                        $html .= "</div>"."\n"; //End navigation
170
171                        $html .= '<div class="language">'."\n";
172                        $html .= '<form class="language" name="lang_form" method="post" action="'.$_SERVER['REQUEST_URI'].'">'."\n";
173                        $html .= _("Language:")."\n";
174                        $html .= "<select name='lang' onChange='javascript: document.lang_form.submit();'>"."\n";
175                        global $AVAIL_LOCALE_ARRAY; //From config file
176                        foreach ($AVAIL_LOCALE_ARRAY as $lang_ids => $lang_names)
177                        {
178                                if (Locale :: getCurrentLocale()->getId() == $lang_ids)
179                                {
180                                        $selected = "SELECTED";
181                                }
182                                else
183                                {
184                                        $selected = '';
185                                }
186                                $html .= '<option label="'.$lang_names.'" value="'.$lang_ids.'" '.$selected.'>'.$lang_names.'</option>'."\n";
187                        }
188                        $html .= "</select>"."\n";
189                        $html .= "</form>"."\n";
190
191                        $html .= "</div>"."\n"; //End language
192
193                        $html .= "<div class='tool_content'>"."\n";
194                        /******************************/
195                        $html .= $this->tool_content;
196                        /******************************/
197                        $html .= "</div>"."\n"; //End tool_content
198                        $html .= '<div class="avis">'."\n";
199                        $html .= '<span class="avis">'."\n";
200                        $html .= sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName());
201                        $html .= _("Please inform us of any problem or service interruption at:");
202                        $tech_support_email = Network :: getCurrentNetwork()->getTechSupportEmail();
203                        $html .= '<a href="mailto:'.$tech_support_email.'">'.$tech_support_email.'</a>'."\n";
204                        $html .= "</span>"."\n"; //End avis
205                        $html .= "</div>"."\n"; //End avis
206                        $html .= "</div>"."\n"; //End tool_section
207
208                }
209                else
210                        if ($section = 'LOGIN')
211                        {
212
213                        }
214                        else
215                        {
216                                $html .= '<p class="errmsg">MainUI::getToolContent(): Unknown section!</p>'."\n";
217                        }
218                return $html;
219        }
220
221        /** Display the page */
222        public function display()
223        {
224                $html = '';
225                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html");
226
227                /**** Headers ****/
228                $html .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'."\n";
229                $html .= '<html>'."\n";
230                $html .= '<head>'."\n";
231                $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n";
232                $html .= '<meta http-equiv="Pragma" CONTENT="no-cache">'."\n";
233                $html .= '<meta http-equiv="Expires" CONTENT="-1">'."\n";
234                $html .= "<html>\n";
235                $html .= "<head>\n";
236                $html .= "<title>{$this->title}</title>\n";
237                $html .= "<style type='text/css'>\n";
238                if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
239                {
240                        $stylesheet_file = NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
241                }
242                else
243                {
244                        $stylesheet_file = DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
245                }
246                $html .= $this->smarty->fetch($stylesheet_file);
247                $html .= "</style>\n";
248                $html .= "</head>\n";
249
250                $html .= "<body>"."\n";
251                $html .= '<div class="outer_container">'."\n";
252        /**** Tools ******/
253        $html .= $this->getToolContent();
254       
255                /**** Main section ****/
256                $html .= "<div id='main_section'>"."\n";
257                $html .= $this->main_content;
258                $html .= "</div>"."\n"; //End main_section
259                $html .= '</div>'."\n"; //End outer_container
260                $html .= "</body>"."\n";
261                $html .= "</html>"."\n";
262                echo $html;
263
264                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
265        }
266} //End class
267?>
Note: See TracBrowser for help on using the browser.