|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 |
| -<ajxp_plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd" name="compression" enabled="false" label="CONF_MESSAGE[Compression Plugin]" description="CONF_MESSAGE[Compress some files.]" > |
| 2 | +<ajxp_plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd" |
| 3 | + name="compression" enabled="true" label="CONF_MESSAGE[Tar Archives Support]" |
| 4 | + description="CONF_MESSAGE[Create and extract tar, tar.gz and tar.bz2 archives.]" > |
3 | 5 |
|
4 | 6 | <client_settings>
|
5 | 7 | <resources>
|
|
8 | 10 | </client_settings>
|
9 | 11 |
|
10 | 12 | <registry_contributions>
|
| 13 | + <extensions> |
| 14 | + <extension mime="tar" icon="archive.png" messageId="61"/> |
| 15 | + <extension mime="bz2" icon="archive.png" messageId="61"/> |
| 16 | + </extensions> |
11 | 17 | <actions>
|
12 | 18 | <action name="compression">
|
13 |
| - <gui text="compression.1" title="compression.2" src="archive_insert.png" iconClass="icon-briefcase" accessKey="" hasAccessKey="false"> |
14 |
| - <context selection="true" dir="true" recycle="hidden" |
15 |
| - actionBar="true" contextMenu="false" infoPanel="false" |
16 |
| - actionBarGroup="remote" inZip="false"> |
17 |
| - </context> |
18 |
| - <selectionContext dir="true" file="true" recycle="false" unique="false"/> |
19 |
| - </gui> |
20 | 19 | <processing>
|
21 |
| - <clientCallback prepareModal="false"><![CDATA[ |
| 20 | + <serverCallback methodName="receiveAction"/> |
| 21 | + </processing> |
| 22 | + </action> |
| 23 | + <action name="compress_ui"> |
| 24 | + <processing> |
| 25 | + <clientCallback prepareModal="true"><![CDATA[ |
22 | 26 | var crtDir = pydio.getContextHolder().getContextNode().getPath();
|
23 | 27 | var userSelection = pydio.getUserSelection();
|
24 | 28 | if (!userSelection.isEmpty()) {
|
25 | 29 | var loadFunc = function (oForm) {
|
26 | 30 | if (userSelection.isEmpty()) {
|
27 | 31 | return;
|
28 | 32 | }
|
29 |
| - var archiveNameInput = oForm.down('input[id="archiveName"]'); |
| 33 | + var archive_nameInput = oForm.down('input[id="archive_name"]'); |
30 | 34 | var changeDuplicateArchiveName = function (name, extension) {
|
31 | 35 | var nameLastIndexOf = name.lastIndexOf("-");
|
32 | 36 | var tmpFileName = name.substr(0, nameLastIndexOf);
|
|
39 | 43 | name = tmpFileName + "-" + compteurFileName;
|
40 | 44 | compteurFileName ++;
|
41 | 45 | }
|
42 |
| - archiveNameInput.setValue(name + extension); |
| 46 | + archive_nameInput.setValue(name + extension); |
43 | 47 | return name;
|
44 | 48 | };
|
45 |
| - var archiveName = archiveNameInput.getValue(); |
| 49 | + var archive_name = archive_nameInput.getValue(); |
46 | 50 | var archiveTypeSelect = oForm.down('select[id="type_archive"]');
|
| 51 | + if(window.multipleFilesDownloadEnabled){ |
| 52 | + archiveTypeSelect.insert({top:'<option value=".zip">ZIP</option>'}); |
| 53 | + } |
47 | 54 | var archiveExtension = archiveTypeSelect.getValue();
|
48 | 55 | if (userSelection.isUnique()) {
|
49 |
| - archiveName = getBaseName(userSelection.getUniqueFileName()).split(".").shift(); |
| 56 | + archive_name = getBaseName(userSelection.getUniqueFileName()).split(".").shift(); |
50 | 57 | } else if (crtDir.length == 1) {
|
51 |
| - archiveName = "Archive"; |
| 58 | + archive_name = "Archive"; |
52 | 59 | } else {
|
53 |
| - archiveName = getBaseName(crtDir); |
| 60 | + archive_name = getBaseName(crtDir); |
54 | 61 | }
|
55 |
| - archiveName = changeDuplicateArchiveName(archiveName, archiveExtension); |
56 |
| - archiveTypeSelect.observe("change", function (){ |
57 |
| - archiveName = changeDuplicateArchiveName(archiveName, archiveTypeSelect.getValue()); |
58 |
| - }); |
59 |
| - archiveNameInput.observe("change", function () { |
60 |
| - archiveName = archiveNameInput.getValue().slice(0, -archiveTypeSelect.getValue().length); |
61 |
| - archiveName = changeDuplicateArchiveName(archiveName, archiveTypeSelect.getValue()); |
| 62 | + var updateFormAndArchiveName = function (){ |
| 63 | + var archiveExtension = archiveTypeSelect.getValue(); |
| 64 | + if(archiveExtension == ".zip"){ |
| 65 | + oForm.setAttribute("action", "compress"); |
| 66 | + oForm.down("#compression_form").setAttribute("action", "compress"); |
| 67 | + oForm.down('input[name="get_action"]').value = "compress"; |
| 68 | + }else{ |
| 69 | + oForm.setAttribute("action", "compression"); |
| 70 | + oForm.down("#compression_form").setAttribute("action", "compression"); |
| 71 | + oForm.down('input[name="get_action"]').value = "compression"; |
| 72 | + } |
| 73 | + changeDuplicateArchiveName(archive_name, archiveExtension); |
| 74 | + }; |
| 75 | + updateFormAndArchiveName(); |
| 76 | + archiveTypeSelect.observe("change", updateFormAndArchiveName); |
| 77 | + archive_nameInput.observe("change", function () { |
| 78 | + archive_name = archive_nameInput.getValue().slice(0, -archiveTypeSelect.getValue().length); |
| 79 | + changeDuplicateArchiveName(archive_name, archiveTypeSelect.getValue()); |
62 | 80 | });
|
63 | 81 | };
|
64 | 82 | var closeFunc = function(){
|
65 | 83 | userSelection.updateFormOrUrl(modal.getForm());
|
66 |
| - pydio.Controller.submitForm(modal.getForm(), true); |
| 84 | + PydioApi.getClient().submitForm(modal.getForm(), true); |
67 | 85 | hideLightBox();
|
68 | 86 | };
|
69 | 87 | modal.showDialogForm('Compress selection to ...', 'compression_form', loadFunc, closeFunc);
|
70 | 88 | }
|
71 | 89 | ]]></clientCallback>
|
72 |
| - <clientForm id="extract_form"><![CDATA[ |
73 |
| - <div id="compression_form" action="compression" box_width="272"> |
74 |
| - <label class="dialogLegend" id="type_archive">AJXP_MESSAGE[compression.3]</label> |
75 |
| - <select name="type_archive" id="type_archive" class="dialogFocus initFicName"> |
76 |
| - <option value=".tar">Archiver en TAR</option> |
77 |
| - <option value=".tar.gz">Archiver en TAR.GZ</option> |
78 |
| - <option value=".tar.bz2">Archiver en TAR.BZ2</option> |
79 |
| - </select> |
80 |
| - <label class="dialogLegend" for="archiveName">AJXP_MESSAGE[compression.4]</label> |
81 |
| - <input type="text" name="archiveName" id="archiveName" class="dialogFocus initFicName" /> |
82 |
| - </div> |
| 90 | + <clientForm id="compression_form"><![CDATA[ |
| 91 | + <div id="compression_form" action="compression" box_width="272"> |
| 92 | + <label class="dialogLegend" id="type_archive" style="display: inline-block;margin-top: 11px;">AJXP_MESSAGE[compression.3]</label> |
| 93 | + <select style="width:100px;" name="type_archive" id="type_archive" class="dialogFocus initFicName"> |
| 94 | + <option value=".tar">TAR</option> |
| 95 | + <option value=".tar.gz">TAR.GZ</option> |
| 96 | + <option value=".tar.bz2">TAR.BZ2</option> |
| 97 | + </select> |
| 98 | + <br/> |
| 99 | + <label class="dialogLegend" for="archive_name" style="display: inline-block;margin-top: 11px;">AJXP_MESSAGE[compression.4]</label> |
| 100 | + <br/> |
| 101 | + <input style="width: 93%;margin-left: 9px;margin-top: 7px; margin-bottom:12px;" type="text" name="archive_name" id="archive_name" class="dialogFocus initFicName" /> |
| 102 | + </div> |
83 | 103 | ]]></clientForm>
|
84 |
| - <serverCallback methodName="receiveAction" pluginId="action.compression" /> |
85 | 104 | </processing>
|
86 | 105 | </action>
|
87 | 106 | <action name="check_compression_status">
|
|
92 | 111 | <action name="extraction">
|
93 | 112 | <gui text="compression.9" title="compression.10" src="archive_insert.png" iconClass="icon-briefcase" accessKey="" hasAccessKey="false">
|
94 | 113 | <context selection="true" dir="true" recycle="hidden"
|
95 |
| - actionBar="true" contextMenu="false" infoPanel="false" |
96 |
| - actionBarGroup="remote" inZip="false"> |
| 114 | + actionBar="true" contextMenu="true" infoPanel="false" |
| 115 | + actionBarGroup="change" inZip="false"> |
97 | 116 | </context>
|
98 | 117 | <selectionContext dir="false" file="true" recycle="false" unique="true"/>
|
99 | 118 | </gui>
|
|
123 | 142 | </actions>
|
124 | 143 | </registry_contributions>
|
125 | 144 | <class_definition filename="plugins/action.compression/class.PluginCompression.php" classname="PluginCompression"/>
|
| 145 | + <dependencies> |
| 146 | + <activePlugin pluginName="access.fs"/> |
| 147 | + </dependencies> |
126 | 148 | </ajxp_plugin>
|
0 commit comments