File size: 2,683 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Ext.onReady(function() {
  cacheFields = new Ext.form.FieldSet({

    title : _('ID_CLEAR_CACHE'),
    items : [
      {
        xtype      : 'checkbox',
        name       : 'javascriptCache',
        fieldLabel : _('ID_TERMS_USE'),
        hideLabel  : true,
        id         : 'javascriptCache',
        boxLabel   : _('ID_JAVASCRIPT_CACHE'),
        listeners  : {
          check : enableBtn
        }
      },
      {
        xtype      : 'checkbox',
        name       : 'metadataCache',
        fieldLabel : _('ID_TERMS_USE'),
        hideLabel  : true,
        id         : 'metadataCache',
        boxLabel   : _('ID_FORMS_METADATA_CACHE'),
        listeners  : {
          check : enableBtn
        }
      },
      {
        xtype      : 'checkbox',
        name       : 'htmlCache',
        fieldLabel : _('ID_TERMS_USE'),
        hideLabel  : true,
        id         : 'htmlCache',
        boxLabel   : _('ID_FORMS_HTML_CACHE'),
        listeners  : {
          check : enableBtn
        }
      }
    ],
    buttons   : [{
      id      : 'btn_save',
      text    : _('ID_CLEAR'),
      disabled: true,
      handler : clearCache
    }]
  });

  var frm = new Ext.FormPanel( {
    title         : '&nbsp',
    id            : 'frmCache',
    width         : 400,
    labelWidth    : 150,
    labelAlign    : 'right',
    autoScroll    : true,
    bodyStyle     : 'padding:2px',
    waitMsgTarget : true,
    frame         : true,
    defaults : {
      allowBlank : false,
      resizable  : true,
      msgTarget  : 'side',
      align      : 'center'
    },
    items : [ cacheFields ]

  });
  
  frm.render(document.body);
});

function enableBtn() {
  Ext.getCmp('btn_save').enable();
}

function clearCache () {
  Ext.getCmp('frmCache').getForm().submit({
    url     : 'clearCompiledAjax',
    waitMsg : _('ID_SAVING_PROCESS'),
    waitTitle : " ",
    timeout : 36000,
    success : function(obj, resp) {
      message = '';
      response = Ext.decode(resp.response.responseText);

      if (response.javascript) {
        message += _('ID_JAVASCRIPT_CACHE') + '<br />';
      }
      
      if (response.xmlform) {
        message += _('ID_FORMS_METADATA_CACHE') + '<br />';
      }
      
      if (response.smarty) {
        message += _('ID_FORMS_HTML_CACHE') + '<br />';
      }
      
      PMExt.notify(_('ID_CLEAR_CACHE'), message + _('ID_HAS_BEEN_DELETED'));

      setTimeout(function() {
        window.location.href = window.location.href;
      }, 1500);
    },
    failure : function(obj, resp) {
      if (typeof resp.response.responseText != 'undefined')
        PMExt.error(_('ID_ERROR'), resp.response.responseText);
    }
  });
}