roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r819249 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/pojos/ src/java/org/apache/roller/weblogger/ui/struts2/editor/ web/WEB-INF/classes/ web/WEB-INF/jsps/editor/
Date Sun, 27 Sep 2009 03:15:04 GMT
Author: snoopdave
Date: Sun Sep 27 03:15:03 2009
New Revision: 819249

URL: http://svn.apache.org/viewvc?rev=819249&view=rev
Log:
Add Media File now supports uploading up to five files and when you're done it allows you
to pick the images and enclosure to be included in a new blog post. This fixes https://issues.apache.org/jira/browse/ROL-1833

Removed:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml
Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
Sun Sep 27 03:15:03 2009
@@ -239,7 +239,6 @@
 
     /**
      * Returns permalink URL for this media file resource.
-     *
      */
     public String getPermalink() {
         return WebloggerFactory.getWeblogger().getUrlStrategy().getMediaFileURL(

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
Sun Sep 27 03:15:03 2009
@@ -17,6 +17,7 @@
  */
 package org.apache.roller.weblogger.ui.struts2.editor;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.business.MediaFileManager;
@@ -35,7 +36,15 @@
     // bean for managing form data
     private EntryBean bean = new EntryBean();
 
+    private String weblog = null;
+    private String enclosureUrl = null;
+    private String[] selectedImages = null;
+    
+
     public EntryAddWithMediaFile() {
+        this.actionName = "entryAdd";
+        this.desiredMenu = "editor";
+        this.pageTitle = "weblogEdit.title.newEntry";
     }
 
     /**
@@ -44,22 +53,34 @@
      */
     @SkipValidation
     public String execute() {
-        MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+        MediaFileManager manager =
+             WebloggerFactory.getWeblogger().getMediaFileManager();
         try {
-            MediaFile mediaFile = manager.getMediaFile(getMediaFileId());
-            String link;
-            if (mediaFile.isImageFile()) {
-                link = "<img src='<url>' alt='<name>' width='<width>'
height='<height>' />";
-                link = link.replace("<url>", getMediaFileURL(mediaFile))
-                           .replace("<name>", mediaFile.getName())
-                           .replace("<width>", "")
-                           .replace("<height>", "");
-            } else {
-                link = "<a href='<url>'><name></a>";
-                link = link.replace("<url>", getMediaFileURL(mediaFile))
-                           .replace("<name>", mediaFile.getName());
+
+            if (selectedImages != null) {
+                for (int i=0; i<selectedImages.length; i++) {
+                    MediaFile mediaFile = manager.getMediaFile(selectedImages[i]);
+                    String link = "";
+
+                    if (mediaFile.isImageFile()) {
+                        link = "<p>" + mediaFile.getName() + "</p>";
+                        link += "<a href='<url>'><img src='<url>?t=true'
alt='<name>' width='<width>' height='<height>'></img></a>";
+                        link = link.replace("<url>", getMediaFileURL(mediaFile))
+                                   .replace("<name>", mediaFile.getName())
+                                   .replace("<width>", ""+mediaFile.getThumbnailWidth())
+                                   .replace("<height>", ""+mediaFile.getThumbnailHeight());
+                    } else {
+                        link = "<a href='<url>'><name></a>";
+                        link = link.replace("<url>", getMediaFileURL(mediaFile))
+                                   .replace("<name>", mediaFile.getName());
+                    }
+                    bean.setText(link);
+                }
+            }
+
+            if (StringUtils.isNotEmpty(enclosureUrl)) {
+                bean.setEnclosureURL(enclosureUrl);
             }
-            bean.setText(link);
 
         } catch (Exception e) {
             log.error("Error while constructing media file link for new entry", e);
@@ -74,4 +95,47 @@
     public void setBean(EntryBean bean) {
         this.bean = bean;
     }
+
+    /**
+     * @return the selectedImages
+     */
+    public String[] getSelectedImages() {
+        return selectedImages;
+    }
+
+    /**
+     * @param selectedImages the selectedImages to set
+     */
+    public void setSelectedImages(String[] selectedImages) {
+        this.selectedImages = selectedImages;
+    }
+
+    /**
+     * @return the enclosureUrl
+     */
+    public String getEnclosureUrl() {
+        return enclosureUrl;
+    }
+
+    /**
+     * @param enclosureUrl the enclosureUrl to set
+     */
+    public void setEnclosureUrl(String enclosureUrl) {
+        this.enclosureUrl = enclosureUrl;
+    }
+
+    /**
+     * @return the weblog
+     */
+    public String getWeblog() {
+        return weblog;
+    }
+
+    /**
+     * @param weblog the weblog to set
+     */
+    public void setWeblog(String weblog) {
+        this.weblog = weblog;
+    }
+
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
Sun Sep 27 03:15:03 2009
@@ -20,6 +20,10 @@
 import java.io.File;
 import java.io.FileInputStream;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -30,7 +34,8 @@
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
-import org.apache.roller.weblogger.pojos.MediaFileType;
+import org.apache.roller.weblogger.util.RollerMessages;
+import org.apache.roller.weblogger.util.RollerMessages.RollerMessage;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
 
@@ -44,14 +49,19 @@
     private MediaFileBean bean = new MediaFileBean();
     private MediaFileDirectory directory;
 
-    // file uploaded by the user
-    private File uploadedFile = null;
+    // an array of files uploaded by the user, if applicable
+    private File[] uploadedFiles = null;
 
-    // content type for upload file
-    private String uploadedFileContentType = null;
+    // an array of content types for upload files
+    private String[] uploadedFilesContentType = null;
+
+    // an array of filenames for uploaded files
+    private String[] uploadedFilesFileName = null;
+
+    private List<MediaFile> newImages = new ArrayList<MediaFile>();
+
+    private List<MediaFile> newFiles = new ArrayList<MediaFile>();
     
-    // filename for uploaded file
-    private String uploadedFileFileName = null;
 
     public MediaFileAdd() {
         this.actionName = "mediaFileAdd";
@@ -93,31 +103,88 @@
      * @return String The result of the action.
      */
     public String save() {
+
         myValidate();
+
         if (!hasActionErrors()) {
+            
             MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
-            try {
-                MediaFile mediaFile = new MediaFile();
-                bean.copyTo(mediaFile);
-                
-                mediaFile.setDirectory(getDirectory());
-                mediaFile.setWeblog(getActionWeblog());
-                mediaFile.setLength(this.uploadedFile.length());
-                mediaFile.setInputStream(new FileInputStream(this.uploadedFile));
-                mediaFile.setContentType(this.uploadedFileContentType);
-                manager.createMediaFile(getActionWeblog(), mediaFile);
-                WebloggerFactory.getWeblogger().flush();
-                bean.setId(mediaFile.getId());
-                return SUCCESS;
 
-            } catch (FileIOException ex) {
-                addError("uploadFiles.error.upload", bean.getName());
-            } catch (Exception e) {
-                log.error("Error saving new entry", e);
-                // TODO: i18n
-                addError("Error reading uploaded file - " + bean.getName());
+            RollerMessages errors = new RollerMessages();
+            List<String> uploaded = new ArrayList();
+            File[] uploads = getUploadedFiles();
+
+            if (uploads != null && uploads.length > 0) {
+
+                // loop over uploaded files and try saving them
+                for (int i = 0; i < uploads.length; i++) {
+
+                    // skip null files
+                    if (uploads[i] == null || !uploads[i].exists()) {
+                        continue;
+                    }
+
+                    try {
+                        MediaFile mediaFile = new MediaFile();
+                        bean.copyTo(mediaFile);
+
+                        String fileName = getUploadedFilesFileName()[i];
+                        int terminated = fileName.indexOf("\000");
+                        if (terminated != -1) {
+                            // disallow sneaky null terminated strings
+                            fileName = fileName.substring(0, terminated).trim();
+                        }
+
+                        // make sure fileName is valid
+                        if (fileName.indexOf("/") != -1 ||
+                                fileName.indexOf("\\") != -1 ||
+                                fileName.indexOf("..") != -1) {
+                            addError("uploadFiles.error.badPath", fileName);
+                            continue;
+                        }
+
+                        mediaFile.setName(       fileName);
+                        mediaFile.setDirectory(  getDirectory());
+                        mediaFile.setWeblog(     getActionWeblog());
+                        mediaFile.setLength(     this.uploadedFiles[i].length());
+                        mediaFile.setInputStream(new FileInputStream(this.uploadedFiles[i]));
+                        mediaFile.setContentType(this.uploadedFilesContentType[i]);
+
+                        manager.createMediaFile(getActionWeblog(), mediaFile);
+                        WebloggerFactory.getWeblogger().flush();
+
+                        if (mediaFile.isImageFile()) {
+                            newImages.add(mediaFile);
+                        } else {
+                            newFiles.add(mediaFile);
+                        }
+
+                    } catch (FileIOException ex) {
+                        addError("uploadFiles.error.upload", bean.getName());
+                    } catch (Exception e) {
+                        log.error("Error saving new entry", e);
+                        // TODO: i18n
+                        addError("Error reading uploaded file - " + bean.getName());
+                    }
+                }
+
+                for (Iterator it = errors.getErrors(); it.hasNext();) {
+                    RollerMessage msg = (RollerMessage) it.next();
+                    addError(msg.getKey(), Arrays.asList(msg.getArgs()));
+                }
+
+                if (uploaded.size() > 0) {
+                    addMessage("uploadFiles.uploadedFiles");
+
+                    for (String upload : uploaded) {
+                        addMessage("uploadFiles.uploadedFile",
+                            WebloggerFactory.getWeblogger().getUrlStrategy()
+                                .getWeblogResourceURL(getActionWeblog(), upload, true));
+                    }
+                }
+                this.pageTitle = "mediaFileAddSuccess.title";
+                return SUCCESS;
             }
-
         }
         return INPUT;
     }
@@ -126,17 +193,15 @@
      * Validates media file to be added.
      */
     public void myValidate() {
-        if (getDirectory().hasMediaFile(getBean().getName())) {
-            addError("MediaFile.error.duplicateName", getBean().getName());
-        }
+
+        //
+        // TODO: don't allow upload if user is over quota
+        //
+
         // make sure uploads are enabled
         if (!WebloggerRuntimeConfig.getBooleanProperty("uploads.enabled")) {
             addError("error.upload.disabled");
         }
-
-        if (StringUtils.isEmpty(this.uploadedFileFileName)) {
-            addError("error.upload.file");
-        }
     }
 
     public MediaFileBean getBean() {
@@ -155,35 +220,55 @@
         this.directory = directory;
     }
 
-    public File getUploadedFile() {
-        return uploadedFile;
+    public File[] getUploadedFiles() {
+        return uploadedFiles;
     }
 
-    public void setUploadedFile(File uploadedFile) {
-        this.uploadedFile = uploadedFile;
+    public void setUploadedFiles(File[] uploadedFiles) {
+        this.uploadedFiles = uploadedFiles;
     }
 
-    public String getUploadedFileContentType() {
-        return uploadedFileContentType;
+    public String[] getUploadedFilesContentType() {
+        return uploadedFilesContentType;
     }
 
-    public void setUploadedFileContentType(String uploadedFileContentType) {
-        this.uploadedFileContentType = uploadedFileContentType;
+    public void setUploadedFilesContentType(String[] uploadedFilesContentType) {
+        this.uploadedFilesContentType = uploadedFilesContentType;
     }
 
-    public String getUploadedFileFileName() {
-        return uploadedFileFileName;
+    public String[] getUploadedFilesFileName() {
+        return uploadedFilesFileName;
     }
 
-    public void setUploadedFileFileName(String uploadedFileFileName) {
-        this.uploadedFileFileName = uploadedFileFileName;
+    public void setUploadedFilesFileName(String[] uploadedFilesFileName) {
+        this.uploadedFilesFileName = uploadedFilesFileName;
     }
 
-    public boolean isContentTypeImage() {
-        if (this.uploadedFileContentType == null) {
-            return false;
-        }
-        return (this.uploadedFileContentType.toLowerCase().startsWith(
-                MediaFileType.IMAGE.getContentTypePrefix().toLowerCase()));
+    /**
+     * @return the newImages
+     */
+    public List<MediaFile> getNewImages() {
+        return newImages;
+    }
+
+    /**
+     * @param newImages the newImages to set
+     */
+    public void setNewImages(List<MediaFile> newImages) {
+        this.newImages = newImages;
+    }
+
+    /**
+     * @return the newFiles
+     */
+    public List<MediaFile> getNewFiles() {
+        return newFiles;
+    }
+
+    /**
+     * @param newFiles the newFiles to set
+     */
+    public void setNewFiles(List<MediaFile> newFiles) {
+        this.newFiles = newFiles;
     }
 }

Modified: roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Sun Sep
27 03:15:03 2009
@@ -954,20 +954,61 @@
 
 # ----------------------------------------------------------- Media file management
 
+mediaFileChooser.popupTitle=Media File Chooser
+
+
+mediaFileImageChooser.title=Choose an image
+mediaFileImageChooser.subtitle=Choose an image
+mediaFileImageChooser.rootPageTip=Click to choose an image or click on a \
+directory to enter it.
+mediaFileImageChooser.dirPageTip=Click to choose an image or click on a \
+directory to enter it. Use breadcrumb links above to return to a previous \
+directory.
+
+
 # -- Media File Add
 
-mediaFileAdd.title=Add new media file
-mediaFileAdd.pageTip=Use the add file button below to select a file then \
-enter name and optionally a description, copyright message and tags. When \
-you're read to upload click the Save button.
+mediaFileAdd.title=Add new media file(s)
+mediaFileAdd.pageTip=Use this page to upload up to five new media files. \
+Form fields that you set below will be applied to all files uploaded.
+mediaFileAdd.multipleNames
 mediaFileAdd.fileLocation=Choose file to upload
-mediaFileAdd.name=Title
+mediaFileAdd.name=Name
 mediaFileAdd.description=Description
 mediaFileAdd.tags=Tags (space separated)
 mediaFileAdd.copyright=Copyright statement
 mediaFileAdd.directory=Place in directory
 mediaFileAdd.includeGallery=Include in Gallery?
 mediaFileAdd.upload=Upload
+mediaFileAdd.multipleNames=(Multiple names)
+
+
+#--- Media File Success
+
+mediaFileAddSuccess.title=Media File Upload Complete
+mediaFileSuccess.subtitle=Create a new weblog entry?
+mediaFileSuccess.pageTip=Your upload was successful. If you would like to \
+create a new weblog entry with your new uploads then use the form \
+below to select the file(s) to be included.
+mediaFileSuccess.uploaded=Uploaded Successfully
+mediaFileSuccess.createPost=Create a weblog post using your new upload
+mediaFileSuccess.addAnother=Add another media file
+mediaFileSuccess.createPost=Create Post
+mediaFileSuccess.createPostPrompt=Once you have selected the file(s) you want, \
+click the button to create your new weblog entry.
+mediaFileSuccess.noEnclosure=No enclosure
+mediaFileSuccess.selectEnclosure=You can select one file (or none) to be \
+included in the weblog entry as an RSS/Atom enclosure (i.e. as a podcast):
+mediaFileSuccess.selectImages=Select the the images that you would like to \
+include in your new weblog entry:
+
+mediaFileSuccess.name=Name:
+mediaFileSuccess.size=Size:
+mediaFileSuccess.type=Type:
+mediaFileSuccess.link=Link:
+mediaFileSuccess.pixels=pixels
+mediaFileSuccess.bytes=bytes
+
 
 # -- Media File Edit
 
@@ -989,7 +1030,7 @@
 mediaFileView.rootPageTip=\
 This page shows the media files that you have uploaded as well as files \
 copied in when you chose to customize a theme. You can use directories \
-to organize your files, and you don't have to worry about "breaking \
+to organize your files, and you do not have to worry about "breaking \
 URLs" when you move or rename files.
 mediaFileView.dirPageTip=\
 This is a media-file directory. You can return to the main directory \
@@ -1052,13 +1093,6 @@
 mediaFileSidebar.view=View Uploaded Files
 mediaFileSidebar.search=Search Uploaded Files
 
-#--- Media File Success
-
-mediaFileSuccess.add=Add Media Files
-mediaFileSuccess.uploaded=Uploaded Successfully
-mediaFileSuccess.createPost=Create a blog post using your new upload
-mediaFileSuccess.addAnother=Add another media file
-
 
 mediaFile.edit.title=Edit media file
 mediaFile.search.title=Search media files

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp Sun Sep 27 03:15:03
2009
@@ -16,24 +16,48 @@
   directory of this distribution.
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+<script type="text/javascript" src="<s:url value="/roller-ui/scripts/jquery-1.3.1.min.js"
/>"></script>
+
 
 <script type="text/javascript">
-<!--
-function getFileName(fullName) {
-   var backslashIndex = fullName.lastIndexOf('/');
-   var fwdslashIndex = fullName.lastIndexOf('\\');
-   var fileName;
-   if (backslashIndex >= 0) {
-       fileName = fullName.substring(backslashIndex + 1);
-   } else if (fwdslashIndex >= 0) {
-       fileName = fullName.substring(fwdslashIndex + 1);
-   }
-   else {
-       fileName = fullName;
-   }
-   return fileName;
-}
--->
+    $(document).ready(function() {
+        $("input[type='file']").change(function() {
+            var name = '';
+            var count = 0;
+            var fileControls = $("input[type='file']");
+            for (var i=0; i<fileControls.size(); i++) {
+                if (jQuery.trim(fileControls.get(i).value).length > 0) {
+                    count++;
+                    name = fileControls.get(i).value;
+                }
+            }
+            if (count == 1) {
+                $("#entry_bean_name").get(0).disabled = false;
+                $("#entry_bean_name").get(0).value = name;
+            } else if (count > 1) {
+                $("#entry_bean_name").css("font-style","italic");
+                $("#entry_bean_name").css("color","grey");
+                $("#entry_bean_name").get(0).value = "<s:text name="mediaFileAdd.multipleNames"
 />";
+                $("#entry_bean_name").get(0).disabled = true;
+            }
+        });
+    });
+
+    function getFileName(fullName) {
+       var backslashIndex = fullName.lastIndexOf('/');
+       var fwdslashIndex = fullName.lastIndexOf('\\');
+       var fileName;
+       if (backslashIndex >= 0) {
+           fileName = fullName.substring(backslashIndex + 1);
+       } else if (fwdslashIndex >= 0) {
+           fileName = fullName.substring(fwdslashIndex + 1);
+       }
+       else {
+           fileName = fullName;
+       }
+       return fileName;
+    }
+
 </script>
 
 <p class="subtitle">
@@ -43,7 +67,7 @@
     <s:text name="mediaFileAdd.pageTip"  />
 </p>
 
-<s:form id="entry" action="mediaFileAdd!save" onsubmit="editorCleanup()" method="POST"
enctype="multipart/form-data">
+<s:form id="entry" action="mediaFileAdd!save" method="POST" enctype="multipart/form-data">
     <s:hidden name="weblog" />
 
     <%-- ================================================================== --%>
@@ -53,18 +77,6 @@
 
         <tr>
             <td class="entryEditFormLabel">
-                <label for="title"><s:text name="mediaFileAdd.fileLocation" /></label>
-            </td>
-            <td>
-                 <s:file name="uploadedFile" size="30" onchange="this.form['bean.name'].value=getFileName(this.value)"
/>
-                 <br />
-                 <br />
-                 <br />
-            </td>
-        </tr>
-
-        <tr>
-            <td class="entryEditFormLabel">
                 <label for="status"><s:text name="mediaFileAdd.name" /></label>
             </td>
             <td>
@@ -117,6 +129,48 @@
             </td>
        </tr>
 
+       <tr>
+           <td>
+                <br />
+                <br />
+                <br />
+           </td>
+           <td>
+           </td>
+       </tr>
+
+        <tr>
+            <td class="entryEditFormLabel">
+                <label for="title"><s:text name="mediaFileAdd.fileLocation" /></label>
+            </td>
+            <td>
+                <div id="fileControl0div" class="miscControl">
+                    <s:file id="fileControl0" name="uploadedFiles" size="30" />
+                    <br />
+                </div>
+
+                <div id="fileControl1div" class="miscControl">
+                    <s:file id="fileControl1" name="uploadedFiles" size="30" />
+                    <br />
+                </div>
+
+                <div id="fileControl2div" class="miscControl">
+                    <s:file id="fileControl2" name="uploadedFiles" size="30" />
+                    <br />
+                </div>
+
+                <div id="fileControl3div" class="miscControl">
+                    <s:file id="fileControl3" name="uploadedFiles" size="30" />
+                    <br />
+                </div>
+
+                <div id="fileControl4div" class="miscControl">
+                    <s:file id="fileControl4" name="uploadedFiles" size="30" />
+                    <br />
+                </div>
+            </td>
+        </tr>
+
     </table>
 
     <br />

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp?rev=819249&r1=819248&r2=819249&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp Sun Sep 27
03:15:03 2009
@@ -16,49 +16,149 @@
   directory of this distribution.
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+<script type="text/javascript" src="<s:url value="/roller-ui/scripts/jquery-1.3.1.min.js"
/>"></script>
+
+<style type="text/css">
+    table.mediaFileTable {
+        margin-left: 2em;
+        width: 90%;
+    }
+    img.mediaFileImage {
+        margin-right: 1em;
+    }
+    span.label {
+        font-weight: bold;
+    }
+</style>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+
+        $("#submit").attr("disabled", true);
+
+        $("input[type='checkbox']").change(function() {
+            $("#submit").attr("disabled", true);
+            var boxes = $("input[type='checkbox']");
+            for (var i=0; i<boxes.length; i++) {
+                if (boxes.get(i).checked) {
+                    $("#submit").attr("disabled", false);
+                    break;
+                }
+            }
+            if ($("#enclosureUrl").get(0).getAttribute("value") != '') {
+            }
+        });
+    });
+
+    function setEnclosure(url) {
+        $("#enclosureUrl").get(0).value = url;
+        if (url != '') {
+            $("#submit").attr("disabled", false);
+        } else {
+            $("#submit").attr("disabled", true);
+        }
+    }
+</script>
+
 
 <p class="subtitle">
-    <s:text name="mediaFileSuccess.add" />
+    <s:text name="mediaFileSuccess.subtitle" />
+</p>
+<p class="pagetip">
+    <s:text name="mediaFileSuccess.pageTip" />
 </p>
 
-<s:form id="entry" action="addMedia!submit" onsubmit="editorCleanup()">
+<s:form id="entry" action="entryAddWithMediaFile">
     <s:hidden name="weblog" />
+    <s:hidden name="enclosureUrl" id="enclosureUrl" />
 
-    <div style="border:1px solid; width=80px;background-color: #cfc;margin-bottom:5px;">
-        <ul>
-            <li> <s:property value="bean.name" /> <s:text name="mediaFileSuccess.uploaded"
/></li>
-        </ul>
-    </div>
 
-    <s:url id="mediaFileURL" value="/%{actionWeblog.handle}/mediaresource/%{bean.id}">
-    </s:url>
+    <s:if test="newImages.size() > 0">
+        <p><s:text name="mediaFileSuccess.selectImages" /></p>
+
+        <%-- checkboxed list of images uploaded --%>
+        <table class="mediaFileTable">
+            <s:iterator value="newImages" id="newImage">
+            <tr>
+                <td>
+                    <%-- checkbox for file --%>
+                    <input type="checkbox"
+                           name="selectedImages"
+                           value="<s:property value="#newImage.id"/>"/>
+                </td>
+                <td>
+                    <%-- description of file --%>
+                    <img align="left" class="mediaFileImage"
+                         src='<s:property value="%{#newImage.permalink}" />?t=true'
alt="thumbnail" />
+
+                    <span class="label"><s:text name="mediaFileSuccess.name" /></span>
+                    <s:property value="%{#newImage.name}" /><br />
+
+                    <span class="label"><s:text name="mediaFileSuccess.type" /></span>
+                    <s:property value="%{#newImage.contentType}" /><br />
+
+                    <span class="label"><s:text name="mediaFileSuccess.link" /></span>
+                    <s:property value="%{#newImage.permalink}" /><br />
+
+                    <span class="label"><s:text name="mediaFileSuccess.size" /></span>
+                    <s:property value="%{#newImage.length}" /> <s:text name="mediaFileSuccess.bytes"
/>, 
+                    <s:property value="%{#newImage.width}" /> x
+                    <s:property value="%{#newImage.height}" /> <s:text name="mediaFileSuccess.pixels"
/>
+
+                </td>
+            </tr>
+            </s:iterator>
+        </table>
 
-    <s:if test="contentTypeImage">
-        <div style="margin-bottom:10px;">
-        <img border="0" src='<s:property value="%{mediaFileURL}" />' width="150px"
alt="image"/></div>
     </s:if>
 
+    <s:if test="newFiles.size() > 0">
+        <p><s:text name="mediaFileSuccess.selectEnclosure" /></p>
 
-    <a style="font-size:11px;color:#000000;text-decoration:underline;"
-       href="<s:property value='%{mediaFileURL}'/>"><s:property value="%{mediaFileURL}"
/>
-        <a>
+        <%-- checkboxed list of other files uploaded uploaded --%>
+        <table class="mediaFileTable">
+            <s:iterator value="newFiles" id="newFile">
+            <tr>
+                <td>
+                    <%-- radio button for file --%>
+                    <input type="radio" name="enclosure"
+                       onchange="setEnclosure('<s:property value="%{#newFile.permalink}"
/>')" />
+                </td>
+                <td>
+                    <%-- description of file --%>
+                    <s:property value="%{#newFile.name}" />
+                </td>
+            </tr>
+            </s:iterator>
+            <tr>
+                <td>
+                    <input type="radio" name="enclosure" onchange="setEnclosure('')" />
+                </td>
+                <td>
+                    <s:text name="mediaFileSuccess.noEnclosure" />
+                </td>
+            </tr>
+        </table>
 
+    </s:if>
 
-    <div style="margin-top:20px;text-decoration:underline">
 
-        <s:url id="createBlogPostURL" action="entryAddWithMediaFile">
-            <s:param name="weblog" value="actionWeblog.handle" />
-            <s:param name="mediaFileId" value="%{bean.id}" />
-        </s:url>
+    <div style="margin-top:20px"">
 
-        <s:a href="%{createBlogPostURL}"><s:text name="mediaFileSuccess.createPost"
/></s:a>
+        <p><s:text name="mediaFileSuccess.createPostPrompt" /></p>
+        <input type="submit" id="submit" value='<s:text name="mediaFileSuccess.createPost"
/>' />
+        <br/>
+        <br/>
         <br/>
 
+        <%-- Link: Upload more files --%>
         <s:url id="mediaFileAddURL" action="mediaFileAdd">
             <s:param name="weblog" value="%{actionWeblog.handle}" />
         </s:url>
+        <s:a href="%{mediaFileAddURL}">
+            <s:text name="mediaFileSuccess.addAnother" />
+        </s:a>
 
-        <s:a href="%{mediaFileAddURL}"><s:text name="mediaFileSuccess.addAnother"
/></s:a>
     </div>
 
 </s:form>



Mime
View raw message