<%-- image_frame.jsp ___________________________________________________ | | | Image and Upload File Manager | | | | Copyright (C) 2000-2008 Revize LLC | | All rights reserved. | | | |___________________________________________________| $Revision: 2.0 $ $Date: 22 May 2008 02:44:50 $ $Author: nickm $ //////////////////////////////////////////////////////////////////////////////// // Image Manager Change Log // //////////////////////////////////////////////////////////////////////////////// --------------------- 10-28-04 DO Changes --------------------- Deleted 11-14-03 dead code -Added support for developer supplied maxwidth and maxheight -Reordered width/height and hspace/vspace to match properties display -caller now correctly calculated using location.host (not location.domain) -Image size constaints are displayed in preview frame when file is uploaded -Image properties can be displayed by clicking on hidden link after the top heading in the right frame --------------------- 11-14-03 DO Changes --------------------- Created RZ.im object for global objects. Corrected numerous problems with absolute vs relative and multi-level locations. The filelocation global javascript variable depreciated because it usage needed review and correct throughout all the frames and pages. It is now in the RZ.im object. Eliminated newfilelocation url parameter, java and javascript variable. New function image_frame.jsp::findImageIdx() developed to find a match in the frameset JavaScript arrays. Must now use location and filename with extension to determine reference file record. Added new location hidden field to image_list.jsp form. Eliminated function image_upload.html::RZfileExists(); Now using new image_frame.jsp::findImageIdx() function. Eliminated function image_upload.html::getFolderLocation(); Was only used by depreciated function image_upload.html::RZfileExists(). RZ.im.currentFolder global contains the upload file location. Moved test for legacy location to image_list.jsp::browseFunction() from image_list_functions.js::loadfile() function. Remamed frameset JavaScript fileName[] array to imageFilename[] Rename other FileName to filename (one of my rules - single word in dictionary) Changed all alerts to call new message function in frameset to that displays the message with an option to enter debug mode if trace or debug enabled. Recoded image_list_functions.js::setup(), which highlights and retains the initial selection and list states for all scenarios. Eliminated image_list_functions.js::initialize() function since it was only called from image_list_functions.js::setup() - code moved into setup() Eliminated image_list_functions.js::blockNewFolder() function since is is only one line of code and only called from once. Deleted lots of dead code but some left for review by Mindfire. Depreciated checkForRTEImage() function and associated global variables: rootLocation, imagePathFileName, imageInfo and imageLoc. Logic moved to new initImageIdx() function. ------------------------------------------------------------------- 11-23-03 DO: testing remaining, known issues and future suggestions ------------------------------------------------------------------- -Opening a folder should automatically select it -Selecting a folder should automatically open it -When "select none" button is clicked, the highlighted file on list should be cleared -When file uploaded and use indicates it should replace existing file, display should indicate (new file) -Uploading files should reset/delete prior upload selection -Filenames with invalid label character's should get selected after upload -Allow selection of files not in ref table (see: 'Not in Reference File Table' message in image_upload.html) -RZ.im.isLegacyAbsoluteLocation not tested -Listing Frame should be split into two frames so Browse always appears and only listing scrolls (scrollTo can then be eliminiated image_list.jsp::setup() function) -When replacing RTE image, prompt to retain prior properties (except height & width) -The following should be options: image properties, browse, create folder, delete file ******************************** not yet done ********************************* validate use of imageLocation in frames (it uses fileLocation) Use findImageIdx to determine displayImageIdx; replaces the following functions: RZfileExists, checkIfExist, getCurrentIndex Remove blanks from label //////////////////////////////////////////////////////////////////////////////// // Image/File Manager Notes // //////////////////////////////////////////////////////////////////////////////// This is the main frame set for the image and file upload support screens. It was originally developed for uploading images, therefore the html page names and internal variables use "image" in the names. It is currently designed to run from ...www/revize/util and is called from the snippet_helper_editform.js::RZselectFile() function. The RZselectFile() function is called in the following manners: 1) via the "change image" button placed directly on the edit form 2) via the "change image" button contained on the link manager screen 3) via the "image" icon contained in the RTE For Revize 4.0, the following enhancements were added: 1) Image properties (height, width, vspace, hspace, border & align) stored in the reference file table (previously these properties were only available when called via the RTE) 2) An image resizing capibility was added based on specified height and width (the original implementation did not retain proportions) 3) Ability for Content Editor to select and create repository folders (the original implementation did not allow the developer to restrict create) The following additional support files are required: (this list of files has not been validated since the original release) QUESTION: Is this list up-to-date? If not, please update. /revize/util/image_error.jsp Clone of: \client\error.jsp (used in xml Requests) /revize/util/image_list.jsp Right frame which displays files in repository /revize/util/image_preview.jsp Center Frame which displays the image /revize/util/image_return.jsp Frame used for normal return from Xml requests /revize/util/image_upload.jsp Top frame containing upload information /revize/util/cacheControl.jsp Prevents image pages from being cached /revize/util/snippet_helper.js JavaScript Developer library /revize/images/edit/noimage.gif Placeholder image for edit form /revize/images/edit/cleardot.gif Placeholder image for preview screen How Image support works: ----------------------- 1. The "Change Image" button or RTE "Image" icon or calls the RZselectFile() function (contained in snipper_helper_editform.jsp). Legacy snippets may call RZselectImage() which in turn calls RZselectFile(). 2. RZselectFile() either opens this file in a new browser window OR gives focus to an image processing window left open from a prior request call and refreshes with current arguments 3. This page (image_frame.jsp) is called by with the following arguments: QUESTION: Is this list up-to-date? If not, please update. -webSpaceName: WebSpace Name -fileType: Type of file: image or file -fileLocation: Location (path / sub-directory in Revize repository) -extensions: Permitted extensions for new uploads -displayElement: HTML Edit Form object used to display image -valueElement: HTML Edit Form field where uploaded filename is stored -fileId: current selected file Id (can be negative - which means no selection) 4. The following frames are opened by this page: QUESTION: Is this list up-to-date? If not, please update. Left Bottom: image_upload.html - used for uploading new images Left Top: image_blank.html (gets set to image_preview.html) Right: another frame set contianing the following frames: top frame: imageListFrame src="image_list.html" (the image_frame.jsp onLoad handler then loads image_list.jsp) bottom frame: deleteImageFrame src="image_delete.html" 5. JSP code on this frame gets a complete list of all images currently stored in the repository and saves them in JavaScript arrays. These are referred to as frameset arrays in comments embedded throughout all the code pages. This enables checking for duplicate names and display of files in the right frame. The Id of the placeholder image (either noimage.gif or cleardot.gif) and all properties of the current image are saved for later use as JavaScript variables. Most JavaScript variables are displayed in the Trace window. Previewing Images ----------------- The image-preview.html frame initially displays the image scr passed via the url query string. If no image src is specified, the blank image located at ...www/revize/images/edit/cleardot.gif is displayed. If the file is not an image, the filename is displayed. A dark blue border with a margin surrounds the image or filename. The file description is displayed under the image or filename. Additional image properties appear when managing images. The image preview frame represents no image selection using the cleardot.gif from the /revize/images/edit/ directory. The edit page html form page always represents no image selection with the "Your Image Here" graphic (noimage.gif) stored under the /revize/images/edit directory. We do not want rely on the repository containing these images for very old backward compatibility. Published pages simply display whatever image is associated with the Id stored in the underlaying record specified via an image or tag. Id=0 should be the noimage.gif placeholder but it could change if noimage.gif is deleted and readded (the current Id will be used in that case). If noimage.gif does not exist, the Id associated with cleardot.gif will be used. If niether exists, an Id of -1 must be used which unfortunately will display a broken image on published pages. The noimage.gif can be restored by exporting the entire webspace, deleting it and importing the export file. An alternative solution is to simply upload noimage.gif or cleardot.gif and go through the change image screen to use the newly assigned Id. Selecting and Deleting Images ----------------------------- The image_list.html right frame displays a list of all images currently stored in the Revize repository at same location as specified for the editable image. The list no longers contains noimage.gif or cleardot.gif files. The "select none" button must be used to specify noimage. QUESTION: Is this list up-to-date? If not, please update. When a new image is selected the main frameset is reloaded so all frames display the updated information. This may be a bit costly but avoids dealing with browser (and Revize) quirks. The image currently in use can not be deleted. A lengthly prompt explains the process to the content editor. Uploading Images or Files ------------------------- The right frame contains a browser field for uploading new images. Uploaded files are displayed in the mainFrame and added to the list in the list of files in the right frameset. Uploaded images are not uploaded to the server until the "save" button in the left bottom frame is clicked. Only one file is uploaded. The uploaded file MUST be in the browse field when save is clicked. Browser security prevents JavaScript from setting this field. It can only be set by the browser user via the browse button. Since the browse field must be used, this implies the left frame form containing this field must be submitted when uploading a file. Updating Calling Page (edit form, link manager and/or RTE --------------------------------------------------------- The image_frame.jsp::updateCaller() always passes the uploaded or selected file and associated parameters back to the calling page. If a servlet request must be made to update the reference file table, the file properties are stored in the opener window and updateCaller() is called after the servlet completes the request and reloads the image_frame.jsp page. When image_frame.jsp is reloaded after a servlet request, the right frame file list is not rebuilt. -------------------------------------------------------------------------------- --%> <%@ page language="java" import="java.util.*" %> <%@ page import="revize.data.*,revize.servlet.*,revize.store.*,revize.request.*, revize.resource.*, idetix.util.*, idetix.security.UserContext" %> <%@ page import="java.io.*" %> <%@ page import="revize.util.*" %> <%@ include file = "cacheControl.jsp" %> <% String webSpaceName = StringUtils.getParameter( request, "webSpaceName" ); String fileType = StringUtils.getParameter( request, "fileType" ); String fileLocation = StringUtils.getParameter( request, "fileLocation" ).replace('\\','/'); if (fileLocation.endsWith("/") && fileLocation.length() > 1) fileLocation = fileLocation.substring(0,fileLocation.length()-1); while (fileLocation.indexOf("//") == 0) fileLocation = fileLocation.substring(1); String filepath = StringUtils.getParameter( request, "filepath" ); String extensions = StringUtils.getParameter( request, "extensions" ); String displayElement = StringUtils.getParameter( request, "displayElement" ); String valueElement = StringUtils.getParameter( request, "valueElement" ); String fileId = StringUtils.getParameter( request, "fileId" ); String caller = StringUtils.getParameter( request, "caller" ); String brief = StringUtils.getParameter( request, "brief" ); boolean isBrief = brief.equals("true") ? true : false; boolean isRTE = StringUtils.getParameterBoolean(request, "rte"); DebugUtils.console( "image_frame", "Page loaded: image_frame.jsp" + "\nfileLocation = " + fileLocation + "\ncaller = " + caller); //----- Create page title containing file location String pageTitle = "Revize Image Manager"; if (fileType.equalsIgnoreCase("file")) pageTitle = "Revize File Manager"; // title tag written with JavaScript below. session = request.getSession(); String tiny_mce = "tiny_mce." + (String)session.getAttribute("tinymce_version"); %> <% if (isRTE) { %> <% } %> <% if(isBrief) {%> <% } else { %> <% } %> <body> <h1>Frames Required</h1> </body>