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

Revision 566, 5.4 KB (checked in by benoitg, 8 years ago)

2005-04-25 Benoit Gr�goire <bock@…>

  • Integration merge, should work, but there will be display problems everywhere. Expect further commits today.
  • Almost 100% complete Network abstraction
  • Much better object encapsulation. Deprecated methods not removed yet.
  • Add MainUI class. Used to display the interface. Inner workings still need work.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[152]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
[566]41   function __construct()
[152]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/';
[316]52
[542]53        /* Register the _ smarty modifier to call the _()
54         * PHP function which is the gettext() function
55         */
[316]56        $this->register_modifier("_","_");
[152]57       
58        $this->caching = false;
59        $this->assign('app_name','Wifidog auth server');
[323]60
61        /* We need this for various forms to redirect properly (language form) */
62        $this->assign('request_uri', $_SERVER["REQUEST_URI"]);
[152]63       
64        if(is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_HEADER_NAME))
65          {
66            $this->assign('header_file',NODE_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
67          }
68        else
69          {
70            $this->assign('header_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
71          }
[316]72
73    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
74        $this->assign('portal_page', NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
75    } else {
76        $this->assign('portal_page', DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
77    }
78
79    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
80        $this->assign('login_page', NODE_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
81    } else {
82        $this->assign('login_page', DEFAULT_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
83    }
[152]84       
85        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_FOOTER_NAME))
86          {
87            $this->assign('footer_file',NODE_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
88          }
89        else
90          {
91            $this->assign('footer_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
92          }     
93       
[227]94        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
95          {
96            $this->assign('stylesheet_file',NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
97          }
98        else
99          {
100            $this->assign('stylesheet_file',DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
101          }
[152]102
103/* Common content */
104        $this->assign('common_content_url',COMMON_CONTENT_URL); /* For html href and src */
105        $this->assign('common_content_smarty_path',COMMON_CONTENT_SMARTY_PATH); /* For smarty includes */
106        $this->assign('network_logo_url',COMMON_CONTENT_URL.NETWORK_LOGO_NAME);
107        $this->assign('network_logo_banner_url',COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME);
108        $this->assign('wifidog_logo_url', COMMON_CONTENT_URL.WIFIDOG_LOGO_NAME);
109        $this->assign('wifidog_logo_banner_url',COMMON_CONTENT_URL.WIFIDOG_LOGO_BANNER_NAME);
110       
111/* Usefull stuff from config.php */
112        $this->assign('hotspot_network_name',HOTSPOT_NETWORK_NAME);
113        $this->assign('hotspot_network_url',HOTSPOT_NETWORK_URL);
114
115     $this->assign('hotspot_logo_url', find_local_content_url(HOTSPOT_LOGO_NAME));
116     $this->assign('hotspot_logo_banner_url', find_local_content_url(HOTSPOT_LOGO_BANNER_NAME));
117
118     $this->assign('hotspot_id', CURRENT_NODE_ID);
119   }
120
121/**similar to display(), but will find the content in the appropriate local content directory */
122   function displayLocalContent($template_filename)
123   {
[164]124     if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.$template_filename))
[152]125       {
126         $this->display(NODE_CONTENT_SMARTY_PATH.$template_filename);
127       }
128     else
129       {
130         $this->display(DEFAULT_CONTENT_SMARTY_PATH.$template_filename);
131       }
132   }
133
134   function SetTemplateDir( $template_dir)
135   {
136     $this->template_dir= $template_dir;
137   }
138
139} /* end class SmartyWifidog */
[553]140?>
Note: See TracBrowser for help on using the browser.