Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
init.php
Go to the documentation of this file.
1 <?php
2 /*-------------------------------------------------------------------------------
3  * Xataface Web Application Framework
4  * Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *-------------------------------------------------------------------------------
20  */
21 
22 function init($site_path, $dataface_url){
23  if (defined('DATAFACE_SITE_PATH')){
24  trigger_error("Error in ".__FILE__."
25  DATAFACE_SITE_PATH previously defined when trying to initialize the site."/*.Dataface_Error::printStackTrace()*/, E_USER_ERROR);
26  }
27 
28  if (defined('DATAFACE_URL')){
29  trigger_error("Error in ".__FILE__."
30  DATAFACE_URL previously defined when trying to initialize the site."/*.Dataface_Error::printStackTrace()*/, E_USER_ERROR);
31  }
32  define('DATAFACE_SITE_PATH', str_replace('\\','/', dirname($site_path)));
33  $temp_site_url = dirname($_SERVER['PHP_SELF']);
34  if ( $temp_site_url{strlen($temp_site_url)-1} == '/'){
35  $temp_site_url = substr($temp_site_url,0, strlen($temp_site_url)-1);
36  }
37  define('DATAFACE_SITE_URL', str_replace('\\','/',$temp_site_url));
38  define('DATAFACE_SITE_HREF', (DATAFACE_SITE_URL != '/' ? DATAFACE_SITE_URL.'/':'/').basename($_SERVER['PHP_SELF']) );
39  if ( !preg_match('#^https?://#', $dataface_url) and $dataface_url and $dataface_url{0} != '/' ){
40  $dataface_url = DATAFACE_SITE_URL.'/'.$dataface_url;
41  }
42  define('DATAFACE_URL', str_replace('\\','/',$dataface_url));
43 
44  require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.inc.php');
45  if ( @$_GET['-action'] == 'js' ){
46  include dirname(__FILE__).DIRECTORY_SEPARATOR.'js.php';
47  }
48  if ( @$_GET['-action'] == 'css' ){
49  include dirname(__FILE__).DIRECTORY_SEPARATOR.'css.php';
50  }
51 
52  if ( !is_writable(DATAFACE_SITE_PATH.DIRECTORY_SEPARATOR.'templates_c') ){
53  die(
54  sprintf(
55  'As of Xataface 1.3 all applications are now required to have its own templates_c directory to house its compiled templates. Please create the directory "%s" and ensure that it is writable by the web server.',
56  DATAFACE_SITE_PATH.DIRECTORY_SEPARATOR.'templates_c'
57  )
58  );
59  }
60 }
61