windows.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. /**
  2. * Generates the Duplicate Resource window.
  3. *
  4. * @class MODx.window.DuplicateResource
  5. * @extends MODx.Window
  6. * @param {Object} config An object of options.
  7. * @xtype modx-window-resource-duplicate
  8. */
  9. MODx.window.DuplicateResource = function(config) {
  10. config = config || {};
  11. this.ident = config.ident || 'dupres'+Ext.id();
  12. Ext.applyIf(config,{
  13. title: config.pagetitle ? _('duplicate') + ' ' + config.pagetitle : _('duplication_options')
  14. ,id: this.ident
  15. // ,width: 500
  16. });
  17. MODx.window.DuplicateResource.superclass.constructor.call(this,config);
  18. };
  19. Ext.extend(MODx.window.DuplicateResource,MODx.Window,{
  20. _loadForm: function() {
  21. if (this.checkIfLoaded(this.config.record)) {
  22. this.fp.getForm().baseParams = {
  23. action: 'resource/updateduplicate'
  24. ,prefixDuplicate: true
  25. ,id: this.config.resource
  26. };
  27. return false;
  28. }
  29. var items = [];
  30. items.push({
  31. xtype: 'textfield'
  32. ,id: 'modx-'+this.ident+'-name'
  33. ,fieldLabel: _('resource_name_new')
  34. ,name: 'name'
  35. ,anchor: '100%'
  36. ,value: ''
  37. });
  38. if (this.config.hasChildren) {
  39. items.push({
  40. xtype: 'xcheckbox'
  41. ,boxLabel: _('duplicate_children') + ' ('+this.config.childCount+')'
  42. ,hideLabel: true
  43. ,name: 'duplicate_children'
  44. ,id: 'modx-'+this.ident+'-duplicate-children'
  45. ,checked: true
  46. ,listeners: {
  47. 'check': {fn: function(cb,checked) {
  48. if (checked) {
  49. this.fp.getForm().findField('modx-'+this.ident+'-name').disable();
  50. } else {
  51. this.fp.getForm().findField('modx-'+this.ident+'-name').enable();
  52. }
  53. },scope:this}
  54. }
  55. });
  56. }
  57. var pov = MODx.config.default_duplicate_publish_option || 'preserve';
  58. items.push({
  59. xtype: 'fieldset'
  60. ,title: _('publishing_options')
  61. ,items: [{
  62. xtype: 'radiogroup'
  63. ,hideLabel: true
  64. ,columns: 1
  65. ,value: pov
  66. ,items: [{
  67. boxLabel: _('po_make_all_unpub')
  68. ,hideLabel: true
  69. ,name: 'published_mode'
  70. ,inputValue: 'unpublish'
  71. },{
  72. boxLabel: _('po_make_all_pub')
  73. ,hideLabel: true
  74. ,name: 'published_mode'
  75. ,inputValue: 'publish'
  76. },{
  77. boxLabel: _('po_preserve')
  78. ,hideLabel: true
  79. ,name: 'published_mode'
  80. ,inputValue: 'preserve'
  81. }]
  82. }]
  83. });
  84. this.fp = this.createForm({
  85. url: this.config.url || MODx.config.connector_url
  86. ,baseParams: this.config.baseParams || {
  87. action: 'resource/duplicate'
  88. ,id: this.config.resource
  89. ,prefixDuplicate: true
  90. }
  91. ,labelWidth: 125
  92. ,defaultType: 'textfield'
  93. ,autoHeight: true
  94. ,items: items
  95. });
  96. this.renderForm();
  97. }
  98. });
  99. Ext.reg('modx-window-resource-duplicate',MODx.window.DuplicateResource);
  100. /**
  101. * Generates the Duplicate Element window
  102. *
  103. * @class MODx.window.DuplicateElement
  104. * @extends MODx.Window
  105. * @param {Object} config An object of options.
  106. * @xtype modx-window-element-duplicate
  107. */
  108. MODx.window.DuplicateElement = function(config) {
  109. config = config || {};
  110. this.ident = config.ident || 'dupeel-'+Ext.id();
  111. var flds = [{
  112. xtype: 'hidden'
  113. ,name: 'id'
  114. ,id: 'modx-'+this.ident+'-id'
  115. },{
  116. xtype: 'hidden'
  117. ,name: 'source'
  118. ,id: 'modx-'+this.ident+'-source'
  119. }, {
  120. xtype: 'textfield'
  121. ,fieldLabel: _('element_name_new')
  122. ,name: config.record.type == 'template' ? 'templatename' : 'name'
  123. ,id: 'modx-'+this.ident+'-name'
  124. ,anchor: '100%'
  125. ,enableKeyEvents: true
  126. ,listeners: {
  127. 'afterRender' : {scope:this,fn:function(f,e) {
  128. this.setStaticElementsPath(f);
  129. }},
  130. 'keyup': {scope:this,fn:function(f,e) {
  131. this.setStaticElementsPath(f);
  132. }}
  133. }
  134. }];
  135. if (config.record.type == 'tv') {
  136. flds.push({
  137. xtype: 'textfield'
  138. ,fieldLabel: _('element_caption_new')
  139. ,name: 'caption'
  140. ,id: 'modx-'+this.ident+'-caption'
  141. ,anchor: '100%'
  142. });
  143. flds.push({
  144. xtype: 'xcheckbox'
  145. ,fieldLabel: _('element_duplicate_values')
  146. ,labelSeparator: ''
  147. ,name: 'duplicateValues'
  148. ,id: 'modx-'+this.ident+'-duplicate-values'
  149. ,anchor: '100%'
  150. ,inputValue: 1
  151. ,checked: false
  152. });
  153. }
  154. if (config.record.static === true) {
  155. flds.push({
  156. xtype: 'textfield'
  157. ,fieldLabel: _('static_file')
  158. ,name: 'static_file'
  159. ,id: 'modx-'+this.ident+'-static_file'
  160. ,anchor: '100%'
  161. }
  162. );
  163. }
  164. Ext.applyIf(config,{
  165. title: _('element_duplicate')
  166. ,url: MODx.config.connector_url
  167. ,action: 'element/'+config.record.type+'/duplicate'
  168. ,width: 600
  169. ,fields: flds
  170. ,labelWidth: 150
  171. });
  172. MODx.window.DuplicateElement.superclass.constructor.call(this,config);
  173. };
  174. Ext.extend(MODx.window.DuplicateElement,MODx.Window, {
  175. setStaticElementsPath: function(f) {
  176. if (this.config.record.static === true) {
  177. var category = this.config.record.category;
  178. if (typeof category !== 'number') {
  179. if (Ext.getCmp('modx-' + this.config.record.type + '-category').getValue() > 0) {
  180. category = Ext.getCmp('modx-' + this.config.record.type + '-category').lastSelectionText;
  181. }
  182. var path = MODx.getStaticElementsPath(f.getValue(), category, this.config.record.type + 's');
  183. Ext.getCmp('modx-' + this.ident + '-static_file').setValue(path);
  184. } else {
  185. // If category is set but is a number, retrieve full category name.
  186. if (typeof category === "number" && category > 0) {
  187. MODx.Ajax.request({
  188. url: MODx.config.connector_url
  189. ,params: {
  190. action: 'element/category/getlist'
  191. ,id: category
  192. }
  193. ,listeners: {
  194. 'success': {fn:function(response) {
  195. for (var i = 0; i < response.results.length; i++) {
  196. if (response.results[i].id === category) {
  197. category = response.results[i].name;
  198. }
  199. }
  200. var path = MODx.getStaticElementsPath(f.getValue(), category, this.config.record.type + 's');
  201. Ext.getCmp('modx-' + this.ident + '-static_file').setValue(path);
  202. },scope:this}
  203. }
  204. });
  205. }
  206. }
  207. }
  208. }
  209. });
  210. Ext.reg('modx-window-element-duplicate',MODx.window.DuplicateElement);
  211. MODx.window.CreateCategory = function(config) {
  212. config = config || {};
  213. this.ident = config.ident || 'ccat'+Ext.id();
  214. Ext.applyIf(config,{
  215. title: _('new_category')
  216. ,id: this.ident
  217. // ,height: 150
  218. // ,width: 350
  219. ,url: MODx.config.connector_url
  220. ,action: 'element/category/create'
  221. ,fields: [{
  222. fieldLabel: _('name')
  223. ,name: 'category'
  224. ,id: 'modx-'+this.ident+'-category'
  225. ,xtype: 'textfield'
  226. ,anchor: '100%'
  227. },{
  228. fieldLabel: _('parent')
  229. ,name: 'parent'
  230. ,hiddenName: 'parent'
  231. ,id: 'modx-'+this.ident+'-parent'
  232. ,xtype: 'modx-combo-category'
  233. ,anchor: '100%'
  234. },{
  235. fieldLabel: _('rank')
  236. ,name: 'rank'
  237. ,id: 'modx-'+this.ident+'-rank'
  238. ,xtype: 'numberfield'
  239. ,anchor: '100%'
  240. }]
  241. });
  242. MODx.window.CreateCategory.superclass.constructor.call(this,config);
  243. };
  244. Ext.extend(MODx.window.CreateCategory,MODx.Window);
  245. Ext.reg('modx-window-category-create',MODx.window.CreateCategory);
  246. /**
  247. * Generates the Rename Category window.
  248. *
  249. * @class MODx.window.RenameCategory
  250. * @extends MODx.Window
  251. * @param {Object} config An object of options.
  252. * @xtype modx-window-category-rename
  253. */
  254. MODx.window.RenameCategory = function(config) {
  255. config = config || {};
  256. this.ident = config.ident || 'rencat-'+Ext.id();
  257. Ext.applyIf(config,{
  258. title: _('category_rename')
  259. // ,height: 150
  260. // ,width: 350
  261. ,url: MODx.config.connector_url
  262. ,action: 'element/category/update'
  263. ,fields: [{
  264. xtype: 'hidden'
  265. ,name: 'id'
  266. ,id: 'modx-'+this.ident+'-id'
  267. ,value: config.record.id
  268. },{
  269. xtype: 'textfield'
  270. ,fieldLabel: _('name')
  271. ,name: 'category'
  272. ,id: 'modx-'+this.ident+'-category'
  273. ,width: 150
  274. ,value: config.record.category
  275. ,anchor: '100%'
  276. },{
  277. fieldLabel: _('rank')
  278. ,name: 'rank'
  279. ,id: 'modx-'+this.ident+'-rank'
  280. ,xtype: 'numberfield'
  281. ,anchor: '100%'
  282. }]
  283. });
  284. MODx.window.RenameCategory.superclass.constructor.call(this,config);
  285. };
  286. Ext.extend(MODx.window.RenameCategory,MODx.Window);
  287. Ext.reg('modx-window-category-rename',MODx.window.RenameCategory);
  288. MODx.window.CreateNamespace = function(config) {
  289. config = config || {};
  290. var r = config.record;
  291. this.ident = config.ident || 'cns'+Ext.id();
  292. Ext.applyIf(config,{
  293. title: _('namespace_create')
  294. ,id: this.ident
  295. ,width: 600
  296. ,url: MODx.config.connector_url
  297. ,action: 'workspace/namespace/create'
  298. ,fields: [{
  299. xtype: 'textfield'
  300. ,fieldLabel: _('name')
  301. ,description: MODx.expandHelp ? '' : _('namespace_name_desc')
  302. ,name: 'name'
  303. ,id: 'modx-'+this.ident+'-name'
  304. ,anchor: '100%'
  305. ,maxLength: 100
  306. ,readOnly: config.isUpdate || false
  307. },{
  308. xtype: MODx.expandHelp ? 'label' : 'hidden'
  309. ,forId: 'modx-'+this.ident+'-name'
  310. ,html: _('namespace_name_desc')
  311. ,cls: 'desc-under'
  312. },{
  313. xtype: 'textfield'
  314. ,fieldLabel: _('namespace_path')
  315. ,description: MODx.expandHelp ? '' : _('namespace_path_desc')
  316. ,name: 'path'
  317. ,id: 'modx-'+this.ident+'-path'
  318. ,anchor: '100%'
  319. },{
  320. xtype: MODx.expandHelp ? 'label' : 'hidden'
  321. ,forId: 'modx-'+this.ident+'-path'
  322. ,html: _('namespace_path_desc')
  323. ,cls: 'desc-under'
  324. },{
  325. xtype: 'textfield'
  326. ,fieldLabel: _('namespace_assets_path')
  327. ,description: MODx.expandHelp ? '' : _('namespace_assets_path_desc')
  328. ,name: 'assets_path'
  329. ,id: 'modx-'+this.ident+'-assets-path'
  330. ,anchor: '100%'
  331. },{
  332. xtype: MODx.expandHelp ? 'label' : 'hidden'
  333. ,forId: 'modx-'+this.ident+'-assets-path'
  334. ,html: _('namespace_assets_path_desc')
  335. ,cls: 'desc-under'
  336. }]
  337. });
  338. MODx.window.CreateNamespace.superclass.constructor.call(this,config);
  339. };
  340. Ext.extend(MODx.window.CreateNamespace,MODx.Window);
  341. Ext.reg('modx-window-namespace-create',MODx.window.CreateNamespace);
  342. MODx.window.UpdateNamespace = function(config) {
  343. config = config || {};
  344. Ext.applyIf(config, {
  345. title: _('namespace_update')
  346. ,action: 'workspace/namespace/update'
  347. ,isUpdate: true
  348. });
  349. MODx.window.UpdateNamespace.superclass.constructor.call(this, config);
  350. };
  351. Ext.extend(MODx.window.UpdateNamespace, MODx.window.CreateNamespace, {});
  352. Ext.reg('modx-window-namespace-update',MODx.window.UpdateNamespace);
  353. MODx.window.QuickCreateChunk = function(config) {
  354. config = config || {};
  355. Ext.applyIf(config,{
  356. title: _('quick_create_chunk')
  357. ,width: 600
  358. //,height: 640
  359. // ,autoHeight: true
  360. ,layout: 'anchor'
  361. ,url: MODx.config.connector_url
  362. ,action: 'element/chunk/create'
  363. ,fields: [{
  364. xtype: 'hidden'
  365. ,name: 'id'
  366. },{
  367. xtype: 'textfield'
  368. ,name: 'name'
  369. ,fieldLabel: _('name')
  370. ,anchor: '100%'
  371. },{
  372. xtype: 'modx-combo-category'
  373. ,name: 'category'
  374. ,fieldLabel: _('category')
  375. ,anchor: '100%'
  376. },{
  377. xtype: 'textarea'
  378. ,name: 'description'
  379. ,fieldLabel: _('description')
  380. ,anchor: '100%'
  381. //,rows: 2
  382. },{
  383. xtype: 'textarea'
  384. ,name: 'snippet'
  385. ,fieldLabel: _('code')
  386. ,anchor: '100%'
  387. ,grow: true
  388. ,growMax: 216
  389. },{
  390. xtype: 'xcheckbox'
  391. ,name: 'clearCache'
  392. ,hideLabel: true
  393. ,boxLabel: _('clear_cache_on_save')
  394. ,description: _('clear_cache_on_save_msg')
  395. ,inputValue: 1
  396. ,checked: true
  397. }]
  398. ,keys: [{
  399. key: Ext.EventObject.ENTER
  400. ,shift: true
  401. ,fn: this.submit
  402. ,scope: this
  403. }]
  404. });
  405. MODx.window.QuickCreateChunk.superclass.constructor.call(this,config);
  406. };
  407. Ext.extend(MODx.window.QuickCreateChunk,MODx.Window);
  408. Ext.reg('modx-window-quick-create-chunk',MODx.window.QuickCreateChunk);
  409. MODx.window.QuickUpdateChunk = function(config) {
  410. config = config || {};
  411. Ext.applyIf(config,{
  412. title: _('quick_update_chunk')
  413. ,action: 'element/chunk/update'
  414. ,buttons: [{
  415. text: config.cancelBtnText || _('cancel')
  416. ,scope: this
  417. ,handler: function() { this.hide(); }
  418. },{
  419. text: config.saveBtnText || _('save')
  420. ,scope: this
  421. ,handler: function() { this.submit(false); }
  422. },{
  423. text: config.saveBtnText || _('save_and_close')
  424. ,cls: 'primary-button'
  425. ,scope: this
  426. ,handler: this.submit
  427. }]
  428. });
  429. MODx.window.QuickUpdateChunk.superclass.constructor.call(this,config);
  430. };
  431. Ext.extend(MODx.window.QuickUpdateChunk, MODx.window.QuickCreateChunk);
  432. Ext.reg('modx-window-quick-update-chunk',MODx.window.QuickUpdateChunk);
  433. MODx.window.QuickCreateTemplate = function(config) {
  434. config = config || {};
  435. Ext.applyIf(config,{
  436. title: _('quick_create_template')
  437. ,width: 600
  438. // ,autoHeight: true
  439. ,layout: 'anchor'
  440. ,url: MODx.config.connector_url
  441. ,action: 'element/template/create'
  442. ,fields: [{
  443. xtype: 'hidden'
  444. ,name: 'id'
  445. },{
  446. xtype: 'textfield'
  447. ,name: 'templatename'
  448. ,fieldLabel: _('name')
  449. ,anchor: '100%'
  450. },{
  451. xtype: 'modx-combo-category'
  452. ,name: 'category'
  453. ,fieldLabel: _('category')
  454. ,anchor: '100%'
  455. },{
  456. xtype: 'textarea'
  457. ,name: 'description'
  458. ,fieldLabel: _('description')
  459. ,anchor: '100%'
  460. },{
  461. xtype: 'textarea'
  462. ,name: 'content'
  463. ,fieldLabel: _('code')
  464. ,anchor: '100%'
  465. ,grow: true
  466. ,growMax: 216
  467. },{
  468. xtype: 'xcheckbox'
  469. ,name: 'clearCache'
  470. ,hideLabel: true
  471. ,boxLabel: _('clear_cache_on_save')
  472. ,description: _('clear_cache_on_save_msg')
  473. ,inputValue: 1
  474. ,checked: true
  475. }]
  476. ,keys: [{
  477. key: Ext.EventObject.ENTER
  478. ,shift: true
  479. ,fn: this.submit
  480. ,scope: this
  481. }]
  482. });
  483. MODx.window.QuickCreateTemplate.superclass.constructor.call(this,config);
  484. };
  485. Ext.extend(MODx.window.QuickCreateTemplate,MODx.Window);
  486. Ext.reg('modx-window-quick-create-template',MODx.window.QuickCreateTemplate);
  487. MODx.window.QuickUpdateTemplate = function(config) {
  488. config = config || {};
  489. Ext.applyIf(config,{
  490. title: _('quick_update_template')
  491. ,action: 'element/template/update'
  492. ,buttons: [{
  493. text: config.cancelBtnText || _('cancel')
  494. ,scope: this
  495. ,handler: function() { this.hide(); }
  496. },{
  497. text: config.saveBtnText || _('save')
  498. ,scope: this
  499. ,handler: function() { this.submit(false); }
  500. },{
  501. text: config.saveBtnText || _('save_and_close')
  502. ,cls: 'primary-button'
  503. ,scope: this
  504. ,handler: this.submit
  505. }]
  506. });
  507. MODx.window.QuickUpdateTemplate.superclass.constructor.call(this,config);
  508. };
  509. Ext.extend(MODx.window.QuickUpdateTemplate,MODx.window.QuickCreateTemplate);
  510. Ext.reg('modx-window-quick-update-template',MODx.window.QuickUpdateTemplate);
  511. MODx.window.QuickCreateSnippet = function(config) {
  512. config = config || {};
  513. Ext.applyIf(config,{
  514. title: _('quick_create_snippet')
  515. ,width: 600
  516. // ,autoHeight: true
  517. ,layout: 'anchor'
  518. ,url: MODx.config.connector_url
  519. ,action: 'element/snippet/create'
  520. ,fields: [{
  521. xtype: 'hidden'
  522. ,name: 'id'
  523. },{
  524. xtype: 'textfield'
  525. ,name: 'name'
  526. ,fieldLabel: _('name')
  527. ,anchor: '100%'
  528. },{
  529. xtype: 'modx-combo-category'
  530. ,name: 'category'
  531. ,fieldLabel: _('category')
  532. ,anchor: '100%'
  533. },{
  534. xtype: 'textarea'
  535. ,name: 'description'
  536. ,fieldLabel: _('description')
  537. ,anchor: '100%'
  538. },{
  539. xtype: 'textarea'
  540. ,name: 'snippet'
  541. ,fieldLabel: _('code')
  542. ,anchor: '100%'
  543. ,grow: true
  544. ,growMax: 216
  545. },{
  546. xtype: 'xcheckbox'
  547. ,name: 'clearCache'
  548. ,hideLabel: true
  549. ,boxLabel: _('clear_cache_on_save')
  550. ,description: _('clear_cache_on_save_msg')
  551. ,inputValue: 1
  552. ,checked: true
  553. }]
  554. ,keys: [{
  555. key: Ext.EventObject.ENTER
  556. ,shift: true
  557. ,fn: this.submit
  558. ,scope: this
  559. }]
  560. });
  561. MODx.window.QuickCreateSnippet.superclass.constructor.call(this,config);
  562. };
  563. Ext.extend(MODx.window.QuickCreateSnippet,MODx.Window);
  564. Ext.reg('modx-window-quick-create-snippet',MODx.window.QuickCreateSnippet);
  565. MODx.window.QuickUpdateSnippet = function(config) {
  566. config = config || {};
  567. Ext.applyIf(config,{
  568. title: _('quick_update_snippet')
  569. ,action: 'element/snippet/update'
  570. ,buttons: [{
  571. text: config.cancelBtnText || _('cancel')
  572. ,scope: this
  573. ,handler: function() { this.hide(); }
  574. },{
  575. text: config.saveBtnText || _('save')
  576. ,scope: this
  577. ,handler: function() { this.submit(false); }
  578. },{
  579. text: config.saveBtnText || _('save_and_close')
  580. ,cls: 'primary-button'
  581. ,scope: this
  582. ,handler: this.submit
  583. }]
  584. });
  585. MODx.window.QuickUpdateSnippet.superclass.constructor.call(this,config);
  586. };
  587. Ext.extend(MODx.window.QuickUpdateSnippet,MODx.window.QuickCreateSnippet);
  588. Ext.reg('modx-window-quick-update-snippet',MODx.window.QuickUpdateSnippet);
  589. MODx.window.QuickCreatePlugin = function(config) {
  590. config = config || {};
  591. Ext.applyIf(config,{
  592. title: _('quick_create_plugin')
  593. ,width: 600
  594. // ,autoHeight: true
  595. ,layout: 'anchor'
  596. ,url: MODx.config.connector_url
  597. ,action: 'element/plugin/create'
  598. ,fields: [{
  599. xtype: 'hidden'
  600. ,name: 'id'
  601. },{
  602. xtype: 'textfield'
  603. ,name: 'name'
  604. ,fieldLabel: _('name')
  605. ,anchor: '100%'
  606. },{
  607. xtype: 'modx-combo-category'
  608. ,name: 'category'
  609. ,fieldLabel: _('category')
  610. ,anchor: '100%'
  611. },{
  612. xtype: 'textarea'
  613. ,name: 'description'
  614. ,fieldLabel: _('description')
  615. ,anchor: '100%'
  616. ,rows: 2
  617. },{
  618. xtype: 'textarea'
  619. ,name: 'plugincode'
  620. ,fieldLabel: _('code')
  621. ,anchor: '100%'
  622. ,grow: true
  623. ,growMax: 216
  624. },{
  625. xtype: 'xcheckbox'
  626. ,name: 'disabled'
  627. ,boxLabel: _('disabled')
  628. ,hideLabel: true
  629. ,inputValue: 1
  630. ,checked: false
  631. },{
  632. xtype: 'xcheckbox'
  633. ,name: 'clearCache'
  634. ,boxLabel: _('clear_cache_on_save')
  635. ,hideLabel: true
  636. ,description: _('clear_cache_on_save_msg')
  637. ,inputValue: 1
  638. ,checked: true
  639. }]
  640. ,keys: [{
  641. key: Ext.EventObject.ENTER
  642. ,shift: true
  643. ,fn: this.submit
  644. ,scope: this
  645. }]
  646. });
  647. MODx.window.QuickCreatePlugin.superclass.constructor.call(this,config);
  648. };
  649. Ext.extend(MODx.window.QuickCreatePlugin,MODx.Window);
  650. Ext.reg('modx-window-quick-create-plugin',MODx.window.QuickCreatePlugin);
  651. MODx.window.QuickUpdatePlugin = function(config) {
  652. config = config || {};
  653. Ext.applyIf(config,{
  654. title: _('quick_update_plugin')
  655. ,action: 'element/plugin/update'
  656. ,buttons: [{
  657. text: config.cancelBtnText || _('cancel')
  658. ,scope: this
  659. ,handler: function() { this.hide(); }
  660. },{
  661. text: config.saveBtnText || _('save')
  662. ,scope: this
  663. ,handler: function() { this.submit(false); }
  664. },{
  665. text: config.saveBtnText || _('save_and_close')
  666. ,cls: 'primary-button'
  667. ,scope: this
  668. ,handler: this.submit
  669. }]
  670. });
  671. MODx.window.QuickUpdatePlugin.superclass.constructor.call(this,config);
  672. };
  673. Ext.extend(MODx.window.QuickUpdatePlugin,MODx.window.QuickCreatePlugin);
  674. Ext.reg('modx-window-quick-update-plugin',MODx.window.QuickUpdatePlugin);
  675. MODx.window.QuickCreateTV = function(config) {
  676. config = config || {};
  677. this.ident = config.ident || 'qtv'+Ext.id();
  678. Ext.applyIf(config,{
  679. title: _('quick_create_tv')
  680. ,width: 700
  681. ,url: MODx.config.connector_url
  682. ,action: 'element/tv/create'
  683. ,fields: [{
  684. xtype: 'hidden'
  685. ,name: 'id'
  686. },{
  687. layout: 'column'
  688. ,border: false
  689. ,items: [{
  690. columnWidth: .6
  691. ,layout: 'form'
  692. ,items: [{
  693. xtype: 'textfield'
  694. ,name: 'name'
  695. ,fieldLabel: _('name')
  696. ,anchor: '100%'
  697. },{
  698. xtype: 'textfield'
  699. ,name: 'caption'
  700. ,id: 'modx-'+this.ident+'-caption'
  701. ,fieldLabel: _('caption')
  702. ,anchor: '100%'
  703. },{
  704. xtype: 'label'
  705. ,forId: 'modx-'+this.ident+'-caption'
  706. ,html: _('caption_desc')
  707. ,cls: 'desc-under'
  708. },{
  709. xtype: 'modx-combo-category'
  710. ,name: 'category'
  711. ,fieldLabel: _('category')
  712. ,anchor: '100%'
  713. },{
  714. xtype: 'textarea'
  715. ,name: 'description'
  716. ,fieldLabel: _('description')
  717. ,anchor: '100%'
  718. }]
  719. },{
  720. columnWidth: .4
  721. ,border: false
  722. ,layout: 'form'
  723. ,items: [{
  724. xtype: 'modx-combo-tv-input-type'
  725. ,fieldLabel: _('tv_type')
  726. ,name: 'type'
  727. ,anchor: '100%'
  728. },{
  729. xtype: 'textfield'
  730. ,fieldLabel: _('tv_elements')
  731. ,name: 'els'
  732. ,id: 'modx-'+this.ident+'-elements'
  733. ,anchor: '100%'
  734. },{
  735. xtype: 'label'
  736. ,forId: 'modx-'+this.ident+'-elements'
  737. ,html: _('tv_elements_desc')
  738. ,cls: 'desc-under'
  739. },{
  740. xtype: 'textarea'
  741. ,fieldLabel: _('tv_default')
  742. ,name: 'default_text'
  743. ,id: 'modx-'+this.ident+'-default-text'
  744. ,anchor: '100%'
  745. ,grow: true
  746. ,growMax: Ext.getBody().getViewSize().height <= 768 ? 300 : 380
  747. },{
  748. xtype: 'label'
  749. ,forId: 'modx-'+this.ident+'-default-text'
  750. ,html: _('tv_default_desc')
  751. ,cls: 'desc-under'
  752. }]
  753. }]
  754. },{
  755. xtype: 'xcheckbox'
  756. ,name: 'clearCache'
  757. ,hideLabel: true
  758. ,boxLabel: _('clear_cache_on_save')
  759. ,description: _('clear_cache_on_save_msg')
  760. ,inputValue: 1
  761. ,checked: true
  762. }]
  763. ,keys: [{
  764. key: Ext.EventObject.ENTER
  765. ,shift: true
  766. ,fn: this.submit
  767. ,scope: this
  768. }]
  769. });
  770. MODx.window.QuickCreateTV.superclass.constructor.call(this,config);
  771. };
  772. Ext.extend(MODx.window.QuickCreateTV,MODx.Window);
  773. Ext.reg('modx-window-quick-create-tv',MODx.window.QuickCreateTV);
  774. MODx.window.QuickUpdateTV = function(config) {
  775. config = config || {};
  776. Ext.applyIf(config,{
  777. title: _('quick_update_tv')
  778. ,action: 'element/tv/update'
  779. ,buttons: [{
  780. text: config.cancelBtnText || _('cancel')
  781. ,scope: this
  782. ,handler: function() { this.hide(); }
  783. },{
  784. text: config.saveBtnText || _('save')
  785. ,scope: this
  786. ,handler: function() { this.submit(false); }
  787. },{
  788. text: config.saveBtnText || _('save_and_close')
  789. ,cls: 'primary-button'
  790. ,scope: this
  791. ,handler: this.submit
  792. }]
  793. });
  794. MODx.window.QuickUpdateTV.superclass.constructor.call(this,config);
  795. };
  796. Ext.extend(MODx.window.QuickUpdateTV,MODx.window.QuickCreateTV);
  797. Ext.reg('modx-window-quick-update-tv',MODx.window.QuickUpdateTV);
  798. MODx.window.DuplicateContext = function(config) {
  799. config = config || {};
  800. this.ident = config.ident || 'dupctx'+Ext.id();
  801. Ext.Ajax.timeout = 0;
  802. Ext.applyIf(config,{
  803. title: _('context_duplicate')
  804. ,id: this.ident
  805. ,url: MODx.config.connector_url
  806. ,action: 'context/duplicate'
  807. // ,width: 400
  808. ,fields: [{
  809. xtype: 'statictextfield'
  810. ,id: 'modx-'+this.ident+'-key'
  811. ,fieldLabel: _('old_key')
  812. ,name: 'key'
  813. ,anchor: '100%'
  814. ,submitValue: true
  815. },{
  816. xtype: 'textfield'
  817. ,id: 'modx-'+this.ident+'-newkey'
  818. ,fieldLabel: _('new_key')
  819. ,name: 'newkey'
  820. ,anchor: '100%'
  821. ,value: ''
  822. },{
  823. xtype: 'checkbox'
  824. ,id: 'modx-'+this.ident+'-preserveresources'
  825. ,hideLabel: true
  826. ,boxLabel: _('preserve_resources')
  827. ,name: 'preserve_resources'
  828. ,anchor: '100%'
  829. ,checked: true
  830. ,listeners: {
  831. 'check': {fn: function(cb,checked) {
  832. if (checked) {
  833. this.fp.getForm().findField('modx-'+this.ident+'-preservealias').setValue(true).enable();
  834. this.fp.getForm().findField('modx-'+this.ident+'-preservemenuindex').setValue(true).enable();
  835. } else {
  836. this.fp.getForm().findField('modx-'+this.ident+'-preservealias').setValue(false).disable();
  837. this.fp.getForm().findField('modx-'+this.ident+'-preservemenuindex').setValue(false).disable();
  838. }
  839. },scope:this}
  840. }
  841. },{
  842. xtype: 'checkbox'
  843. ,id: 'modx-'+this.ident+'-preservealias'
  844. ,hideLabel: true
  845. ,boxLabel: _('preserve_alias') // Todo: add translation
  846. ,name: 'preserve_alias'
  847. ,anchor: '100%'
  848. ,checked: true
  849. },{
  850. xtype: 'checkbox'
  851. ,id: 'modx-'+this.ident+'-preservemenuindex'
  852. ,hideLabel: true
  853. ,boxLabel: _('preserve_menuindex') // Todo: add translation
  854. ,name: 'preserve_menuindex'
  855. ,anchor: '100%'
  856. ,checked: true
  857. }]
  858. });
  859. MODx.window.DuplicateContext.superclass.constructor.call(this,config);
  860. };
  861. Ext.extend(MODx.window.DuplicateContext,MODx.Window);
  862. Ext.reg('modx-window-context-duplicate',MODx.window.DuplicateContext);
  863. MODx.window.Login = function(config) {
  864. config = config || {};
  865. this.ident = config.ident || 'dupctx'+Ext.id();
  866. Ext.Ajax.timeout = 0;
  867. Ext.applyIf(config,{
  868. title: _('login')
  869. ,id: this.ident
  870. ,url: MODx.config.connectors_url
  871. ,action: 'security/login'
  872. // ,width: 400
  873. ,fields: [{
  874. html: '<p>'+_('session_logging_out')+'</p>'
  875. ,xtype: 'modx-description'
  876. },{
  877. xtype: 'textfield'
  878. ,id: 'modx-'+this.ident+'-username'
  879. ,fieldLabel: _('username')
  880. ,name: 'username'
  881. ,anchor: '100%'
  882. },{
  883. xtype: 'textfield'
  884. ,inputType: 'password'
  885. ,id: 'modx-'+this.ident+'-password'
  886. ,fieldLabel: _('password')
  887. ,name: 'password'
  888. ,anchor: '100%'
  889. },{
  890. xtype: 'hidden'
  891. ,name: 'rememberme'
  892. ,value: 1
  893. }]
  894. ,buttons: [{
  895. text: _('logout')
  896. ,scope: this
  897. ,handler: function() { location.href = '?logout=1' }
  898. },{
  899. text: _('login')
  900. ,cls: 'primary-button'
  901. ,scope: this
  902. ,handler: this.submit
  903. }]
  904. });
  905. MODx.window.Login.superclass.constructor.call(this,config);
  906. this.on('success',this.onLogin,this);
  907. };
  908. Ext.extend(MODx.window.Login,MODx.Window,{
  909. onLogin: function(o) {
  910. var r = o.a.result;
  911. if (r.object && r.object.token) {
  912. Ext.Ajax.defaultHeaders = {
  913. 'modAuth': r.object.token
  914. };
  915. Ext.Ajax.extraParams = {
  916. 'HTTP_MODAUTH': r.object.token
  917. };
  918. MODx.siteId = r.object.token;
  919. MODx.msg.status({
  920. message: _('session_extended')
  921. });
  922. }
  923. }
  924. });
  925. Ext.reg('modx-window-login',MODx.window.Login);