Commit 69559020 authored by f4eyq's avatar f4eyq

update crx-framework/26/05/2019

parent 024781ad
......@@ -2,6 +2,12 @@
CRX FRAMEWORK
Current version:3.0.1
Date:01/2008
------------------------
Update 26/05/2019
------------------------
- Update language.
------------------------
Update 28/04/2019
------------------------
......
......@@ -486,19 +486,26 @@ extends crxCore{
}
function disableLngCache(){
return self::$_frameworkProcess->disableLngCache();
}
function lng($key,$mod=null,$lng_selected=null){
/* xdebug test : $_SESSION:5.1ms / without => 5ms
if(isset($_SESSION) && $_SESSION['lngc'][$lng_selected][$key]){
return $_SESSION['lngc'][$lng_selected][$key];
}
*/
if($mod){
$module = $mod;
}
else{
if(isset($this->_moduleName))
$module = $this->_moduleName;
$module = $this->_moduleName;
}
......
<?php
#update:21042019
#update:22052019
namespace crx;
......@@ -7,28 +7,17 @@ class crxFrameworkScript{
static $_modules_dictionnary = array();
function onModuleLoadingError(){}
function disableLngCache(){}
function displayOutput(){
}
function listenAction(){
}
function onModuleLoadingError(){}
function displayOutput(){}
function initContext(){
}
function listenAction(){}
function setModuleOutput(){
function initContext(){}
}
function setModuleOutput(){}
/*-----------------------------------------
add only for class compatibility /
......
......@@ -3,16 +3,18 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @creation date 2005
* @revision 30/04/2019
* @revision 25/05/2019
* @module crxFrameworkWeb
* @copyright see header
* @version 2.0.2
* @version 2.0.2-1
*/
namespace crx;
class crxFrameworkWebCommon {
var $_lng_cache = 1;
var $_defaultLanguage = '';
static $_currentUserLanguage = 'fr';
......@@ -282,7 +284,7 @@ class crxFrameworkWebCommon {
debugAndContinue('[INFO] caching_ini_to_user_session => 1',DEBUG_LNG_LAYER);
debugAndContinue('[INFO] -> Caching ini file data to user session',DEBUG_LNG_LAYER);
$cached_languages = $this->getCommmonUsersGlobalValue('cached_languages');
if(!isset($cached_languages['common'][$current_lng])){
debugAndContinue('[INFO] Loading dictionnary : '.$current_lng.' file ('.$path.')',DEBUG_LNG_LAYER);
$cached_languages['common'][$current_lng] = $this->parseIniLangFileOrIncludeLangPhpFile('common',$current_lng,$path);
......@@ -326,114 +328,150 @@ class crxFrameworkWebCommon {
}
function disableLngCache(){
$this->_lng_cache=0;
}
function lng($key,$current_module){
$debug=1;
$d=0;
if($key=='MENU_SUB_CLUSTER_WEBSERVICE'){
$d=1;
}
$current_lang = $this->getGlobalValue('lang');
//ex: current_lang => fr , current_lang => en.
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);
}
$md=self::$_modules_dictionnary;
if(
is_array($md)
&& is_string($current_module)
&& is_string($current_lang)
&& is_string($key)
&& isset($md[$current_module][$current_lang][$key])
){
debugAndContinue('[FOUND]['.$key.'] in memory return value:<b>'.$md[$current_module][$current_lang][$key].'</b> ',DEBUG_LNG_LAYER);
return $md[$current_module][$current_lang][$key];
$disable_cache_ini_2_php=0;
if($this->_lng_cache<>0){
$r=$this->initCache(
$current_module,
$current_lang
);
}
$this->_crxWebApp = crxWebApplication::getInstance();
if(
!isset(self::$_modules_dictionnary['common'][$current_lang]) ||
!self::$_modules_dictionnary['common'][$current_lang]
){
$this->loadGlobalLng($current_lang);
else{
$disable_cache_ini_2_php=1;
}
# var_dump(self::$_modules_dictionnary['common'][$current_lang]);
//$disable_cache=0;
//if($this->_lng_cache==0){$disable_cache=1;}
if(
is_string($key) &&
isset(self::$_modules_dictionnary['common'][$current_lang][$key])
){
return self::$_modules_dictionnary['common'][$current_lang][$key];
//cache didnt exist, we force loading data :
if( $this->_lng_cache<>0 && !$r ){
$this->__forceLoadModuleDictionnary($current_module,$current_lang,$key);
}
if($this->_lng_cache<>0){
$md=self::$_modules_dictionnary;
if(
is_array($md)
&& is_string($current_module)
&& is_string($current_lang)
&& is_string($key)
&& isset($md[$current_module][$current_lang][$key])
){
debugAndContinue('[FOUND]['.$key.'] in memory return value:<b>'.$md[$current_module][$current_lang][$key].'</b> ',DEBUG_LNG_LAYER);
return $md[$current_module][$current_lang][$key];
}
$this->_crxWebApp = crxWebApplication::getInstance();
if(
!isset(self::$_modules_dictionnary['common'][$current_lang]) ||
!self::$_modules_dictionnary['common'][$current_lang]
){
$this->loadGlobalLng($current_lang);
}
if(empty(self::$_languages)){
self::$_languages = $this->_crxWebApp -> getInterfaceLanguageConfiguration();
}
if(
is_string($key) &&
isset(self::$_modules_dictionnary['common'][$current_lang][$key])
){
return self::$_modules_dictionnary['common'][$current_lang][$key];
}
if(empty(self::$_languages)){
self::$_languages = $this->_crxWebApp -> getInterfaceLanguageConfiguration();
}
if(!is_array(self::$_languages)){
return false;
}
if(!is_array(self::$_languages)){
return false;
}
$i = crxModule::getInstance()->getModuleInfo(TRUE,'module_name');
//Test in english first (by default)
//Try current lang ( P1 ) :
$dic = new crxLanguage(FALSE);
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setCurrentLanguageIsInUse('en');
$dic_data = $dic -> loadDictionnary();
/*
if($key == 'LNG_YOUR_MOBILE_PHONE' ){
echo $key._BR_;
echo '[INFO][lng()] current language set is :<b>'.$current_lang.'</b> '._BR_;
var_dump($i[$current_module]);
var_dump($dic_data);
}
*/
$dic -> setCurrentLanguageIsInUse($current_lang);
$dic_data = $dic -> loadDictionnary($disable_cache_ini_2_php,0);
$key=(string)$key;
if(isset($dic_data[$key])){
if(isset($dic_data[$key])){
//Update memory and put the result inside the lang stack :
$cached_languages = $this->getCommmonUsersGlobalValue('cached_languages');
$cached_languages[$current_module][$current_lang][$key] = $dic_data[$key];
self::setCommmonUsersGlobalValue('cached_languages',$cached_languages);
self::setCommmonUsersGlobalValue('cached_languages',$cached_languages);
//Finnaly return the result :
debugAndContinue('[FOUND]['.$current_lang.'] value:[<b>'.$dic_data[$key].'</b>] and update cache.',DEBUG_LNG_LAYER);
return $dic_data[$key];
}
foreach(self::$_languages as $k=>$lang){//
$dic = new crxLanguage(FALSE);
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setCurrentLanguageIsInUse($k);
$dic_data = $dic -> loadDictionnary();
if(isset($dic_data[$key])){
//}
//Try current English ( P2 ) :
$dic = new crxLanguage(FALSE);
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setCurrentLanguageIsInUse('en');
$dic_data = $dic -> loadDictionnary($disable_cache_ini_2_php);
$key=(string)$key;
if($this->_lng_cache<>0){
if(isset($dic_data[$key])){
//Update memory and put the result inside the lang stack :
$cached_languages = $this->getCommmonUsersGlobalValue('cached_languages');
$cached_languages[$current_module][$current_lang][$key] = $dic_data[$key];
self::setCommmonUsersGlobalValue('cached_languages',$cached_languages);
//Finnaly return the result :
debugAndContinue('[FOUND]['.$current_lang.'] value:[<b>'.$dic_data[$key].'</b>] and update cache.',DEBUG_LNG_LAYER);
return $dic_data[$key];
}
}
}
//Try other languages :
foreach(self::$_languages as $k=>$lang){//
if($k<>$current_lang && $k<>'en'){
$dic = new crxLanguage(FALSE);
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setCurrentLanguageIsInUse($k);
$dic_data = $dic -> loadDictionnary($disable_cache_ini_2_php);
if(isset($dic_data[$key])){
debugAndContinue('[FOUND]['.$current_lang.'] value:[<b>'.$dic_data[$key].'</b>].',DEBUG_LNG_LAYER);
return $dic_data[$key];
}
}
}
// cache is disable nothing is found on other language,
// try english :
$dic = new crxLanguage(FALSE);
$dic -> setCurrentModuleInformation($i[$current_module]);
$dic -> setCurrentLanguageIsInUse('en');
$dic_data = $dic -> loadDictionnary($disable_cache_ini_2_php);
$key=(string)$key;
if(isset($dic_data[$key])){
return $dic_data[$key];
}
return '';
}
function __forceLoadModuleDictionnary($current_module,$current_lang,$key=NULL){
......@@ -464,6 +502,7 @@ class crxFrameworkWebCommon {
if(isset($dic_data)){
$cached_languages[$current_module][$current_lang] = $dic_data;
}else{
}
......@@ -587,11 +626,15 @@ class crxFrameworkWebCommon {
if(isset($uri['data']['action']) && $uri['data']['action'] == 'crxFrameworkSetLng'){
$user = crxFramework::getUserInstance();
$user->setValue('lang_pref',$uri['data']['lang'],crxFrameworkWebCommon::getGlobalValue('userId'));
self::setCommmonUsersGlobalValue('cached_languages',NULL);
$this->setGlobalValue('lang',$uri['data']['lang']);
$this->setGlobalValue('lang',$uri['data']['lang']);
$_SESSION['cache']=NULL;
return $this->redirect();
......
......@@ -12,7 +12,9 @@
namespace crx;
class crxFile{
var $_var_line = '';
function fileExist($file){
if(file_exists($file))return true;
return false;
......@@ -66,7 +68,7 @@ class crxFile{
//setFileContent($file,$content)
//crxFile
var $_var_line = '';
function appendVarLine($str_var,$str_value){
$this->_var_line.=''.$str_var.'='.$str_value.';'."\n";
......@@ -216,25 +218,16 @@ class crxFile{
//todo implement new method : file_put_contents
static function setFileContent($file,$content){
$file = trim($file);
if(empty($file))return false;
if(!file_exists($file)){
$r=touch($file);
if(!$r){
return false;
}
}
}
$f=file_put_contents($file,$content);
//var_dump($f);
return true;
/*
if(
file_exists($file) &&
......@@ -255,11 +248,6 @@ class crxFile{
return false;
}
*/
}
function fileSize($file){
......
......@@ -61,7 +61,7 @@ namespace crx;
var $_date = '10/03/2017';
var $_release_version = '31032019';
var $_release_version = '22052019';
var $_force_insert_with_pk_field_set = 0;
......@@ -132,6 +132,11 @@ namespace crx;
}
function flushObjectProperties(){
$this->itemsProperties=array();
}
function retreive($fields=array(),$use_field='',$return_method='BOTH'){
......
<?php
/*
*************************************************************************************
*
* Crx-cms powered by CRX-PHP-FRAMEWORK http://git.crx.cloud/crx-php/crx-framework
* Copyright (c) Bastien Barbe and contributors. All rights
* reserved.
*
* Crx-cms 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 (cms part)
* @date 01/01/2005
* @revision 04/14/2014
* @revision 05/05/2019
* @module generic
* @copyright see header
* @version 1.1.20140414
* @version 1.2
*/
namespace crx;
......@@ -200,7 +182,7 @@ class generic_crxItem extends crxFramework{
}
function remove($key,$key_id){
$this->c_db -> formatSqlQuery($data,$this->_tableName,'DELETE',array($key=>$key_id));
$this->c_db -> formatSqlQuery(array(),$this->_tableName,'DELETE',array($key=>$key_id));
if($this->_debug)$this->c_db -> printQuery();
else $this->c_db -> execSql();
}
......
......@@ -3,7 +3,7 @@
* CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 11/04/2019
* @revision 25/05/2019
* @lib languages
* @version 1.2.1
*/
......@@ -25,8 +25,8 @@ extends crxFramework{
var $_debug_lng = FALSE;
// english/french/italian/spanish
var $_languages_coding_list = array('en','fr','it','es');
// english/french/italian/spanish/german
var $_languages_coding_list = array('en','fr','it','es','gm');
var $_currentLanguageInUse = 'fr';
......@@ -43,42 +43,37 @@ extends crxFramework{
}
function setCurrentLanguageIsInUse( $lng ){
$this->_currentLanguageInUse = $lng;
function setCurrentLanguageIsInUse( $lng ){
$this->_currentLanguageInUse = $lng;
}
function setCurrentModuleInformation( $m ){
function setCurrentModuleInformation( $m ){
$this->_current_module_information = $m;
//$this->_languages_coding_list
//_CACHE_PXML_FOLDER_
}
function parsingModuleLanguageFile($lang){
function parsingModuleLanguageFile($lang,$debug=0){
$dic=null;
$dic=null;
$ini_language_file = _APPLI_MAIN_MODULES_PATH_.$this->_current_module_information['module_directory'].'/lang_files/'.$lang.'/lang.ini';
$ini_language_file = _APPLI_MAIN_MODULES_PATH_.$this->_current_module_information['module_directory'].'/lang_files/'.$lang.'/lang.ini';
if(file_exists($ini_language_file)){
//if($debug)echo "@parsingModuleLanguageFile";
//if($debug)var_dump($ini_language_file);
if(file_exists($ini_language_file)){
debugAndContinue('[INFO] Parsing language : '.$lang.' file ('.$ini_language_file.')',DEBUG_LNG_LAYER);
$f = new crxIniParsor($ini_language_file);
//array('format'=>'utf8_decode')
$dic = $f->getAllIniValue();//NOT nessecary : array('format'=>'utf8_decode')
}
}
if(is_array($dic)){
foreach($dic as $k_=>$v_){
$dic[$k_]=trim(str_replace("\r\n", "",htmlentities(stripslashes($v_))));
}
}
return $dic;
foreach($dic as $k_=>$v_){
$dic[$k_]=trim(str_replace("\r\n", "",htmlentities(stripslashes($v_))));
}
}
return $dic;
}
function initLanguagesModulesCachingValues($force_cache_refresh=false){
......@@ -119,28 +114,28 @@ extends crxFramework{
}
function loadDictionnary(){
function loadDictionnary($disable_cache=0,$debug=0){
if(crxFramework::getFrameworkObjectsOption('caching_ini_to_php')){
if($disable_cache == 0 && crxFramework::getFrameworkObjectsOption('caching_ini_to_php')){
//Try to load compiled version :
$path_cache_lang_include_file = _CACHE_PXML_FOLDER_.$this->_current_module_information['module_directory']._SD_.$this->_currentLanguageInUse._SD_.'lang.php';
if(file_exists($path_cache_lang_include_file)){
$lang = $this->_currentLanguageInUse;
if(file_exists($path_cache_lang_include_file)){
debugAndContinue('[INFO] caching_ini_to_php => 1',DEBUG_LNG_LAYER);
debugAndContinue('[INFO] Loading php lng file : '.$path_cache_lang_include_file.' lang ('.$this->_currentLanguageInUse.')',DEBUG_LNG_LAYER);
require($path_cache_lang_include_file);
require($path_cache_lang_include_file);
if( empty($this->_dic) || !($this->_dic)){
debugAndContinue('[INFO] Language values not found lang => '.$lang.', module=>'.$this->_current_module_information['module_directory'],DEBUG_LNG_LAYER);
}
return $this->_dic;
}
else{
}else{
debugAndContinue('[INFO] Language ('.count($this->_dic).')values found, lang => '.$lang.', module=>'.$this->_current_module_information['module_directory'],DEBUG_LNG_LAYER);
}
return $this->_dic;
}
else{
$this->initLanguagesModulesCachingValues();
debugAndContinue('[INFO] caching_ini_to_php => 1',DEBUG_LNG_LAYER);
......@@ -161,12 +156,9 @@ extends crxFramework{
}
else{
debugAndContinue('[INFO] caching_ini_to_php => 0',DEBUG_LNG_LAYER);
$this->_dic = $this->parsingModuleLanguageFile($this->_currentLanguageInUse);
return $this->_dic;
debugAndContinue('[INFO] caching_ini_to_php => 0',DEBUG_LNG_LAYER);
$this->_dic = $this->parsingModuleLanguageFile($this->_currentLanguageInUse,$debug);
return $this->_dic;
}
}
......
......@@ -72,7 +72,7 @@ class abstractDxClusterSpot{
function getDebug(){
return $this->_dsql;
return $this->_debug_details;
}
function debugMessage($m){
......
<?php
/**
* @date 01/01/2005
* @revision 122018
* @revision 12/05/2019
* @lib radioamator
* @copyright see header
*/
......
......@@ -4,9 +4,9 @@
* @web http://git.crx.cloud/crx-php/crx-framework
* @author Bastien Barbe
* @date 04/10/2014
* @revision 04042019
* @revision 25/05/2019
* @package radioamator/crxRadioStation
* @version 1.2
* @version 1.2-2
*/
/*
CREATE TABLE IF NOT EXISTS `crx_users_radiostations` (
......@@ -36,7 +36,6 @@ CREATE TABLE IF NOT EXISTS `crx_users_radiostations` (
namespace crx;
use \crx\generic_crxItem;
class crxRadioStation
extends generic_crxItem{
......@@ -88,6 +87,13 @@ extends generic_crxItem{
);
function lng($k){
return $this->_data['_p'] -> lng($k);
}
function setParent($p){
$this->_p=$p;
}
function setStationType($st){
......@@ -143,12 +149,11 @@ extends generic_crxItem{
function userRadioStationsHtmlRenderer($stations){
$type=array(
'station_fixe'=>'Home',
'station_portable'=>'Portable',
'station_mobile'=>'Mobile'
'station_fixe'=>$this->lng('LNG_PROF_STATION_H'),
'station_portable'=>$this->lng('LNG_PROF_STATION_P'),
'station_mobile'=>$this->lng('LNG_PROF_STATION_M')
);
//@todo cal tab if display or not !
$html='<ul class="tabs left">';
$station_tab_id=1;
......@@ -177,23 +182,21 @@ extends generic_crxItem{
<img src="'.$p.'" width="250px">
</a>';
*/
// photo station
/* fancybox version with button:*/
$photos.='
<a class="fancybox" href="'.$p.'" data-fancybox-group="gallery" title="Station Photo ('.$i.')">
$photos.='
<a class="fancybox" href="'.$p.'" data-fancybox-group="gallery" title="'.$this->lng('LNG_SOTD_PHOTO').' ('.$i.')">
<img src="'.$p.'" width="250px">
</a>';
}
$i++;
}
if($v['station_display_inside_profile']){
$v['station_desc']='<p>'.str_replace("\r",'<br />',$v['station_desc']).'</p>';
$v['station_desc']=str_replace("\\",'',$v['station_desc']);
$v['station_desc']=str_replace("\\",'',$v['station_desc']);
$html.='
<div id="tabr'.$station_tab_id.'" class="tab-content">
<table>
......@@ -201,32 +204,30 @@ extends generic_crxItem{
<th>'.$type[$v['station_type']].' </th> <td>&nbsp;</td> </tr>