*/
function display(){
if ($this -> idForm == 'view') {
- self :: loadDependenciesDisplayView();
+ self :: loadDependenciesDisplayView($this -> $ldapObject);
}
else {
LSsession :: addJSscript('LSformElement_field.js');
*
* @retval void
*/
- public static function loadDependenciesDisplayView() {
+ public static function loadDependenciesDisplayView($ldapObject=false) {
LSsession :: addCssFile('LSform.css');
LSsession :: addJSscript('LSform.js');
- LSsession :: addJSconfigParam('LSview_labels', array(
+ $customActionLabels = array ();
+ if (is_a($ldapObject,'LSldapObject')) {
+ $objectname=$ldapObject -> getDisplayName();
+ $customActionsConfig = LSconfig :: get('LSobjects.'.$ldapObject->type_name.'.customActions');
+ if (is_array($customActionsConfig)) {
+ foreach($customActionsConfig as $name => $config) {
+ if (isset($config['question_format'])) {
+ $customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData(__($config['question_format']),$objectname);
+ }
+ else {
+ $customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData(
+ _('Do you really want to execute custom action %{customAction} on %{objectname} ?'),
+ array(
+ 'objectname' => $objectname,
+ 'customAction' => $name
+ )
+ );
+ }
+ }
+ }
+ }
+ LSsession :: addJSconfigParam('LSview_labels', array_merge(array(
'delete_confirm_text' => _("Do you really want to delete"),
'delete_confirm_title' => _("Caution"),
'delete_confirm_validate' => _("Delete")
- ));
+ ),$customActionLabels));
if (LSsession :: loadLSclass('LSconfirmBox')) {
LSconfirmBox :: loadDependenciesDisplay();
}
* @retval void
*/
function displayView(){
- self :: loadDependenciesDisplayView();
+ self :: loadDependenciesDisplayView($this -> ldapObject);
$LSform_object = array(
'type' => $this -> ldapObject -> getType(),
removeFromA: function(a) {
document.location = a.href+'&valid';
+ },
+
+ onCustomActionBtnClick: function(event,a) {
+ Event(event).stop();
+ if (!this._confirmBoxOpen) {
+ this._confirmBoxOpen = 1;
+ var getName = new RegExp('customAction=([^&]*)');
+ var name = getName.exec(a.href)[1];
+ if (name) {
+ var title = a.innerHTML;
+ if ($type(this.labels['custom_action_'+name+'_confirm_text'])) {
+ var text = this.labels['custom_action_'+name+'_confirm_text']
+ }
+ else {
+ var objectname = $('LSview_title').innerHTML;
+ var text = getFData('Do you really want to execute custom action %{customAction} on %{objectname} ?',{customAction: name, objectname: objectname });
+ }
+ this.confirmBox = new LSconfirmBox({
+ text: text,
+ title: title,
+ startElement: a,
+ onConfirm: this.executeCustomActionFromA.bind(this,a),
+ onClose: this.onConfirmBoxClose.bind(this)
+ });
+ }
+ }
+ },
+
+ executeCustomActionFromA: function(a) {
+ document.location = a.href+'&valid';
}
});
$LSview_actions[] = array (
'label' => ((isset($config['label']))?__($config['label']):__($name)),
'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.$dn.'&customAction='.$name,
- 'action' => ((isset($config['icon']))?$config['icon']:'generate')
+ 'action' => ((isset($config['icon']))?$config['icon']:'generate'),
+ 'class' => 'LScustomActions'
);
}
}