Commit 903d4ee9 authored by f4eyq's avatar f4eyq

update framework v3 namespace support

parent d444b26c
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -3,6 +3,15 @@ CRX FRAMEWORK
Current version:2.0.2
Update:31032019
Date:01/2008
------------------------
Update XX/XX/2019
------------------------
------------------------
Update 31/03/2019
------------------------
......
<?php
/*
********************************************************************************
* CRX-PHP-FRAMEWORK http://crxframework.crxcluster.com
* Copyright (c) Bastien Barbe and contributors. All rights
* reserved.
* CRX-PHP-FRAMEWORK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Crx-cms is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
********************************************************************************
*/
/**
* @author Bastien Barbe - CRX FRAMEWORK
* CRX-FRAMEWORK
* @author Bastien Barbe
* @creation date 2005
* @revision 17062018
* @module dxClusterWeb
* @copyright see header
* @version 2.0.1
* @version 2.0.2
*/
class crxFramework extends crxCore{
namespace crx;
class crxFramework
extends crxCore{
static function getCurrentConnectedUserInfo(){
//\crx\crxFramework
//$u=self::getUserInstance();
return self::getUserInstance()->getUserInfo(
$login='',
self::getGlobalValue('userId')
);
}
function returnModuleGid($moduleName){
$moduleCrx=crxModule::getInstance();
$moduleCrx->setPropertie('module_name',$moduleName);
$moduleCrx->setModuleSchema($this->_moduleShema);
return $moduleCrx->getPropertie('module_gid',$search_with='module_name');
}
public $_charSet = 'utf8';
......@@ -34,15 +51,20 @@ class crxFramework extends crxCore{
'module_version',
'module_name',
'module_desc',
'module_name_space',//name space of the module ex: crxcms
/* Module controler */
'module_user_controler',
/* User and Admin view of the module
(separated file for security)*/
'module_admin_controler',
/* Define visibility */
'module_is_private',
'module_is_enable',
'research_possibility'
);
var $_env = array(
......@@ -168,14 +190,10 @@ class crxFramework extends crxCore{
debugAndContinue($e->getMessage());
}
if(is_object(self::$_GOB_db)){
if(self::$_frameworkConfiguration['load_user_module']){
self::$_userItemInstance = new crxUser('main instance');
self::$_userItemInstance -> setDataInstance(self::$_GOB_db);
self::$_userItemInstance -> setDataKey('id_user');
......@@ -189,6 +207,9 @@ class crxFramework extends crxCore{
}
}
}
}else{
}
......@@ -340,33 +361,47 @@ class crxFramework extends crxCore{
function __createFrameworkProcessHttp(){
require_once('crxFrameworkWebCommon.php');
require_once('crxFrameworkWeb.php');
crxFrameworkWeb::setUrlmode('normal');
self::$_frameworkProcess=new crxFrameworkWeb();
self::$_frameworkProcess->initContext();
$this->_env = self::$_frameworkProcess->listenAction();
}
//HTTP AJAX (didn't display with TEMPLATE XHTML
function __createFrameworkProcessHttpAjax(){
require_once('crxFrameworkWebCommon.php');
require_once('crxFrameworkAjax.php');
///crxFrameworkWeb::setUrlmode('normal');
self::$_frameworkProcess=new crxFrameworkAjax();
self::$_frameworkProcess->initContext();
self::$_frameworkProcess->listenAction();
}
//Simple script / process PHP display NOTHING
function __createFrameworkProcessScript(){
require_once('crxFrameworkScript.php');
self::$_frameworkProcess=new crxFrameworkScript();
self::$_frameworkProcess->initContext();
self::$_frameworkProcess->listenAction();
$params=(bootScript::getParameters());
$params=(\crxboot\bootScript::getParameters());
if($params){
......@@ -385,13 +420,13 @@ class crxFramework extends crxCore{
//
// BUG :
////////////////////////////////////////
function getGlobalValue($k){
static function getGlobalValue($k){
return self::$_frameworkProcess->getGlobalValue($k);
}
function setGlobalValue($k,$v){
static function setGlobalValue($k,$v){
return self::$_frameworkProcess->setGlobalValue($k,$v);
......@@ -453,9 +488,7 @@ class crxFramework extends crxCore{
}
*/
if($mod){
$module = $mod;
}
else{
......@@ -465,9 +498,7 @@ class crxFramework extends crxCore{
}
if(empty($module)){
$module = crxFramework::getFrameworkCurrentModule();
}
$out = self::$_frameworkProcess->lng($key,$module,$lng_selected);
......@@ -634,6 +665,18 @@ class crxFramework extends crxCore{
}
function getDataSourceInformation(){
if(is_object(self::$_GOB_db))
return self::$_GOB_db -> _dataSourceInformation;
else
return false;
}
static function getDataSourceInstance($data_src_name=NULL){
return self::$_GOB_db;
......@@ -744,7 +787,10 @@ class crxFramework extends crxCore{
function mailAdminNotification($content,$mail_admin=null,$usersGroups=null,$subject=null){
if(!$this->crxCfg)$this->loadConfiguration();
if(!$mail_admin)$mail_admin=$this->crxCfg['configuration']['global']['website_webmaster_mail'];
if(!isset($mail_admin))return false;
$this->mail = new crxMail();
$this->mail->debug($this->_debug_mail_inside_log,$this->_dont_send_mail_on_network);
$this->mail -> from(
......
<?php
/**
* @author Bastien Barbe - CRX FRAMEWORK
* @creation date 2005
* @revision 15/06/2017
* @version 3.0
* CRX-PHP-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 03/04/2019
* @package core
* @version 3.1
* @web http://git.crx.cloud/crx-php/crx-framework
*/
namespace crx;
define('_STRICT_ACL_MODE_LOADER_',1);
class crxFrameworkModuleLoader{
......@@ -15,11 +19,8 @@ class crxFrameworkModuleLoader{
static $process_options_for_module_to_load = NULL;
static $__ACL_MODE_LOADER_ERROR_CODE = NULL;
//var $_frameworkConfiguration = null;
#var $_frameworkModulesConfiguration = null;
......@@ -105,7 +106,9 @@ class crxFrameworkModuleLoader{
debugAndContinue('[INFO] options => '.dumper($_process_options_for_module_to_load),DEBUG_FRMW_MODULE_LOADER_LAYER);
$_frameworkConfiguration = crxFramework::getFrameworkConfiguration();
//$force_reload_module_configuration=1;
self::$_frameworkModulesConfiguration = $module_info = self::getModulesInfo(
$force_reload_module_configuration,
'module_name'
......@@ -115,7 +118,6 @@ class crxFrameworkModuleLoader{
# $force_reload_module_configuration,
# 'module_name'
#);
//If nessecary load common module :
if(
......@@ -123,31 +125,25 @@ class crxFrameworkModuleLoader{
$_frameworkConfiguration['load_common_module'] &&
$disabled_common_module_loading == FALSE
){
//debugAndContinue('[INFO] crxFrameworkModuleLoader::run => => '.dumper($module_to_load),DEBUG_FRMW_MODULE_LOADER_LAYER);
self::runModule(
$_frameworkConfiguration['common_module_name'],
$module_info[$_frameworkConfiguration['common_module_name']],
$_process_options_for_module_to_load,
$controller_type,
$disable_acl_control
);
}
//Default module is not set and nothing is send what can we do ?
if(!isset($module_info[$module_to_load])){
debugAndContinue('[ERROR] Unknow module, please check modules.xml registry configuration.',DEBUG_FRMW_MODULE_LOADER_LAYER);
#if(DEBUG_FRMW_MODULE_LOADER_LAYER){debugAndContinue(dumper($module_info));}
debugAndContinue('[ERROR] Unknow module ('.$module_to_load.'), please check modules.xml registry configuration.',DEBUG_FRMW_MODULE_LOADER_LAYER);
if(!isset($_frameworkConfiguration['if_access_to_unknow_module']))
$_frameworkConfiguration['if_access_to_unknow_module']='print_error';
switch($_frameworkConfiguration['if_access_to_unknow_module']){
case 'load_default_module':
......@@ -320,65 +316,64 @@ class crxFrameworkModuleLoader{
$controller_type='module_user_controler',
$disable_acl_control=TRUE
){
self::$process_options_for_module_to_load['data'] = $process_options_for_module_to_load;
self::$process_options_for_module_to_load = $process_options_for_module_to_load;
self::$process_options_for_module_to_load = $process_options_for_module_to_load;
debugAndContinue('[INFO] runModule('.$module_name.')',DEBUG_FRMW_MODULE_LOADER_LAYER);
//print 'runModule : '.$module_name._BR_;
///print_r($moduleInfo)._BR_;
$path_user_controler = _APPLI_MAIN_MODULES_PATH_ . $moduleInfo['module_directory'] . _SD_ . $moduleInfo[$controller_type] . _PHP_F_EX_;
//var_dump($moduleInfo);
//var_dump($path_user_controler);
if(is_file($path_user_controler)){
//Loading $path_user_controler
include_once($path_user_controler);
debugAndContinue('[INFO] include php controler('.$path_user_controler.')',DEBUG_FRMW_MODULE_LOADER_LAYER);
}
else{
throw new Exception('[ERROR]['.$module_name.'] can not found module controler ('. $moduleInfo['module_directory'] .'), please check modules.xml registry configuration. '."\nFile php controller:".$path_user_controler.'
');
throw new crxException('[ERROR]['.$module_name.'] can not found module controler ('. $moduleInfo['module_directory'] .'), please check modules.xml registry configuration. '."\nFile php controller:".$path_user_controler.'');
}
$ns='';
if($moduleInfo['module_name_space'])
$ns='\\'.$moduleInfo['module_name_space'].'\\';
//Try to load module singleton
if(
is_callable(array($moduleInfo[$controller_type],'getInstance'))
&& class_exists($moduleInfo[$controller_type])
is_callable(array($ns.$moduleInfo[$controller_type],'getInstance'))
&& class_exists($ns.$moduleInfo[$controller_type])
){
debugAndContinue('[INFO] run module main class singleton:getInstance',DEBUG_FRMW_MODULE_LOADER_LAYER);
#echo "using singleton call => ".$this->moduleInfo['instanceUserName'];
//eval("$moduleInstance = $class::getInstance();");
$_moduleInstance=call_user_func(array($moduleInfo[$controller_type], 'getInstance'));
$_moduleInstance=call_user_func(array($ns.$moduleInfo[$controller_type], 'getInstance'));
}
//Else simply load module constructor method :
elseif($moduleInfo[$controller_type]){
debugAndContinue('[INFO] run module main class controler: new '.$moduleInfo[$controller_type].'();',DEBUG_FRMW_MODULE_LOADER_LAYER);
$_moduleInstance = new $moduleInfo[$controller_type]();
debugAndContinue('[INFO] run module main class controler: new '.$ns.$moduleInfo[$controller_type].'();',DEBUG_FRMW_MODULE_LOADER_LAYER);
$ctl=$ns.$moduleInfo[$controller_type];
$_moduleInstance = new $ctl();
}
//Else return exeception
else{
throw new Exception(
throw new crxException(
'[ERROR] controler class didnt exist ! pse check : '.
$path_user_controler.' and '. $moduleInfo['module_directory'] .' module.');
}
///Init module ENV :
debugAndContinue('[INFO] Init module configuration:'.$module_name,DEBUG_FRMW_MODULE_LOADER_LAYER);
self::__initModuleConfiguration($module_name,$_moduleInstance);
$_moduleInstance = self::__initModuleConfiguration($module_name,$_moduleInstance);
debugAndContinue('[INFO] Init framework module env values:'.$module_name,DEBUG_FRMW_MODULE_LOADER_LAYER);
......@@ -391,20 +386,20 @@ class crxFrameworkModuleLoader{
if( method_exists($_moduleInstance,'__setModuleAccessHandlers') && !$disable_acl_control ){
$run_main_from_module=self::__calcAndSetModuleHandlersAccess(
$run_main_from_module = self::__calcAndSetModuleHandlersAccess(
$_moduleInstance -> __setModuleAccessHandlers(),
$_moduleInstance -> _defaultMethodCall
);
}
if(! $run_main_from_module){
$show_output = crxFramework::getFrameworkConfigurationValue('display_html_modules_output');
$framework_conf_display_html_modules_output = crxFramework::getFrameworkConfigurationValue('display_modules_output');
......@@ -419,26 +414,21 @@ class crxFrameworkModuleLoader{
$_moduleInstance
);
}
return;
}
if( $run_main_from_module && method_exists($_moduleInstance,'runMain') ){
try{
//var_dump($_moduleInstance ->_currentModuleConfiguration);
//var_dump(self::$process_options_for_module_to_load);
$_moduleInstance -> runMain(
self::$process_options_for_module_to_load
);
//echo "@@@";
}
catch(crxException $e){
echo $e->getSummary();
......@@ -485,17 +475,17 @@ class crxFrameworkModuleLoader{
}
if(isset($conf)){
debugAndContinue('[INFO] Set MODULE ENV -> local conf XML for module '.$module_name.' contain : '.count($conf).' entries : $this->_currentModuleConfiguration',DEBUG_FRMW_MODULE_LOADER_LAYER);
//Old var name :
$module_instance ->_confXml = $conf;
//New var name :
$module_instance ->_module_configuration = $conf;
$module_instance ->_currentModuleConfiguration = $conf;
self::$_currentModuleConfiguration = $conf;
}
return $module_instance;
}
......@@ -545,24 +535,25 @@ class crxFrameworkModuleLoader{
if(crxFramework::getFrameworkConfigurationValue('load_user_module')){
#$u=$this->getUserInstance();
$u=crxFramework::getUserInstance();
$u->currentModuleGid=self::$_currentModuleGid;
$module_instance->ACL=$u->getUserRightsOnCurrentModule();
$acl=$u->getUserRightsOnCurrentModule();
$module_instance->ACL = $acl;
}
else{
$module_instance->ACL=array();
}
self::$_userPreferedLanguageInterface = 'fr';
self::$_defaultLanguageInterface = 'fr';
self::$_defaultLanguageInterface = 'fr';
return $module_instance;
......
<?php
#update:23062018
#update:21042019
namespace crx;
class crxFrameworkScript{
static $_modules_dictionnary = array();
function onModuleLoadingError(){}
function displayOutput(){
......
......@@ -8,8 +8,8 @@
* @author Bastien Barbe - CRX FRAMEWORK
* @creation date 2005
* @revision 15/06/2017
* @version 2.0
* @revision 02/04/2019
* @version 2.1
*/
/**
Must implement
......@@ -38,6 +38,8 @@ Must implement
*/
namespace crx;
class crxFrameworkWeb extends crxFrameworkWebCommon{
static $_url_mode = 'normal';
......@@ -81,7 +83,7 @@ class crxFrameworkWeb extends crxFrameworkWebCommon{
}
}
function compressHtml($in){
static function compressHtml($in){
$c = new crxTemplateXhtmlWrapper();
......
......@@ -9,6 +9,8 @@
* @version 2.0.2
*/
namespace crx;
class crxFrameworkWebCommon {
var $_defaultLanguage = '';
......@@ -102,7 +104,7 @@ class crxFrameworkWebCommon {
}
//Single user stack value ($_SESSION)
function setGlobalValue($k,$v){
static function setGlobalValue($k,$v){
//var_dump(_APPLI_SEC_KEY_);
//print "$k => $v"._BR_;
......@@ -330,13 +332,14 @@ class crxFrameworkWebCommon {
//ex: current_lang => fr , current_lang => en.
debugAndContinue('[INFO][lng()] current language set is :<b>'.$current_lang.'</b> ',DEBUG_LNG_LAYER);
debugAndContinue('[INFO][lng()] current language set is :<b>'.$current_lang.'</b> , module is : '.$current_module.', key is : <b>'.$key.'</b> ',DEBUG_LNG_LAYER);
$r=$this->initCache(
$current_module,
$current_lang
);
//cache didnt exist, we force loading data :
if(!$r){
$this->__forceLoadModuleDictionnary($current_module,$current_lang,$key);
}
......@@ -435,18 +438,17 @@ class crxFrameworkWebCommon {
function __forceLoadModuleDictionnary($current_module,$current_lang,$key=NULL){
$dic = new crxLanguage(FALSE);
$dic -> setCurrentLanguageIsInUse(
$this->getGlobalValue('lang')
$current_lng = $this->getGlobalValue('lang');
);
$dic = new crxLanguage(FALSE);
$dic -> setCurrentLanguageIsInUse($current_lng);
$i = crxModule::getInstance()->getModuleInfo(TRUE,'module_name');
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setDic(_APPLI_MAIN_MODULES_PATH_.$current_module.'/lang_files/'.$current_lang.'/lang.ini');
$p=_APPLI_MAIN_MODULES_PATH_.$current_module.'/lang_files/'.$current_lang.'/lang.ini';
$dic -> setDic($p);
if(
is_string($key) &&
......@@ -456,22 +458,28 @@ class crxFrameworkWebCommon {
if(!isset($cached_languages[$current_module][$current_lang])){
$dic_data = $dic -> loadDictionnary();
if(isset($dic_data)){
$cached_languages[$current_module][$current_lang] = $dic_data;
}else{
}
//SCRICT_LNG_LAYER
}
$this->setCommmonUsersGlobalValue('cached_languages',$cached_languages);
}
if(isset($current_lang) && isset(self::$_modules_dictionnary[$current_module])){
if(isset($current_lang) && isset(self::$_modules_dictionnary[$current_module]) && isset($cached_languages)){
self::$_modules_dictionnary[$current_module][$current_lang] = $cached_languages[$current_module][$current_lang];
}
}
......
......@@ -6,47 +6,52 @@
* @crx-core classes
* @copyright see header
*/
namespace crx;
function __crxAutoloader($c) {
debugAndContinue('[INFO]crxLoader.php, crxLoader, __AutoLoad('.$c.') ',DEBUG_FRMW_MODULE_LOADER_LAYER);
// debugAndContinue('[INFO]crxLoader.php, crxLoader, __AutoLoad('.$c.') ',DEBUG_FRMW_MODULE_LOADER_LAYER);
$locator = new crxLoader();
$locator->load($c);
}
spl_autoload_register('__crxAutoloader');
spl_autoload_register('crx\__crxAutoloader');
//spl_autoload_register('__crxAutoloader');
class crxLoader{
protected static $namesSpaces = array();
public function load($class_name){
/*
bloc to add for namespace support :
*/
//echo $class_name._BR_;
if(!$class_name)return false;