939c41d00dd18bb086917b4918aabf0f6bfd83ac
[Packages/TYPO3.CMS.git] / typo3 / sysext / em / res / js / em_components.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2010 Steffen Kamper <info@sk-typo3.de>
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 *
16 * This script is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * This copyright notice MUST APPEAR in all copies of the script!
22 ***************************************************************/
23
24 /**
25 * ExtJS for the extension manager.
26 *
27 *
28 * @author Steffen Kamper <info@sk-typo3.de>
29 * @package TYPO3
30 * @subpackage extension manager
31 */
32 Ext.ns('TYPO3.EM', 'TYPO3.EM.GridColumns', 'TYPO3.EM.ExtDirect', 'TYPO3.EMSOAP.ExtDirect');
33
34 ///////////////////////////////////////////////////////
35 // Grid
36 ///////////////////////////////////////////////////////
37
38 TYPO3.EM.Filters = new Ext.ux.grid.GridFilters({
39 encode: true,
40 local: true,
41 menuFilterText: TYPO3.l10n.localize('cmd_filter'),
42 filters: [
43 {
44 type: 'string',
45 dataIndex: 'title'
46 }, {
47 type: 'string',
48 dataIndex: 'extkey'
49 }, {
50 type: 'string',
51 dataIndex: 'author'
52 }, {
53 type: 'string',
54 dataIndex: 'category'
55 }, {
56 type: 'list',
57 dataIndex: 'state',
58 options: [
59 TYPO3.l10n.localize('state_alpha'),
60 TYPO3.l10n.localize('state_beta'),
61 TYPO3.l10n.localize('state_stable'),
62 TYPO3.l10n.localize('state_experimental'),
63 TYPO3.l10n.localize('state_test'),
64 TYPO3.l10n.localize('state_obsolete'),
65 TYPO3.l10n.localize('state_exclude_from_updates')
66 ],
67 phpMode: true
68 }, {
69 type: 'boolean',
70 dataIndex: 'installed'
71 }, {
72 type: 'list',
73 dataIndex: 'type',
74 options: [TYPO3.l10n.localize('type_system'), TYPO3.l10n.localize('type_global'), TYPO3.l10n.localize('type_local')],
75 phpMode: true
76 }
77 ],
78 getRecordFilter: function(){
79 var f = [];
80 this.filters.each(function(filter){
81 if(filter.active) f.push(filter);
82 });
83 // add custom filter
84 f.push(this.grid.store);
85 var len = f.length, me = this;
86 return function(record){
87 for(var i=0; i<len; i++)
88 if(!f[i].validateRecord(record))
89 return false;
90
91 return true;
92 };
93 }
94 });
95
96 TYPO3.EM.RemoteFilters = new Ext.ux.grid.GridFilters({
97 encode: true,
98 local: false,
99 filters: [{
100 type: 'string',
101 dataIndex: 'title'
102 }, {
103 type: 'string',
104 dataIndex: 'extkey'
105 }, {
106 type: 'string',
107 dataIndex: 'authorname'
108 }, {
109 type: 'list',
110 dataIndex: 'statevalue',
111 options: [
112 [0, TYPO3.l10n.localize('state_alpha')],
113 [1, TYPO3.l10n.localize('state_beta')],
114 [2, TYPO3.l10n.localize('state_stable')],
115 [3, TYPO3.l10n.localize('state_experimental')],
116 [4, TYPO3.l10n.localize('state_test')],
117 [5, TYPO3.l10n.localize('state_obsolete')],
118 [6, TYPO3.l10n.localize('state_exclude_from_updates')],
119 [999, TYPO3.l10n.localize('translation_n_a')]
120 ],
121 phpMode: true
122 }, {
123 type: 'list',
124 dataIndex: 'category',
125 options: [
126 [0, TYPO3.l10n.localize('category_BE')],
127 [1, TYPO3.l10n.localize('category_BE_modules')],
128 [2, TYPO3.l10n.localize('category_FE')],
129 [3, TYPO3.l10n.localize('category_FE_plugins')],
130 [4, TYPO3.l10n.localize('category_miscellanous')],
131 [5, TYPO3.l10n.localize('category_services')],
132 [6, TYPO3.l10n.localize('category_templates')],
133 [8, TYPO3.l10n.localize('category_documentation')],
134 [9, TYPO3.l10n.localize('category_examples')]
135 ],
136 phpMode: true
137 }, {
138 type: 'boolean',
139 dataIndex: 'installed'
140 }]
141 });
142
143 TYPO3.EM.GridColumns.DummyColumn = {
144 header: '',
145 width: 20,
146 sortable: false,
147 hideable: false,
148 fixed: true,
149 groupable: false,
150 menuDisabled: true
151 };
152
153 TYPO3.EM.GridColumns.InstallExtension = {
154 header: '',
155 width: 29,
156 sortable: false,
157 hideable: false,
158 fixed: true,
159 groupable: false,
160 menuDisabled: true,
161 xtype: 'actioncolumn',
162 items: [
163 {
164 getClass: function(value, meta, record) {
165 if (record.get('installed') == 0) {
166 this.items[0].tooltip = TYPO3.l10n.localize('menu_install_extensions');
167 return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-install';
168 } else {
169 if (record.get('required')) {
170 this.items[0].tooltip = TYPO3.l10n.localize('ext_details_always_loaded');
171 return 't3-icon t3-icon-extensions t3-icon-extensions-em t3-icon-em-extension-required';
172 } else {
173 this.items[0].tooltip = TYPO3.l10n.localize('ext_details_remove_ext');
174 return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-uninstall';
175 }
176 }
177 },
178 handler: function(grid, rowIndex, colIndex) {
179 var record = grid.store.getAt(rowIndex).data;
180 if (!record.required) {
181 var action = record.installed ? TYPO3.l10n.localize('ext_details_remove_ext') : TYPO3.l10n.localize('menu_install_extensions');
182 var link = TYPO3.settings.EM.scriptLink
183 + '&nodoc=1&view=info&CMD[silentMode]=1&CMD[standAlone]=1&CMD[showExt]=' + record.extkey
184 + '&CMD[' + (record.installed ? 'remove' : 'load') + ']=1&CMD[clrCmd]=1&SET[singleDetails]=info';
185
186 TYPO3.EM.ImportWindow = new TYPO3.EM.InstallWindow({
187 title: action + ': ' + record.title + ' (' + record.extkey + ') version ' + record.version,
188 record: record,
189 installAction: 'install',
190 url: link,
191 listeners: {
192 close: function() {
193 grid.store.reload();
194 TYPO3.EM.Tools.refreshMenu(record, 'install');
195 }
196 }
197 }).show(true, function(){
198 Ext.getCmp('emInstallIframeWindow').setUrl(link);
199 });
200 }
201 }
202 }
203 ]
204 };
205
206 TYPO3.EM.GridColumns.ImportExtension = {
207 header: '',
208 width: 29,
209 sortable: false,
210 fixed: true,
211 groupable: false,
212 menuDisabled: true,
213 xtype: 'actioncolumn',
214 items: [
215 {
216 getClass: function(value, meta, record) {
217 if (record.data.exists) {
218 if (record.data.versionislower) {
219 this.items[0].tooltip = String.format(TYPO3.l10n.localize('menu_update_extension'), record.data.existingVersion, record.data.version);
220 return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-update';
221 } else {
222 return '';
223 }
224 } else {
225 this.items[0].tooltip = TYPO3.l10n.localize('menu_import_extensions');
226 return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-import';
227 }
228 },
229 handler: function(grid, rowIndex, colIndex) {
230 var record = grid.store.getAt(rowIndex).data;
231 var action = TYPO3.l10n.localize('menu_import_extensions');
232 if (record.exists && record.versionislower) {
233 action = TYPO3.l10n.localize('menu_update_extensions');
234 }
235 var link = TYPO3.settings.EM.scriptLink
236 + '&nodoc=1&view=info&CMD[silentMode]=1&CMD[standAlone]=1&ter_connect=1&CMD[importExt]='
237 + record.extkey + '&CMD[extVersion]=' + record.version + '&CMD[loc]=L'
238
239
240 TYPO3.EM.ImportWindow = new TYPO3.EM.InstallWindow({
241 title: action + ': ' + record.title + ' (' + record.extkey + ') version ' + record.version,
242 record: record,
243 installAction: 'import',
244 listeners: {
245 close: function() {
246 TYPO3.EM.Tools.refreshMenu(record, 'import');
247 }
248 }
249 }).show(true, function(){
250 Ext.getCmp('emInstallIframeWindow').setUrl(link);
251 });
252 }
253 }
254 ]
255 };
256
257
258 TYPO3.EM.GridColumns.ExtensionTitle = {
259 header: TYPO3.l10n.localize('tab_mod_name'),
260 width: 150,
261 sortable: true,
262 dataIndex: 'title',
263 filterable: true,
264 hideable: true,
265 renderer:function(value, metaData, record, rowIndex, colIndex, store) {
266 metaData.css += 'action-title-cell';
267 var description = record.data.description;
268 if (value == '') {
269 value = '[no title]';
270 }
271 if (record.data.reviewstate < 0) {
272 metaData.css += ' insecureExtension';
273 description += '<br><br><strong>' + TYPO3.l10n.localize('insecureExtension') + '</strong>';
274 }
275 if (description) {
276 metaData.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(description) + '"';
277 }
278 value = store.highlightSearch(value);
279 return record.data.icon + ' ' + value + ' (v' + record.data.version + ')';
280 }
281 };
282
283 TYPO3.EM.GridColumns.ExtensionKey = {
284 header: TYPO3.l10n.localize('tab_mod_key'),
285 width: 80,
286 sortable: true,
287 filterable: true,
288 hideable: true,
289 dataIndex: 'extkey',
290 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
291 return store.highlightSearch(value);
292 }
293 };
294
295 TYPO3.EM.GridColumns.ExtensionCategory = {
296 header: TYPO3.l10n.localize('list_order_category'),
297 width: 70,
298 sortable: true,
299 dataIndex: 'category',
300 filterable: true,
301 hideable: true,
302 hidden: true
303 };
304
305 TYPO3.EM.GridColumns.ExtensionCategoryRemote = {
306 header: TYPO3.l10n.localize('list_order_category'),
307 width: 70,
308 sortable: true,
309 hideable: true,
310 dataIndex: 'category',
311 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
312 return TYPO3.EM.App.getCategoryLabel(value);
313 }
314 };
315
316 TYPO3.EM.GridColumns.ExtensionAuthor = {
317 header: TYPO3.l10n.localize('list_order_author'),
318 width: 120,
319 sortable: true,
320 hidden: true,
321 hideable: true,
322 dataIndex:'author',
323 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
324 metaData.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(value) + '"';
325 var t = Ext.util.Format.ellipsis(value, 20);
326 if (record.data.author_email) {
327 return '<a class="email" href="mailto:' + record.data.author_email + '">' + t + '</a>';
328 } else {
329 return t;
330 }
331 },
332 groupRenderer: function(value) {
333 return value;
334 }
335 };
336
337 TYPO3.EM.GridColumns.ExtensionRemoteAuthor = {
338 header: TYPO3.l10n.localize('list_order_author'),
339 width: 120,
340 sortable: true,
341 hidden: true,
342 hideable: true,
343 dataIndex:'authorname',
344 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
345 metaData.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(value) + '"';
346 var t = Ext.util.Format.ellipsis(value, 20);
347 if (record.data.authoremail) {
348 return '<a class="email" href="mailto:' + record.data.authoremail + '">' + t + '</a>';
349 } else {
350 return t;
351 }
352 }
353 };
354
355 TYPO3.EM.GridColumns.ExtensionType = {
356 header: TYPO3.l10n.localize('list_order_type'),
357 width:50,
358 sortable:true,
359 dataIndex:'type',
360 hideable: true,
361 filterable: true,
362 hidden: true,
363 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
364 if (record.data.doubleInstallShort && record.data.doubleInstallShort.length > 1) {
365 var temp = record.data.doubleInstall.split('/');
366 value = '<strong>' + record.data.doubleInstall + '</strong>';
367 metaData.attr = 'ext:qtip="' + String.format(TYPO3.l10n.localize('double_inclusion_js'), temp[1], temp[0]) + '"';
368 }
369 return value;
370 }
371 };
372
373 TYPO3.EM.GridColumns.ExtensionState = {
374 header: TYPO3.l10n.localize('list_order_state'),
375 align: 'center',
376 width: 100,
377 sortable: true,
378 resizable: false,
379 fixed: true,
380 hideable: true,
381 filterable: true,
382 dataIndex:'state',
383 renderer: function(value, metaData, record, rowIndex, colIndex, store){
384 metaData.css += record.data.stateCls + ' ';
385 return value;
386 }
387 };
388
389 TYPO3.EM.GridColumns.ExtensionStateValue = {
390 header: TYPO3.l10n.localize('list_order_state'),
391 align: 'center',
392 width: 100,
393 sortable: true,
394 resizable: false,
395 fixed: true,
396 hideable: true,
397 dataIndex:'statevalue',
398 renderer: function(value, metaData, record, rowIndex, colIndex, store){
399 metaData.css += record.data.stateCls + ' ';
400 var label = TYPO3.l10n.localize('translation_n_a');
401 switch (parseInt(value, 10)) {
402 case 0:
403 label = TYPO3.l10n.localize('state_alpha');
404 break;
405 case 1:
406 label = TYPO3.l10n.localize('state_beta');
407 break;
408 case 2:
409 label = TYPO3.l10n.localize('state_stable');
410 break;
411 case 3:
412 label = TYPO3.l10n.localize('state_experimental');
413 break;
414 case 4:
415 label = TYPO3.l10n.localize('state_test');
416 break;
417 case 5:
418 label = TYPO3.l10n.localize('state_obsolete');
419 break;
420 case 6:
421 label = TYPO3.l10n.localize('state_exclude_from_updates');
422 break;
423 }
424 return label;
425 },
426 filterable: true
427 };
428
429 TYPO3.EM.GridColumns.ExtensionDownloads = {
430 header: TYPO3.l10n.localize('list_order_downloads'),
431 width: 40,
432 sortable: true,
433 hideable: true,
434 dataIndex:'alldownloadcounter',
435 renderer: function(value, metaData, record, rowIndex, colIndex, store){
436 return record.data.alldownloadcounter + ' / ' + record.data.downloadcounter;
437 },
438 filterable: true
439 };
440
441 TYPO3.EM.GridColumns.ExtensionVersion = {
442 header: TYPO3.l10n.localize('extInfoArray_version'),
443 width:40,
444 sortable: true,
445 hideable: true,
446 hidden: true,
447 dataIndex:'version'
448 };
449
450 TYPO3.EM.GridColumns.Relevance = {
451 header: TYPO3.l10n.localize('extInfoArray_relevance'),
452 width:40,
453 sortable: true,
454 hideable: true,
455 dataIndex:'relevance'
456 };
457
458
459 ///////////////////////////////////////////////////////
460 // Stores
461 ///////////////////////////////////////////////////////
462
463 TYPO3.EM.LocationStore = new Ext.data.JsonStore({
464 fields : ['name', 'value'],
465 data : [
466 {name : 'Local (../typo3conf/ext/)', value: 'L'}
467 ]
468 });
469
470
471 ///////////////////////////////////////////////////////
472 // Panels + Tabs
473 ///////////////////////////////////////////////////////
474
475 TYPO3.EM.LocalListTab = {
476 title : TYPO3.l10n.localize('localExtensions'),
477 xtype: 'TYPO3.EM.LocalList',
478 id: 'em-local-extensions',
479 listeners: {
480 activate: function(panel) {
481 if (TYPO3.EM.App.refreshLocalList) {
482 Ext.StoreMgr.get('localstore').load();
483 }
484 },
485 scope: this
486 }
487 };
488
489 TYPO3.EM.RepositoryListTab = {
490 title : TYPO3.l10n.localize('remoteRepository'),
491 layout: 'fit',
492 items: [/*{
493 xtype: 'repository',
494 region: 'north'
495 },*/{
496 xtype: 'remoteextlist',
497 flex: 1,
498 region: 'center',
499 margins: '0 0 0 0'
500 }],
501 id: 'em-remote-extensions'
502 };
503
504 TYPO3.EM.LanguageTab = {
505 title: TYPO3.l10n.localize('menu_language_packges'),
506 xtype: 'extlanguages',
507 id: 'em-translations',
508 listeners: {
509 activate: function(panel) {
510 var store = Ext.StoreMgr.get('em-language-store');
511 if (!store.getCount()) {
512 store.load();
513 }
514 },
515 afterrender: function(panel) {
516
517 },
518 scope: this
519 }
520 };
521
522 TYPO3.EM.SettingsTab = {
523 title: TYPO3.l10n.localize('menu_settings'),
524 xtype: 'extsettings'
525 };
526
527 TYPO3.EM.UserTab = {
528 title: TYPO3.l10n.localize('myExtensions'),
529 xtype: 'TYPO3.EM.UserTools',
530 disabled: !TYPO3.settings.EM.hasCredentials,
531 listeners: {
532 activate: function(panel) {
533 var store = Ext.StoreMgr.get('em-userext');
534 if (!TYPO3.settings.EM.hasCredentials) {
535 TYPO3.Flashmessage.display(TYPO3.Severity.error,'Settings', 'No user+password specified. Please enter your credentials in "Settings" tab! ', 15);
536 store.removeAll();
537 Ext.getCmp('extvalidformbutton').disable();
538 } else {
539 store.load();
540 }
541 },
542 scope: this
543 }
544 };
545
546
547 TYPO3.EM.UploadLocationCombo = new Ext.form.ComboBox({
548 mode: 'local',
549 value: 'L',
550 triggerAction: 'all',
551 forceSelection: true,
552 editable: false,
553 name: 'loc',
554 hiddenName: 'loc',
555 displayField: 'name',
556 valueField: 'value',
557 store: TYPO3.EM.LocationStore,
558 width: 250,
559 fieldLabel: '...to location'
560 });
561
562 TYPO3.EM.RepositoryCombo = new Ext.form.ComboBox({
563 id: 'repCombo',
564 mode: 'local',
565 triggerAction: 'all',
566 forceSelection: true,
567 editable: false,
568 name: 'selectedRepository',
569 hiddenName: 'selectedRepository',
570 displayField: 'title',
571 valueField: 'uid',
572 store: null,
573 width: 250
574 });
575
576 TYPO3.EM.LanguagesActionPanel = {
577 xtype: 'container',
578 layout: 'hbox',
579 height: 30,
580 id: 'LanguagesActionPanel',
581 layoutConfig: {
582 align: 'middle'
583 },
584 defaults: {
585 border:false,
586 flex: 1
587 },
588 items: [{
589 xtype: 'button',
590 text: TYPO3.l10n.localize('translation_check_status_button'),
591 id: 'lang-checkbutton',
592 margins: '0 10 10 0'
593 }, {
594 xtype: 'button',
595 text: TYPO3.l10n.localize('translation_update_button'),
596 id: 'lang-updatebutton',
597 margins: '0 0 10 10'
598 }]
599 };
600
601 TYPO3.EM.LanguagesProgressBar = new Ext.ProgressBar ({
602 id: 'langpb',
603 cls: 'left-align',
604 style: 'margin: 0 0 20px 0',
605 animate: true
606 });
607
608 TYPO3.EM.LanguagesProgressPanel = {
609 xtype: 'container',
610 layout: 'hbox',
611 height: 40,
612 id: 'LanguagesProgressPanel',
613 hidden: true,
614 layoutConfig: {
615 align: 'middle'
616 },
617 defaults: {
618 border: false,
619 flex: 1,
620 height: 20
621 },
622 items: [
623 TYPO3.EM.LanguagesProgressBar,
624 {
625 xtype: 'button',
626 text: 'cancel', //TYPO3.l10n.localize('cancel'),
627 id: 'lang-cancelbutton',
628 margins: '0 0 10 10',
629 width: 80
630 }
631 ]
632 };
633
634 TYPO3.EM.InstallWindow = Ext.extend(Ext.Window, {
635 width: 500,
636 height: 400,
637 closable: true,
638 resizable: true,
639 plain: true,
640 border: false,
641 modal: true,
642 draggable: true,
643 layout: 'anchor',
644 constructor: function(config) {
645 config = config || {};
646 Ext.apply(this, config, {
647 items: [{
648 xtype: 'iframePanel',
649 anchor: '100% 100%',
650 border: false,
651 id: 'emInstallIframeWindow'
652 }]
653 });
654 TYPO3.EM.InstallWindow.superclass.constructor.call(this, config);
655 }
656 });
657
658 TYPO3.EM.ImportWindow = Ext.extend(Ext.Window, {
659 width: 500,
660 height: 400,
661 closable: true,
662 resizable: true,
663 plain: true,
664 border: false,
665 modal: true,
666 draggable: true,
667 layout: 'anchor',
668 constructor: function(config) {
669 config = config || {};
670 Ext.apply(this, config, {
671 items: [{
672 xtype: 'iframePanel',
673 anchor: '100% 100%',
674 border: false,
675 id: 'emImportIframeWindow'
676 }]
677 });
678 TYPO3.EM.InstallWindow.superclass.constructor.call(this, config);
679 }
680 });
681
682 TYPO3.EM.TerUpload = Ext.extend(Ext.form.FormPanel, {
683 border:false,
684 recordData: null,
685
686 initComponent:function() {
687
688
689
690 Ext.apply(this, {
691 itemId: 'extUploadForm',
692 height: 340,
693 defaultType: 'textfield',
694
695 defaults: {width: 350},
696 items: [{
697 fieldLabel: TYPO3.l10n.localize('repositoryUploadForm_username'),
698 name: 'fe_u'
699 }, {
700 fieldLabel: TYPO3.l10n.localize('repositoryUploadForm_password'),
701 inputType: 'password',
702 name: 'fe_p'
703 }, {
704 fieldLabel: TYPO3.l10n.localize('repositoryUploadForm_changelog'),
705 xtype: 'textarea',
706 height: 150,
707 name: 'uploadcomment'
708 }, {
709 xtype: 'radiogroup',
710 fieldLabel: TYPO3.l10n.localize('repositoryUploadForm_new_version'),
711 itemCls: 'x-check-group-alt',
712 columns: 1,
713 items: [
714 {
715 boxLabel: TYPO3.l10n.localize('repositoryUploadForm_new_bugfix').replace('%s', 'x.x.<strong><span class="typo3-red">x+1</span></strong>'),
716 name: 'newversion',
717 inputValue: 'new_dev',
718 checked: true
719 },
720 {
721 boxLabel: TYPO3.l10n.localize('repositoryUploadForm_new_sub_version').replace('%s', 'x.<strong><span class="typo3-red">x+1</span></strong>.0'),
722 name: 'newversion',
723 inputValue: 'new_sub'
724 },
725 {
726 boxLabel: TYPO3.l10n.localize('repositoryUploadForm_new_main_version').replace('%s', '<strong><span class="typo3-red">x+1</span></strong>.0.0'),
727 name: 'newversion',
728 inputValue: 'new_main'
729 }
730 ]
731 }, {
732 xtype: 'button',
733 text: TYPO3.l10n.localize('repositoryUploadForm_upload'),
734 scope: this,
735 handler: function() {
736 this.form.submit({
737 waitMsg : TYPO3.l10n.localize('action_sending_data'),
738 success: function(form, action) {
739 TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('cmd_terupload'), TYPO3.l10n.localize('msg_terupload'), 5);
740 form.reset();
741 },
742 failure: function(form, action) {
743 if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
744 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('msg_error'),
745 TYPO3.l10n.localize('list_order_state') + ':' + action.response.status + ': ' +
746 action.response.statusText, 15);
747 }
748 if (action.failureType === Ext.form.Action.SERVER_INVALID){
749 // server responded with success = false
750 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('msg_invalid'), action.result.errormsg, 5);
751 }
752 }
753 });
754 }
755 }],
756 listeners: {
757
758 activate: function(panel) {
759
760
761 }
762 },
763 scope: this
764 });
765
766 TYPO3.EM.TerUpload.superclass.initComponent.apply(this, arguments);
767 },
768
769 onRender: function() {
770
771
772 TYPO3.EM.TerUpload.superclass.onRender.apply(this, arguments);
773
774 Ext.apply(this.getForm(),{
775 api: {
776 load: TYPO3.EM.ExtDirect.loadUploadExtToTer,
777 submit: TYPO3.EM.ExtDirect.uploadExtToTer
778 },
779 paramsAsHash: false
780
781 });
782 this.form.load();
783 }
784
785
786 });
787
788 Ext.reg('terupload', TYPO3.EM.TerUpload);
789
790 TYPO3.EM.ExtensionUploadWindowInstance = null;
791 TYPO3.EM.ExtensionUploadWindow = Ext.extend(Ext.Window, {
792 title: 'Upload extension file directly (.t3x)',
793 modal: true,
794 closable: true,
795 closeAction: 'hide',
796 plain: true,
797 width: 400,
798 height: 160,
799 layout: 'fit',
800
801 constructor: function(config) {
802 config = config || {};
803 Ext.apply(this, config, {
804 items: [
805 {
806 xtype: 'form',
807 itemId: 'uploadForm',
808 fileUpload: true,
809 api: {
810 submit: TYPO3.EM.ExtDirect.uploadExtension
811 },
812 items: [
813 {
814 xtype: 'fileuploadfield',
815 id: 'form-file',
816 emptyText: TYPO3.l10n.localize('upload_selectExtension'),
817 fieldLabel: 'Extension',
818 name: 'extupload-path',
819 buttonText: '...',
820 width: 250,
821 validator: function(value) {
822 if (value) {
823 return value.split('.').pop().toLowerCase() === 't3x';
824 }
825 return false;
826 }
827 },
828 TYPO3.EM.UploadLocationCombo,
829 {
830 xtype: 'checkbox',
831 fieldLabel: TYPO3.l10n.localize('overwrite_ext'),
832 name: 'uploadOverwrite',
833 labelWidth: 250
834 },
835 {
836 xtype: 'button',
837 text: TYPO3.l10n.localize('upload_ext_from'),
838 id: 'uploadSubmitButton',
839 width: 420,
840 scope: this,
841 handler: function() {
842 var form = this.getComponent('uploadForm').getForm();
843 if (form.isValid()) {
844 form.submit({
845 waitMsg : TYPO3.l10n.localize('action_sending_data'),
846 success: function(form, action) {
847 form.reset();
848 TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('upload_ext'), String.format(TYPO3.l10n.localize('msg_uploaded'), action.result.extKey), 5);
849 TYPO3.EM.ExtensionUploadWindowInstance.hide();
850 TYPO3.EM.Tools.displayLocalExtension(action.result.extKey, true);
851 },
852 failure: function(form, action) {
853 if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
854 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('msg_error'),
855 TYPO3.l10n.localize('msg_status') + ': ' + action.response.status + ': ' +
856 action.response.statusText, 15);
857 }
858 if (action.failureType === Ext.form.Action.SERVER_INVALID) {
859 // server responded with success = false
860 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('msg_invalid'), action.result.error, 5);
861 }
862 }
863 });
864 }
865 }
866 }
867 ]
868 }
869 ]
870 });
871 TYPO3.EM.ExtensionUploadWindow.superclass.constructor.call(this, config);
872 }
873 });