Jeff PHP framework
0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
|
00001 <?php 00026 class core { 00027 00031 protected $_registry; 00032 00036 private $_base_path; 00037 00045 function __construct() { 00046 00047 session_name(SESSIONNAME); 00048 session_start(); 00049 require_once(ABS_CORE.DS.'tables.php'); 00050 require_once(ABS_CORE.DS.'include.php'); 00051 00052 $this->_base_path = BASE_PATH; 00053 00054 // initializing registry variable 00055 $this->_registry = registry::instance(); 00056 $this->_registry->db = db::instance(); 00057 $this->_registry->url = $_SERVER['REQUEST_URI']; 00058 $this->_registry->admin_privilege = 1; 00059 $this->_registry->admin_view_privilege = 2; 00060 $this->_registry->public_view_privilege = 3; 00061 $this->_registry->private_view_privilege = 4; 00062 $this->_registry->theme = $this->getTheme(); 00063 $this->_registry->lng = language::setLanguage($this->_registry); 00064 $this->_registry->site_settings = new siteSettings($this->_registry); 00065 $this->_registry->dtime = new dtime($this->_registry); 00066 $this->_registry->router = new router($this->_base_path); 00067 $this->_registry->isHome = preg_match("#^module=index&method=index(&.*)?$#", $_SERVER['QUERY_STRING']) ? true : false; 00068 $this->_registry->css = array(); 00069 $this->_registry->js = array(); 00070 $this->_registry->meta = array(); 00071 $this->_registry->head_links = array(); 00072 00073 //set session timeout 00074 if($this->_registry->site_settings->session_timeout) { 00075 if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > $this->_registry->site_settings->session_timeout)) { 00076 // last request was more than timeout seconds ago 00077 session_regenerate_id(true); 00078 session_destroy(); 00079 unset($_SESSION); 00080 session_start(); 00081 } 00082 $_SESSION['last_activity'] = time(); // update last activity time stamp 00083 } 00084 00085 // extra plugins 00086 $plugins_objs = array(); 00087 if(is_readable(ABS_ROOT.DS.'plugins.php')) { 00088 require_once(ABS_ROOT.DS.'plugins.php'); 00089 foreach($plugins as $k=>$v) { 00090 if(is_readable(ABS_PLUGINS.DS.$k.DS.$k.".php")) { 00091 require_once(ABS_PLUGINS.DS.$k.DS.$k.".php"); 00092 $plugins_objs[$k] = new $k($this->_registry, $v); 00093 } 00094 else 00095 exit(error::syserrorMessage(get_class($this), '__construct', sprintf(__("cantFindPluginSource"), $k), __LINE__)); 00096 } 00097 } 00098 $this->_registry->plugins = $plugins_objs; 00099 00100 } 00101 00108 public function renderApp($site=null) { 00109 00110 ob_start(); 00111 00112 // some other registry properties 00113 $this->_registry->site = $site=='admin' ? 'admin':'main'; 00114 00115 /* 00116 * check login/logout 00117 */ 00118 authentication::check(); 00119 00120 /* 00121 * create document 00122 */ 00123 $doc = new document(); 00124 $buffer = $doc->render(); 00125 00126 ob_end_flush(); 00127 00128 } 00129 00135 public function methodPointer() { 00136 00137 ob_start(); 00138 00139 /* 00140 * check login/logout 00141 */ 00142 authentication::check($this->_registry); 00143 00144 echo $this->_registry->router->loader(null); 00145 ob_end_flush(); 00146 00147 exit(); 00148 } 00149 00155 public function getTheme() { 00156 00157 $rows = $this->_registry->db->autoSelect(array("name"), TBL_THEMES, "active='1'", ''); 00158 $theme_name = $rows[0]['name']; 00159 00160 if(is_readable(ABS_THEMES.DS.$theme_name.DS.$theme_name.'.php')) 00161 require_once(ABS_THEMES.DS.$theme_name.DS.$theme_name.'.php'); 00162 else 00163 Error::syserrorMessage('coew', 'getTheme', sprintf(__("CantLoadThemeError"), $theme_name, __LINE__)); 00164 00165 $theme_class = $theme_name.'Theme'; 00166 00167 if(class_exists($theme_class)) 00168 return new $theme_class(); 00169 else 00170 Error::syserrorMessage('coew', 'getTheme', sprintf(__("CantLoadThemeError"), $theme_name, __LINE__)); 00171 00172 } 00173 00174 } 00175 00176 ?>