root/trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php @ 402

Revision 402, 5.3 KB (checked in by aprilp, 8 years ago)

Some kind of virtual login (we need to talk about this).
New User and Node classes
Modified all files to work with the classes.
Remove mgmt_helpers (all done in User class now)

  • 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
22   * @author Copyright (C) 2004 Technologies Coeus inc.
23   */
24  /*Prevent caching*/
25
26require_once BASEPATH.'include/common.php';
27define('DEFAULT_CONTENT_SMARTY_PATH', LOCAL_CONTENT_REL_PATH.DEFAULT_NODE_ID.'/');
28define('NODE_CONTENT_SMARTY_PATH', LOCAL_CONTENT_REL_PATH.CURRENT_NODE_ID.'/');
29define('COMMON_CONTENT_SMARTY_PATH', LOCAL_CONTENT_REL_PATH.'common/');
30
31// load Smarty library
32require_once(BASEPATH.'lib/smarty/Smarty.class.php');
33
34// The setup.php file is a good place to load
35// required application library files, and you
36// can do that right here. An example:
37// require('guestbook/guestbook.lib.php');
38
39class SmartyWifidog extends Smarty {
40
41   function SmartyWifidog()
42   {
43   
44        // Class Constructor. These automatically get set with each new instance.
45
46        $this->Smarty();
47
48        $this->template_dir = BASEPATH;
49        $this->compile_dir = BASEPATH.'tmp/smarty/templates_c/';
50        $this->config_dir = BASEPATH.'tmp/smarty/configs/';
51        $this->cache_dir = BASEPATH.'tmp/smarty/cache/';
52
53        $this->register_modifier("_","_");
54       
55        $this->caching = false;
56        $this->assign('app_name','Wifidog auth server');
57
58        /* We need this for various forms to redirect properly (language form) */
59        $this->assign('request_uri', $_SERVER["REQUEST_URI"]);
60       
61        if(is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_HEADER_NAME))
62          {
63            $this->assign('header_file',NODE_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
64          }
65        else
66          {
67            $this->assign('header_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
68          }
69
70    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
71        $this->assign('portal_page', NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
72    } else {
73        $this->assign('portal_page', DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
74    }
75
76    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
77        $this->assign('login_page', NODE_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
78    } else {
79        $this->assign('login_page', DEFAULT_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
80    }
81       
82        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_FOOTER_NAME))
83          {
84            $this->assign('footer_file',NODE_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
85          }
86        else
87          {
88            $this->assign('footer_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
89          }     
90       
91        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
92          {
93            $this->assign('stylesheet_file',NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
94          }
95        else
96          {
97            $this->assign('stylesheet_file',DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
98          }
99
100/* Common content */
101        $this->assign('common_content_url',COMMON_CONTENT_URL); /* For html href and src */
102        $this->assign('common_content_smarty_path',COMMON_CONTENT_SMARTY_PATH); /* For smarty includes */
103        $this->assign('network_logo_url',COMMON_CONTENT_URL.NETWORK_LOGO_NAME);
104        $this->assign('network_logo_banner_url',COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME);
105        $this->assign('wifidog_logo_url', COMMON_CONTENT_URL.WIFIDOG_LOGO_NAME);
106        $this->assign('wifidog_logo_banner_url',COMMON_CONTENT_URL.WIFIDOG_LOGO_BANNER_NAME);
107       
108/* Usefull stuff from config.php */
109        $this->assign('hotspot_network_name',HOTSPOT_NETWORK_NAME);
110        $this->assign('hotspot_network_url',HOTSPOT_NETWORK_URL);
111
112     $this->assign('hotspot_logo_url', find_local_content_url(HOTSPOT_LOGO_NAME));
113     $this->assign('hotspot_logo_banner_url', find_local_content_url(HOTSPOT_LOGO_BANNER_NAME));
114
115     $this->assign('hotspot_id', CURRENT_NODE_ID);
116   }
117
118/**similar to display(), but will find the content in the appropriate local content directory */
119   function displayLocalContent($template_filename)
120   {
121     if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.$template_filename))
122       {
123         $this->display(NODE_CONTENT_SMARTY_PATH.$template_filename);
124       }
125     else
126       {
127         $this->display(DEFAULT_CONTENT_SMARTY_PATH.$template_filename);
128       }
129   }
130
131   function SetTemplateDir( $template_dir)
132   {
133     $this->template_dir= $template_dir;
134   }
135
136} /* end class SmartyWifidog */
137?>
Note: See TracBrowser for help on using the browser.