language.grid.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**
  2. * Loads a grid for managing languages.
  3. *
  4. * @class MODx.grid.Language
  5. * @extends MODx.grid.Grid
  6. * @param {Object} config An object of configuration properties
  7. * @xtype modx-grid-language
  8. */
  9. MODx.grid.Language = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. title: _('languages')
  13. ,id: 'modx-grid-language'
  14. ,url: MODx.config.connector_url+'system/language.php'
  15. ,baseParams: {
  16. action: 'system/language/getlist'
  17. }
  18. ,fields: ['id','name','menu']
  19. ,width: '97%'
  20. ,paging: true
  21. ,autosave: true
  22. ,primaryKey: 'name'
  23. ,columns: [{
  24. header: _('name')
  25. ,dataIndex: 'name'
  26. ,width: 200
  27. ,sortable: true
  28. }]
  29. ,tbar: [{
  30. text: _('language_create')
  31. ,handler: {
  32. xtype: 'modx-window-language-create'
  33. ,listeners: {
  34. 'success':{fn:function(o) {
  35. var r = o.a.result.object;
  36. this.refresh();
  37. var g = Ext.getCmp('modx-grid-lexicon');
  38. if (g) {
  39. g.setFilterParams(null,null,r.name);
  40. }
  41. },scope:this}
  42. }
  43. }
  44. ,scope: this
  45. }]
  46. });
  47. MODx.grid.Language.superclass.constructor.call(this,config);
  48. };
  49. Ext.extend(MODx.grid.Language,MODx.grid.Grid,{
  50. duplicateLanguage: function(btn,e) {
  51. var df = Ext.Ajax.timeout;
  52. Ext.Ajax.timeout = 0;
  53. this.menu.record.new_name = _('duplicate_of')+this.menu.record.name;
  54. this.loadWindow(btn,e,{
  55. xtype: 'modx-window-language-duplicate'
  56. ,record: this.menu.record
  57. ,listeners: {
  58. 'success': {fn:function(r) {
  59. Ext.Ajax.timeout = df;
  60. this.refresh();
  61. var g = Ext.getCmp('modx-grid-lexicon');
  62. if (g) {
  63. g.setFilterParams(null,null,r.name);
  64. }
  65. },scope:this}
  66. }
  67. });
  68. }
  69. });
  70. Ext.reg('modx-grid-language',MODx.grid.Language);
  71. /**
  72. * Generates the create language window.
  73. *
  74. * @class MODx.window.CreateLanguage
  75. * @extends MODx.Window
  76. * @param {Object} config An object of options.
  77. * @xtype modx-window-language-create
  78. */
  79. MODx.window.CreateLanguage = function(config) {
  80. config = config || {};
  81. var r = config.record;
  82. Ext.applyIf(config,{
  83. title: _('language_create')
  84. ,url: MODx.config.connector_url
  85. ,action: 'system/language/create'
  86. ,fields: [{
  87. xtype: 'textfield'
  88. ,fieldLabel: _('name')
  89. ,name: 'name'
  90. ,itemId: 'name'
  91. ,anchor: '100%'
  92. ,maxLength: 100
  93. ,allowBlank: false
  94. }]
  95. });
  96. MODx.window.CreateLanguage.superclass.constructor.call(this,config);
  97. };
  98. Ext.extend(MODx.window.CreateLanguage,MODx.Window);
  99. Ext.reg('modx-window-language-create',MODx.window.CreateLanguage);
  100. MODx.window.DuplicateLanguage = function(config) {
  101. config = config || {};
  102. var r = config.record;
  103. Ext.applyIf(config,{
  104. title: _('language_duplicate')
  105. ,url: MODx.config.connector_url
  106. ,action: 'system/language/duplicate'
  107. ,fields: [{
  108. xtype: 'statictextfield'
  109. ,fieldLabel: _('duplicate')
  110. ,name: 'name'
  111. ,itemId: 'name'
  112. ,anchor: '100%'
  113. ,maxLength: 100
  114. ,allowBlank: false
  115. ,submitValue: true
  116. },{
  117. xtype: 'textfield'
  118. ,fieldLabel: _('language_new_name')
  119. ,description: _('language_new_name_desc')
  120. ,name: 'new_name'
  121. ,itemId: 'new_name'
  122. ,anchor: '100%'
  123. ,allowBlank: false
  124. },{
  125. xtype: 'xcheckbox'
  126. ,boxLabel: _('language_recursive')
  127. ,description: _('language_recursive_desc')
  128. ,name: 'recursive'
  129. ,itemId: 'recursive'
  130. ,inputValue: 1
  131. ,checked: true
  132. }]
  133. });
  134. MODx.window.DuplicateLanguage.superclass.constructor.call(this,config);
  135. };
  136. Ext.extend(MODx.window.DuplicateLanguage,MODx.Window);
  137. Ext.reg('modx-window-language-duplicate',MODx.window.DuplicateLanguage);