📄 itemlisttag.java
字号:
} // close the table out.println("</table>"); } catch (IOException ie) { throw new JspException(ie); } return SKIP_BODY; } /** * Get the items to list * * @return the items */ public Item[] getItems() { return items; } /** * Set the items to list * * @param itemsIn * the items */ public void setItems(Item[] itemsIn) { items = itemsIn; } /** * Get the row to highlight - null or -1 for no row * * @return the row to highlight */ public String getHighlightrow() { return String.valueOf(highlightRow); } /** * Set the row to highlight * * @param highlightRowIn * the row to highlight or -1 for no highlight */ public void setHighlightrow(String highlightRowIn) { if ((highlightRowIn == null) || highlightRowIn.equals("")) { highlightRow = -1; } else { try { highlightRow = Integer.parseInt(highlightRowIn); } catch (NumberFormatException nfe) { highlightRow = -1; } } } /** * Get the column to emphasise - "title", "date" or null * * @return the column to emphasise */ public String getEmphcolumn() { return emphColumn; } /** * Set the column to emphasise - "title", "date" or null * * @param emphColumnIn * column to emphasise */ public void setEmphcolumn(String emphColumnIn) { emphColumn = emphColumnIn; } public void release() { highlightRow = -1; emphColumn = null; items = null; } /* get the required thumbnail config items */ private void getThumbSettings() { showThumbs = ConfigurationManager .getBooleanProperty("webui.browse.thumbnail.show"); if (showThumbs) { thumbItemListMaxHeight = ConfigurationManager .getIntProperty("webui.browse.thumbnail.maxheight"); if (thumbItemListMaxHeight == 0) { thumbItemListMaxHeight = ConfigurationManager .getIntProperty("thumbnail.maxheight"); } thumbItemListMaxWidth = ConfigurationManager .getIntProperty("webui.browse.thumbnail.maxwidth"); if (thumbItemListMaxWidth == 0) { thumbItemListMaxWidth = ConfigurationManager .getIntProperty("thumbnail.maxwidth"); } } String linkBehaviour = ConfigurationManager .getProperty("webui.browse.thumbnail.linkbehaviour"); if (linkBehaviour != null) { if (linkBehaviour.equals("bitstream")) { linkToBitstream = true; } } } /* * Get the (X)HTML width and height attributes. As the browser is being used * for scaling, we only scale down otherwise we'll get hideously chunky * images. This means the media filter should be run with the maxheight and * maxwidth set greater than or equal to the size of the images required in * the search/browse */ private String getScalingAttr(HttpServletRequest hrq, Bitstream bitstream) throws JspException { BufferedImage buf; try { Context c = UIUtil.obtainContext(hrq); InputStream is = BitstreamStorageManager.retrieve(c, bitstream .getID()); //AuthorizeManager.authorizeAction(bContext, this, Constants.READ); // read in bitstream's image buf = ImageIO.read(is); is.close(); } catch (SQLException sqle) { throw new JspException(sqle.getMessage()); } catch (IOException ioe) { throw new JspException(ioe.getMessage()); } // now get the image dimensions float xsize = (float) buf.getWidth(null); float ysize = (float) buf.getHeight(null); // scale by x first if needed if (xsize > (float) thumbItemListMaxWidth) { // calculate scaling factor so that xsize * scale = new size (max) float scale_factor = (float) thumbItemListMaxWidth / xsize; // now reduce x size and y size xsize = xsize * scale_factor; ysize = ysize * scale_factor; } // scale by y if needed if (ysize > (float) thumbItemListMaxHeight) { float scale_factor = (float) thumbItemListMaxHeight / ysize; // now reduce x size // and y size xsize = xsize * scale_factor; ysize = ysize * scale_factor; } StringBuffer sb = new StringBuffer("width=\"").append(xsize).append( "\" height=\"").append(ysize).append("\""); return sb.toString(); } /* generate the (X)HTML required to show the thumbnail */ private String getThumbMarkup(HttpServletRequest hrq, Item item) throws JspException { Bundle[] original = null; try { original = item.getBundles("ORIGINAL"); } catch(SQLException sqle) { throw new JspException(sqle.getMessage()); } if (original.length == 0) { return ""; } boolean html = false; // if multiple bitstreams, check if the primary one is HTML if (original[0].getBitstreams().length > 1) { Bitstream[] bitstreams = original[0].getBitstreams(); for (int i = 0; (i < bitstreams.length) && !html; i++) { if (bitstreams[i].getID() == original[0] .getPrimaryBitstreamID()) { html = bitstreams[i].getFormat().getMIMEType().equals( "text/html"); } } } try { Bundle[] thumbs = item.getBundles("THUMBNAIL"); // if there are thumbs and we're not dealing with an HTML item // then show the thumbnail if ((thumbs.length > 0) && !html) { Context c = UIUtil.obtainContext(hrq); Bitstream thumbnailBitstream; Bitstream originalBitstream; if ((original[0].getBitstreams().length > 1) && (original[0].getPrimaryBitstreamID() > -1)) { originalBitstream = Bitstream.find(c, original[0] .getPrimaryBitstreamID()); thumbnailBitstream = thumbs[0] .getBitstreamByName(originalBitstream.getName() + ".jpg"); } else { originalBitstream = original[0].getBitstreams()[0]; thumbnailBitstream = thumbs[0].getBitstreams()[0]; } if ((thumbnailBitstream != null) && (AuthorizeManager.authorizeActionBoolean(c, thumbnailBitstream, Constants.READ))) { StringBuffer thumbLink; if (linkToBitstream) { thumbLink = new StringBuffer( "<br/><a target=\"_blank\" href=\"").append( hrq.getContextPath()).append("/bitstream/") .append(item.getHandle()).append("/").append( originalBitstream.getSequenceID()) .append("/").append( UIUtil.encodeBitstreamName(originalBitstream .getName(), Constants.DEFAULT_ENCODING)); } else { thumbLink = new StringBuffer("<br/><a href=\"").append( hrq.getContextPath()).append("/handle/") .append(item.getHandle()); } thumbLink.append("\"><img src=\"").append( hrq.getContextPath()).append("/retrieve/").append( thumbnailBitstream.getID()).append("/").append( UIUtil.encodeBitstreamName(thumbnailBitstream.getName(), Constants.DEFAULT_ENCODING)).append( "\" alt=\"").append(thumbnailBitstream.getName()) .append("\" ").append( getScalingAttr(hrq, thumbnailBitstream)) .append("/></a>"); return thumbLink.toString(); } } } catch (SQLException sqle) { throw new JspException(sqle.getMessage()); } catch (UnsupportedEncodingException e) { throw new JspException( "Server does not support DSpace's default encoding. ", e); } return ""; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -