### Eclipse Workspace Patch 1.0 #P MyAmetys-plugin-explorer Index: main/plugin-explorer/resources/img/resources/concel_html_16.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\concel_html_16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/HtmlEditorGenerator.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/HtmlEditorGenerator.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/HtmlEditorGenerator.java (revision 0) @@ -0,0 +1,70 @@ +package org.ametys.plugins.explorer.resources.generators; + +import java.io.IOException; +import java.io.InputStream; + +import org.ametys.plugins.explorer.resources.ModifiableResource; +import org.ametys.plugins.explorer.resources.ModifiableResourceCollection; +import org.ametys.plugins.explorer.resources.ResourceCollection; +import org.ametys.plugins.repository.AmetysObjectResolver; +import org.ametys.runtime.user.UsersManager; +import org.ametys.runtime.util.IgnoreRootHandler; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.environment.ObjectModelHelper; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.generation.ServiceableGenerator; +import org.apache.cocoon.xml.XMLUtils; +import org.apache.commons.compress.utils.IOUtils; +import org.apache.excalibur.source.SourceUtil; +import org.apache.excalibur.xml.sax.SAXParser; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +public class HtmlEditorGenerator extends ServiceableGenerator +{ + + protected AmetysObjectResolver _resolver; + protected UsersManager _usersManager; + protected SAXParser _saxParser; + + @Override + public void service(ServiceManager sManager) throws ServiceException + { + super.service(sManager); + _resolver = (AmetysObjectResolver) sManager.lookup(AmetysObjectResolver.ROLE); + _usersManager = (UsersManager) sManager.lookup(UsersManager.ROLE); + _saxParser = (SAXParser) sManager.lookup(SAXParser.ROLE); + } + @Override + public void generate() throws IOException, SAXException, ProcessingException + { + Request request = ObjectModelHelper.getRequest(objectModel); + String id = request.getParameter("id"); + ResourceCollection HtmlFolder = _resolver.resolveById(id); + ModifiableResource file = HtmlFolder.getChild("index.html"); + + //XML document + InputStream is = null; + try { + contentHandler.startDocument(); + + is = file.getInputStream(); + + _saxParser.parse(new InputSource(is), new IgnoreRootHandler(contentHandler)); + + contentHandler.endDocument(); + + }finally + { + org.apache.commons.io.IOUtils.closeQuietly(is); + } + + + } + +} + + + Index: main/plugin-explorer/resources/img/resources/html_edition_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\html_edition_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/sitemap.xmap =================================================================== --- main/plugin-explorer/sitemap.xmap (revision 10091) +++ main/plugin-explorer/sitemap.xmap (working copy) @@ -19,6 +19,11 @@ + + + + + @@ -54,6 +59,9 @@ + + + @@ -110,8 +118,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: main/plugin-explorer/resources/img/resources/file_exportzip_16.jpg =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\file_exportzip_16.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/htmleditor/htmleditorApplication.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/htmleditor/htmleditorApplication.i18n.js (revision 0) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/htmleditor/htmleditorApplication.i18n.js (revision 0) @@ -0,0 +1,443 @@ +/* + * Copyright 2010 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.explorer.applications.htmleditor'); + +org.ametys.explorer.applications.htmleditor.htmleditorApplication = function (explorer, id, pluginName) +{ + org.ametys.explorer.applications.htmleditor.htmleditorApplication.superclass.constructor.call(this, explorer, id, pluginName); + this._explorer = explorer; +}; + +Ext.extend(org.ametys.explorer.applications.htmleditor.htmleditorApplication, org.ametys.explorer.applications.resources.ResourcesApplication, {}); + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._appPrefix = 'search-app-'; + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype.createPanel = function () +{ + + var node = this._explorer.getSelectedNode(); + this.currentId = node.id; + if (node == null) + return; + + this.viewPanel = new Ext.Panel({ + html: '<iframe style = "border : none" src="' + getPluginDirectUrl('explorer') + '/get-index-html?id=' + this.currentId +'"/>' + + }); + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/get-index-html',{'id': node.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null, 'xml2text'); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + this._content = new Ext.form.TextArea ({ + name: 'content', + value : response[org.ametys.servercomm.ServerComm.xmlTextContent], + id : 'textareaid', + hideLabel: true, + height: 285, + width: 700 + }); + + this._store = this._getStore(); + this._content.addListener('render', this._createEditor,this); + + this.editPanel = new Ext.Panel ({ + border: false, + layout:'form', + width:600, + items:[this._content] + }); + + this._panel = new Ext.Panel ({ + border: false, + layout:'card', + activeItem: 0, + items:[this.viewPanel, this.editPanel] + }); + + return this._panel; +}; + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._createEditor = function() +{ + tinyMCE.init({ + mode : "textareas", + theme : "advanced", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", + theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", + theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor", + theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", + theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : true + }); + +} + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._HtmlIndexSave = function(application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + var params = {}; + + var ContentBody = tinyMCE.get('textareaid').getContent(); + var HtmlContent = '<html><body>'+ContentBody+'</body></html>'; + params.id = node.id; + params.content = HtmlContent; + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/save-index-html', + params, + org.ametys.servercomm.ServerComm.PRIORITY_MAJOR, + addHtmlEditorCb, + this, + null); + org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + +} + +function addHtmlEditorCb (response, args) +{ + var id = response.selectSingleNode('ActionResult/id')[org.ametys.servercomm.ServerComm.xmlTextContent]; + var content = response.selectSingleNode('ActionResult/content')[org.ametys.servercomm.ServerComm.xmlTextContent]; + + this.viewPanel.body.update('<iframe style = "border : none" src="' + getPluginDirectUrl('explorer') + '/get-index-html?id=' + id +'"/>') + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Edition'); + btn.setDisabled (false); + this._panel.layout.setActiveItem(0); + +} + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._OnEditionView = function() +{ + var activeItem = this._panel.getLayout().activeItem; + var activeIndex = this._panel.items.indexOf(activeItem); + var node = this._explorer.getSelectedNode(); + + if (activeIndex == 0) + { + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/get-index-html',{'id': node.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null, 'xml2text'); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (tinymce.activeEditor) + { + tinymce.activeEditor.setContent(response[org.ametys.servercomm.ServerComm.xmlTextContent]); + }else + { + this._content.setValue(response[org.ametys.servercomm.ServerComm.xmlTextContent]); + } + this._panel.layout.setActiveItem(1); + + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Edition'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (false); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (false); + } + else + { + this.viewPanel.body.update('<iframe style = "border : none" src="' + getPluginDirectUrl('explorer') + '/get-index-html?id=' + this.currentId +'"/>') + this._panel.layout.setActiveItem(0); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (true); + + + } +} + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._ConcelHtmlEdition = function() +{ + + Ext.Msg.confirm('Sauvegarder modification!', 'Etes-vous sur de vouloir quitter sans sauvegarder ?', function(click, text){ + + if (click == 'yes'){ + + this._panel.layout.setActiveItem(0); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (true); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Edition'); + btn.setDisabled (false); + } + }, this); + +} + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype.createToolbar = function () +{ + var folderGp = new Ext.ButtonGroup ({ + columns: 3, + height: 90, + title: "", + defaults: { + scale: 'small' + }, + items:[ + { + id: this._appPrefix + 'toolbar-btn-folder-add', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png', + iconAlign: 'top', + scale: 'large', + minWidth: 34, + rowspan: 3, + application: this, + handler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.Folder.add (this.application); + }, + //rightId: 'Plugin_Explorer_Folder_Add', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-search', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/search_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/search_32.png'), + scale: 'small', + application: this, + handler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.File.search(this.application); + }, + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-cmis-add', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS (this.application); + }, + //rightId: 'Plugin_Explorer_CMIS_Add', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-folder-rename', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.rename (this.application); + }, + //rightId: 'Plugin_Explorer_Folder_Edit', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-folder-delete', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.remove (this.application); + }, + //rightId: 'Plugin_Explorer_Folder_Delete', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-folder-EditHtml', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_16.png', + scale: 'small', + application: this, + handler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.Folder.addHtmlEditor(this.application); + }, + rightId: 'Plugin_Explorer_FolderHtml', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-folder-exportzip', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_exportzip_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_exportzip_16.jpg', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.archive (this.application); + }, + rightId: 'Plugin_Explorer_Folder_ExportZip', + disabled: false + } + ] + }); + + + this.HtmlEditiorGp = new Ext.ButtonGroup ({ + columns: 1, + height: 90, +// width : 110, + title: "", + defaults: { + scale: 'small' + }, + items:[ + { + id: this._appPrefix + 'toolbar-btn-Html-Edition', + name : 'save', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_16.png', + scale: 'small', + application: this, + handler: function () { + this.application._OnEditionView(); + }, + rightId: 'Plugin_Explorer_HtmlEditor', + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-Html-Save', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/Save_html_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/Save_html_32.png'), + application: this, + handler: function (btn, state) { + this.application._HtmlIndexSave(this.application); + }, + rightId: 'Plugin_Explorer_HtmlEditor', + disabled: false + } + , + { + id: this._appPrefix + 'toolbar-btn-Html-Concel', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/concel_html_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/concel_html_16.png'), + application: this, + handler: function (btn, state) { + this.application._ConcelHtmlEdition(this.application); + }, + rightId: 'Plugin_Explorer_HtmlEditor', + disabled: false + } + ] + }); + + this._toolbar = new Ext.Panel ({ + autoheight : true, + autowidth : true, + tbar : [folderGp, + this.HtmlEditiorGp] + + + }); + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': this._explorer._tree.getRootNode().childNodes[0].id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.HtmlEditor.HTMLEditorApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Runtime_Rights_Rights_Handle']") != null) + { + var rightsGp = org.ametys.explorer.rights.RightsAssignment.getToolbarGroupItems (this); + this._toolbar.getTopToolbar().add (rightsGp); + } + + + return this._toolbar; +}; + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._getUserRights = function (folder) +{ + var rights = []; + if (folder != null) + { + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': folder}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + if (org.ametys.servercomm.ServerComm.handleBadResponse("Une erreur est survenue : impossible de v?rifier les droits de l'utilisateur", response, "org.ametys.explorer.applications.resources.ResourcesApplicationon")) + { + return false; + } + var rightNodes = response.selectNodes ('user-rights/right'); + + for (var i=0; i < rightNodes.length; i++) + { + rights.push (rightNodes[i].getAttribute("id")); + } + + } + return rights; +} +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype._hasRight = function (rights, rightId) +{ + if (rightId == null) + { + return true; + } + + for (var i=0; rights != null && i <rights.length; i++) + { + if (rightId == rights[i]) + { + return true; + } + } +} + + +org.ametys.explorer.applications.htmleditor.htmleditorApplication._updateToolbar = function (folder, files, rightNode) +{ + var isRoot = this._explorer._params.id == folder; + var isRightsPanelActive = this._explorer._profilesTree != null && this._explorer._mainPanel.items.get(1).getLayout().activeItem.id == this._explorer._profilesTree.id; + var rights = this._getUserRights (folder); + var node = folder != null ? this._explorer._tree.getNodeById(folder) : null; + var isModifiable = node != null ? node.attributes.isModifiable == 'true' : false; + var canCreateChild = node != null ? node.attributes.canCreateChild == 'true' : false; + + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-EditHtml'); + btn.setDisabled (folder == null || (!isModifiable) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Edition'); + btn.setDisabled (folder == null || (!isModifiable) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (folder == null || (!isModifiable) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-delete'); + btn.setDisabled (folder == null || !isModifiable || !this._hasRight (rights, btn.rightId)); + +} + +org.ametys.explorer.applications.htmleditor.htmleditorApplication.prototype.refresh = function(id) +{ + this.viewPanel.body.update('<iframe style = "border : none" src="' + getPluginDirectUrl('explorer') + '/get-index-html?id=' +id+'"/>') +} \ No newline at end of file Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/UpdateIndexHtmlAction.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/UpdateIndexHtmlAction.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/UpdateIndexHtmlAction.java (revision 0) @@ -0,0 +1,20 @@ +package org.ametys.plugins.explorer.resources.actions; + +import java.util.Map; + +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.cocoon.acting.ServiceableAction; +import org.apache.cocoon.environment.Redirector; +import org.apache.cocoon.environment.SourceResolver; + +public class UpdateIndexHtmlAction extends ServiceableAction { + + @Override + public Map act(Redirector redirector, SourceResolver resolver, + Map objectModel, String source, Parameters parameters) + throws Exception { + // TODO Auto-generated method stub + return null; + } + +} Index: main/plugin-explorer/resources/img/resources/folder_exportzip_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\folder_exportzip_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/img/resources/folder_exportzip_16.jpg =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\folder_exportzip_16.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/HtmleditionFactory.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/HtmleditionFactory.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/HtmleditionFactory.java (revision 0) @@ -0,0 +1,18 @@ +package org.ametys.plugins.explorer.resources; + +import javax.jcr.Node; + +import org.ametys.plugins.explorer.resources.jcr.JCRResourcesCollectionFactory; +import org.ametys.plugins.repository.AmetysRepositoryException; +import org.ametys.plugins.repository.RepositoryConstants; + +public class HtmleditionFactory extends JCRResourcesCollectionFactory { + + public static final String HTMLFOLDER_NODETYPE = RepositoryConstants.NAMESPACE_PREFIX + ":html_folder"; + + public HtmlFolderApplication getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException + { + return new HtmlFolderApplication(node, parentPath, this); + } + +} Index: main/plugin-explorer/resources/img/resources/file_exportzip_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\file_exportzip_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/img/resources/Save_html_16.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\Save_html_16.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/img/resources/Edit_Html_50.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\Edit_Html_50.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (revision 10091) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (working copy) @@ -16,6 +16,7 @@ Ext.namespace('org.ametys.explorer.applications.resources'); + org.ametys.explorer.applications.resources.ResourcesApplication = function(explorer, id, pluginName) { org.ametys.explorer.applications.resources.ResourcesApplication.superclass.constructor.call(this, id, pluginName); @@ -233,6 +234,19 @@ }, rightId: 'Plugin_Explorer_Folder_Delete', disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-folder-EditHtml', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/Edit_Html_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.addHtmlEditor(this.application); + }, + rightId: 'Plugin_Explorer_FolderHtml', + disabled: true } ] }); @@ -323,6 +337,7 @@ }, disabled: true } + /* EXPLORER-108, { id: this._appPrefix + 'toolbar-btn-file-export-rdf', @@ -516,7 +531,20 @@ var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-add'); btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-EditHtml'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Edition'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Save'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-Html-Concel'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-cmis-add'); btn.setDisabled (folder == null || (!isRoot && !isModifiable) || !this._hasRight (rights, btn.rightId)); @@ -923,6 +951,7 @@ } } + org.ametys.explorer.applications.resources.ResourcesApplication.prototype.execCommand = function (cmd, params) { switch (cmd) @@ -1029,12 +1058,14 @@ } break; + case 'updateToolbar': this._updateToolbar (params.id, params.files, params.rightNode); break; default: throw "The command '" + cmd + "' is unknown"; break; + } } Index: main/plugin-explorer/resources/img/resources/Save_html_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\Save_html_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/SaveIndexHtmlAction.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/SaveIndexHtmlAction.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/SaveIndexHtmlAction.java (revision 0) @@ -0,0 +1,64 @@ +package org.ametys.plugins.explorer.resources.actions; + +import java.io.ByteArrayInputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import org.ametys.plugins.explorer.resources.ModifiableResource; +import org.ametys.plugins.explorer.resources.ModifiableResourceCollection; +import org.ametys.plugins.explorer.resources.Resource; +import org.ametys.plugins.explorer.resources.jcr.JCRResource; +import org.ametys.plugins.repository.AmetysObject; +import org.ametys.plugins.repository.AmetysObjectResolver; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.cocoon.acting.ServiceableAction; +import org.apache.cocoon.environment.ObjectModelHelper; +import org.apache.cocoon.environment.Redirector; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.SourceResolver; +import org.apache.commons.lang.IllegalClassException; +import org.apache.commons.lang.StringUtils; + +public class SaveIndexHtmlAction extends ServiceableAction { + + private AmetysObjectResolver _resolver; + + @Override + public void service(ServiceManager sManager) throws ServiceException + { + super.service(sManager); + _resolver = (AmetysObjectResolver) sManager.lookup(AmetysObjectResolver.ROLE); + } + + @Override + public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception + { + Map result = new HashMap(); + Request request = ObjectModelHelper.getRequest(objectModel); + + String id = request.getParameter("id"); + //String name = request.getParameter("name"); + String content = request.getParameter("content"); + + AmetysObject object = _resolver.resolveById(id); + if (!(object instanceof ModifiableResourceCollection)) + { + throw new IllegalClassException(ModifiableResourceCollection.class, object.getClass()); + } + + ModifiableResourceCollection FolderHtml = (ModifiableResourceCollection) object; + + ModifiableResource IndexHtmlfile = FolderHtml.getChild("index.html"); + IndexHtmlfile.setData(new ByteArrayInputStream(content.getBytes("UTF-8")), "text/html", new Date() ,""); + FolderHtml.saveChanges(); + + result.put("id", FolderHtml.getId()); + //result.put("name", name); + result.put("content", content); + + return result; + } + +} Index: main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (revision 9478) +++ main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (working copy) @@ -1,969 +0,0 @@ -/* - * Copyright 2010 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.namespace('org.ametys.explorer'); - -/** - * Creates a new resource explorer - * @param {Object} The explorer parameters: <br> - * <ul> - * <li>id: the resource root id</li> - * <li>toolbar: true to display the toolbar actions</li> - * <li>rightsContextPrefix: the rights context prefix (defaults to '/resources')</li> - * <li>handleRights: true to handle rights on resources</li> - * </ul> - */ -org.ametys.explorer.ResourcesExplorer = function(params) -{ - this._params = params; -}; - -/** - * The tool parameters - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._params; - -/** - * A object containing the drawn applications - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._applications; - -/** - * The current selection - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._currentSelection; - -/** - * Create the panel - */ -org.ametys.explorer.ResourcesExplorer.prototype.createPanel = function() -{ - this._applications = {}; - - // Toolbar - if (this._params.toolbar) - { - this._toolbarPanel = new Ext.Panel ({ - region: 'north', - height: 95, - layout: 'card', - activeItem: 0, - border: false, - - layoutOnCardChange: true, - - html: '' - }); - } - - // Tree applications - var loader = new org.ametys.explorer.tree.ExplorerNodeXmlLoader ({ - dataUrl: getPluginDirectUrl("explorer") + '/explorer-nodes' - }); - - this._tree = new org.ametys.explorer.ExplorerTreePanel ({ - region: 'west', - width: 250, - region: 'center', - split: true, - - autoScroll:true, - animate:true, - enableDD:true, - ddGroup: 'explorerGp', - ddAppendOnly: true, - - border: false, - containerScroll: true, - - loader: loader, - - rootVisible: false, - root: new Ext.tree.TreeNode ({ - draggable: false, //This node is not draggable - editable: false, - name: 'root', - text: 'root' - }) - }); - this._tree.getRootNode().expand(); - this._tree.getSelectionModel().addListener('selectionchange', this._onSelectNode, this); - this._tree.addListener ('beforemovenode', this._moveNode, this); - this._tree.addListener ('beforenodedrop', this._dropNode, this); - this._tree.addListener ('dblclick', this._startEditNode, this); - this._tree.addListener ('afterrender', this._createResourceNode, this); - - this._treeEditor = new Ext.tree.TreeEditor (this._tree, - { - allowBlank:false - },{ - editDelay:10, - cancelOnEsc:true, - completeOnEnter:true, - ignoreNoChange:false - } - ); - - this._treeEditor.addListener ('beforestartedit', this._beforeEdit, this); - this._treeEditor.addListener ('beforecomplete', this._editNode, this); - this._treeEditor.addListener ('complete', this._trimValue, this); - - // Alphabetical sort - this._treeSorter = new Ext.tree.TreeSorter(this._tree, { - folderSort: true, - leafAttr: 'leafSort' - }); - - this._mainPanel = new Ext.Panel ({ - layout: 'border', - region: 'center', - - items: [ - new Ext.Panel ({ - region: 'west', - width: 250, - split: true, - border: false, - layout: 'border', - items: [ - new Ext.Panel ({region: 'north', height: 35, border: false, id: 'explorer-tree-hint-rights', cls: 'explorer-tree-hint-panel', html: "", hidden: true}), - this._tree - ] - }), - new Ext.Panel ({ - region: 'center', - split: true, - border: false, - layout: 'card', - activeItem: 0, - id: 'card-layout', - - layoutOnCardChange: true, - - html: '' - }) - ] - }); - - // The application panel - this._appPanel = new Ext.Panel ({ - region: 'center', - layout: 'card', - activeItem: 0, - - layoutOnCardChange: true, - - html: '' - }); - this._mainPanel.items.get(1).add(this._appPanel); - - this._rightsCxtPrefix = this._params.rightsContextPrefix ? this._params.rightsContextPrefix : '/resources'; - if (this._params.toolbar) - { - // The rights panel - this._profilesTree = new org.ametys.rights.profile.ProfilesTreePanel ({ - id: 'tree-rights-panel', - region: 'center', - context: this._rightsCxtPrefix, - rootID: this._params.id, - upToContextFn: this._upToContext.createDelegate(this) - }); - this._profilesTree.getSelectionModel().addListener ('selectionchange', org.ametys.explorer.ResourcesExplorer.prototype._onSelectProfile, this) - this._mainPanel.items.get(1).add(this._profilesTree); - } - - if (this._params.toolbar) - { - this._mainPanel.add(this._toolbarPanel); - } - return this._mainPanel; -} - -org.ametys.explorer.ResourcesExplorer.prototype._upToContext = function (context) -{ - if (/^(\/[^\/]*)?\/resources\/(.*)$/.test(context)) - { - var path = '/root/resources/' + RegExp.$2; - this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); - } - else if (/^(\/[^\/]*)?\/resources$/.test(context)) - { - var path = '/root/resources'; - this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); - } -} - -/** - * Expand the tree and select a node by its complete path - * @param path The complete path from the root node - */ -org.ametys.explorer.ResourcesExplorer.prototype.selectByPath = function (path) -{ - this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); -} - -org.ametys.explorer.ResourcesExplorer.prototype._selectByPathCb = function (success, lastNode) -{ - if (lastNode != null) - { - lastNode.ensureVisible(); // scroll to node - this._tree.getSelectionModel().select(lastNode)// select node - } -} - -/** - * This function is called when a explorer node is selected.
This function draw or activate the application panel. - * @param {Ext.tree.DefaultSelectionModel} sm The selection model - * @param {Ext.tree.TreeNode} node The selected node - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._onSelectNode = function (sm, node) -{ - if (node != null && node.attributes.applicationId) - { - if (this._mainPanel.items.get(1).getLayout().activeItem.id == 'tree-rights-panel') - { - this._updateRightsPanel(node); - } - else - { - this._updateApplicationPanel(node); - } - - this._currentSelection = node.id; - } - else - { - this._currentSelection = null; - } - - this.fireEventSelection (node); -} - -/** - * This function is called when a node of profile tree is selected.
- * @param {Ext.tree.DefaultSelectionModel} sm The selection model - * @param {Ext.tree.TreeNode} node The selected node - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._onSelectProfile = function (sm, node) -{ - if (node == null) - return; - - if (this._params.toolbar) - { - var treeNode = this._tree.getSelectionModel().getSelectedNode(); - if (treeNode == null) - return; - - var appId = treeNode.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].execCommand ('updateToolbar', {'id': treeNode.id, 'rightNode': node}); - } - } - this._profilesTree.getTopToolbar().items.get(4).setDisabled (node == null || node.attributes.inherit != 'true'); -} - -org.ametys.explorer.ResourcesExplorer.prototype._onUpdateProfile = function (sm, node) -{ - if (this._params.toolbar) - { - var treeNode = this._tree.getSelectionModel().getSelectedNode(); - if (treeNode == null) - return; - - var appId = treeNode.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].execCommand ('updateToolbar', {'id': treeNode.id}); - } - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._updateRightsPanel = function (node, init) -{ - if (node.attributes.applicationId == 'org.ametys.plugins.explorer.applications.Resources') - { - var serverMessage = new org.ametys.servercomm.ServerMessage("explorer", "/exporer-entity", {'id': node.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - var params = {}; // necessary to check rights - var name = response.selectSingleNode('Node').getAttribute('name'); - var path = response.selectSingleNode('Node').getAttribute('path'); - this._profilesTree.updateContext (this._rightsCxtPrefix + (path != '' ? '/' + path : ''), params, init); - - var text = "" + " " + name; - this._profilesTree.updateContextHelperText (text); - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._updateApplicationPanel = function (node) -{ - var appId = node.attributes.applicationId; - if (!this._applications[appId]) - { - // Draw card - this._drawApplicationPanel (appId); - } - // Active and refresh application - this._activeApplicationItem (appId); - this._applications[appId].refresh (node.id); -} - -org.ametys.explorer.ResourcesExplorer.prototype._moveNode = function (tree, node, oldParent, newParent, index) -{ - var params = {}; - params.id = node.id; - params.target = newParent.id; - - var sibling = newParent.item(index); - if (sibling != null) - { - params.sibling = sibling.id; - } - - var appId = node.attributes.applicationId; - if (!this._applications[appId].execCommand ('move-node', params)) - { - // Cancel the move - return false; - } - - this.fireNodeMoved (newParent, node) -} - -org.ametys.explorer.ResourcesExplorer.prototype._dropNode = function (dropEvent) -{ - var records = dropEvent.data.records || dropEvent.data.selections; - if (!records) - { - return; - } - - var node = dropEvent.target; - var appId = node.attributes.applicationId; - - var params = {}; - params.target = node.id; - params.ids = []; - for (var i in records) - { - if (typeof (records[i]) != 'function') - { - params.ids.push (records[i].data.id); - } - } - - if (!this._applications[appId].execCommand ('move', params)) - { - dropEvent.cancel = true; - return; - } - - // Prevent the animated "repair" - dropEvent.dropStatus = true; - - // Select the target node - this._selectNode (node.id); - - this.fireRecordsMoved (node, params.ids) -} - -/** - * Get the current selected node - * @return {Ext.tree.TreeNode} The selected node - */ -org.ametys.explorer.ResourcesExplorer.prototype.getSelectedNode = function () -{ - return this._tree.getSelectionModel().getSelectedNode(); -} - -/** - * Gets a node in the tree by its id - * @param {String} The node id - * @return {Ext.tree.Node} The node or null. - */ -org.ametys.explorer.ResourcesExplorer.prototype.getNodeById = function (id) -{ - return this._tree.getNodeById (id); -} - -/** - * Call this function to add a new node - * @params {Object} nodeAttributes The attributes/config for the node or just a string with the text for the node - */ -org.ametys.explorer.ResourcesExplorer.prototype.addNode = function (parentId, nodeAttributes) -{ - var node = this._tree.getNodeById(parentId); - if (node == null) - return; - - var childNode = new Ext.tree.TreeNode (nodeAttributes); - // Make sure to render plus/minus icon - node.leaf = false; - return node.appendChild (childNode); -} - -org.ametys.explorer.ResourcesExplorer.prototype.expandNode = function (id) -{ - var node = this._tree.getNodeById(id); - if (node == null) - return; - - if (!node.isExpanded()) - node.expand(); -} - - -/** - * Call this function to rename a node - * @params {Ext.tree.Node} node The node to rename - */ -org.ametys.explorer.ResourcesExplorer.prototype.renameNode = function (id) -{ - var node = this._tree.getNodeById(id); - if (node != null) - { - node.select(); - this._startEditNode(node); - } -} - -/** - * Call this function to delete a node - * params {Ext.tree.Node} node The node to delete - */ -org.ametys.explorer.ResourcesExplorer.prototype.deleteNode = function (id) -{ - if (this._tree) - { - var node = this._tree.getNodeById(id); - if (node != null) - { - var parentNode = node.parentNode; - node.remove(); - parentNode.select(); - } - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._startEditNode = function (node, event) -{ - var appId = node.attributes.applicationId; - if (!this._applications[appId].canRenameNode (node)) - { - return; - } - - this._treeEditor.triggerEdit(node); - try - { - // Force the input selection - var fd = Ext.getCmp(this._treeEditor.getItemId()).field; - if (fd != null && fd.isFormField) - { - fd.focus(true, 10); - } - }catch (e) {} -} - -org.ametys.explorer.ResourcesExplorer.prototype._beforeEdit = function (editor, el, value) -{ - var node = this._tree.getSelectionModel().getSelectedNode(); - - // check rights - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': node.attributes.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Edit']") == null) - { - return false; - } - - // Store node to edit - this._nodeToRename = node; - - return true; -} - -org.ametys.explorer.ResourcesExplorer.prototype._editNode = function (editor, value, oldValue) -{ - var node = this._nodeToRename; - if (node == null) - return false; - - if (value.trim() == oldValue.trim()) - return; - - var appId = node.attributes.applicationId; - - var result = this._applications[appId].execCommand ('rename', {'id': node.id, 'value': value.trim()}); - if (!result) - { - editor.cancelEdit(); - return false; - } - - this.fireNodeRenamed (node); -} - -org.ametys.explorer.ResourcesExplorer.prototype._trimValue = function (editor, value, startValue) -{ - if (this._nodeToRename != null) - { - this._nodeToRename.setText(value.trim()); - } - this._nodeToRename = null; -} - -/** - * Draw the application panel - * @param {String} id The application id to draw - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._drawApplicationPanel = function (id) -{ - var serverMessage = new org.ametys.servercomm.ServerMessage("explorer", "/applications", {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.ResourcesExplorer")) - { - throw "org.ametys.explorer.ResourcesExplorer request failed"; - } - - var applications = response.selectNodes("applications/application"); - for (var i=0; i < applications.length; i++) - { - var appId = applications[i].getAttribute("id"); - if (appId == id) - { - var className = applications[i].selectSingleNode("action").getAttribute("class"); - var plugin = applications[i].getAttribute("plugin"); - - eval("var application = new " + className + "(this, appId, plugin)"); - this._applications[id] = application; - - var panel = application.createPanel(); - application.setIndex (this._appPanel.items.length); - - if (this._params.toolbar) - { - var toolbar = application.createToolbar (); - this._toolbarPanel.add (toolbar); - this._toolbarPanel.doLayout(); - } - - this._appPanel.add(panel); - this._appPanel.doLayout(); - } - } -} - -/** - * Active an application panel - * @param {String} appId The application id to activate - * @private - */ -org.ametys.explorer.ResourcesExplorer.prototype._activeApplicationItem = function (appId) -{ - var index = this._applications[appId].getIndex(); - - var appLayout = this._appPanel.getLayout(); - appLayout.setActiveItem(index); - - if (this._params.toolbar) - { - var toolbarLayout = this._toolbarPanel.getLayout(); - toolbarLayout.setActiveItem(index); - } -} - - -org.ametys.explorer.ResourcesExplorer.prototype.showHideRightsPanel = function (show) -{ - if (this._profilesTree != null && show) - { - this._mainPanel.items.get(1).getLayout().setActiveItem (this._profilesTree.id); - this._updateRightsPanel (this._tree.getSelectionModel().getSelectedNode(), true); - Ext.getCmp ('explorer-tree-hint-rights').show(); - } - else - { - this._mainPanel.items.get(1).getLayout().setActiveItem (0); - var node = this._tree.getSelectionModel().getSelectedNode(); - this._updateApplicationPanel (node); - - if (this._params.toolbar) - { - var appId = node.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].execCommand ('updateToolbar', {'id': node.id}); - } - } - } - Ext.getCmp ('explorer-tree-hint-rights').ownerCt.doLayout(); -} - -org.ametys.explorer.ResourcesExplorer.prototype.refreshSearch = function (params) -{ - var node = this._tree.getNodeById (this._searchNodeId); - if (node == null) - { - this._createSearchNode(); - } - this._tree.getNodeById (this._searchNodeId).select(); - - if (this._applications['org.ametys.plugins.explorer.applications.Search'] != null) - { - this._applications['org.ametys.plugins.explorer.applications.Search'].execCommand ('refresh', params); - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._onFocus = function () -{ - var node = this._tree.getSelectionModel().getSelectedNode(); - if (node != null) - { - this.fireEventSelection (node); - - var appId = node.attributes.applicationId; - if (this._applications[appId] && (typeof this._applications[appId]._onFocus == 'function')) - { - this._applications[appId]._onFocus (); - } - - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._onBlur = function () -{ -} - -org.ametys.explorer.ResourcesExplorer.prototype._onClose = function () -{ - this.fireEventSelection (null); -} - -/** - * Get the application of given id - * @param {String} id The application id - * @return The application or null. - */ -org.ametys.explorer.ResourcesExplorer.prototype.getApplication = function (id) -{ - return this._applications[id]; -} - -org.ametys.explorer.ResourcesExplorer.prototype.refresh = function () -{ - this._tree.getLoader().load(this._tree.getRootNode()); - this._tree.getRootNode().expand(); -} - -org.ametys.explorer.ResourcesExplorer.prototype._refreshNode = function (id, callback, args) -{ - if (this._tree) - { - var node = this._tree.getNodeById(id); - if (node != null) - { - if (typeof callback == 'function') - { - node.reload(callback.createDelegate(this, args)); - } - else - { - node.reload(); - } - } - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._refreshApp = function (id) -{ - var node = this._tree.getSelectionModel().getSelectedNode(); - if (node != null && node.id == id) - { - var appId = node.attributes.applicationId; - this._applications[appId].execCommand ('refresh', {'id': id}); - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._selectNextNode = function () -{ - if (org.ametys.explorer.ResourcesExplorer._nextNodeToSelect != null) - { - this._selectNode(org.ametys.explorer.ResourcesExplorer._nextNodeToSelect); - org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = null; - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._selectNode = function (id) -{ - org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = null; - - if (this._tree) - { - var node = this._tree.getNodeById(id); - if (node == null) - { - // Le noeud n'existe pas encore - org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = id; - return; - } - if (node != null && this._currentSelection != id) - { - node.select(); - } - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._updateNodeText = function (id, text) -{ - if (this._tree) - { - var node = this._tree.getNodeById(id); - if (node != null) - { - node.setText(text); - } - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._onSelectRecords = function (records, type) -{ - var node = this._tree.getSelectionModel().getSelectedNode(); - if (node != null) - { - this.fireRecordsSelection (node, records, type); - } -} - -org.ametys.explorer.ResourcesExplorer.prototype._onViewChange = function (appId, view) -{ - this.fireViewChange (appId, view); -} - -/** - * Select the root node of the tree - */ -org.ametys.explorer.ResourcesExplorer.prototype._createResourceNode = function () -{ - // Resource node - var node = new Ext.tree.AsyncTreeNode ({ - draggable: false, //This node is not draggable - icon : getPluginResourcesUrl("explorer") + "/img/root.png", - text : "", - id: this._params.id, - applicationId: 'org.ametys.plugins.explorer.applications.Resources', - editable: false, - name: 'resources' - }); - this._tree.getRootNode().appendChild(node); - node.expand.defer(200, node); - node.select.defer(200, node); - -} - -/** - * The search node - */ -org.ametys.explorer.ResourcesExplorer.prototype._searchNodeId = 'search-application-node' -org.ametys.explorer.ResourcesExplorer.prototype._createSearchNode = function () -{ - var node = new Ext.tree.TreeNode ({ - id: this._searchNodeId, - leaf: true, - leafSort: true, - text: "", - name: "", - type: 'search', - applicationId: 'org.ametys.plugins.explorer.applications.Search', - icon: getPluginResourcesUrl('explorer') + '/img/resources/search_16.png', - editable: false - }); - this._tree.getRootNode().appendChild(node); -} - -/*----- INTERNAL EVENTS -----*/ -/** - * This method is called when a node is selected. Override this method to do specific action. - * @param {Ext.tree.Node} node The selected node. Can be null - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireEventSelection = function(node) -{ - if (node == null) - return; - - if (this._params.toolbar) - { - var appId = node.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].execCommand ('updateToolbar', {'id': node.id}); - } - } -} - -/** - * This method is called when a node is renamed. Override this method to do specific action. - * @param {Ext.tree.Node} node The selected node. Can be null - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireNodeRenamed = function(node) -{ -} - -/** - * This method is called when a node is removed. Override this method to do specific action. - * @param {Ext.tree.Node} parentNode The new parent node. - * @param {Ext.tree.Node} node The moved node. - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireNodeMoved = function (parentNode, node) -{ -} - -/** - * This method is called when a record is removed. Override this method to do specific action. - * @param {Ext.tree.Node} parentNode The new parent node. - * @param {Ext.tree.Node} records The moved records. - * @param {String} type The records type - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireRecordsMoved = function (parentNode, records, type) -{ - if (this._params.toolbar) - { - var appId = parentNode.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].queryCommandState ('resourceMoved', {'parentID': parentNode.id, 'id': records[0]}); - } - } -} - -/** - * This method is called when a record is selected. Override this method to do specific action. - * @param {String} The type of selected records. - * @param {Ext.tree.Record[]} records The selected records - * @param {String} type The records type - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireRecordsSelection = function (node, records, type) -{ - if (this._params.toolbar) - { - var appId = node.attributes.applicationId; - if (this._applications[appId]) - { - this._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records}); - } - } -} - -/** - * This method is called when the application view is initialize (view or icons). Override this method to do specific action. - * @param appId The application id - * @param {String} view The selected view. - */ -org.ametys.explorer.ResourcesExplorer.prototype.fireViewChange = function(appId, view) -{ -} - -// -------------------------------------------------- -/** - * This class extends {@link Ext.tree.TreePanel} to override the initEvents method to allow DD on leaf node - */ -org.ametys.explorer.ExplorerTreePanel = Ext.extend(Ext.tree.TreePanel, { - initEvents: function() - { - Ext.tree.TreePanel.superclass.initEvents.call(this); - - if(this.containerScroll) - { - Ext.dd.ScrollManager.register(this.body); - } - - if((this.enableDD || this.enableDrop) && !this.dropZone) - { - - this.dropZone = new org.ametys.explorer.TreeDropZone (this, this.dropConfig || { - ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true - }); - } - - if((this.enableDD || this.enableDrag) && !this.dragZone) - { - this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { - ddGroup: this.ddGroup || "TreeDD", - scroll: this.ddScroll - }); - } - - this.getSelectionModel().init(this); - }, - - selectNodeByPath: function (path) - { - var rootText = this.getRootNode().text + '/' + this.getRootNode().childNodes[0].text; - this.expandPath("/" + rootText + path, 'text', this._expandPathCb); - }, - - _expandPathCb: function(bSuccess, oLastNode) - { - if (oLastNode != null) - { - oLastNode.ensureVisible(); // scroll to node - oLastNode.select(); // select node - } - } - -}); -//-------------------------------------------------- -/** - * This class extends {@link Ext.tree.TreeDropZone} to allow DD on leaf node - */ -org.ametys.explorer.TreeDropZone = Ext.extend(Ext.tree.TreeDropZone, { - - /** Override isValidDropPoint */ - isValidDropPoint: function(n, pt, dd, e, data) - { - var isLeaf = n.node.leaf; - var targetNode = n.node; - if (isLeaf) - { - targetNode.leaf = false; // Change leaf property to allow DD for leaf nodes - } - - if (targetNode.attributes.isModifiable != 'true' || targetNode.attributes.canCreateChild != 'true') - { - return false; - } - - var result = org.ametys.explorer.TreeDropZone.superclass.isValidDropPoint.call(this, n, pt, dd, e, data); - - return result; - } -}); - Index: main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (revision 0) +++ main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (revision 9478) @@ -0,0 +1,972 @@ +/* + * Copyright 2010 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.explorer'); + +/** + * Creates a new resource explorer + * @param {Object} The explorer parameters: <br> + * <ul> + * <li>id: the resource root id</li> + * <li>toolbar: true to display the toolbar actions</li> + * <li>rightsContextPrefix: the rights context prefix (defaults to '/resources')</li> + * <li>handleRights: true to handle rights on resources</li> + * </ul> + */ +org.ametys.explorer.ResourcesExplorer = function(params) +{ + this._params = params; +}; + +/** + * The tool parameters + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._params; + +/** + * A object containing the drawn applications + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._applications; + +/** + * The current selection + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._currentSelection; + +/** + * Create the panel + */ +org.ametys.explorer.ResourcesExplorer.prototype.createPanel = function() +{ + this._applications = {}; + + // Toolbar + if (this._params.toolbar) + { + this._toolbarPanel = new Ext.Panel ({ + region: 'north', + height: 95, + layout: 'card', + activeItem: 0, + border: false, + + layoutOnCardChange: true, + + html: '' + }); + } + + // Tree applications + var loader = new org.ametys.explorer.tree.ExplorerNodeXmlLoader ({ + dataUrl: getPluginDirectUrl("explorer") + '/explorer-nodes' + }); + + this._tree = new org.ametys.explorer.ExplorerTreePanel ({ + region: 'west', + width: 250, + region: 'center', + split: true, + + autoScroll:true, + animate:true, + enableDD:true, + ddGroup: 'explorerGp', + ddAppendOnly: true, + + border: false, + containerScroll: true, + + loader: loader, + + rootVisible: false, + root: new Ext.tree.TreeNode ({ + draggable: false, //This node is not draggable + editable: false, + name: 'root', + text: 'root' + }) + }); + this._tree.getRootNode().expand(); + this._tree.getSelectionModel().addListener('selectionchange', this._onSelectNode, this); + this._tree.addListener ('beforemovenode', this._moveNode, this); + this._tree.addListener ('beforenodedrop', this._dropNode, this); + this._tree.addListener ('dblclick', this._startEditNode, this); + this._tree.addListener ('afterrender', this._createResourceNode, this); + + this._treeEditor = new Ext.tree.TreeEditor (this._tree, + { + allowBlank:false + },{ + editDelay:10, + cancelOnEsc:true, + completeOnEnter:true, + ignoreNoChange:false + } + ); + + this._treeEditor.addListener ('beforestartedit', this._beforeEdit, this); + this._treeEditor.addListener ('beforecomplete', this._editNode, this); + this._treeEditor.addListener ('complete', this._trimValue, this); + + // Alphabetical sort + this._treeSorter = new Ext.tree.TreeSorter(this._tree, { + folderSort: true, + leafAttr: 'leafSort' + }); + + this._mainPanel = new Ext.Panel ({ + layout: 'border', + region: 'center', + + items: [ + new Ext.Panel ({ + region: 'west', + width: 250, + split: true, + border: false, + layout: 'border', + items: [ + new Ext.Panel ({region: 'north', height: 35, border: false, id: 'explorer-tree-hint-rights', cls: 'explorer-tree-hint-panel', html: "", hidden: true}), + this._tree + ] + }), + new Ext.Panel ({ + region: 'center', + split: true, + border: false, + layout: 'card', + activeItem: 0, + id: 'card-layout', + + layoutOnCardChange: true, + + html: '' + }) + ] + }); + + // The application panel + this._appPanel = new Ext.Panel ({ + region: 'center', + layout: 'card', + activeItem: 0, + + layoutOnCardChange: true, + + html: '' + }); + this._mainPanel.items.get(1).add(this._appPanel); + + this._rightsCxtPrefix = this._params.rightsContextPrefix ? this._params.rightsContextPrefix : '/resources'; + if (this._params.toolbar) + { + // The rights panel + this._profilesTree = new org.ametys.rights.profile.ProfilesTreePanel ({ + id: 'tree-rights-panel', + region: 'center', + context: this._rightsCxtPrefix, + rootID: this._params.id, + upToContextFn: this._upToContext.createDelegate(this) + }); + this._profilesTree.getSelectionModel().addListener ('selectionchange', org.ametys.explorer.ResourcesExplorer.prototype._onSelectProfile, this) + this._mainPanel.items.get(1).add(this._profilesTree); + } + + if (this._params.toolbar) + { + this._mainPanel.add(this._toolbarPanel); + } + return this._mainPanel; +} + +org.ametys.explorer.ResourcesExplorer.prototype._upToContext = function (context) +{ + if (/^(\/[^\/]*)?\/resources\/(.*)$/.test(context)) + { + var path = '/root/resources/' + RegExp.$2; + this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); + } + else if (/^(\/[^\/]*)?\/resources$/.test(context)) + { + var path = '/root/resources'; + this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); + } +} + +/** + * Expand the tree and select a node by its complete path + * @param path The complete path from the root node + */ +org.ametys.explorer.ResourcesExplorer.prototype.selectByPath = function (path) +{ + this._tree.expandPath (path, 'name', this._selectByPathCb.createDelegate(this)); +} + +org.ametys.explorer.ResourcesExplorer.prototype._selectByPathCb = function (success, lastNode) +{ + if (lastNode != null) + { + lastNode.ensureVisible(); // scroll to node + this._tree.getSelectionModel().select(lastNode)// select node + } +} + +/** + * This function is called when a explorer node is selected.
This function draw or activate the application panel. + * @param {Ext.tree.DefaultSelectionModel} sm The selection model + * @param {Ext.tree.TreeNode} node The selected node + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._onSelectNode = function (sm, node) +{ + if (node != null && node.attributes.applicationId) + { + if (this._mainPanel.items.get(1).getLayout().activeItem.id == 'tree-rights-panel') + { + this._updateRightsPanel(node); + } + else + { + this._updateApplicationPanel(node); + } + + this._currentSelection = node.id; + } + else + { + this._currentSelection = null; + } + + this.fireEventSelection (node); +} + +/** + * This function is called when a node of profile tree is selected.
+ * @param {Ext.tree.DefaultSelectionModel} sm The selection model + * @param {Ext.tree.TreeNode} node The selected node + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._onSelectProfile = function (sm, node) +{ + if (node == null) + return; + + if (this._params.toolbar) + { + var treeNode = this._tree.getSelectionModel().getSelectedNode(); + if (treeNode == null) + return; + + var appId = treeNode.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].execCommand ('updateToolbar', {'id': treeNode.id, 'rightNode': node}); + } + } + this._profilesTree.getTopToolbar().items.get(4).setDisabled (node == null || node.attributes.inherit != 'true'); +} + +org.ametys.explorer.ResourcesExplorer.prototype._onUpdateProfile = function (sm, node) +{ + if (this._params.toolbar) + { + var treeNode = this._tree.getSelectionModel().getSelectedNode(); + if (treeNode == null) + return; + + var appId = treeNode.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].execCommand ('updateToolbar', {'id': treeNode.id}); + } + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._updateRightsPanel = function (node, init) +{ + if (node.attributes.applicationId == 'org.ametys.plugins.explorer.applications.Resources') + { + var serverMessage = new org.ametys.servercomm.ServerMessage("explorer", "/exporer-entity", {'id': node.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + var params = {}; // necessary to check rights + var name = response.selectSingleNode('Node').getAttribute('name'); + var path = response.selectSingleNode('Node').getAttribute('path'); + this._profilesTree.updateContext (this._rightsCxtPrefix + (path != '' ? '/' + path : ''), params, init); + + var text = "" + " " + name; + this._profilesTree.updateContextHelperText (text); + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._updateApplicationPanel = function (node) +{ + var appId = node.attributes.applicationId; + if (!this._applications[appId]) + { + // Draw card + this._drawApplicationPanel (appId); + } + // Active and refresh application + this._activeApplicationItem (appId); + this._applications[appId].refresh (node.id); +} + +org.ametys.explorer.ResourcesExplorer.prototype._moveNode = function (tree, node, oldParent, newParent, index) +{ + var params = {}; + params.id = node.id; + params.target = newParent.id; + + var sibling = newParent.item(index); + if (sibling != null) + { + params.sibling = sibling.id; + } + + var appId = node.attributes.applicationId; + if (!this._applications[appId].execCommand ('move-node', params)) + { + // Cancel the move + return false; + } + + this.fireNodeMoved (newParent, node) +} + +org.ametys.explorer.ResourcesExplorer.prototype._dropNode = function (dropEvent) +{ + var records = dropEvent.data.records || dropEvent.data.selections; + if (!records) + { + return; + } + + var node = dropEvent.target; + var appId = node.attributes.applicationId; + + var params = {}; + params.target = node.id; + params.ids = []; + for (var i in records) + { + if (typeof (records[i]) != 'function') + { + params.ids.push (records[i].data.id); + } + } + + if (!this._applications[appId].execCommand ('move', params)) + { + dropEvent.cancel = true; + return; + } + + // Prevent the animated "repair" + dropEvent.dropStatus = true; + + // Select the target node + this._selectNode (node.id); + + this.fireRecordsMoved (node, params.ids) +} + +/** + * Get the current selected node + * @return {Ext.tree.TreeNode} The selected node + */ +org.ametys.explorer.ResourcesExplorer.prototype.getSelectedNode = function () +{ + return this._tree.getSelectionModel().getSelectedNode(); +} + +/** + * Gets a node in the tree by its id + * @param {String} The node id + * @return {Ext.tree.Node} The node or null. + */ +org.ametys.explorer.ResourcesExplorer.prototype.getNodeById = function (id) +{ + return this._tree.getNodeById (id); +} + +/** + * Call this function to add a new node + * @params {Object} nodeAttributes The attributes/config for the node or just a string with the text for the node + */ +org.ametys.explorer.ResourcesExplorer.prototype.addNode = function (parentId, nodeAttributes) +{ + var node = this._tree.getNodeById(parentId); + if (node == null) + return; + + var childNode = new Ext.tree.TreeNode (nodeAttributes); + // Make sure to render plus/minus icon + node.leaf = false; + return node.appendChild (childNode); +} + +org.ametys.explorer.ResourcesExplorer.prototype.expandNode = function (id) +{ + var node = this._tree.getNodeById(id); + if (node == null) + return; + + if (!node.isExpanded()) + node.expand(); +} + + +/** + * Call this function to rename a node + * @params {Ext.tree.Node} node The node to rename + */ +org.ametys.explorer.ResourcesExplorer.prototype.renameNode = function (id) +{ + var node = this._tree.getNodeById(id); + if (node != null) + { + node.select(); + this._startEditNode(node); + } +} + +/** + * Call this function to delete a node + * params {Ext.tree.Node} node The node to delete + */ +org.ametys.explorer.ResourcesExplorer.prototype.deleteNode = function (id) +{ + if (this._tree) + { + var node = this._tree.getNodeById(id); + if (node != null) + { + var parentNode = node.parentNode; + node.remove(); + parentNode.select(); + } + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._startEditNode = function (node, event) +{ + var appId = node.attributes.applicationId; + if (!this._applications[appId].canRenameNode (node)) + { + return; + } + + this._treeEditor.triggerEdit(node); + try + { + // Force the input selection + var fd = Ext.getCmp(this._treeEditor.getItemId()).field; + if (fd != null && fd.isFormField) + { + fd.focus(true, 10); + } + }catch (e) {} +} + +org.ametys.explorer.ResourcesExplorer.prototype._beforeEdit = function (editor, el, value) +{ + var node = this._tree.getSelectionModel().getSelectedNode(); + + // check rights + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': node.attributes.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Edit']") == null) + { + return false; + } + + // Store node to edit + this._nodeToRename = node; + + return true; +} + +org.ametys.explorer.ResourcesExplorer.prototype._editNode = function (editor, value, oldValue) +{ + var node = this._nodeToRename; + if (node == null) + return false; + + if (value.trim() == oldValue.trim()) + return; + + var appId = node.attributes.applicationId; + + var result = this._applications[appId].execCommand ('rename', {'id': node.id, 'value': value.trim()}); + if (!result) + { + editor.cancelEdit(); + return false; + } + + this.fireNodeRenamed (node); +} + +org.ametys.explorer.ResourcesExplorer.prototype._trimValue = function (editor, value, startValue) +{ + if (this._nodeToRename != null) + { + this._nodeToRename.setText(value.trim()); + } + this._nodeToRename = null; +} + +/** + * Draw the application panel + * @param {String} id The application id to draw + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._drawApplicationPanel = function (id) +{ + var serverMessage = new org.ametys.servercomm.ServerMessage("explorer", "/applications", {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.ResourcesExplorer")) + { + throw "org.ametys.explorer.ResourcesExplorer request failed"; + } + + var applications = response.selectNodes("applications/application"); + for (var i=0; i < applications.length; i++) + { + var appId = applications[i].getAttribute("id"); + if (appId == id) + { + var className = applications[i].selectSingleNode("action").getAttribute("class"); + var plugin = applications[i].getAttribute("plugin"); + + eval("var application = new " + className + "(this, appId, plugin)"); + this._applications[id] = application; + + var panel = application.createPanel(); + application.setIndex (this._appPanel.items.length); + + if (this._params.toolbar) + { + var toolbar = application.createToolbar (); + this._toolbarPanel.add (toolbar); + this._toolbarPanel.doLayout(); + } + + this._appPanel.add(panel); + this._appPanel.doLayout(); + } + } +} + +/** + * Active an application panel + * @param {String} appId The application id to activate + * @private + */ +org.ametys.explorer.ResourcesExplorer.prototype._activeApplicationItem = function (appId) +{ + var index = this._applications[appId].getIndex(); + + var appLayout = this._appPanel.getLayout(); + appLayout.setActiveItem(index); + + if (this._params.toolbar) + { + var toolbarLayout = this._toolbarPanel.getLayout(); + toolbarLayout.setActiveItem(index); + } +} + + +org.ametys.explorer.ResourcesExplorer.prototype.showHideRightsPanel = function (show) +{ + if (this._profilesTree != null && show) + { + this._mainPanel.items.get(1).getLayout().setActiveItem (this._profilesTree.id); + this._updateRightsPanel (this._tree.getSelectionModel().getSelectedNode(), true); + Ext.getCmp ('explorer-tree-hint-rights').show(); + } + else + { + this._mainPanel.items.get(1).getLayout().setActiveItem (0); + var node = this._tree.getSelectionModel().getSelectedNode(); + this._updateApplicationPanel (node); + + if (this._params.toolbar) + { + var appId = node.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].execCommand ('updateToolbar', {'id': node.id}); + } + } + } + Ext.getCmp ('explorer-tree-hint-rights').ownerCt.doLayout(); +} + +org.ametys.explorer.ResourcesExplorer.prototype.refreshSearch = function (params) +{ + var node = this._tree.getNodeById (this._searchNodeId); + if (node == null) + { + this._createSearchNode(); + } + this._tree.getNodeById (this._searchNodeId).select(); + + if (this._applications['org.ametys.plugins.explorer.applications.Search'] != null) + { + this._applications['org.ametys.plugins.explorer.applications.Search'].execCommand ('refresh', params); + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._onFocus = function () +{ + var node = this._tree.getSelectionModel().getSelectedNode(); + if (node != null) + { + this.fireEventSelection (node); + + var appId = node.attributes.applicationId; + if (this._applications[appId] && (typeof this._applications[appId]._onFocus == 'function')) + { + this._applications[appId]._onFocus (); + } + + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._onBlur = function () +{ +} + +org.ametys.explorer.ResourcesExplorer.prototype._onClose = function () +{ + this.fireEventSelection (null); +} + +/** + * Get the application of given id + * @param {String} id The application id + * @return The application or null. + */ +org.ametys.explorer.ResourcesExplorer.prototype.getApplication = function (id) +{ + return this._applications[id]; +} + +org.ametys.explorer.ResourcesExplorer.prototype.refresh = function () +{ + this._tree.getLoader().load(this._tree.getRootNode()); + this._tree.getRootNode().expand(); +} + +org.ametys.explorer.ResourcesExplorer.prototype._refreshNode = function (id, callback, args) +{ + if (this._tree) + { + var node = this._tree.getNodeById(id); + if (node != null) + { + if (typeof callback == 'function') + { + node.reload(callback.createDelegate(this, args)); + } + else + { + node.reload(); + } + } + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._refreshApp = function (id) +{ + var node = this._tree.getSelectionModel().getSelectedNode(); + if (node != null && node.id == id) + { + var appId = node.attributes.applicationId; + this._applications[appId].execCommand ('refresh', {'id': id}); + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._selectNextNode = function () +{ + if (org.ametys.explorer.ResourcesExplorer._nextNodeToSelect != null) + { + this._selectNode(org.ametys.explorer.ResourcesExplorer._nextNodeToSelect); + org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = null; + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._selectNode = function (id) +{ + org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = null; + + if (this._tree) + { + var node = this._tree.getNodeById(id); + if (node == null) + { + // Le noeud n'existe pas encore + org.ametys.explorer.ResourcesExplorer._nextNodeToSelect = id; + return; + } + if (node != null && this._currentSelection != id) + { + node.select(); + } + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._updateNodeText = function (id, text) +{ + if (this._tree) + { + var node = this._tree.getNodeById(id); + if (node != null) + { + node.setText(text); + } + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._onSelectRecords = function (records, type) +{ + var node = this._tree.getSelectionModel().getSelectedNode(); + if (node != null) + { + this.fireRecordsSelection (node, records, type); + } +} + +org.ametys.explorer.ResourcesExplorer.prototype._onViewChange = function (appId, view) +{ + this.fireViewChange (appId, view); +} + +/** + * Select the root node of the tree + */ +org.ametys.explorer.ResourcesExplorer.prototype._createResourceNode = function () +{ + // Resource node + var node = new Ext.tree.AsyncTreeNode ({ + draggable: false, //This node is not draggable + icon : getPluginResourcesUrl("explorer") + "/img/root.png", + text : "", + id: this._params.id, + applicationId: 'org.ametys.plugins.explorer.applications.Resources', + editable: false, + name: 'resources' + }); + this._tree.getRootNode().appendChild(node); + node.expand.defer(200, node); + node.select.defer(200, node); + +} + +/** + * The search node + */ +org.ametys.explorer.ResourcesExplorer.prototype._searchNodeId = 'search-application-node' +org.ametys.explorer.ResourcesExplorer.prototype._createSearchNode = function () +{ + var node = new Ext.tree.TreeNode ({ + id: this._searchNodeId, + leaf: true, + leafSort: true, + text: "", + name: "", + type: 'search', + applicationId: 'org.ametys.plugins.explorer.applications.Search', + icon: getPluginResourcesUrl('explorer') + '/img/resources/search_16.png', + editable: false + }); + this._tree.getRootNode().appendChild(node); +} + + + + +/*----- INTERNAL EVENTS -----*/ +/** + * This method is called when a node is selected. Override this method to do specific action. + * @param {Ext.tree.Node} node The selected node. Can be null + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireEventSelection = function(node) +{ + if (node == null) + return; + + if (this._params.toolbar) + { + var appId = node.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].execCommand ('updateToolbar', {'id': node.id}); + } + } +} + +/** + * This method is called when a node is renamed. Override this method to do specific action. + * @param {Ext.tree.Node} node The selected node. Can be null + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireNodeRenamed = function(node) +{ +} + +/** + * This method is called when a node is removed. Override this method to do specific action. + * @param {Ext.tree.Node} parentNode The new parent node. + * @param {Ext.tree.Node} node The moved node. + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireNodeMoved = function (parentNode, node) +{ +} + +/** + * This method is called when a record is removed. Override this method to do specific action. + * @param {Ext.tree.Node} parentNode The new parent node. + * @param {Ext.tree.Node} records The moved records. + * @param {String} type The records type + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireRecordsMoved = function (parentNode, records, type) +{ + if (this._params.toolbar) + { + var appId = parentNode.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].queryCommandState ('resourceMoved', {'parentID': parentNode.id, 'id': records[0]}); + } + } +} + +/** + * This method is called when a record is selected. Override this method to do specific action. + * @param {String} The type of selected records. + * @param {Ext.tree.Record[]} records The selected records + * @param {String} type The records type + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireRecordsSelection = function (node, records, type) +{ + if (this._params.toolbar) + { + var appId = node.attributes.applicationId; + if (this._applications[appId]) + { + this._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records}); + } + } +} + +/** + * This method is called when the application view is initialize (view or icons). Override this method to do specific action. + * @param appId The application id + * @param {String} view The selected view. + */ +org.ametys.explorer.ResourcesExplorer.prototype.fireViewChange = function(appId, view) +{ +} + +// -------------------------------------------------- +/** + * This class extends {@link Ext.tree.TreePanel} to override the initEvents method to allow DD on leaf node + */ +org.ametys.explorer.ExplorerTreePanel = Ext.extend(Ext.tree.TreePanel, { + initEvents: function() + { + Ext.tree.TreePanel.superclass.initEvents.call(this); + + if(this.containerScroll) + { + Ext.dd.ScrollManager.register(this.body); + } + + if((this.enableDD || this.enableDrop) && !this.dropZone) + { + + this.dropZone = new org.ametys.explorer.TreeDropZone (this, this.dropConfig || { + ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true + }); + } + + if((this.enableDD || this.enableDrag) && !this.dragZone) + { + this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { + ddGroup: this.ddGroup || "TreeDD", + scroll: this.ddScroll + }); + } + + this.getSelectionModel().init(this); + }, + + selectNodeByPath: function (path) + { + var rootText = this.getRootNode().text + '/' + this.getRootNode().childNodes[0].text; + this.expandPath("/" + rootText + path, 'text', this._expandPathCb); + }, + + _expandPathCb: function(bSuccess, oLastNode) + { + if (oLastNode != null) + { + oLastNode.ensureVisible(); // scroll to node + oLastNode.select(); // select node + } + } + +}); +//-------------------------------------------------- +/** + * This class extends {@link Ext.tree.TreeDropZone} to allow DD on leaf node + */ +org.ametys.explorer.TreeDropZone = Ext.extend(Ext.tree.TreeDropZone, { + + /** Override isValidDropPoint */ + isValidDropPoint: function(n, pt, dd, e, data) + { + var isLeaf = n.node.leaf; + var targetNode = n.node; + if (isLeaf) + { + targetNode.leaf = false; // Change leaf property to allow DD for leaf nodes + } + + if (targetNode.attributes.isModifiable != 'true' || targetNode.attributes.canCreateChild != 'true') + { + return false; + } + + var result = org.ametys.explorer.TreeDropZone.superclass.isValidDropPoint.call(this, n, pt, dd, e, data); + + return result; + } +}); + Index: main/plugin-explorer/i18n/messages_fr.xml =================================================================== --- main/plugin-explorer/i18n/messages_fr.xml (revision 10091) +++ main/plugin-explorer/i18n/messages_fr.xml (working copy) @@ -24,6 +24,16 @@ Autorise à ajouter un serveur CMIS Renommer un dossier Autorise à renommer un dossier + + Editer une page html + Autorise à editer une page html + + Créer un dossier html + Autorise à créer un dossier html + + Sauvegarde page html + Autorise la sauvegarde d'une page html + Supprimer un dossier Autorise à supprimer un dossier Ajouter un fichier @@ -39,7 +49,9 @@ Application ressources Application ressources - + Dossier Html Editor + Application HtmlEditor + Application HtmlEditor Ressources Une erreur est survenue : elle a empêchée l'affichage de l'application sélectionnée. @@ -62,6 +74,7 @@ Dossiers + Dossiers Nouveau Ajoute un nouveau sous-dossier Voir l'aide pour plus de détails @@ -77,11 +90,26 @@ Supprimer Supprime le dossier sélectionné Voir l'aide pour plus de détails + Nouveau dossier html + Dossier HTML + Crée un nouveau dossier d'edition de pages html + Voir l'aide pour plus de détails + + Exporter Zip + Crée une archive zip avec le contenu du dossier Exporter (ZIP) Crée une archive ZIP avec le contenu du dossier sélectionné et de ses sous-dossiers Voir l'aide pour plus de détails + Edition html + Modifier + basculer entre mode edition et rendu html + Sauvegarder + Sauvegarde de la page html + Quitter + Passer en mode édition sans sauvegarde les modifications + Fichiers Nouveau Insère un nouveau fichier ou met à jour un fichier existant @@ -150,6 +178,12 @@ Diaporama Ce bouton lance un diaporama sur la sélection d'images afin de visualiser ces dernières en plein écran. + + + Zip + Exporter Zip + Lorsque vous sélectionnez au moins un fichier, ce bouton vous permet de l'exporter sous format zip' + Gestion des droits Droits Affecte les droits aux utilisateurs ou groupes sur l'explorateur Index: main/plugin-explorer/resources/img/resources/Edit_Html_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\img\resources\Edit_Html_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddHtmlFolderAction.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddHtmlFolderAction.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddHtmlFolderAction.java (revision 0) @@ -0,0 +1,113 @@ +/* + * Copyright 2010 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ametys.plugins.explorer.resources.actions; +import java.io.ByteArrayInputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.cocoon.acting.ServiceableAction; +import org.apache.cocoon.environment.ObjectModelHelper; +import org.apache.cocoon.environment.Redirector; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.SourceResolver; +import org.apache.commons.lang.IllegalClassException; +import org.ametys.plugins.explorer.resources.ModifiableResource; +import org.ametys.plugins.explorer.resources.ModifiableResourceCollection; +import org.ametys.plugins.explorer.resources.HtmleditionFactory; +import org.ametys.plugins.explorer.resources.Resource; +import org.ametys.plugins.explorer.resources.jcr.JCRResourcesCollectionFactory; +import org.ametys.plugins.repository.AmetysObject; +import org.ametys.plugins.repository.AmetysObjectResolver; + +/** + * Action for adding a resource collection (html folder). + */ +public class AddHtmlFolderAction extends ServiceableAction +{ + private AmetysObjectResolver _resolver; + + @Override + public void service(ServiceManager sManager) throws ServiceException + { + super.service(sManager); + + _resolver = (AmetysObjectResolver) sManager.lookup(AmetysObjectResolver.ROLE); + + } + + @Override + public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception + { + Map result = new HashMap(); + Request request = ObjectModelHelper.getRequest(objectModel); + + String id = request.getParameter("id"); + String originalName = request.getParameter("name"); + boolean renameIfExists = request.getParameter("renameIfExists") == null ? false : Boolean.valueOf(request.getParameter("renameIfExists")); + assert id != null; + + + AmetysObject object = _resolver.resolveById(id); + if (!(object instanceof ModifiableResourceCollection)) + { + throw new IllegalClassException(ModifiableResourceCollection.class, object.getClass()); + } + + ModifiableResourceCollection collection = (ModifiableResourceCollection) object; + + // FIXME CMS-2297 + // Check user right + /*if (_rightsManager.hasRight(_userProvider.getUser(), "Plugin_Explorer_Folder_Add", "/resources" + collection.getResourcePath()) != RightResult.RIGHT_OK) + { + throw new IllegalAccessException("User '" + _userProvider.getUser() + "' tried to access a privilege feature without convenient right [Plugin_Explorer_Folder_Add, /resources" + collection.getResourcePath() + "]"); + }*/ + + if (!renameIfExists && collection.hasChild(originalName)) + { + getLogger().warn("The object '" + object.getName() + "' can not be renamed in '" + originalName + "' : a object of same name already exists."); + result.put("message", "already-exist"); + return result; + } + + int index = 2; + String name = originalName; + while (collection.hasChild(name)) + { + name = originalName + " (" + index + ")"; + index++; + } + + //AmetysObject child = collection.createChild(name, JCRResourcesCollectionFactory.RESOURCESCOLLECTION_NODETYPE); + //AmetysObject child = collection.createChild(name, HtmlEditorAppliFactory.htmleditor_collection_NODETYPE); + + ModifiableResourceCollection FolderHtml = collection.createChild(name, HtmleditionFactory.HTMLFOLDER_NODETYPE); + + ModifiableResource IndexHtmlfile = FolderHtml.createChild("index.html",FolderHtml.getResourceType()); + IndexHtmlfile.setData(new ByteArrayInputStream("

".getBytes()), "text/html", new Date() ,""); + + collection.saveChanges(); + + result.put("id", IndexHtmlfile.getId()); + result.put("parentID", id); + result.put("name", name); + + + return result; + } +} \ No newline at end of file Index: main/plugin-explorer/resources/folder_exportzip_32.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\folder_exportzip_32.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/plugin.xml =================================================================== --- main/plugin-explorer/plugin.xml (revision 10091) +++ main/plugin-explorer/plugin.xml (working copy) @@ -65,8 +65,17 @@ cmis-root-collection ametys:cmis-root-collection resources_nodetypes.xml - + + + + html_folder + ametys:html_folder + resources_nodetypes.xml + + @@ -101,6 +110,7 @@ ux/js/DataView-more.js js/jquery.min.js js/jquery-ui.min.js + js/tiny_mce.js pirobox_extended_min.js @@ -129,9 +139,30 @@ js/org/ametys/explorer/applications/search/SearchApplication.i18n.js - + + + + + PLUGINS_EXPLORER_APPLICATION_SEARCH_LABEL + PLUGINS_EXPLORER_APPLICATION_SEARCH_DESC + img/search/icon_small.png + img/search/icon_medium.png + img/search/icon_large.png + + + js/org/ametys/explorer/applications/Application.js + js/org/ametys/explorer/applications/htmleditor/htmleditorApplication.i18n.js + + + + + + + New Html Folder + Html Folder + Html editor + Update + overbalance between edition mode and html view + Save + Save the html page + Concel + Cross in edition mode without save modifications + + An error occurred: unable to check user rights Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (revision 10070) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (working copy) @@ -1,403 +0,0 @@ -/* - * Copyright 2010 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.namespace('org.ametys.explorer.applications.resources.toolbar'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.View'); - -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.Folder.add = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - org.ametys.explorer.applications.resources.Folder.add (parentID, - "", - function (parentID, id, name) { - org.ametys.explorer.applications.resources.toolbar.Folder._addCb (parentID, id, name, application) - } - ); -} -org.ametys.explorer.applications.resources.toolbar.Folder._addCb = function (parentID, id, name, application) -{ - application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/is-cmis-root', - {id: node.id}, - org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, - null, - this, - null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS")) - { - return; - } - - var isCmisRoot = response.selectSingleNode('ActionResult/isCmisRoot')[org.ametys.servercomm.ServerComm.xmlTextContent] == 'true'; - org.ametys.explorer.applications.resources.Folder.addCMIS (parentID, isCmisRoot ? 'edit' : 'new', - function (parentID, id, name) { - org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb (parentID, id, name, application) - } - ); -} -org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb = function (parentID, id, name, application) -{ - if (parentID == null) - { - application._explorer._refreshNode (id); - } - else - { - application._explorer._refreshNode (parentID); - } - -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.Folder.rename = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var id = node.id; - - application._explorer.renameNode (id); - - return; - - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var id = node.id; - - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/exporer-entity', {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.Folder.rename")) - { - return false; - } - - var name = response.selectSingleNode('Node').getAttribute('name'); - Ext.Msg.prompt("", - "", - function (btn, text) { - org.ametys.explorer.applications.resources.toolbar.Folder._doRename (btn, text, id, application) - }, - this, - false, - name - ); -} -org.ametys.explorer.applications.resources.toolbar.Folder._doRename = function (btn, text, id, application) -{ - if (btn == 'ok') - { - - } -} -org.ametys.explorer.applications.resources.toolbar.Folder._renameCb = function(id, name, application) -{ - // TODO Update view -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.Folder.remove = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var id = node.id; - - org.ametys.explorer.applications.resources.Folder.remove (id, - function (id) { - org.ametys.explorer.applications.resources.toolbar.Folder._removeCb (id, application); - } - ); -} -org.ametys.explorer.applications.resources.toolbar.Folder._removeCb = function (id, application) -{ - application._explorer.deleteNode (id); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.Folder.archive = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var id = node.id; - - org.ametys.explorer.applications.resources.Folder.archive (id, node.attributes.name); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.search = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var id = node.id; - - org.ametys.explorer.applications.resources.Search (id, function (params) { - org.ametys.explorer.applications.resources.toolbar.File._searchCb (params, application); - }); -} -org.ametys.explorer.applications.resources.toolbar.File._searchCb = function (params, application) -{ - application._explorer.refreshSearch (params); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.add = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - org.ametys.explorer.applications.resources.File.add ( - parentID, - function (id, parentID, reload) - { - org.ametys.explorer.applications.resources.toolbar.File._addCb (id, parentID, reload, application) - } - ); -} -org.ametys.explorer.applications.resources.toolbar.File._addCb = function (id, parentID, reload, application) -{ - application.execCommand ('refresh', {'id': parentID, 'reload': reload}); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.update = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - var id = application.getSelectedFiles()[0]; - - org.ametys.explorer.applications.resources.File.update ( - id, - parentID, - function (id, parentID) - { - org.ametys.explorer.applications.resources.toolbar.File._updateCb (id, parentID, application) - } - ); -} -org.ametys.explorer.applications.resources.toolbar.File._updateCb = function (id, parentID, application) -{ - application.execCommand ('refresh', {'id': parentID}); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.rename = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - var id = application.getSelectedFiles()[0]; - application.execCommand ('renameFile', {'id': id, 'parentID': parentID}); -} -org.ametys.explorer.applications.resources.toolbar.File._doRename = function (btn, text, id, application) -{ - if (btn == 'ok') - { - org.ametys.explorer.applications.resources.File.rename (id, text, - function (id, name) { - org.ametys.explorer.applications.resources.toolbar.File._renameCb (id, name, application); - } - ) - } -} -org.ametys.explorer.applications.resources.toolbar.File._renameCb = function(id, name, application) -{ - application.queryCommandState ('resourceRenamed', {'id': id}); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.viewHistory = function (application) -{ - var id = application.getSelectedFiles()[0]; - var node = application._explorer.getSelectedNode(); - var parentID = node != null ? node.id : null; - - org.ametys.explorer.applications.resources.History (id, parentID, null, - function (id, parentID) { - org.ametys.explorer.applications.resources.toolbar.File._restoreVersionCb (id, parentID, application); - } - ) -} -org.ametys.explorer.applications.resources.toolbar.File._restoreVersionCb = function (id, parentID, application) -{ - application.execCommand ('refresh', {'id': parentID}); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.editDublinCore = function (application) -{ - var id = application.getSelectedFiles()[0]; - var node = application._explorer.getSelectedNode(); - var parentID = node != null ? node.id : null; - - org.ametys.explorer.applications.resources.DublinCore (id, parentID, null, - function (id, parentID) { - org.ametys.explorer.applications.resources.toolbar.File._editDublinCoreCb (id, parentID, application); - } - ) -} -org.ametys.explorer.applications.resources.toolbar.File._editDublinCoreCb = function (id, parentID, application) -{ -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.remove = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - var ids = application.getSelectedFiles(); - - org.ametys.explorer.applications.resources.File.remove (parentID, ids, - function (parentID, ids) { - org.ametys.explorer.applications.resources.toolbar.File._removeCb (parentID, ids, application) - } - ); -} -org.ametys.explorer.applications.resources.toolbar.File._removeCb = function (parentID, ids, application) -{ - application.execCommand ('refresh', {'id': parentID}); -} - -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.download = function (application) -{ - var files = application.getSelectedFiles(); - if (files.length > 1) - { - // ZIP export - var node = application._explorer.getSelectedNode(); - org.ametys.explorer.applications.resources.File.exportZIP (node.id, files); - } - else - { - org.ametys.explorer.applications.resources.File.download (files[0]); - } - - -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.exportRDF = function (application) -{ - var id = application.getSelectedFiles()[0]; - - org.ametys.explorer.applications.resources.File.exportRDF (id); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.copy = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - var ids = application.getSelectedFiles(); - - org.ametys.explorer.applications.resources.File.copy (parentID, ids); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.cut = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - var ids = application.getSelectedFiles(); - - org.ametys.explorer.applications.resources.File.cut (parentID, ids); -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.paste = function (application) -{ - var node = application._explorer.getSelectedNode(); - if (node == null) - return; - - var parentID = node.id; - - org.ametys.explorer.applications.resources.File.paste (parentID, - function (parentID, files) { - org.ametys.explorer.applications.resources.toolbar.File._pasteCb (parentID, files, application); - } - ); -} -org.ametys.explorer.applications.resources.toolbar.File._pasteCb = function (parentID, files, application) -{ - application.queryCommandState ('resourceMoved', {'id': files[0], 'parentID': parentID}); -} - -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.View.icons = function (btn, state, application) -{ - if (state) - { - application.execCommand ('changeView', {'mode': 'icons'}); - } -} -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.View.details = function (btn, state, application) -{ - if (state) - { - application.execCommand ('changeView', {'mode': 'details'}); - } -} - - -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.File.slideshow = function (btn, state, application) -{ - org.ametys.explorer.applications.resources.File.slideshow (btn._ids); -} - -/*------------------------------------------------------------------------*/ -org.ametys.explorer.applications.resources.toolbar.AssignRights = function (btn, state, application) -{ - application._explorer.showHideRightsPanel (state); -} \ No newline at end of file Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (revision 0) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (revision 10070) @@ -0,0 +1,456 @@ +/* + * Copyright 2010 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.explorer.applications.resources.toolbar'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.View'); + +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.add = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + org.ametys.explorer.applications.resources.Folder.add (parentID, + "", + function (parentID, id, name) { + org.ametys.explorer.applications.resources.toolbar.Folder._addCb (parentID, id, name, application) + } + ); +} +org.ametys.explorer.applications.resources.toolbar.Folder._addCb = function (parentID, id, name, application) +{ + application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/is-cmis-root', + {id: node.id}, + org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, + null, + this, + null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS")) + { + return; + } + + var isCmisRoot = response.selectSingleNode('ActionResult/isCmisRoot')[org.ametys.servercomm.ServerComm.xmlTextContent] == 'true'; + org.ametys.explorer.applications.resources.Folder.addCMIS (parentID, isCmisRoot ? 'edit' : 'new', + function (parentID, id, name) { + org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb (parentID, id, name, application) + } + ); +} +org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb = function (parentID, id, name, application) +{ + if (parentID == null) + { + application._explorer._refreshNode (id); + } + else + { + application._explorer._refreshNode (parentID); + } + +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.rename = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var id = node.id; + + application._explorer.renameNode (id); + + return; + + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var id = node.id; + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/exporer-entity', {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.Folder.rename")) + { + return false; + } + + var name = response.selectSingleNode('Node').getAttribute('name'); + Ext.Msg.prompt("", + "", + function (btn, text) { + org.ametys.explorer.applications.resources.toolbar.Folder._doRename (btn, text, id, application) + }, + this, + false, + name + ); +} +org.ametys.explorer.applications.resources.toolbar.Folder._doRename = function (btn, text, id, application) +{ + if (btn == 'ok') + { + + } +} +org.ametys.explorer.applications.resources.toolbar.Folder._renameCb = function(id, name, application) +{ + // TODO Update view +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.remove = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var id = node.id; + + org.ametys.explorer.applications.resources.Folder.remove (id, + function (id) { + org.ametys.explorer.applications.resources.toolbar.Folder._removeCb (id, application); + } + ); +} +org.ametys.explorer.applications.resources.toolbar.Folder._removeCb = function (id, application) +{ + application._explorer.deleteNode (id); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.archive = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var id = node.id; + + org.ametys.explorer.applications.resources.Folder.archive (id, node.attributes.name); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.search = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var id = node.id; + + org.ametys.explorer.applications.resources.Search (id, function (params) { + org.ametys.explorer.applications.resources.toolbar.File._searchCb (params, application); + }); +} +org.ametys.explorer.applications.resources.toolbar.File._searchCb = function (params, application) +{ + application._explorer.refreshSearch (params); +} +/*------------------------------------------------------------------------*/ + +org.ametys.explorer.applications.resources.toolbar.Folder.addHtmlEditor = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + org.ametys.explorer.applications.resources.Folder.addHtmlEditor (parentID, +// "Nouveau dossier HTML", + "", + function (parentID, id, name) { + org.ametys.explorer.applications.resources.toolbar.Folder._addCb (parentID, id, name, application) + } + ); +} + +org.ametys.explorer.applications.resources.toolbar.Folder._addCb = function (parentID, id, name, application) +{ + application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]); +} +/*------------------------------------------------------------------------*/ + + +/*------------------------------------------------------------------------*/ +/* +org.ametys.explorer.applications.resources.toolbar.Folder.AjoutFichierHtml = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + org.ametys.explorer.applications.resources.Folder.AjoutEditeurHtml (parentID, + "Un Noeaud", + //"", + function (parentID, id, name) { + org.ametys.explorer.applications.resources.toolbar.Folder._AjoutCb (parentID, id, name, application) + } + ); +} + +org.ametys.explorer.applications.resources.toolbar.Folder._AjoutCb = function (parentID, id, name, application) +{ + application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]); +} + +*/ +/*------------------------------------------------------------------------*/ + + +org.ametys.explorer.applications.resources.toolbar.File.add = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + org.ametys.explorer.applications.resources.File.add ( + parentID, + function (id, parentID, reload) + { + org.ametys.explorer.applications.resources.toolbar.File._addCb (id, parentID, reload, application) + } + ); +} +org.ametys.explorer.applications.resources.toolbar.File._addCb = function (id, parentID, reload, application) +{ + application.execCommand ('refresh', {'id': parentID, 'reload': reload}); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.update = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + var id = application.getSelectedFiles()[0]; + + org.ametys.explorer.applications.resources.File.update ( + id, + parentID, + function (id, parentID) + { + org.ametys.explorer.applications.resources.toolbar.File._updateCb (id, parentID, application) + } + ); +} +org.ametys.explorer.applications.resources.toolbar.File._updateCb = function (id, parentID, application) +{ + application.execCommand ('refresh', {'id': parentID}); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.rename = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + var id = application.getSelectedFiles()[0]; + application.execCommand ('renameFile', {'id': id, 'parentID': parentID}); +} +org.ametys.explorer.applications.resources.toolbar.File._doRename = function (btn, text, id, application) +{ + if (btn == 'ok') + { + org.ametys.explorer.applications.resources.File.rename (id, text, + function (id, name) { + org.ametys.explorer.applications.resources.toolbar.File._renameCb (id, name, application); + } + ) + } +} +org.ametys.explorer.applications.resources.toolbar.File._renameCb = function(id, name, application) +{ + application.queryCommandState ('resourceRenamed', {'id': id}); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.viewHistory = function (application) +{ + var id = application.getSelectedFiles()[0]; + var node = application._explorer.getSelectedNode(); + var parentID = node != null ? node.id : null; + + org.ametys.explorer.applications.resources.History (id, parentID, null, + function (id, parentID) { + org.ametys.explorer.applications.resources.toolbar.File._restoreVersionCb (id, parentID, application); + } + ) +} +org.ametys.explorer.applications.resources.toolbar.File._restoreVersionCb = function (id, parentID, application) +{ + application.execCommand ('refresh', {'id': parentID}); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.editDublinCore = function (application) +{ + var id = application.getSelectedFiles()[0]; + var node = application._explorer.getSelectedNode(); + var parentID = node != null ? node.id : null; + + org.ametys.explorer.applications.resources.DublinCore (id, parentID, null, + function (id, parentID) { + org.ametys.explorer.applications.resources.toolbar.File._editDublinCoreCb (id, parentID, application); + } + ) +} +org.ametys.explorer.applications.resources.toolbar.File._editDublinCoreCb = function (id, parentID, application) +{ +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.remove = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + var ids = application.getSelectedFiles(); + + org.ametys.explorer.applications.resources.File.remove (parentID, ids, + function (parentID, ids) { + org.ametys.explorer.applications.resources.toolbar.File._removeCb (parentID, ids, application) + } + ); +} +org.ametys.explorer.applications.resources.toolbar.File._removeCb = function (parentID, ids, application) +{ + application.execCommand ('refresh', {'id': parentID}); +} + +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.download = function (application) +{ + var files = application.getSelectedFiles(); + if (files.length > 1) + { + // ZIP export + var node = application._explorer.getSelectedNode(); + org.ametys.explorer.applications.resources.File.exportZIP (node.id, files); + } + else + { + org.ametys.explorer.applications.resources.File.download (files[0]); + } + + +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.exportRDF = function (application) +{ + var id = application.getSelectedFiles()[0]; + + org.ametys.explorer.applications.resources.File.exportRDF (id); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.copy = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + var ids = application.getSelectedFiles(); + + org.ametys.explorer.applications.resources.File.copy (parentID, ids); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.cut = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + var ids = application.getSelectedFiles(); + + org.ametys.explorer.applications.resources.File.cut (parentID, ids); +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.paste = function (application) +{ + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + var parentID = node.id; + + org.ametys.explorer.applications.resources.File.paste (parentID, + function (parentID, files) { + org.ametys.explorer.applications.resources.toolbar.File._pasteCb (parentID, files, application); + } + ); +} +org.ametys.explorer.applications.resources.toolbar.File._pasteCb = function (parentID, files, application) +{ + application.queryCommandState ('resourceMoved', {'id': files[0], 'parentID': parentID}); +} + +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.View.icons = function (btn, state, application) +{ + if (state) + { + application.execCommand ('changeView', {'mode': 'icons'}); + } +} +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.View.details = function (btn, state, application) +{ + if (state) + { + application.execCommand ('changeView', {'mode': 'details'}); + } +} + + +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.slideshow = function (btn, state, application) +{ + org.ametys.explorer.applications.resources.File.slideshow (btn._ids); +} + +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.AssignRights = function (btn, state, application) +{ + application._explorer.showHideRightsPanel (state); +} \ No newline at end of file Index: main/plugin-explorer/resources_nodetypes.xml =================================================================== --- main/plugin-explorer/resources_nodetypes.xml (revision 10091) +++ main/plugin-explorer/resources_nodetypes.xml (working copy) @@ -40,5 +40,13 @@ + + + + nt:folder + ametys:object + + +