- 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); $GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
if (is_array($GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout'])) { $layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
$GLOBALS['Smarty'] -> assign('LSform_layout',$GLOBALS['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.')); $GLOBALS['Smarty'] -> assign('LSform_layout_nofield_label',_('No field.'));
} }
@ -175,8 +176,9 @@ class LSform {
} }
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields); $GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
if (is_array($GLOBALS['LSobjects'][$LSform_object['type']]['LSform']['layout'])) { $layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
$GLOBALS['Smarty'] -> assign('LSform_layout',$GLOBALS['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.')); $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 :: addCssFile('theme.css',LS_LIB_DIR.'jscalendar/skins/aqua/');
LSsession :: addJSscript('calendar.js',LS_LIB_DIR.'jscalendar/'); LSsession :: addJSscript('calendar.js',LS_LIB_DIR.'jscalendar/');
LSsession :: addJSscript('calendar-en.js',LS_LIB_DIR.'jscalendar/lang/'); 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('calendar-'.$codeLang.'.js',LS_LIB_DIR.'jscalendar/lang/');
LSsession :: addJSscript('LSformElement_date_field.js'); LSsession :: addJSscript('LSformElement_date_field.js');
LSsession :: addJSscript('LSformElement_date.js'); LSsession :: addJSscript('LSformElement_date.js');

View file

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

View file

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

View file

@ -353,6 +353,20 @@ class LSsession {
return $list; 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 * 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
* *
* Définition du serveur Ldap de la session à partir de son ID dans * 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 * @param[in] integer Index du serveur Ldap
* *

View file

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

View file

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