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

Revision 779, 5.8 KB (checked in by benoitg, 8 years ago)

2005-09-27 Benoit Gr�goire <bock@…>

  • Partial login page content manager support (Node only for 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# Check if Smarty installed, if not redirect user to web-base installation
32if (file_exists(BASEPATH.'lib/smarty/Smarty.class.php')) {
33  require_once(BASEPATH.'lib/smarty/Smarty.class.php');       # load Smarty library
34} else {
35  $exploded_path = explode("/", $_SERVER['SCRIPT_NAME']);     # Split directories in token
36  array_pop($exploded_path);                                  # Remove install.php from the list
37  $system_path = implode("/", $exploded_path);                # Build the system_path for the auth-server
38  print "Redirection to Wifidog web-base install <META HTTP-EQUIV=Refresh CONTENT=\"1; URL=$system_path/install.php\">";
39  exit();
40}
41
42// The setup.php file is a good place to load
43// required application library files, and you
44// can do that right here. An example:
45// require('guestbook/guestbook.lib.php');
46
47class SmartyWifidog extends Smarty {
48
49   function __construct()
50   {
51   
52        // Class Constructor. These automatically get set with each new instance.
53
54        $this->Smarty();
55
56        $this->template_dir = BASEPATH;
57        $this->compile_dir = BASEPATH.'tmp/smarty/templates_c/';
58        $this->config_dir = BASEPATH.'tmp/smarty/configs/';
59        $this->cache_dir = BASEPATH.'tmp/smarty/cache/';
60
61        /* Register the _ smarty modifier to call the _()
62         * PHP function which is the gettext() function
63         */
64        $this->register_modifier("_","_");
65       
66        $this->caching = false;
67        $this->assign('app_name','Wifidog auth server');
68
69        /* We need this for various forms to redirect properly (language form) */
70        $this->assign('request_uri', $_SERVER["REQUEST_URI"]);
71       
72        if(is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_HEADER_NAME))
73          {
74            $this->assign('header_file',NODE_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
75          }
76        else
77          {
78            $this->assign('header_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_HEADER_NAME);
79          }
80
81    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
82        $this->assign('portal_page', NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
83    } else {
84        $this->assign('portal_page', DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
85    }
86
87    if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
88        $this->assign('login_page', NODE_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
89    } else {
90        $this->assign('login_page', DEFAULT_CONTENT_SMARTY_PATH.LOGIN_PAGE_NAME);
91    }
92       
93        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PAGE_FOOTER_NAME))
94          {
95            $this->assign('footer_file',NODE_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
96          }
97        else
98          {
99            $this->assign('footer_file',DEFAULT_CONTENT_SMARTY_PATH.PAGE_FOOTER_NAME);
100          }     
101       
102        if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
103          {
104            $this->assign('stylesheet_file',NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
105          }
106        else
107          {
108            $this->assign('stylesheet_file',DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME);
109          }
110
111/* Common content */
112        $this->assign('common_content_url',COMMON_CONTENT_URL); /* For html href and src */
113        $this->assign('common_content_smarty_path',COMMON_CONTENT_SMARTY_PATH); /* For smarty includes */
114        $this->assign('network_logo_url',COMMON_CONTENT_URL.NETWORK_LOGO_NAME);
115        $this->assign('network_logo_banner_url',COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME);
116        $this->assign('wifidog_logo_url', COMMON_CONTENT_URL.WIFIDOG_LOGO_NAME);
117        $this->assign('wifidog_logo_banner_url',COMMON_CONTENT_URL.WIFIDOG_LOGO_BANNER_NAME);
118        $network = Network::GetCurrentNetwork();
119/* Usefull stuff from config.php */
120        $this->assign('hotspot_network_name',$network->getName());
121        $this->assign('hotspot_network_url',$network->getHomepageURL());
122
123     $this->assign('hotspot_id', CURRENT_NODE_ID);
124   }
125
126/**similar to display(), but will find the content in the appropriate local content directory */
127   function displayLocalContent($template_filename)
128   {
129     if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.$template_filename))
130       {
131         $this->display(NODE_CONTENT_SMARTY_PATH.$template_filename);
132       }
133     else
134       {
135         $this->display(DEFAULT_CONTENT_SMARTY_PATH.$template_filename);
136       }
137   }
138
139   function SetTemplateDir( $template_dir)
140   {
141     $this->template_dir= $template_dir;
142   }
143
144} /* end class SmartyWifidog */
145?>
Note: See TracBrowser for help on using the browser.