diff --git a/public_html/conf/config.inc.php b/public_html/conf/config.inc.php
index cf46ff46..2bbb5626 100644
--- a/public_html/conf/config.inc.php
+++ b/public_html/conf/config.inc.php
@@ -177,7 +177,7 @@ $GLOBALS['LSconfig'] = array(
// Theme Default
define('LS_THEME','default');
-define('LS_TEMPLATES_DIR', 'templates/'.LS_THEME);
+define('LS_TEMPLATES_DIR', 'templates');
define('LS_IMAGES_DIR', 'images/'.LS_THEME);
define('LS_CSS_DIR', 'css/'.LS_THEME);
diff --git a/public_html/create.php b/public_html/create.php
index 49f85733..88b9a2de 100644
--- a/public_html/create.php
+++ b/public_html/create.php
@@ -46,11 +46,11 @@ if(LSsession :: startLSsession()) {
if (isset($_REQUEST['LSform_dataEntryForm'])) {
$form -> applyDataEntryForm((string)$_REQUEST['LSform_dataEntryForm']);
- $GLOBALS['Smarty'] -> assign('LSform_dataEntryForm',(string)$_REQUEST['LSform_dataEntryForm']);
+ LStemplate :: assign('LSform_dataEntryForm',(string)$_REQUEST['LSform_dataEntryForm']);
}
- $GLOBALS['Smarty'] -> assign('listAvailableDataEntryForm',LSform :: listAvailableDataEntryForm($LSobject));
- $GLOBALS['Smarty'] -> assign('DataEntryFormLabel',_('Data entry form'));
+ LStemplate :: assign('listAvailableDataEntryForm',LSform :: listAvailableDataEntryForm($LSobject));
+ LStemplate :: assign('DataEntryFormLabel',_('Data entry form'));
if ($form->validate()) {
// Data update for LDAP object
@@ -95,7 +95,7 @@ if(LSsession :: startLSsession()) {
exit();
}
// Define page title
- $GLOBALS['Smarty'] -> assign('pagetitle',_('New').' : '.$object -> getLabel());
+ LStemplate :: assign('pagetitle',_('New').' : '.$object -> getLabel());
LSsession :: setTemplate('create.tpl');
$form -> display();
}
diff --git a/public_html/custom_action.php b/public_html/custom_action.php
index 81b68cec..5ab34179 100644
--- a/public_html/custom_action.php
+++ b/public_html/custom_action.php
@@ -43,7 +43,7 @@ if(LSsession :: startLSsession()) {
}
if (isset($_GET['valid']) || $config['noConfirmation']) {
$objectname=$object -> getDisplayName();
- $GLOBALS['Smarty'] -> assign('pagetitle',$title.' : '.$objectname);
+ LStemplate :: assign('pagetitle',$title.' : '.$objectname);
if ($config['function']($object)) {
if ($config['disableOnSuccessMsg']!=true) {
if ($config['onSuccessMsgFormat']) {
@@ -77,10 +77,10 @@ if(LSsession :: startLSsession()) {
)
)
);
- $GLOBALS['Smarty'] -> assign('pagetitle',$title.' : '.$objectname);
- $GLOBALS['Smarty'] -> assign('question',$question);
- $GLOBALS['Smarty'] -> assign('validation_url','custom_action.php?LSobject='.urlencode($LSobject).'&dn='.urlencode($dn).'&customAction='.urlencode($customAction).'&valid');
- $GLOBALS['Smarty'] -> assign('validation_label',_('Validate'));
+ LStemplate :: assign('pagetitle',$title.' : '.$objectname);
+ LStemplate :: assign('question',$question);
+ LStemplate :: assign('validation_url','custom_action.php?LSobject='.urlencode($LSobject).'&dn='.urlencode($dn).'&customAction='.urlencode($customAction).'&valid');
+ LStemplate :: assign('validation_label',_('Validate'));
}
LSsession :: setTemplate('question.tpl');
}
diff --git a/public_html/includes/class/class.LSerror.php b/public_html/includes/class/class.LSerror.php
index e71b8bfb..0da9a1e9 100644
--- a/public_html/includes/class/class.LSerror.php
+++ b/public_html/includes/class/class.LSerror.php
@@ -82,7 +82,7 @@ class LSerror {
if ($return) {
return $errors;
}
- $GLOBALS['Smarty'] -> assign('LSerrors',$errors);
+ LStemplate :: assign('LSerrors',$errors);
}
}
diff --git a/public_html/includes/class/class.LSform.php b/public_html/includes/class/class.LSform.php
index 3f7ea0eb..924de608 100644
--- a/public_html/includes/class/class.LSform.php
+++ b/public_html/includes/class/class.LSform.php
@@ -100,7 +100,7 @@ class LSform {
)
);
- $GLOBALS['Smarty'] -> assign('LSform_action',$_SERVER['PHP_SELF']);
+ LStemplate :: assign('LSform_action',$_SERVER['PHP_SELF']);
$LSform_header = "\t\n
\t\n
\t\n
@@ -111,14 +111,14 @@ class LSform {
'type' => $this -> ldapObject -> getType(),
'dn' => $this -> ldapObject -> getValue('dn')
);
- $GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
+ LStemplate :: assign('LSform_object',$LSform_object);
$layout_config=LSconfig :: get("LSobjects.".$LSform_object['type'].".LSform.layout");
if (!isset($this -> dataEntryFormConfig['disabledLayout']) || $this -> dataEntryFormConfig['disabledLayout']==false) {
if (is_array($layout_config)) {
- $GLOBALS['Smarty'] -> assign('LSform_layout',$layout_config);
- $GLOBALS['Smarty'] -> assign('LSform_layout_nofield_label',_('No field.'));
+ LStemplate :: assign('LSform_layout',$layout_config);
+ LStemplate :: assign('LSform_layout_nofield_label',_('No field.'));
}
}
@@ -164,9 +164,9 @@ class LSform {
if ($this -> maxFileSize) {
$LSform_header.="\t\n";
}
- $GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
+ LStemplate :: assign('LSform_header',$LSform_header);
- $GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
+ LStemplate :: assign('LSform_fields',$fields);
$JSconfig = array (
'ajaxSubmit' => ((isset($this -> config['LSform']['ajaxSubmit']))?$this -> config['LSform']['ajaxSubmit']:1)
@@ -179,7 +179,7 @@ class LSform {
LSsession :: addJSconfigParam('LSform_'.$this -> idForm,$JSconfig);
if($this -> can_validate) {
- $GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
+ LStemplate :: assign('LSform_submittxt',$this -> submit);
}
}
@@ -237,18 +237,18 @@ class LSform {
'type' => $this -> ldapObject -> getType(),
'dn' => $this -> ldapObject -> getDn()
);
- $GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
+ LStemplate :: assign('LSform_object',$LSform_object);
$fields = array();
foreach($this -> elements as $element) {
$field = $element -> getDisplay();
$fields[$element -> name] = $field;
}
- $GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
+ LStemplate :: assign('LSform_fields',$fields);
$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.'));
+ LStemplate :: assign('LSform_layout',$layout_config);
+ LStemplate :: assign('LSform_layout_nofield_label',_('No field.'));
}
}
diff --git a/public_html/includes/class/class.LSformElement_image.php b/public_html/includes/class/class.LSformElement_image.php
index 18513907..eea1e565 100644
--- a/public_html/includes/class/class.LSformElement_image.php
+++ b/public_html/includes/class/class.LSformElement_image.php
@@ -62,16 +62,16 @@ class LSformElement_image extends LSformElement {
if (!empty($this -> values[0])) {
$img_path = LSsession :: getTmpFile($this -> values[0]);
- $GLOBALS['Smarty'] -> assign('LSformElement_image',array(
+ LStemplate :: assign('LSformElement_image',array(
'img' => $img_path,
'id' => $id,
));
if (!$this -> isFreeze()) {
- $GLOBALS['Smarty'] -> assign('LSformElement_image_actions','delete');
+ LStemplate :: assign('LSformElement_image_actions','delete');
}
if ($this -> form -> definedError($this -> name)) {
- $GLOBALS['Smarty'] -> assign('LSformElement_image_errors',true);
+ LStemplate :: assign('LSformElement_image_errors',true);
}
if (LSsession :: loadLSclass('LSsmoothbox')) {
LSsmoothbox :: loadDependenciesDisplay();
diff --git a/public_html/includes/class/class.LSmail.php b/public_html/includes/class/class.LSmail.php
index ab64a18b..636e00b6 100644
--- a/public_html/includes/class/class.LSmail.php
+++ b/public_html/includes/class/class.LSmail.php
@@ -50,17 +50,17 @@ class LSmail {
$subject = $_REQUEST['subject'];
}
- $GLOBALS['Smarty'] -> assign('LSmail_msg',$msg);
- $GLOBALS['Smarty'] -> assign('LSmail_subject',$subject);
+ LStemplate :: assign('LSmail_msg',$msg);
+ LStemplate :: assign('LSmail_subject',$subject);
if (is_array($_REQUEST['mails'])) {
- $GLOBALS['Smarty'] -> assign('LSmail_mails',$_REQUEST['mails']);
+ LStemplate :: assign('LSmail_mails',$_REQUEST['mails']);
}
else if(empty($_REQUEST['mails'])) {
- $GLOBALS['Smarty'] -> assign('LSmail_mails',array($_REQUEST['mails']));
+ LStemplate :: assign('LSmail_mails',array($_REQUEST['mails']));
}
- $GLOBALS['Smarty'] -> assign('LSmail_mail_label',_('Email'));
- $GLOBALS['Smarty'] -> assign('LSmail_subject_label',_('Title'));
- $GLOBALS['Smarty'] -> assign('LSmail_msg_label',_('Message'));
+ LStemplate :: assign('LSmail_mail_label',_('Email'));
+ LStemplate :: assign('LSmail_subject_label',_('Title'));
+ LStemplate :: assign('LSmail_msg_label',_('Message'));
$data = array(
'html' => LSsession :: fetchTemplate('LSmail.tpl')
diff --git a/public_html/includes/class/class.LSrelation.php b/public_html/includes/class/class.LSrelation.php
index 605fc1c2..6eaa9f40 100644
--- a/public_html/includes/class/class.LSrelation.php
+++ b/public_html/includes/class/class.LSrelation.php
@@ -123,7 +123,7 @@ class LSrelation {
}
}
- $GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
+ LStemplate :: assign('LSrelations',$LSrelations);
LSsession :: addJSconfigParam('LSrelations',$LSrelations_JSparams);
}
}
diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php
index a93ff512..e5727d01 100644
--- a/public_html/includes/class/class.LSsession.php
+++ b/public_html/includes/class/class.LSsession.php
@@ -132,48 +132,19 @@ class LSsession {
* @retval true si tout c'est bien passé, false sinon
*/
private static function startLStemplate() {
- if ( self :: includeFile(LSconfig :: get('Smarty')) ) {
- $GLOBALS['Smarty'] = new Smarty();
- $GLOBALS['Smarty'] -> template_dir = LS_TEMPLATES_DIR;
- $GLOBALS['Smarty'] -> compile_dir = LS_TMP_DIR;
- if ( ! is_writable(LS_TMP_DIR) ) {
- die('Smarty compile directory is not writable (dir : '.LS_TMP_DIR.')');
- }
-
- if (LSdebug) {
- $GLOBALS['Smarty'] -> caching = 0;
- // cache files are always regenerated
- $GLOBALS['Smarty'] -> force_compile = TRUE;
- // recompile template if it is changed
- $GLOBALS['Smarty'] -> compile_check = TRUE;
- if (isset($_REQUEST['debug_smarty'])) {
- // debug smarty
- $GLOBALS['Smarty'] -> debugging = true;
- }
- }
-
- if (method_exists($GLOBALS['Smarty'],'register_function')) {
- define('SMARTY3',False);
- $GLOBALS['Smarty'] -> register_function('getFData','smarty_getFData');
- $GLOBALS['Smarty'] -> register_function('tr','smarty_tr');
- }
- elseif (method_exists($GLOBALS['Smarty'],'registerPlugin')) {
- define('SMARTY3',True);
- $GLOBALS['Smarty'] -> registerPlugin("function","getFData", "smarty_getFData");
- $GLOBALS['Smarty'] -> registerPlugin("function","tr", "smarty_tr");
- }
- else {
- die("Smarty : Can't register getFData fonction");
- }
-
- $GLOBALS['Smarty'] -> assign('LS_CSS_DIR',LS_CSS_DIR);
- $GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR);
-
+ if ( self :: loadLSclass('LStemplate') ) {
self :: addJSconfigParam('LS_IMAGES_DIR',LS_IMAGES_DIR);
- return true;
+ return LStemplate :: start(
+ array(
+ 'smarty_path' => LSconfig :: get('Smarty'),
+ 'template_dir' => LS_TEMPLATES_DIR,
+ 'compile_dir' => LS_TMP_DIR,
+ 'debug' => LSdebug,
+ 'debug_smarty' => (isset($_REQUEST['LStemplate_debug'])),
+ )
+ );
}
- die("ERROR : Can't load Smarty.");
- return;
+ return False;
}
/**
@@ -557,7 +528,7 @@ class LSsession {
self :: loadLSaccess();
}
- $GLOBALS['Smarty'] -> assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
+ LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
if (isset ($_POST['LSsession_topDn']) && $_POST['LSsession_topDn']) {
if (self :: validSubDnLdapServer($_POST['LSsession_topDn'])) {
@@ -614,7 +585,7 @@ class LSsession {
self :: $rdn = $LSuserObject->getValue('rdn');
self :: loadLSprofiles();
self :: loadLSaccess();
- $GLOBALS['Smarty'] -> assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
+ LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
$_SESSION['LSsession']=self :: getContextInfos();
return true;
}
@@ -625,9 +596,9 @@ class LSsession {
}
if (self :: $ldapServerId) {
- $GLOBALS['Smarty'] -> assign('ldapServerId',self :: $ldapServerId);
+ LStemplate :: assign('ldapServerId',self :: $ldapServerId);
}
- $GLOBALS['Smarty'] -> assign('topDn',self :: $topDn);
+ LStemplate :: assign('topDn',self :: $topDn);
if (isset($_GET['LSsession_recoverPassword'])) {
self :: displayRecoverPasswordForm($recoveryPasswordInfos);
}
@@ -1159,31 +1130,31 @@ class LSsession {
* @retval void
*/
public static function displayLoginForm() {
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Connection'));
+ LStemplate :: assign('pagetitle',_('Connection'));
if (isset($_GET['LSsession_logout'])) {
- $GLOBALS['Smarty'] -> assign('loginform_action','index.php');
+ LStemplate :: assign('loginform_action','index.php');
}
else {
- $GLOBALS['Smarty'] -> assign('loginform_action',$_SERVER['REQUEST_URI']);
+ LStemplate :: assign('loginform_action',$_SERVER['REQUEST_URI']);
}
if (count(LSconfig :: get('ldap_servers'))==1) {
- $GLOBALS['Smarty'] -> assign('loginform_ldapserver_style','style="display: none"');
+ LStemplate :: assign('loginform_ldapserver_style','style="display: none"');
}
- $GLOBALS['Smarty'] -> assign('loginform_label_ldapserver',_('LDAP server'));
+ LStemplate :: assign('loginform_label_ldapserver',_('LDAP server'));
$ldapservers_name=array();
$ldapservers_index=array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
$ldapservers_index[]=$id;
$ldapservers_name[]=__($infos['name']);
}
- $GLOBALS['Smarty'] -> assign('loginform_ldapservers_name',$ldapservers_name);
- $GLOBALS['Smarty'] -> assign('loginform_ldapservers_index',$ldapservers_index);
+ LStemplate :: assign('loginform_ldapservers_name',$ldapservers_name);
+ LStemplate :: assign('loginform_ldapservers_index',$ldapservers_index);
- $GLOBALS['Smarty'] -> assign('loginform_label_level',_('Level'));
- $GLOBALS['Smarty'] -> assign('loginform_label_user',_('Identifier'));
- $GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Password'));
- $GLOBALS['Smarty'] -> assign('loginform_label_submit',_('Connect'));
- $GLOBALS['Smarty'] -> assign('loginform_label_recoverPassword',_('Forgot your password ?'));
+ LStemplate :: assign('loginform_label_level',_('Level'));
+ LStemplate :: assign('loginform_label_user',_('Identifier'));
+ LStemplate :: assign('loginform_label_pwd',_('Password'));
+ LStemplate :: assign('loginform_label_submit',_('Connect'));
+ LStemplate :: assign('loginform_label_recoverPassword',_('Forgot your password ?'));
self :: setTemplate('login.tpl');
self :: addJSscript('LSsession_login.js');
@@ -1201,26 +1172,26 @@ class LSsession {
* @retval void
*/
public static function displayRecoverPasswordForm($recoveryPasswordInfos) {
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Recovery of your credentials'));
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_action','index.php?LSsession_recoverPassword');
+ LStemplate :: assign('pagetitle',_('Recovery of your credentials'));
+ LStemplate :: assign('recoverpasswordform_action','index.php?LSsession_recoverPassword');
if (count(LSconfig :: get('ldap_servers'))==1) {
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_ldapserver_style','style="display: none"');
+ LStemplate :: assign('recoverpasswordform_ldapserver_style','style="display: none"');
}
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_label_ldapserver',_('LDAP server'));
+ LStemplate :: assign('recoverpasswordform_label_ldapserver',_('LDAP server'));
$ldapservers_name=array();
$ldapservers_index=array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
$ldapservers_index[]=$id;
$ldapservers_name[]=$infos['name'];
}
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_ldapservers_name',$ldapservers_name);
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_ldapservers_index',$ldapservers_index);
+ LStemplate :: assign('recoverpasswordform_ldapservers_name',$ldapservers_name);
+ LStemplate :: assign('recoverpasswordform_ldapservers_index',$ldapservers_index);
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_label_user',_('Identifier'));
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_label_submit',_('Validate'));
- $GLOBALS['Smarty'] -> assign('recoverpasswordform_label_back',_('Back'));
+ LStemplate :: assign('recoverpasswordform_label_user',_('Identifier'));
+ LStemplate :: assign('recoverpasswordform_label_submit',_('Validate'));
+ LStemplate :: assign('recoverpasswordform_label_back',_('Back'));
$recoverpassword_msg = _('Please fill the identifier field to proceed recovery procedure');
@@ -1239,7 +1210,7 @@ class LSsession {
);
}
- $GLOBALS['Smarty'] -> assign('recoverpassword_msg',$recoverpassword_msg);
+ LStemplate :: assign('recoverpassword_msg',$recoverpassword_msg);
self :: setTemplate('recoverpassword.tpl');
self :: addJSscript('LSsession_recoverPassword.js');
@@ -1342,7 +1313,7 @@ class LSsession {
self :: addJSconfigParam('keepLSsessionActive',ini_get('session.gc_maxlifetime'));
}
- $GLOBALS['Smarty'] -> assign('LSjsConfig',json_encode(self :: $_JSconfigParams));
+ LStemplate :: assign('LSjsConfig',json_encode(self :: $_JSconfigParams));
if (LSdebug) {
$JSscript_txt.="\n";
@@ -1351,7 +1322,7 @@ class LSsession {
$JSscript_txt.="\n";
}
- $GLOBALS['Smarty'] -> assign('LSsession_js',$JSscript_txt);
+ LStemplate :: assign('LSsession_js',$JSscript_txt);
// Css
self :: addCssFile("LSdefault.css");
@@ -1362,37 +1333,37 @@ class LSsession {
}
$Css_txt.="\n";
}
- $GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
+ LStemplate :: assign('LSsession_css',$Css_txt);
if (isset(self :: $LSaccess[self :: $topDn])) {
- $GLOBALS['Smarty'] -> assign('LSaccess',self :: $LSaccess[self :: $topDn]);
+ LStemplate :: assign('LSaccess',self :: $LSaccess[self :: $topDn]);
}
// Niveau
$listTopDn = self :: getSubDnLdapServer();
if (is_array($listTopDn)) {
asort($listTopDn);
- $GLOBALS['Smarty'] -> assign('label_level',self :: getSubDnLabel());
- $GLOBALS['Smarty'] -> assign('_refresh',_('Refresh'));
+ LStemplate :: assign('label_level',self :: getSubDnLabel());
+ LStemplate :: assign('_refresh',_('Refresh'));
$LSsession_topDn_index = array();
$LSsession_topDn_name = array();
foreach($listTopDn as $index => $name) {
$LSsession_topDn_index[] = $index;
$LSsession_topDn_name[] = $name;
}
- $GLOBALS['Smarty'] -> assign('LSsession_subDn_indexes',$LSsession_topDn_index);
- $GLOBALS['Smarty'] -> assign('LSsession_subDn_names',$LSsession_topDn_name);
- $GLOBALS['Smarty'] -> assign('LSsession_subDn',self :: $topDn);
- $GLOBALS['Smarty'] -> assign('LSsession_subDnName',self :: getSubDnName());
+ LStemplate :: assign('LSsession_subDn_indexes',$LSsession_topDn_index);
+ LStemplate :: assign('LSsession_subDn_names',$LSsession_topDn_name);
+ LStemplate :: assign('LSsession_subDn',self :: $topDn);
+ LStemplate :: assign('LSsession_subDnName',self :: getSubDnName());
}
- $GLOBALS['Smarty'] -> assign('LSlanguages',self :: getLangList());
- $GLOBALS['Smarty'] -> assign('LSlang',self :: $lang);
- $GLOBALS['Smarty'] -> assign('LSencoding',self :: $encoding);
- $GLOBALS['Smarty'] -> assign('lang_label',_('Language'));
+ LStemplate :: assign('LSlanguages',self :: getLangList());
+ LStemplate :: assign('LSlang',self :: $lang);
+ LStemplate :: assign('LSencoding',self :: $encoding);
+ LStemplate :: assign('lang_label',_('Language'));
- $GLOBALS['Smarty'] -> assign('displayLogoutBtn',LSauth :: displayLogoutBtn());
- $GLOBALS['Smarty'] -> assign('displaySelfAccess',LSauth :: displaySelfAccess());
+ LStemplate :: assign('displayLogoutBtn',LSauth :: displayLogoutBtn());
+ LStemplate :: assign('displaySelfAccess',LSauth :: displaySelfAccess());
// Infos
if((!empty($_SESSION['LSsession_infos']))&&(is_array($_SESSION['LSsession_infos']))) {
@@ -1401,13 +1372,13 @@ class LSsession {
$txt_infos.="
$info\n";
}
$txt_infos.="\n";
- $GLOBALS['Smarty'] -> assign('LSinfos',$txt_infos);
+ LStemplate :: assign('LSinfos',$txt_infos);
$_SESSION['LSsession_infos']=array();
}
if (self :: $ajaxDisplay) {
- $GLOBALS['Smarty'] -> assign('LSerror_txt',LSerror :: getErrors());
- $GLOBALS['Smarty'] -> assign('LSdebug_txt',LSdebug_print(true));
+ LStemplate :: assign('LSerror_txt',LSerror :: getErrors());
+ LStemplate :: assign('LSdebug_txt',LSdebug_print(true));
}
else {
LSerror :: display();
@@ -1416,9 +1387,9 @@ class LSsession {
if (!self :: $template)
self :: setTemplate('empty.tpl');
- $GLOBALS['Smarty'] -> assign('connected_as',_("Connected as"));
+ LStemplate :: assign('connected_as',_("Connected as"));
- $GLOBALS['Smarty'] -> display(self :: $template);
+ LStemplate :: display(self :: $template);
}
/**
@@ -1481,9 +1452,9 @@ class LSsession {
*/
public static function fetchTemplate($template,$variables=array()) {
foreach($variables as $name => $val) {
- $GLOBALS['Smarty'] -> assign($name,$val);
+ LStemplate :: assign($name,$val);
}
- return $GLOBALS['Smarty'] -> fetch($template);
+ return LStemplate :: fetch($template);
}
/**
@@ -2131,8 +2102,8 @@ class LSsession {
* @retval void
*/
public static function redirect($url,$exit=true) {
- $GLOBALS['Smarty'] -> assign('url',$url);
- $GLOBALS['Smarty'] -> display('redirect.tpl');
+ LStemplate :: assign('url',$url);
+ LStemplate :: display('redirect.tpl');
if ($exit) {
exit();
}
diff --git a/public_html/includes/class/class.LStemplate.php b/public_html/includes/class/class.LStemplate.php
new file mode 100644
index 00000000..b252b6e3
--- /dev/null
+++ b/public_html/includes/class/class.LStemplate.php
@@ -0,0 +1,207 @@
+
+ */
+class LStemplate {
+
+ /**
+ * LStemplate configuration
+ *
+ * array(
+ * 'smarty_path' => '/path/to/Smarty.php',
+ * 'template_dir' => '/path/to/template/directory',
+ * 'compile_dir' => '/path/to/compile/directory',
+ * 'debug' => True,
+ * 'debug_smarty' => True
+ * )
+ *
+ **/
+ private static $config = NULL;
+
+ // Smarty object
+ public static $_smarty = NULL;
+
+ // Smarty version
+ private static $_smarty_version = NULL;
+
+ /**
+ * Start LStemplate
+ *
+ * Set configuration from parameter $config and initialize
+ * Smarty object.
+ *
+ * @param[in] $config array LStemplate configuration
+ *
+ * @retval boolean True on success, False instead
+ **/
+ public static function start($config) {
+ self :: $config = $config;
+
+ if (LSsession :: includeFile($config['smarty_path'])) {
+ self :: $_smarty = new Smarty();
+ self :: $_smarty -> template_dir = $config['template_dir'];
+
+ if ( ! is_writable($config['compile_dir']) ) {
+ die(_('LStemplate : compile directory is not writable (dir : '.$config['compile_dir'].')'));
+ }
+ self :: $_smarty -> compile_dir = $config['compile_dir'];
+
+ if ($config['debug']) {
+ self :: $_smarty -> caching = 0;
+ // cache files are always regenerated
+ self :: $_smarty -> force_compile = TRUE;
+ // recompile template if it is changed
+ self :: $_smarty -> compile_check = TRUE;
+ if ($config['debug_smarty']) {
+ // debug smarty
+ self :: $_smarty -> debugging = true;
+ }
+ }
+
+ if (method_exists(self :: $_smarty,'register_function')) {
+ self :: $_smarty_version=2;
+ if (!LSsession :: loadLSclass('LStemplate_smarty2_support')) {
+ die(_("LStemplate : Can't load Smarty 2 support file"));
+ }
+
+ }
+ elseif (method_exists(self :: $_smarty,'registerPlugin')) {
+ self :: $_smarty_version=3;
+ if (!LSsession :: loadLSclass('LStemplate_smarty3_support')) {
+ die(_("LStemplate : Can't load Smarty 2 support file"));
+ }
+ }
+ else {
+ die(_("LStemplate : Smarty version not recognized."));
+ }
+
+ self :: $_smarty -> assign('LS_CSS_DIR',LS_CSS_DIR);
+ self :: $_smarty -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR);
+
+ return True;
+ }
+ else {
+ die(_("LStemplate : Can't load Smarty."));
+ return False;
+ }
+ }
+
+ /**
+ * Return the path of the Smarty template file to use
+ *
+ * @param[in] string $template The template name (eg: top.tpl)
+ *
+ * @retval string The path of the Smarty template file
+ **/
+ public static function getTemplatePath($template) {
+ $directories=array(
+ 'local',
+ LS_THEME
+ );
+ foreach($directories as $dir) {
+ if (file_exists(self :: $config['template_dir'].'/'.$dir.'/'.$template)) {
+ return self :: $config['template_dir'].'/'.$dir.'/'.$template;
+ }
+ }
+ return $config['template_dir'].'/default/'.$template;
+ }
+
+ /**
+ * Return the content of a Smarty template file.
+ *
+ * @param[in] string $template The template name (eg: top.tpl)
+ *
+ * @retval string The content of the Smarty template file
+ **/
+ public static function getTemplateSource($template) {
+ $tpl_path=self :: getTemplatePath($template);
+ if (!is_readable($tpl_path)) {
+ $tpl_path=self :: getTemplatePath('empty.tpl');
+ LSerror::addErrorCode('LStemplate_01',$template);
+ }
+ return implode('',file($tpl_path));
+ }
+
+ /**
+ * Return the timestamp of the last change of a Smarty
+ * template file.
+ *
+ * @param[in] string $template The template name (eg: top.tpl)
+ *
+ * @retval string The timestamp of the last change of the Smarty template file
+ **/
+ public static function getTemplateTimestamp($template) {
+ $tpl_path=self :: getTemplatePath($template);
+ if (is_file($tpl_path)) {
+ $time=filemtime($tpl_path);
+ if ($time)
+ return $time;
+ }
+ return NULL;
+ }
+
+ /**
+ * Assign template variable
+ *
+ * @param[in] string $name The variable name
+ * @param[in] mixed $value The variable value
+ *
+ * @retval void
+ **/
+ public static function assign($name,$value) {
+ return self :: $_smarty -> assign($name,$value);
+ }
+
+ /**
+ * Display a template
+ *
+ * @param[in] string $template The template name (eg: empty.tpl)
+ *
+ * @retval void
+ **/
+ public static function display($template) {
+ return self :: $_smarty -> display("ls:$template");
+ }
+
+ /**
+ * Fetch a template
+ *
+ * @param[in] string $template The template name (eg: empty.tpl)
+ *
+ * @retval string The template compiled
+ **/
+ public static function fetch($template) {
+ return self :: $_smarty -> fetch("ls:$template");
+ }
+
+}
+
+// Errors
+LSerror :: defineError('LStemplate_01',
+_("LStemplate : Template %{file} not found.")
+);
diff --git a/public_html/includes/class/class.LStemplate_smarty2_support.php b/public_html/includes/class/class.LStemplate_smarty2_support.php
new file mode 100644
index 00000000..a3355d52
--- /dev/null
+++ b/public_html/includes/class/class.LStemplate_smarty2_support.php
@@ -0,0 +1,108 @@
+
+ **/
+
+/**
+ * Retrieve a resource
+ *
+ * @param[in] $tpl_name string The template name
+ * @param[in] $tpl_source string Variable passed by reference
+ * where the result should be stored.
+ * @param[in] $smarty_obj object The Smarty object
+ *
+ * @return bool TRUE if it was able to successfully retrieve
+ * the resource and FALSE otherwise.
+ **/
+function LStemplate_smarty_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
+ $tpl_source=LStemplate :: getTemplateSource($tpl_name);
+ return True;
+}
+
+/**
+ * Retrieve the last modification timestamp of a template
+ *
+ * @param[in] $tpl_name string The template name
+ * @param[in] $tpl_timestamp int Variable passed by reference
+ * where the result should be stored.
+ * @param[in] $smarty_obj object The Smarty object
+ *
+ * @return bool TRUE if the timestamp could be succesfully determined,
+ * or FALSE otherwise
+ **/
+function LStemplate_smarty_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) {
+ $time=LStemplate :: getTemplateTimestamp($tpl_name);
+ if ($time) {
+ $tpl_timestamp=$time;
+ return True;
+ }
+ return False;
+}
+
+/**
+ * Determine if template is secured or not
+ *
+ * This function is used only for template resources but should
+ * still be defined.
+ *
+ * @param[in] $tpl_name string The template name
+ * @param[in] $smarty_obj object The Smarty object
+ *
+ * @return bool TRUE if the template is secured, or FALSE otherwise
+ **/
+function LStemplate_smarty_get_secure($tpl_name, &$smarty_obj) {
+ return True;
+}
+The fourth function, trusted() is supposed to return TRUE or FALSE, depending on whether the requested resource is trusted or not. This function is used for only for PHP script components requested by {include_php} tag or {insert} tag with the src attribute. However, it should still be defined even for template resources.
+/**
+ * Determine if template is trusted or not
+ *
+ * This function is used for only for PHP script components
+ * requested by {include_php} tag or {insert} tag with the
+ * src attribute. However, it should still be defined even
+ * for template resources.
+ *
+ * @param[in] $tpl_name string The template name
+ * @param[in] $smarty_obj object The Smarty object
+ *
+ * @return bool TRUE if the template is trusted, or FALSE otherwise
+ **/
+function LStemplate_smarty_get_trusted($tpl_name, &$smarty_obj) {
+ return True;
+}
+
+// Register 'ls' template ressource
+LStemplate :: $_smarty -> register_resource('ls', array(
+ 'LStemplate_smarty_get_template',
+ 'LStemplate_smarty_get_timestamp',
+ 'LStemplate_smarty_get_secure',
+ 'LStemplate_smarty_get_trusted'
+ )
+ );
+
+// Register special template functions
+LStemplate :: $_smarty -> register_function('getFData','smarty_getFData');
+LStemplate :: $_smarty -> register_function('tr','smarty_tr');
+
diff --git a/public_html/includes/class/class.LStemplate_smarty3_support.php b/public_html/includes/class/class.LStemplate_smarty3_support.php
new file mode 100644
index 00000000..8937b0df
--- /dev/null
+++ b/public_html/includes/class/class.LStemplate_smarty3_support.php
@@ -0,0 +1,66 @@
+
+ */
+class Smarty_Resource_LdapSaisie extends Smarty_Resource_Custom {
+
+ // prepared fetch() statement
+ protected $fetch;
+ // prepared fetchTimestamp() statement
+ protected $mtime;
+
+ /**
+ * Fetch a template and its modification time from database
+ *
+ * @param string $name template name
+ * @param string $source template source
+ * @param integer $mtime template modification timestamp (epoch)
+ * @return void
+ */
+ protected function fetch($name, &$source, &$mtime) {
+ $source = LStemplate :: getTemplateSource($name);
+ $mtime = LStemplate :: getTemplateTimestamp($name);
+ }
+
+ /**
+ * Fetch a template's modification time from database
+ *
+ * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
+ * @param string $name template name
+ * @return integer timestamp (epoch) the template was modified
+ */
+ protected function fetchTimestamp($name) {
+ return LStemplate :: getTemplateTimestamp($name);
+ }
+}
+
+// Register 'ls' template ressource
+LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie());
+
+// Register special template functions
+LStemplate :: $_smarty -> registerPlugin("function","getFData", "smarty_getFData");
+LStemplate :: $_smarty -> registerPlugin("function","tr", "smarty_tr");
+
diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php
index 0e2e7b74..293ea3f7 100644
--- a/public_html/includes/functions.php
+++ b/public_html/includes/functions.php
@@ -241,7 +241,7 @@ function LSdebug_print($return=false,$ul=true) {
}
}
if ($ul) $txt.='';
- $GLOBALS['Smarty'] -> assign('LSdebug',$txt);
+ LStemplate :: assign('LSdebug',$txt);
if ($return) {
return $txt;
}
diff --git a/public_html/index.php b/public_html/index.php
index fa12dbba..ba7e474d 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -25,7 +25,7 @@ require_once 'core.php';
if(LSsession :: startLSsession()) {
// Définition du Titre de la page
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Home'));
+ LStemplate :: assign('pagetitle',_('Home'));
// Template
LSsession :: setTemplate('accueil.tpl');
diff --git a/public_html/modify.php b/public_html/modify.php
index 57337536..d374bf0e 100644
--- a/public_html/modify.php
+++ b/public_html/modify.php
@@ -51,7 +51,7 @@ if(LSsession :: startLSsession()) {
$object = new $LSobject();
if ($object -> loadData($dn)) {
// Définition du Titre de la page
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Modify').' : '.$object -> getDisplayName());
+ LStemplate :: assign('pagetitle',_('Modify').' : '.$object -> getDisplayName());
$form = $object -> getForm('modify');
if ($form->validate()) {
// MàJ des données de l'objet LDAP
@@ -114,7 +114,7 @@ if(LSsession :: startLSsession()) {
);
}
- $GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
+ LStemplate :: assign('LSview_actions',$LSview_actions);
LSsession :: setTemplate('modify.tpl');
$form -> display();
LSsession :: displayTemplate();
diff --git a/public_html/remove.php b/public_html/remove.php
index bea77129..c42bd803 100644
--- a/public_html/remove.php
+++ b/public_html/remove.php
@@ -34,7 +34,7 @@ if(LSsession :: startLSsession()) {
if ($object -> loadData($dn)) {
if (isset($_GET['valid'])) {
$objectname=$object -> getDisplayName();
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Deleting').' : '.$objectname);
+ LStemplate :: assign('pagetitle',_('Deleting').' : '.$objectname);
if ($object -> remove()) {
LSsession :: addInfo($objectname.' '._('has been deleted successfully').'.');
LSsession :: redirect('view.php?LSobject='.$LSobject.'&refresh');
@@ -45,10 +45,10 @@ if(LSsession :: startLSsession()) {
}
else {
// Définition du Titre de la page
- $GLOBALS['Smarty'] -> assign('pagetitle',_('Deleting').' : '.$object -> getDisplayName());
- $GLOBALS['Smarty'] -> assign('question',_('Do you really want to delete').' '.$object -> getDisplayName().' ?');
- $GLOBALS['Smarty'] -> assign('validation_url','remove.php?LSobject='.$LSobject.'&dn='.urlencode($dn).'&valid');
- $GLOBALS['Smarty'] -> assign('validation_label',_('Validate'));
+ LStemplate :: assign('pagetitle',_('Deleting').' : '.$object -> getDisplayName());
+ LStemplate :: assign('question',_('Do you really want to delete').' '.$object -> getDisplayName().' ?');
+ LStemplate :: assign('validation_url','remove.php?LSobject='.$LSobject.'&dn='.urlencode($dn).'&valid');
+ LStemplate :: assign('validation_label',_('Validate'));
}
LSsession :: setTemplate('question.tpl');
}
diff --git a/public_html/select.php b/public_html/select.php
index fbcf5e49..a5aefc3f 100644
--- a/public_html/select.php
+++ b/public_html/select.php
@@ -29,7 +29,7 @@ if(LSsession :: startLSsession()) {
if ( LSsession ::loadLSobject($LSobject) ) {
if (LSsession :: loadLSclass('LSsearch')) {
$object = new $LSobject();
- $GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
+ LStemplate :: assign('pagetitle',$object -> getLabel());
$LSsearch = new LSsearch($LSobject,'LSselect');
$LSsearch -> setParamsFormPostData();
@@ -80,7 +80,7 @@ if(LSsession :: startLSsession()) {
)
)
);
- $GLOBALS['Smarty']->assign('searchForm',$searchForm);
+ LStemplate :: assign('searchForm',$searchForm);
$LSview_actions=array(
array (
@@ -89,15 +89,15 @@ if(LSsession :: startLSsession()) {
'action' => 'refresh'
)
);
- $GLOBALS['Smarty']->assign('LSview_actions',$LSview_actions);
+ LStemplate :: assign('LSview_actions',$LSview_actions);
$LSsearch -> run();
$page=(isset($_REQUEST['page'])?(int)$_REQUEST['page']:0);
$page = $LSsearch -> getPage($page);
- $GLOBALS['Smarty']->assign('page',$page);
- $GLOBALS['Smarty']->assign('LSsearch',$LSsearch);
+ LStemplate :: assign('page',$page);
+ LStemplate :: assign('LSsearch',$LSsearch);
- $GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
+ LStemplate :: assign('LSobject_list_objectname',$object -> getLabel());
if (isset($_REQUEST['ajax'])) {
LSsession :: setTemplate('select_table.tpl');
diff --git a/public_html/templates/default/LSformElement.tpl b/public_html/templates/default/LSformElement.tpl
index ceaef1d1..5cd9d850 100644
--- a/public_html/templates/default/LSformElement.tpl
+++ b/public_html/templates/default/LSformElement.tpl
@@ -1,8 +1,8 @@
diff --git a/public_html/templates/default/LSformElement_boolean.tpl b/public_html/templates/default/LSformElement_boolean.tpl
index ee4b2a8a..385e55e0 100644
--- a/public_html/templates/default/LSformElement_boolean.tpl
+++ b/public_html/templates/default/LSformElement_boolean.tpl
@@ -1,8 +1,8 @@
diff --git a/public_html/templates/default/LSformElement_password.tpl b/public_html/templates/default/LSformElement_password.tpl
index 5b53d8c3..5e8110aa 100644
--- a/public_html/templates/default/LSformElement_password.tpl
+++ b/public_html/templates/default/LSformElement_password.tpl
@@ -1,3 +1,3 @@
diff --git a/public_html/templates/default/LSformElement_select_object.tpl b/public_html/templates/default/LSformElement_select_object.tpl
index 04c6d5b6..92fa3f05 100644
--- a/public_html/templates/default/LSformElement_select_object.tpl
+++ b/public_html/templates/default/LSformElement_select_object.tpl
@@ -5,11 +5,11 @@
{/if}
{if !$freeze}
diff --git a/public_html/templates/default/LSformElement_ssh_key.tpl b/public_html/templates/default/LSformElement_ssh_key.tpl
index 8af878d9..eac135be 100644
--- a/public_html/templates/default/LSformElement_ssh_key.tpl
+++ b/public_html/templates/default/LSformElement_ssh_key.tpl
@@ -1,7 +1,7 @@
diff --git a/public_html/templates/default/LSformElement_supannLabeledValue.tpl b/public_html/templates/default/LSformElement_supannLabeledValue.tpl
index a24bdcd3..2cfda2a5 100644
--- a/public_html/templates/default/LSformElement_supannLabeledValue.tpl
+++ b/public_html/templates/default/LSformElement_supannLabeledValue.tpl
@@ -3,19 +3,19 @@
{foreach from=$parseValues item=parseValue}
{if $parseValue.translated}{assign var=value value=$parseValue.translated}{else}{assign var=value value=$parseValue.value}{/if}
{if $parseValue.label!="no"}{assign var=label value=$parseValue.label}{else}{assign var=label value=""}{/if}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{foreachelse}
{assign var=value value=""}
{assign var=parseValue value=""}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{/foreach}
{else}
{foreach from=$values item=value}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{foreachelse}
{assign var=value value=""}
{assign var=parseValue value=""}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{/foreach}
{/if}
diff --git a/public_html/templates/default/LSformElement_supannRoleEntite.tpl b/public_html/templates/default/LSformElement_supannRoleEntite.tpl
index 0536a02b..1774ad49 100644
--- a/public_html/templates/default/LSformElement_supannRoleEntite.tpl
+++ b/public_html/templates/default/LSformElement_supannRoleEntite.tpl
@@ -7,19 +7,19 @@
{if $parseValue.type.label!="no"}{assign var=label_type value=$parseValue.type.label}{else}{assign var=label_type value=""}{/if}
{if $parseValue.code.translated}{assign var=code value=$parseValue.code.translated}{else}{assign var=code value=$parseValue.code.value}{/if}
{if $parseValue.code.label!="no"}{assign var=label_code value=$parseValue.code.label}{else}{assign var=label_code value=""}{/if}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{foreachelse}
{assign var=value value=""}
{assign var=parseValue value=""}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{/foreach}
{else}
{foreach from=$values item=value}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{foreachelse}
{assign var=value value=""}
{assign var=parseValue value=""}
- {include file=$fieldTemplate}
+ {include file="ls:$fieldTemplate"}
{/foreach}
{/if}
diff --git a/public_html/templates/default/accueil.tpl b/public_html/templates/default/accueil.tpl
index 069bcac4..a0a0c0c7 100644
--- a/public_html/templates/default/accueil.tpl
+++ b/public_html/templates/default/accueil.tpl
@@ -1,3 +1,3 @@
-{include file='top.tpl'}
+{include file='ls:top.tpl'}
{$pagetitle}
-{include file='bottom.tpl'}
+{include file='ls:bottom.tpl'}
diff --git a/public_html/templates/default/blank.tpl b/public_html/templates/default/blank.tpl
index 9721cbe8..781f34ff 100644
--- a/public_html/templates/default/blank.tpl
+++ b/public_html/templates/default/blank.tpl
@@ -12,7 +12,7 @@
-{include file='LSdefault.tpl'}
+{include file='ls:LSdefault.tpl'}
{$LSsession_js}
diff --git a/public_html/templates/default/create.tpl b/public_html/templates/default/create.tpl
index e65cbac2..5c674bd8 100644
--- a/public_html/templates/default/create.tpl
+++ b/public_html/templates/default/create.tpl
@@ -1,4 +1,4 @@
-{include file='top.tpl'}
+{include file='ls:top.tpl'}
{if $pagetitle != ''}{/if}
{if !empty($listAvailableDataEntryForm)}
@@ -10,5 +10,5 @@
{/if}
- {include file='LSform.tpl'}
-{include file='bottom.tpl'}
+ {include file='ls:LSform.tpl'}
+{include file='ls:bottom.tpl'}
diff --git a/public_html/templates/default/empty.tpl b/public_html/templates/default/empty.tpl
index 70430570..e9ef92ff 100644
--- a/public_html/templates/default/empty.tpl
+++ b/public_html/templates/default/empty.tpl
@@ -1,2 +1,2 @@
-{include file='top.tpl'}
-{include file='bottom.tpl'}
+{include file='ls:top.tpl'}
+{include file='ls:bottom.tpl'}
diff --git a/public_html/templates/default/login.tpl b/public_html/templates/default/login.tpl
index 8467fcfd..88b3c7cc 100644
--- a/public_html/templates/default/login.tpl
+++ b/public_html/templates/default/login.tpl
@@ -11,7 +11,7 @@
-{include file='LSdefault.tpl'}
+{include file='ls:LSdefault.tpl'}