- Utilisation de LSconfig dans tout le projet

- LSsession :
  -> Ajout de la méthode getLang()
  -> Correction commentaires
This commit is contained in:
Benjamin Renard 2009-03-25 17:46:48 +00:00
parent 0fe2b04ee9
commit 065ee771d8
7 changed files with 38 additions and 20 deletions

View file

@ -108,8 +108,9 @@ class LSform {
);
$GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
if (is_array($GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout'])) {
$GLOBALS['Smarty'] -> assign('LSform_layout',$GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout']);
$layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
if (is_array($layout_config)) {
$GLOBALS['Smarty'] -> assign('LSform_layout',$layout_config);
$GLOBALS['Smarty'] -> assign('LSform_layout_nofield_label',_('No field.'));
}
@ -175,8 +176,9 @@ class LSform {
}
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
if (is_array($GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout'])) {
$GLOBALS['Smarty'] -> assign('LSform_layout',$GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout']);
$layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
if (is_array($layout_config)) {
$GLOBALS['Smarty'] -> assign('LSform_layout',$layout_config);
$GLOBALS['Smarty'] -> assign('LSform_layout_nofield_label',_('No field.'));
}
}

View file

@ -152,7 +152,7 @@ class LSformElement_date extends LSformElement {
LSsession :: addCssFile('theme.css',LS_LIB_DIR.'jscalendar/skins/aqua/');
LSsession :: addJSscript('calendar.js',LS_LIB_DIR.'jscalendar/');
LSsession :: addJSscript('calendar-en.js',LS_LIB_DIR.'jscalendar/lang/');
$codeLang = strtolower($GLOBALS['LSconfig']['lang'][0].$GLOBALS['LSconfig']['lang'][1]);
$codeLang = LSsession :: getLang(true);
LSsession :: addJSscript('calendar-'.$codeLang.'.js',LS_LIB_DIR.'jscalendar/lang/');
LSsession :: addJSscript('LSformElement_date_field.js');
LSsession :: addJSscript('LSformElement_date.js');

View file

@ -184,8 +184,8 @@ class LSldap {
* )
*/
public static function getEntry($object_type,$dn) {
if(isset($GLOBALS['LSobjects'][$object_type])){
$obj_conf=$GLOBALS['LSobjects'][$object_type];
$obj_conf=LSconfig :: get('LSobjects.'.$object_type);
if(is_array($obj_conf)){
$entry = self :: $cnx -> getEntry($dn);
if (Net_LDAP2::isError($entry)) {
//$newentry = new Net_LDAP2_Entry(&self :: $cnx);

View file

@ -59,8 +59,9 @@ class LSldapObject {
*/
function LSldapObject() {
$this -> type_name = get_class($this);
if(is_array($GLOBALS['LSobjects'][$this -> type_name])) {
$this -> config = $GLOBALS['LSobjects'][$this -> type_name];
$config = LSconfig :: get('LSobjects.'.$this -> type_name);
if(is_array($config)) {
$this -> config = $config;
}
else {
LSerror :: addErrorCode('LSldapObject_01');
@ -650,11 +651,11 @@ class LSldapObject {
*/
function getPatternFilter($pattern=null,$approx=null) {
if ($pattern!=NULL) {
if (is_array($GLOBALS['LSobjects'][$this -> getType()]['LSsearch']['attrs'])) {
$attrs=$GLOBALS['LSobjects'][$this -> getType()]['LSsearch']['attrs'];
if (is_array($this -> config['LSsearch']['attrs'])) {
$attrs=$this -> config['LSsearch']['attrs'];
}
else {
$attrs=array($GLOBALS['LSobjects'][$this -> getType()]['rdn']);
$attrs=array($this -> config['rdn']);
}
$pfilter='(|';
if ($approx) {
@ -1338,14 +1339,15 @@ class LSldapObject {
if (is_array(LSsession :: $ldapServer['subDn']['LSobject'][$this -> getType()]['LSobjects'])) {
foreach(LSsession :: $ldapServer['subDn']['LSobject'][$this -> getType()]['LSobjects'] as $type) {
if (LSsession :: loadLSobject($type)) {
if (isset($GLOBALS['LSobjects'][$type]['container_auto_create'])&&isset($GLOBALS['LSobjects'][$type]['container_dn'])) {
$dn = $GLOBALS['LSobjects'][$type]['container_dn'].','.$this -> getDn();
if(!LSldap :: getNewEntry($dn,$GLOBALS['LSobjects'][$type]['container_auto_create']['objectclass'],$GLOBALS['LSobjects'][$type]['container_auto_create']['attrs'],true)) {
$conf_type=LSconfig :: get("LSobjects.$type");
if (isset($conf_type['container_auto_create'])&&isset($conf_type['container_dn'])) {
$dn = $conf_type['container_dn'].','.$this -> getDn();
if(!LSldap :: getNewEntry($dn,$conf_type['container_auto_create']['objectclass'],$conf_type['container_auto_create']['attrs'],true)) {
LSdebug("Impossible de créer l'entrée fille : ".print_r(
array(
'dn' => $dn,
'objectClass' => $GLOBALS['LSobjects'][$type]['container_auto_create']['objectclass'],
'attrs' => $GLOBALS['LSobjects'][$type]['container_auto_create']['attrs']
'objectClass' => $conf_type['container_auto_create']['objectclass'],
'attrs' => $conf_type['container_auto_create']['attrs']
)
,true));
$error=1;

View file

@ -353,6 +353,20 @@ class LSsession {
return $list;
}
/**
* Retourne la langue courante de la session
*
* @param[in] boolean Si true, le code langue retourné sera court
*
* @retval string La langue de la session
**/
public static function getLang($short=false) {
if ($short) {
return strtolower(self :: $lang[0].self :: $lang[1]);
}
return self :: $lang;
}
/**
* Vérifie si une locale est disponible
*
@ -787,7 +801,7 @@ class LSsession {
* Définition du serveur Ldap de la session
*
* Définition du serveur Ldap de la session à partir de son ID dans
* le tableau $GLOBALS['LSconfig']['ldap_servers'].
* le tableau LSconfig :: get('ldap_servers').
*
* @param[in] integer Index du serveur Ldap
*

View file

@ -65,7 +65,7 @@ if(LSsession :: startLSsession()) {
$approx = false;
$selectedTopDn = LSsession :: getTopDn();
$orderby = false;
$_REQUEST['orderby']=$GLOBALS['LSobjects'][$LSobject]['orderby'];
$_REQUEST['orderby']=LSconfig :: get("LSobjects.$LSobject.orderby");
$ordersense = 'ASC';
$subDnLdapServer = LSsession :: getSubDnLdapServer();
$doSubDn = (($subDnLdapServer)&&(!LSsession :: isSubDnLSobject($LSobject)));

View file

@ -119,7 +119,7 @@ if(LSsession :: startLSsession()) {
$recur = false;
$approx = false;
$orderby = false;
$_REQUEST['orderby']=$GLOBALS['LSobjects'][$LSobject]['orderby'];
$_REQUEST['orderby']=LSconfig :: get("LSobjects.$LSobject.orderby");
$ordersense = 'ASC';
$subDnLdapServer = LSsession :: getSubDnLdapServer();
$doSubDn = (($subDnLdapServer)&&(!LSsession :: isSubDnLSobject($LSobject)));