diff --git a/config/alfresco/templates/client/node_summary_panel.ftl b/config/alfresco/templates/client/node_summary_panel.ftl index 1a30ab6470..84d49d97e5 100644 --- a/config/alfresco/templates/client/node_summary_panel.ftl +++ b/config/alfresco/templates/client/node_summary_panel.ftl @@ -7,7 +7,7 @@ - <#if node.isDocument> + <#if node.isDocument || node.isLinkToDocument> <#assign navurl="/navigate/showDocDetails/"> <#else> <#assign navurl="/navigate/showSpaceDetails/"> diff --git a/source/java/org/alfresco/web/app/servlet/HTTPRequestAuthenticationFilter.java b/source/java/org/alfresco/web/app/servlet/HTTPRequestAuthenticationFilter.java index 37dff00e4e..b5efa0c092 100644 --- a/source/java/org/alfresco/web/app/servlet/HTTPRequestAuthenticationFilter.java +++ b/source/java/org/alfresco/web/app/servlet/HTTPRequestAuthenticationFilter.java @@ -92,42 +92,6 @@ public class HTTPRequestAuthenticationFilter extends AbstractAuthenticationFilte private Pattern authPattern = null; - /** - * Define the HTTP header that contains the user name - * - * @param httpServletRequestAuthHeaderName - */ - public HTTPRequestAuthenticationFilter(String httpServletRequestAuthHeaderName) - { - this(httpServletRequestAuthHeaderName, null); - } - - /** - * Define the header that contains the user name and how to extract the user name. - * - * @param httpServletRequestAuthHeaderName - * @param authPatternString - */ - public HTTPRequestAuthenticationFilter(String httpServletRequestAuthHeaderName, String authPatternString) - { - super(); - assert (httpServletRequestAuthHeaderName != null); - this.httpServletRequestAuthHeaderName = httpServletRequestAuthHeaderName; - this.authPatternString = authPatternString; - if (this.authPatternString != null) - { - try - { - authPattern = Pattern.compile(this.authPatternString); - } - catch (PatternSyntaxException e) - { - logger.warn("Invalid pattern: " + this.authPatternString, e); - authPattern = null; - } - } - } - public void destroy() { // Nothing to do @@ -341,27 +305,51 @@ public class HTTPRequestAuthenticationFilter extends AbstractAuthenticationFilte I18NUtil.setLocale(Application.getLanguage(httpSess)); } + public void init(FilterConfig config) throws ServletException { + // Save the context + this.context = config.getServletContext(); + + // Setup the authentication context + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); + ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - transactionService = serviceRegistry.getTransactionService(); nodeService = serviceRegistry.getNodeService(); - + authService = serviceRegistry.getAuthenticationService(); + transactionService = serviceRegistry.getTransactionService(); + personService = (PersonService) ctx.getBean("PersonService"); // transactional and permission-checked authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); - authService = (AuthenticationService) ctx.getBean("authenticationService"); - personService = (PersonService) ctx.getBean("personService"); - - // Get a list of the available locales - + + ConfigService configServiceService = (ConfigService) ctx.getBean("webClientConfigService"); LanguagesConfigElement configElement = (LanguagesConfigElement) configServiceService.getConfig("Languages") .getConfigElement(LanguagesConfigElement.CONFIG_ELEMENT_ID); m_languages = configElement.getLanguages(); - authPattern = Pattern.compile(authPatternString); + + httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName"); + if(httpServletRequestAuthHeaderName == null) + { + httpServletRequestAuthHeaderName = "x-user"; + } + this.authPatternString = config.getInitParameter("authPatternString"); + if (this.authPatternString != null) + { + try + { + authPattern = Pattern.compile(this.authPatternString); + } + catch (PatternSyntaxException e) + { + logger.warn("Invalid pattern: " + this.authPatternString, e); + authPattern = null; + } + } + } /** diff --git a/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java b/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java index 8137f4ca40..b78676b525 100644 --- a/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java @@ -176,6 +176,9 @@ public class LinkValidationDialog extends BaseDialogBean this.runningReport = true; executeReport(); + // reset the isFinished flag so we can run the report again + this.isFinished = false; + return null; } diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 6cae008eb1..48a058e2bf 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -51,6 +51,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.avm.locking.AVMLockingService; import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMSyncService; @@ -414,6 +415,9 @@ public class SubmitDialog extends BaseDialogBean String destPath = stagingPath + wrapper.getPath(); AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); diffs.add(diff); + + // process the expiration date (if any) + processExpirationDate(srcPath); // recursively remove locks from this item recursivelyRemoveLocks(storeId, -1, this.avmService.lookup(-1, srcPath, true), srcPath); @@ -426,9 +430,6 @@ public class SubmitDialog extends BaseDialogBean { this.virtUpdatePath = destPath; } - - // process the expiration date (if any) - processExpirationDate(srcPath); } // write changes to layer so files are marked as modified @@ -1033,8 +1034,12 @@ public class SubmitDialog extends BaseDialogBean submittedPaths.add(renditionPath); } } - this.workflows.add(new FormWorkflowWrapper(fid.getForm().getDefaultWorkflow().getName(), - fid.getForm().getDefaultWorkflowParameters())); + WorkflowDefinition defaultWfDef = fid.getForm().getDefaultWorkflow(); + if (defaultWfDef != null) + { + this.workflows.add(new FormWorkflowWrapper(defaultWfDef.getName(), + fid.getForm().getDefaultWorkflowParameters())); + } } } } @@ -1045,6 +1050,9 @@ public class SubmitDialog extends BaseDialogBean { // rollback the transaction on error try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + + // rethrow the exception to highlight the problem + throw (RuntimeException)e; } } diff --git a/source/java/org/alfresco/web/forms/FormImpl.java b/source/java/org/alfresco/web/forms/FormImpl.java index 85768aac36..f91d74da9d 100644 --- a/source/java/org/alfresco/web/forms/FormImpl.java +++ b/source/java/org/alfresco/web/forms/FormImpl.java @@ -37,6 +37,7 @@ import javax.faces.context.FacesContext; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -201,8 +202,9 @@ public class FormImpl te); } result = AVMUtil.buildPath(parentAVMPath, - result, - AVMUtil.PathRelation.SANDBOX_RELATIVE); + result, + AVMUtil.PathRelation.SANDBOX_RELATIVE); + result = AVMNodeConverter.NormalizePath(result); LOGGER.debug("processed pattern " + outputPathPattern + " as " + result); return result; } diff --git a/source/java/org/alfresco/web/forms/FormsTest.java b/source/java/org/alfresco/web/forms/FormsTest.java new file mode 100644 index 0000000000..c1e429432f --- /dev/null +++ b/source/java/org/alfresco/web/forms/FormsTest.java @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing + */ +package org.alfresco.web.forms; + +import java.io.*; +import java.util.*; +import org.alfresco.service.namespace.QName; +import org.alfresco.model.WCMAppModel; +import junit.framework.AssertionFailedError; +import org.alfresco.service.cmr.repository.*; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.util.BaseSpringTest; +import org.alfresco.web.forms.XMLUtil; +import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.jxpath.Pointer; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chiba.xml.ns.NamespaceConstants; +import org.chiba.xml.events.XFormsEventNames; +import org.chiba.xml.events.XMLEvent; +import org.chiba.xml.xforms.ChibaBean; +import org.chiba.xml.xforms.exception.XFormsException; +import org.chiba.xml.xforms.XFormsElement; +import org.chiba.xml.events.DOMEventNames; +import org.w3c.dom.*; +import org.w3c.dom.events.*; +import org.xml.sax.*; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; +import org.alfresco.service.cmr.security.AuthenticationService; +import org.alfresco.service.cmr.model.*; +import org.alfresco.repo.security.authentication.MutableAuthenticationDao; +import org.alfresco.util.TestWithUserUtils; +import org.apache.shale.test.mock.*; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.StaticWebApplicationContext; + +/** + * JUnit tests to exercise parts of the forms codebase + * + * @author ariel backenroth + */ +public class FormsTest + extends BaseSpringTest +{ + + ///////////////////////////////////////////////////////////////////////////// + + private static class MockForm + extends FormImpl + { + + MockForm(final NodeRef folderNodeRef, + final FormsService formsService) + { + super(folderNodeRef, formsService); + } + + + public void setOutputPathPattern(final String opp) + { + final NodeService nodeService = this.getServiceRegistry().getNodeService(); + nodeService.setProperty(this.getNodeRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN, opp); + } + } + + ///////////////////////////////////////////////////////////////////////////// + + private final static Log LOGGER = LogFactory.getLog(FormsTest.class); + private final static String WEB_CLIENT_APPLICATION_CONTEXT = + "classpath:alfresco/web-client-application-context.xml"; + + private NodeService nodeService; + private FormsService formsService; + private MockForm mockForm; + + protected void onSetUpInTransaction() + throws Exception + { + System.err.println("onSetUpInTransaction"); + super.onSetUpInTransaction(); + this.nodeService = (NodeService)super.applicationContext.getBean("dbNodeService"); + assertNotNull(this.nodeService); + final FileFolderService fileFolderService = (FileFolderService) + super.applicationContext.getBean("fileFolderService"); + assertNotNull(fileFolderService); + this.formsService = (FormsService)super.applicationContext.getBean("FormsService"); + assertNotNull(this.formsService); + final AuthenticationService authenticationService = (AuthenticationService) + applicationContext.getBean("authenticationService"); + authenticationService.clearCurrentSecurityContext(); + final MutableAuthenticationDao authenticationDAO = (MutableAuthenticationDao) + applicationContext.getBean("authenticationDao"); + + // Create a workspace that contains the 'live' nodes + final StoreRef testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, + "Test_" + System.currentTimeMillis()); + + // Get a reference to the root node + final NodeRef rootNodeRef = this.nodeService.getRootNode(testStoreRef); + + // Create an authenticate the user + if(!authenticationDAO.userExists("admin")) + { + authenticationService.createAuthentication("admin", "admin".toCharArray()); + } + + TestWithUserUtils.authenticateUser("admin", + "admin", + rootNodeRef, + authenticationService); + + // set up a faces context + final MockExternalContext ec = new MockExternalContext(new MockServletContext(), + new MockHttpServletRequest(), + new MockHttpServletResponse()); + final StaticWebApplicationContext ac = new StaticWebApplicationContext(); + ac.setParent(this.applicationContext); + this.applicationContext = ac; + ec.getApplicationMap().put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, + this.applicationContext); + new MockFacesContext(ec); + + + final FileInfo folderInfo = + fileFolderService.create(rootNodeRef, + "test_form", + WCMAppModel.TYPE_FORMFOLDER); + final HashMap props = new HashMap(); + this.nodeService.addAspect(folderInfo.getNodeRef(), + WCMAppModel.ASPECT_FORM, + props); + this.mockForm = new MockForm(folderInfo.getNodeRef(), this.formsService); + } + + @Override + protected String[] getConfigLocations() + { + return (String[])ArrayUtils.add(super.getConfigLocations(), + WEB_CLIENT_APPLICATION_CONTEXT); + } + + @Override + protected ConfigurableApplicationContext loadContext(Object key) + throws Exception + { + return new ClassPathXmlApplicationContext((String[])key); + } + + public void testOutputPathPatternForFormInstanceData() + throws Exception + { + class OutputPathPatternTest + { + public final String expected; + public final String pattern; + public final Document xml; + public final String name; + public final String parentAVMPath; + public final String webapp; + + public OutputPathPatternTest(final String expected, + final String pattern, + final Document xml, + final String name, + final String parentAVMPath, + final String webapp) + { + this.expected = expected; + this.pattern = pattern; + this.xml = xml; + this.name = name; + this.parentAVMPath = parentAVMPath; + this.webapp = webapp; + } + } + + final OutputPathPatternTest[] opps = new OutputPathPatternTest[] { + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml", + "${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/foo.xml", + "/${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml", + "/${webapp}/${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml", + "/${webapp}/${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/another_webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir1/dir2/foo.xml", + "/${webapp}/${cwd}/${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/another_webapp/dir1/dir2", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/" + Calendar.getInstance().get(Calendar.YEAR) + "_foo.xml", + "${date?string('yyyy')}_${name}.xml", + XMLUtil.parse(""), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml", + "${xml.root_tag.name}.xml", + XMLUtil.parse("foo"), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/07.xml", + "${xml.root_tag.date?date('yyyy-MM-dd')?string('MM')}.xml", + XMLUtil.parse("1776-07-04"), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp"), + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml", + "${xml['foons:root_tag/foons:name']}.xml", + XMLUtil.parse("foo"), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp")/*, + new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml", + "${xml.root_tag.name}", + XMLUtil.parse("foo"), + "foo", + "avmstore:/www/avm_webapps/webapp/dir", + "webapp")*/ + }; + for (final OutputPathPatternTest oppt : opps) + { + this.mockForm.setOutputPathPattern(oppt.pattern); + assertEquals(oppt.pattern + " failed", + oppt.expected, + this.mockForm.getOutputPathForFormInstanceData(oppt.xml, + oppt.name, + oppt.parentAVMPath, + oppt.webapp)); + } + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java index ccbe788d53..634d6fe968 100644 --- a/source/java/org/alfresco/web/ui/common/Utils.java +++ b/source/java/org/alfresco/web/ui/common/Utils.java @@ -57,6 +57,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.filesys.CIFSServer; import org.alfresco.filesys.server.filesys.DiskSharedDevice; import org.alfresco.filesys.smb.server.repo.ContentContext; +import org.alfresco.model.ApplicationModel; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.webdav.WebDAVServlet; @@ -821,7 +822,8 @@ public final class Utils String outcome = ExternalAccessServlet.OUTCOME_DOCDETAILS; // if the node is a type of folder then make the outcome to show space details - if (dd.isSubClass(node.getType(), ContentModel.TYPE_FOLDER)) + if ((dd.isSubClass(node.getType(), ContentModel.TYPE_FOLDER)) || + (dd.isSubClass(node.getType(), ApplicationModel.TYPE_FOLDERLINK))) { outcome = ExternalAccessServlet.OUTCOME_SPACEDETAILS; } diff --git a/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp b/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp index 71d2dfd39c..2785fe7c2b 100644 --- a/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp +++ b/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp @@ -40,10 +40,7 @@ src="${pageContext.request.contextPath}/scripts/tiny_mce/tiny_mce.js">  - + src="${pageContext.request.contextPath}/scripts/ajax/common.js">  + + + + +
diff --git a/source/web/jsp/wcm/tiny_mce_image_dialog.jsp b/source/web/jsp/wcm/tiny_mce_image_dialog.jsp deleted file mode 100644 index 853d4490a7..0000000000 --- a/source/web/jsp/wcm/tiny_mce_image_dialog.jsp +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - {$lang_insert_image_title} -   - - - - - - - - - - - - - - -
- - -
-
-
${node.name?html}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
- x -
- - - -
-
- -
- -
- -
-
- - - - diff --git a/source/web/jsp/wcm/tiny_mce_link_dialog.jsp b/source/web/jsp/wcm/tiny_mce_link_dialog.jsp deleted file mode 100644 index 9d7ee47a85..0000000000 --- a/source/web/jsp/wcm/tiny_mce_link_dialog.jsp +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - - - {$lang_insert_link_title} -   - - - - - - - - - - - - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - -
- -
-
-
- -
-
-
-
-
- -
- -
- -
-
-
- - -
diff --git a/source/web/scripts/ajax/file_picker_widget.js b/source/web/scripts/ajax/file_picker_widget.js index fbc8ac1009..62f19aa2d9 100644 --- a/source/web/scripts/ajax/file_picker_widget.js +++ b/source/web/scripts/ajax/file_picker_widget.js @@ -47,6 +47,7 @@ alfresco.FilePickerWidget = function(uploadId, value, readonly, change_callback, + cancel_callback, resize_callback, selectableTypes, filterMimetypes) @@ -56,7 +57,8 @@ alfresco.FilePickerWidget = function(uploadId, this.value = value == null || value.length == 0 ? null : value; this.readonly = readonly || false; this.change_callback = change_callback; - this.resize_callback = resize_callback; + this.cancel_callback = cancel_callback || function() {}; + this.resize_callback = resize_callback || function() {}; this.selectableTypes = selectableTypes; this.filterMimetypes = filterMimetypes; } @@ -72,7 +74,6 @@ alfresco.FilePickerWidget._handleUpload = function(id, fileInput, webappRelative path: fileInput.value, webappRelativePath: webappRelativePath }; - handle_upload_helper(fileInput, id, alfresco.FilePickerWidget._upload_completeHandler, @@ -123,6 +124,13 @@ setReadonly: function(r) } }, +destroy: function() +{ + dojo.dom.removeChildren(this.node); + this.node.parentNode.removeChild(this.node); + this.node = null; +}, + render: function() { this._showSelectedValue(); @@ -181,6 +189,10 @@ _hideStatus: function() _showSelectedValue: function() { + if (this.node == null) + { + return; + } var d = this.node.ownerDocument; dojo.dom.removeChildren(this.node); this.statusDiv = null; @@ -306,21 +318,21 @@ _showPicker: function(data) event.currentTarget.style.borderStyle = "solid"; } }); - dojo.event.connect(this.headerMenuTriggerLink, - "onclick", - function(event) - { - var t = event.currentTarget; - var w = t.filePickerWidget; - if (w.parentPathMenu) - { - w._closeParentPathMenu(); - } - else - { - w._openParentPathMenu(t, t.getAttribute("webappRelativePath")); - } - }); + // can't use dojo's event handling since it screws up when opened in another window + var filePickerWidget = this; + var headerMenuTriggerLink = this.headerMenuTriggerLink; + this.headerMenuTriggerLink.onclick = function(event) + { + if (filePickerWidget.parentPathMenu) + { + filePickerWidget._closeParentPathMenu(); + } + else + { + filePickerWidget._openParentPathMenu(headerMenuTriggerLink, + headerMenuTriggerLink.getAttribute("webappRelativePath")); + } + }; this.headerMenuTriggerLink.appendChild(d.createTextNode(currentPathName)); @@ -422,6 +434,7 @@ _showPicker: function(data) dojo.event.connect(cancelButton, "onclick", function(event) { var w = event.target.filePickerWidget; + w.cancel_callback(this); w._showSelectedValue(); }); this.contentDiv.style.height = (this.node.offsetHeight - @@ -457,33 +470,19 @@ _createRow: function(fileName, webappRelativePath, isDirectory, isSelectable, f var d = this.contentDiv.ownerDocument; var result = d.createElement("div"); result.setAttribute("id", fileName + "-row"); - + result.setAttribute("webappRelativePath", webappRelativePath); + result.filePickerWidget = this; dojo.html.setClass(result, "xformsFilePickerRow " + rowClass); - dojo.event.browser.addListener(result, - "mouseover", - function(event) - { - var prevHover = event.currentTarget.parentNode.hoverNode; - if (prevHover) - { - dojo.html.removeClass(prevHover, "xformsRowHover"); - } - event.currentTarget.parentNode.hoverNode = event.currentTarget; - dojo.html.addClass(event.currentTarget, "xformsRowHover"); - }, - true); - dojo.event.browser.addListener(result, - "mouseout", - function(event) - { - if (event.relatedTarget && - event.relatedTarget.parentNode == event.currentTarget) - { - return true; - } - dojo.html.removeClass(event.currentTarget, "xformsRowHover"); - }, - true); + result.onmouseover = function() + { + var prevHover = result.parentNode.hoverNode; + if (prevHover) + { + dojo.html.removeClass(prevHover, "xformsRowHover"); + } + result.parentNode.hoverNode = result; + dojo.html.addClass(result, "xformsRowHover"); + }; var e = d.createElement("img"); e.align = "absmiddle"; e.style.margin = "0px 4px 0px 4px"; @@ -493,16 +492,15 @@ _createRow: function(fileName, webappRelativePath, isDirectory, isSelectable, f if (isDirectory) { e = d.createElement("a"); - e.filePickerWidget = this; e.style.textDecoration = "none"; e.setAttribute("href", "javascript:void(0)"); - e.setAttribute("webappRelativePath", webappRelativePath); - dojo.event.connect(e, "onclick", function(event) - { - var w = event.target.filePickerWidget; - w._navigateToNode(event.target.getAttribute("webappRelativePath")); - return true; - }); + + e.onclick = function() + { + var w = result.filePickerWidget; + w._navigateToNode(result.getAttribute("webappRelativePath")); + return true; + }; e.appendChild(d.createTextNode(fileName)); result.appendChild(e); } @@ -513,7 +511,6 @@ _createRow: function(fileName, webappRelativePath, isDirectory, isSelectable, f if (isSelectable) { e = d.createElement("input"); - e.filePickerWidget = this; e.type = "button"; e.name = webappRelativePath; e.value = "Select"; @@ -522,12 +519,12 @@ _createRow: function(fileName, webappRelativePath, isDirectory, isSelectable, f e.style.position = "absolute"; e.style.right = "10px"; e.style.top = (.5 * result.offsetHeight) - (.5 * e.offsetHeight) + "px"; - dojo.event.connect(e, "onclick", function(event) - { - var w = event.target.filePickerWidget; - w.setValue(event.target.name); - w._showSelectedValue(); - }); + e.onclick = function() + { + var w = result.filePickerWidget; + w.setValue(result.getAttribute("webappRelativePath")); + w._showSelectedValue(); + }; } return result; }, @@ -578,33 +575,33 @@ _showAddContent: function(currentPath) fileInputDiv.style.right = "10px"; fileInputDiv.style.top = (.5 * this.addContentDiv.offsetHeight) - (.5 * fileInputDiv.offsetHeight) + "px"; - dojo.event.connect(fileInput, - "onchange", - function(event) - { - var w = event.target.widget; - if (w.addContentDiv) - { - var d = w.addContentDiv.ownerDocument; - dojo.dom.removeChildren(w.addContentDiv); - - var fileName = event.target.value.replace(/.*[\/\\]([^\/\\]+)/, "$1"); - w.addContentDiv.appendChild(d.createTextNode(alfresco.resources["upload"] + ": " + fileName)); - var img = d.createElement("img"); - img.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + - "/images/icons/process_animation.gif"); - img.style.position = "absolute"; - img.style.right = "10px"; - img.style.height = (.5 * w.addContentDiv.offsetHeight) + "px"; - img.style.top = (.25 * w.addContentDiv.offsetHeight) + "px"; - w.addContentDiv.appendChild(img); - } - - alfresco.FilePickerWidget._handleUpload(w.uploadId, - event.target, - event.target.getAttribute("webappRelativePath"), - w); - }); + fileInput.onchange = function(event) + { + event = event || fileInput.ownerDocument.parentWindow.event; + var target = event.target || event.srcElement; + var w = target.widget; + if (w.addContentDiv) + { + var d = w.addContentDiv.ownerDocument; + dojo.dom.removeChildren(w.addContentDiv); + + var fileName = target.value.replace(/.*[\/\\]([^\/\\]+)/, "$1"); + w.addContentDiv.appendChild(d.createTextNode(alfresco.resources["upload"] + ": " + fileName)); + var img = d.createElement("img"); + img.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + + "/images/icons/process_animation.gif"); + img.style.position = "absolute"; + img.style.right = "10px"; + img.style.height = (.5 * w.addContentDiv.offsetHeight) + "px"; + img.style.top = (.25 * w.addContentDiv.offsetHeight) + "px"; + w.addContentDiv.appendChild(img); + } + + alfresco.FilePickerWidget._handleUpload(w.uploadId, + target, + target.getAttribute("webappRelativePath"), + w); + }; }, _upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, error) @@ -626,6 +623,7 @@ _upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, e var row = this._createRow(fileName, webappRelativePath == "/" ? "/" + fileName : webappRelativePath + "/" + fileName, false, + true /* this is potentially inaccurate - need to add some checks in the backing bean to check selectable */, fileTypeImage, rowClass); this.contentDiv.replaceChild(row, this.addContentDiv); @@ -655,11 +653,11 @@ _openParentPathMenu: function(target, path) // outside of the menu var parentPathMenu_documentClickHandler = function(event) { - var t = event.target; - var d = event.target.ownerDocument; + event = event || d.parentWindow.event; + var t = event.target || event.srcElement; // always remove - this handler only ever needs to handle a single click - d.removeEventListener("click", parentPathMenu_documentClickHandler, true); + dojo.event.browser.removeListener(d, "click", parentPathMenu_documentClickHandler, true, true); while (t && t != d) { if (t == d.currentParentPathMenu || @@ -672,7 +670,8 @@ _openParentPathMenu: function(target, path) } d.currentParentPathMenu.filePickerWidget._closeParentPathMenu(); }; - d.addEventListener("click", parentPathMenu_documentClickHandler, true); + + dojo.event.browser.addListener(d, "click", parentPathMenu_documentClickHandler, true, true); dojo.html.setClass(this.parentPathMenu, "xformsFilePickerParentPathMenu"); diff --git a/source/web/scripts/ajax/tiny_mce_wcm_extensions.js b/source/web/scripts/ajax/tiny_mce_wcm_extensions.js index ca6940c7b3..47f72da733 100644 --- a/source/web/scripts/ajax/tiny_mce_wcm_extensions.js +++ b/source/web/scripts/ajax/tiny_mce_wcm_extensions.js @@ -48,184 +48,42 @@ function alfresco_TinyMCE_urlconverter_callback(href, element, onsave) return result; } -function alfresco_TinyMCE_execcommand_callback(editor_id, elm, command, user_interface, value) +function alfresco_TinyMCE_file_browser_callback(field_name, url, type, win) { - if (command == "mceLink") - { - // BEGIN COPIED FROM ADVANCED THEME editor_template_src.js - var inst = tinyMCE.getInstanceById(editor_id); - var doc = inst.getDoc(); - var selectedText = (tinyMCE.isMSIE - ? doc.selection.createRange().text - : inst.getSel().toString()); - - if (!tinyMCE.linkElement && - tinyMCE.selectedElement.nodeName.toLowerCase() != "img" && - selectedText.length <= 0) - { - return true; - } - - var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; - - if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") - { - tinyMCE.linkElement = tinyMCE.selectedElement; - } - - // Is anchor not a link - if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") - { - tinyMCE.linkElement = null; - } - - if (tinyMCE.linkElement) - { - href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); - target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); - title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); - - // Try old onclick to if copy/pasted content - if (onclick == "") - { - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - } - onclick = tinyMCE.cleanupEventStr(onclick); - - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - - // Use mce_href if defined - mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); - if (mceRealHref != "") - { - href = mceRealHref; - if (tinyMCE.getParam('convert_urls')) - { - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - } - } - - action = "update"; - } - - var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_link_dialog.jsp", - width: 510 + tinyMCE.getLang('lang_insert_link_delta_width', 0), - height: 265 + tinyMCE.getLang('lang_insert_link_delta_height', 0) }; - var dialog_props = { href: href, - target: target, - title: title, - onclick: onclick, - action: action, - className: style_class, - inline: "yes" }; - tinyMCE.openWindow(window_props, dialog_props); - return true; - } - else if (command == "mceImage") - { - var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "", - title = "", onmouseover = "", onmouseout = "", action = "insert"; - var img = tinyMCE.imgElement; - var inst = tinyMCE.getInstanceById(editor_id); - - if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") - { - img = tinyMCE.selectedElement; - tinyMCE.imgElement = img; - } - - if (img) - { - // Is it a internal MCE visual aid image, then skip this one. - if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) - { - return true; - } - - src = tinyMCE.getAttrib(img, 'src'); - alt = tinyMCE.getAttrib(img, 'alt'); - - // Try polling out the title - if (alt == "") - { - alt = tinyMCE.getAttrib(img, 'title'); - } - - // Fix width/height attributes if the styles is specified - if (tinyMCE.isGecko) - { - var w = img.style.width; - if (w != null && w.length != 0) - { - img.setAttribute("width", w); - } - - var h = img.style.height; - if (h != null && h.length != 0) - { - img.setAttribute("height", h); - } - } - - border = tinyMCE.getAttrib(img, 'border'); - hspace = tinyMCE.getAttrib(img, 'hspace'); - vspace = tinyMCE.getAttrib(img, 'vspace'); - width = tinyMCE.getAttrib(img, 'width'); - height = tinyMCE.getAttrib(img, 'height'); - align = tinyMCE.getAttrib(img, 'align'); - onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); - onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); - title = tinyMCE.getAttrib(img, 'title'); - - // Is realy specified? - if (tinyMCE.isMSIE) - { - width = img.attributes['width'].specified ? width : ""; - height = img.attributes['height'].specified ? height : ""; - } - - //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); - //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); - - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - - // Use mce_src if defined - mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); - if (mceRealSrc != "") - { - src = mceRealSrc; - - if (tinyMCE.getParam('convert_urls')) - { - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - } - } - action = "update"; - } - - var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_image_dialog.jsp", - width: 510 + tinyMCE.getLang('lang_insert_image_delta_width', 0), - height: 265 + (tinyMCE.isMSIE ? 25 : 0) + tinyMCE.getLang('lang_insert_image_delta_height', 0) }; - var dialog_props = { src: src, - alt: alt, - border: border, - hspace: hspace, - vspace: vspace, - width: width, - height: height, - align: align, - title: title, - onmouseover: onmouseover, - onmouseout: onmouseout, - action: action, - inline: "yes" }; - tinyMCE.openWindow(window_props, dialog_props); - return true; - } - else - { - return false; - } + tinyMCE.importCSS(win.document, alfresco.constants.WEBAPP_CONTEXT + "/css/xforms.css"); + var div = win.document.createElement("div"); + div.style.width = "100%"; + div.style.height = "100%"; + div.style.backgroundColor = "white"; + div.style.position = "absolute"; + div.style.top = "0px"; + div.style.left = "0px"; + win.document.body.appendChild(div); + var pickerDiv = win.document.createElement("div"); + pickerDiv.style.height = "100%"; + pickerDiv.style.position = "relative"; + div.appendChild(pickerDiv); + var picker = new alfresco.FilePickerWidget("alfFilePicker", + pickerDiv, + url, + false, + function(picker) + { + win.document.getElementById(field_name).value = picker.getValue(); + picker.destroy(); + div.parentNode.removeChild(div); + }, + function() + { + picker.destroy(); + div.parentNode.removeChild(div); + }, + function(picker) + { + picker.node.style.height = div.offsetHeight + "px"; + picker.node.style.width = div.offsetWidth + "px"; + }, + type == "image" ? ["wcm:avmcontent"] : [], + type == "image" ? ["image/*"] : []); + picker._navigateToNode(url); } diff --git a/source/web/scripts/ajax/xforms.js b/source/web/scripts/ajax/xforms.js index c3ddd5458d..de35f6c5dc 100644 --- a/source/web/scripts/ajax/xforms.js +++ b/source/web/scripts/ajax/xforms.js @@ -534,6 +534,7 @@ dojo.declare("alfresco.xforms.FilePicker", this.getInitialValue(), false, this._filePicker_changeHandler, + null /* cancel is ignored */, this._filePicker_resizeHandler, this._selectableTypes, this._filterMimetypes); @@ -4725,13 +4726,13 @@ alfresco.constants.TINY_MCE_DEFAULT_SETTINGS = entity_encoding: "raw", add_unload_trigger: false, add_form_submit_trigger: false, - execcommand_callback: "alfresco_TinyMCE_execcommand_callback", theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", theme_advanced_buttons1: "", theme_advanced_buttons2: "", theme_advanced_buttons3: "", - urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback" + urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback", + file_browser_callback: "alfresco_TinyMCE_file_browser_callback" }; tinyMCE.init(dojo.lang.mixin(new Object(), alfresco.constants.TINY_MCE_DEFAULT_SETTINGS)); diff --git a/source/web/scripts/upload_helper.js b/source/web/scripts/upload_helper.js index 421b2ca048..a97ca12a7f 100644 --- a/source/web/scripts/upload_helper.js +++ b/source/web/scripts/upload_helper.js @@ -9,14 +9,15 @@ function handle_upload_helper(fileInputElement, { var id = fileInputElement.getAttribute("name"); var d = fileInputElement.ownerDocument; + var w = d.defaultView || d.parentWindow; var iframe = d.createElement("iframe"); iframe.style.display = "none"; iframe.name = id + "upload_frame"; iframe.id = iframe.name; - document.body.appendChild(iframe); + d.body.appendChild(iframe); // makes it possible to target the frame properly in ie. - window.frames[iframe.name].name = iframe.name; + w.frames[iframe.name].name = iframe.name; _uploads[uploadId] = { path: fileInputElement.value, callback: callback }; @@ -33,7 +34,7 @@ function handle_upload_helper(fileInputElement, form.action = contextPath + actionUrl; form.appendChild(fileInputElement); - var id = document.createElement("input"); + var id = d.createElement("input"); id.type = "hidden"; form.appendChild(id); id.name = "upload-id"; @@ -41,17 +42,22 @@ function handle_upload_helper(fileInputElement, for (var i in params) { - var p = document.createElement("input"); + var p = d.createElement("input"); p.type = "hidden"; form.appendChild(p); id.name = i; id.value = params[i]; } - var rp = document.createElement("input"); + var rp = d.createElement("input"); rp.type = "hidden"; form.appendChild(rp); rp.name = "return-page"; + if (w != window) + { + w.upload_complete_helper = window.upload_complete_helper; + } + rp.value = "javascript:window.parent.upload_complete_helper('" + uploadId + "',{error: '${_UPLOAD_ERROR}', fileTypeImage: '${_FILE_TYPE_IMAGE}'})";