Index: wiki/src/main/resources/XWSCode/PhotoGallery =================================================================== --- wiki/src/main/resources/XWSCode/PhotoGallery (revision 10081) +++ wiki/src/main/resources/XWSCode/PhotoGallery (working copy) @@ -12,9 +12,9 @@ XWiki.Admin 1194541221000 -1207864953000 -1208424732000 -5.1 +1212493101000 +1212493101000 +19.1 PhotoGallery @@ -54,77 +54,79 @@ -## ============================================ -## Photo gallery sheet -## ============================================ -## Displays view & edit of a photo gallery -## Mandatory input : $space -## ============================================ -#set($gallery = $doc.getObject('XWSCode.PhotoGalleryClass')) - #if($gallery) ## check there is actually a gallery here - #if($context.action=="inline") - ## --------------- - ## Edit a gallery - ##---------------- - 1.1 $msg.get('space.photos.gallery.editing') : <i>$doc.title</i> - - $msg.get('space.photos.gallery.description') : - - $gallery.display("description","edit") - - #if(!$doc.isNew()) - ## - ## Add photos to an existing gallery - ## - $msg.get('space.photos.gallery.addphotostogallery') : - - #set($url=$xwiki.xwsmgr.getApplicationURL(${workspace.spaceName},"Photos","WebHome","xpage=plain&do=upload&gallery=${doc.name}")) - {pre} - <script type="text/javascript"> - function setsize(h) {document.getElementById('frameupload').style.height=h+'px';} - </script> - {/pre} - <iframe style="border:0;overflow:hidden;" id="frameupload" src="${url}" width="680" >${url}</iframe> - #end - #else - ## -------------- - ## View a gallery - ## -------------- - 1.1 $doc.title - <p> - $gallery.display("description","view") - </p> - #set($hql = "where doc.web='${doc.space}' and doc.name like '${doc.name}_%' order by doc.creationDate desc") - #set($photoList = $xwiki.searchDocuments($hql)) - - <div id="gallery"> - #foreach($dName in $photoList) - #set($pDoc = $xwiki.getDocument($dName)) - #if($pDoc.getAttachmentList().size() > 0) - #set($photo = $pDoc.getAttachmentList().get(0)) - #if($photo.isImage()) - #set($filename = $photo.filename) - #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) - #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) - #if($width > $height) - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=190")) - #else - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=210")) - #end - <a class="gallery-item" href="$pDoc.getURL('view','viewer=photo')"> - #if($filename.length() > 80) - #set($filename = "${filename.substring(0,79)}...") - #end - <span class="photo-filename">${filename}</span> - <img src="${imageurl}"/><br /><span class="photo-upload"> $msg.get('space.photos.photo.uploadedon') $xwiki.formatDate($photo.getDate(),"$msg.get('xws.dateformat')")</span> - </a> - #end - #end - #end - #end - </div> - <div class="clearfloats"></div> -#else - #error("$msg.get('space.photos.error.nogalleryfound')") +## ============================================ +## Photo gallery sheet +## ============================================ +## Displays view & edit of a photo gallery +## Mandatory input : $space +## ============================================ +#set($gallery = $doc.getObject('XWSCode.PhotoGalleryClass')) + #if($gallery) ## check there is actually a gallery here + #if($context.action=="inline") + ## --------------- + ## Edit a gallery + ##---------------- + #if($doc.title.length() > 45) + #set($title=$doc.title.substring(0,39)+"...") + #else + #set($title=$doc.title) + #end + 1.1 $msg.get('space.photos.gallery.editing') : <i>$title</i> + $msg.get('space.photos.gallery.description') : + $gallery.display("description","edit") + #if(!$doc.isNew()) + ## + ## Add photos to an existing gallery + ## + $msg.get('space.photos.gallery.addphotostogallery') : + + #set($url=$xwiki.xwsmgr.getApplicationURL(${workspace.spaceName},"Photos","WebHome","xpage=plain&do=upload&gallery=${doc.name}")) + {pre} + <script type="text/javascript"> + function setsize(h) {document.getElementById('frameupload').style.height=h+'px';} + </script> + {/pre} + <iframe style="border:0;overflow:hidden;" id="frameupload" src="${url}" width="680" >${url}</iframe> + #end + #else + ## -------------- + ## View a gallery + ## -------------- + 1.1 $doc.title + <p> + $gallery.display("description","view") + </p> + #set($hql = "where doc.web='${doc.space}' and doc.name like '${doc.name}_%' order by doc.creationDate desc") + #set($photoList = $xwiki.searchDocuments($hql)) + + <div id="gallery"> + #foreach($dName in $photoList) + #set($pDoc = $xwiki.getDocument($dName)) + #if($pDoc.getAttachmentList().size() > 0) + #set($photo = $pDoc.getAttachmentList().get(0)) + #if($photo.isImage()) + #set($filename = $photo.filename) + #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) + #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) + #if(($width * 9) > ($height * 10)) ## this will change depending on the information displayed above/below the image + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=190")) + #else + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=175")) + #end + <a class="gallery-item" href="$pDoc.getURL('view','viewer=photo')"> + #if($filename.length() > 25) + #set($filename = "${filename.substring(0,24)}...") + #end + <span class="photo-filename">${filename}</span> + <img src="${imageurl}"/><br /><span class="photo-upload"> $msg.get('space.photos.photo.uploadedon') $xwiki.formatDate($photo.getDate(),"$msg.get('xws.dateformat')")</span> + </a> + #end + #end + #end + #end + </div> + <div class="clearfloats"></div> +#else + #error("$msg.get('space.photos.error.nogalleryfound')") #end Index: wiki/src/main/resources/XWSCode/PhotoUpload =================================================================== --- wiki/src/main/resources/XWSCode/PhotoUpload (revision 10081) +++ wiki/src/main/resources/XWSCode/PhotoUpload (working copy) @@ -12,10 +12,10 @@ XWiki.Admin 1194607560000 -1208166816000 -1208166816000 -16.1 - +1212485784000 +1212485784000 +4.1 +PhotoUpload @@ -54,126 +54,126 @@ -## ============================================ -## Photo upload form -## ============================================ -## Form for uploading a photo in a gallery. -## This sheet is intended to be displayed in a -## iframe when viewing a gallery in "inline" -## "mode". See NBSheets.PhotoGalery -## ============================================ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" lang="${context.language}" xml:lang="${context.language}"> -<head> -<title></title> -<style type="text/css"> -div.gallery-item-edit {border-style:solid; border-width:1px; float:left; margin:10px 10px 0pt 0pt; text-align:center; width:120px; height:120px; border-color:#ccc;} -div.imagelist-title {font-family:sans;font-size:12px;margin-top:10px;} -</style> -{pre} -<script type="text/javascript"> -function init() { - if(document.all) - h=document.body.scrollHeight; - else h=document.body.offsetHeight; - window.parent.setsize(h+50); -} -function updateAttachName(form, msg) { - var fname = form.filepath.value; - if (fname == "") return false; - var i = fname.lastIndexOf('\\'); - if (i == -1){ - i = fname.lastIndexOf('/'); - } - fname = fname.substring(i + 1); - if (form.filename.value == fname){ - return true; - } - if (form.filename.value == ""){ - form.filename.value = fname; - } - else { - if (confirm(msg + " '" + fname + "' ?")){ - form.filename.value = fname; - } - } - return true; -} -</script> -{/pre} -</head> -<body onload="init()"> -#set($gallery = $request.gallery) -## --------------------- -## Post upload treatment -## --------------------- -#if($request.post && $request.post!="") - #set($pDoc = $xwiki.getDocument("${doc.space}.${gallery}_${request.post}")) - #if(!$pDoc.isNew()) - #set($ok = $pDoc.setParent("${doc.space}.${gallery}")) - #set($ok = $pDoc.save()) - #info("$msg.get('space.photos.gallery.uploadsuccess')") - #end -#end -## ----------- -## Upload Form -## ----------- -#set($photoId = $xwiki.generateRandomString(12)) -#set($targetDocname = "${doc.space}.${gallery}_${photoId}") -#set($action = $xwiki.getURL("${targetDocname}","upload")) -<form action="${action}" enctype="multipart/form-data" method="post"> -<div> -#set($redirecturl=$doc.getURL("view","xpage=plain&do=upload&gallery=${request.gallery}&post=${photoId}")) - <input type="hidden" name="xredirect" value="${redirecturl}" /> - <div><input id="xwikiuploadname" type="hidden" name="filename" value="" size="40"/></div> - <div><input id="xwikiuploadfile" type="file" name="filepath" value="" size="40"/></div> - <div> - <input type="submit" value="$msg.get('commons.form.validate')" onclick="return updateAttachName(this.form, '$msg.get('commons.form.replacefile')');" class="button"/> - </div> -</div> -</form> -## ----------- -## Photos list -## ----------- -<div class="imagelist-title">$msg.get('space.photos.gallery.existingphotos')</div> -#set($hql = "where doc.web='${doc.space}' and doc.name like '${gallery}_%' order by doc.creationDate desc") -#set($photoList = $xwiki.searchDocuments($hql)) -#set($galleryDoc = "${doc.space}.${gallery}") -#set($galleryURL = $xwiki.getURL("${galleryDoc}","inline")) -<div id="gallery"> -#foreach($dName in $photoList) - #set($pDoc = $xwiki.getDocument($dName)) - #if($pDoc.getAttachmentList().size() > 0) - #set($photo = $pDoc.getAttachmentList().get(0)) - #if($photo.isImage()) - #set($filename = $photo.filename) - #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) - #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) - #set($maxsize=100) - #if($width > $height) - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=$maxsize")) - #else - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=$maxsize")) - #end - <div class="gallery-item-edit"> - #if($filename.length() > 16) - #set($abbr = "${filename.substring(0,15)}...") - #else - #set($abbr = $filename) - #end - <acronym title="${filename}" style="font-size:12px;"><b>$abbr</b></acronym><br /> - #if($width > $height) - <img src="${imageurl}" width="100"/><br /> - #else - <img src="${imageurl}" height="80"/><br /> - #end - <a class="gallery-item" style="font-size:11px;" href='${pDoc.getURL("delete")}' target="_parent" onclick="if(!confirm('$msg.get("space.photos.gallery.deleteconfirm")')) return false; else {this.href = this.href + '?confirm=1&xredirect=${galleryURL}';return true;}">$msg.get('commons.actions.delete')</a> - </div> - #end - #end -#end -</div> -<div style="clear:both;"></div> +## ============================================ +## Photo upload form +## ============================================ +## Form for uploading a photo in a gallery. +## This sheet is intended to be displayed in a +## iframe when viewing a gallery in "inline" +## "mode". See NBSheets.PhotoGalery +## ============================================ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="${context.language}" xml:lang="${context.language}"> +<head> +<title></title> +<style type="text/css"> +div.gallery-item-edit {border-style:solid; border-width:1px; float:left; margin:10px 10px 0pt 0pt; text-align:center; width:120px; height:120px; border-color:#ccc;} +div.imagelist-title {font-family:sans;font-size:12px;margin-top:10px;} +</style> +{pre} +<script type="text/javascript"> +function init() { + if(document.all) + h=document.body.scrollHeight; + else h=document.body.offsetHeight; + window.parent.setsize(h+50); +} +function updateAttachName(form, msg) { + var fname = form.filepath.value; + if (fname == "") return false; + var i = fname.lastIndexOf('\\'); + if (i == -1){ + i = fname.lastIndexOf('/'); + } + fname = fname.substring(i + 1); + if (form.filename.value == fname){ + return true; + } + if (form.filename.value == ""){ + form.filename.value = fname; + } + else { + if (confirm(msg + " '" + fname + "' ?")){ + form.filename.value = fname; + } + } + return true; +} +</script> +{/pre} +</head> +<body onload="init()"> +#set($gallery = $request.gallery) +## --------------------- +## Post upload treatment +## --------------------- +#if($request.post && $request.post!="") + #set($pDoc = $xwiki.getDocument("${doc.space}.${gallery}_${request.post}")) + #if(!$pDoc.isNew()) + #set($ok = $pDoc.setParent("${doc.space}.${gallery}")) + #set($ok = $pDoc.save()) + #info("$msg.get('space.photos.gallery.uploadsuccess')") + #end +#end +## ----------- +## Upload Form +## ----------- +#set($photoId = $xwiki.generateRandomString(12)) +#set($targetDocname = "${doc.space}.${gallery}_${photoId}") +#set($action = $xwiki.getURL("${targetDocname}","upload")) +<form action="${action}" enctype="multipart/form-data" method="post"> +<div> +#set($redirecturl=$doc.getURL("view","xpage=plain&do=upload&gallery=${request.gallery}&post=${photoId}")) + <input type="hidden" name="xredirect" value="${redirecturl}" /> + <div><input id="xwikiuploadname" type="hidden" name="filename" value="" size="40"/></div> + <div><input id="xwikiuploadfile" type="file" name="filepath" value="" size="40"/></div> + <div> + <input type="submit" value="$msg.get('commons.form.validate')" onclick="return updateAttachName(this.form, '$msg.get('commons.form.replacefile')');" class="button"/> + </div> +</div> +</form> +## ----------- +## Photos list +## ----------- +<div class="imagelist-title">$msg.get('space.photos.gallery.existingphotos')</div> +#set($hql = "where doc.web='${doc.space}' and doc.name like '${gallery}_%' order by doc.creationDate desc") +#set($photoList = $xwiki.searchDocuments($hql)) +#set($galleryDoc = "${doc.space}.${gallery}") +#set($galleryURL = $xwiki.getURL("${galleryDoc}","inline")) +<div id="gallery"> +#foreach($dName in $photoList) + #set($pDoc = $xwiki.getDocument($dName)) + #if($pDoc.getAttachmentList().size() > 0) + #set($photo = $pDoc.getAttachmentList().get(0)) + #if($photo.isImage()) + #set($filename = $photo.filename) + #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) + #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) + #set($maxsize=100) + #if($width > $height) + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=$maxsize")) + #else + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=$maxsize")) + #end + <div class="gallery-item-edit"> + #if($filename.length() > 16) + #set($abbr = "${filename.substring(0,15)}...") + #else + #set($abbr = $filename) + #end + <acronym title="${filename}" style="font-size:12px;"><b>$abbr</b></acronym><br /> + #if(($width * 9) > ($height * 10)) + <img src="${imageurl}" width="100"/><br /> + #else + <img src="${imageurl}" height="70"/><br /> + #end + <a class="gallery-item" style="font-size:11px;" href='${pDoc.getURL("delete")}' target="_parent" onclick="if(!confirm('$msg.get("space.photos.gallery.deleteconfirm")')) return false; else {this.href = this.href + '?confirm=1&xredirect=${galleryURL}';return true;}">$msg.get('commons.actions.delete')</a> + </div> + #end + #end +#end +</div> +<div style="clear:both;"></div> </body> Index: wiki/src/main/resources/XWSPhotos/WebHome =================================================================== --- wiki/src/main/resources/XWSPhotos/WebHome (revision 10081) +++ wiki/src/main/resources/XWSPhotos/WebHome (working copy) @@ -12,9 +12,9 @@ XWiki.Admin 1194534618000 -1208167895000 -1208167895000 -4.1 +1212488500000 +1212488500000 +10.1 SpacePhotos @@ -54,136 +54,141 @@ -## ============================================ -## Photos entry point for Space -## ============================================ -## Displays list of photo galleries for a space -## Mandatory input : $space -## ============================================ -#if($request.do) - #if($request.do=="upload") - #includeInContext('XWSCode.PhotoUpload') - #elseif($request.do=="delete" && $request.which && $request.which!="") - ## ---------------- - ## Delete a gallery - ## ---------------- - #set($url=$xwiki.xwsmgr.getApplicationURL(${workspace.spaceName},"Photos")) - #set($gallery=$request.which) - #set($gDoc=$xwiki.getDocument($gallery)) - #if($request.confirm && $request.confirm=="1") - ## Perform deletion - ## $doc.deleteDocument() - #set($msgdeleted = $xwiki.arrayList) - #set($ok = $msgdeleted.add("<u>$gDoc.title</u>")) - <div class="infomessage"> - <h2>$msg.get("space.photos.galleries.gallerydeleted", $msgdeleted)</h2> - <a class="button" href="$url">$msg.get("space.photos.galleries.returntogalleries")</a - #set($hql = "where doc.web='${doc.space}' and doc.parent='$gallery'") - #set($photoList = $xwiki.searchDocuments($hql)) - <ul> - #foreach($dName in $photoList) - #set($pDoc = $xwiki.getDocument($dName)) - #if($pDoc.getAttachmentList().size() > 0) - #set($photo = $pDoc.getAttachmentList().get(0)) - #set($filename = $photo.filename) - $pDoc.delete() - <li>$filename $msg.get("space.photos.galleries.photodeleted")</li> - #end - #end - </ul> - $gDoc.delete() - <div class="clearfloats"></div> - <div> - #else - ## Ask for the confirmation - #set($url=$doc.getURL("view","do=delete&confirm=1&which=${gallery}")) - #set($msgparams = $xwiki.arrayList) - #set($ok = $msgparams.add("<u>$gDoc.title</u>")) - <div class="infomessage"> - <h2>$msg.get("space.photos.galleries.confirmdeletegalleries", $msgparams)</h2> - <a class="button" href="$url">$msg.get("space.photos.galleries.confirmdelete")</a> - #set($hql = "where doc.web='${doc.space}' and doc.parent='${gallery}'") - #set($photoList = $xwiki.searchDocuments($hql)) - <div id="gallery"> - #foreach($dName in $photoList) - #set($pDoc = $xwiki.getDocument($dName)) - #if($pDoc.getAttachmentList().size() > 0) - #set($photo = $pDoc.getAttachmentList().get(0)) - #if($photo.isImage()) - #set($filename = $photo.filename) - #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) - #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) - #set($maxsize=100) - #if($width > $height) - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=$maxsize")) - #else - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=$maxsize")) - #end - #if($filename.length() > 16) - #set($abbr = "${filename.substring(0,15)}...") - #else - #set($abbr = $filename) - #end - <div class="gallery-item-edit"> - <a class="gallery-item" href="$pDoc.getURL('view','viewer=photo')" style="width: 120px; height: 120px;"> - <em>$abbr</em> <img src="${imageurl}"/> - </a> - </div> - #end - #end - #end - <div class="clearfloats"></div> - </div> - </div> - #end - #else - #error("$msg.get('service.common.error.badrequest')") - #end -#else -#set($hql = ", BaseObject as obj where doc.web='${doc.space}' and obj.name=doc.fullName and obj.className='XWSCode.PhotoGalleryClass'") -#set($galleries = $xwiki.searchDocuments($hql)) -#if($galleries && $galleries.size()>0) - 1 $msg.get('space.photos.galleries') - <div id="gallery"> - #set($index = 0) - #foreach($gallery in $galleries) - #set($index = $index + 1) - #set($galDoc = $xwiki.getDocument($gallery)) - #if($galDoc && $galDoc.title != "") - #set($hql = "where doc.name like '${galDoc.name}_%' and doc.parent='${galDoc.fullName}'") - #set($photoList = $xwiki.searchDocuments($hql)) - #set($link = $galDoc.fullName) - #set($id = "gallery_" + $index) - <a id="$id" class="gallery-item" href="$!xwiki.getURL("${link}", "view")"> - <span class="heading-1-1"> $galDoc.title</span> - #set($photo_index = 1) - #foreach($dName in $photoList) - #if($photo_index <= 4) - #set($pDoc = $xwiki.getDocument($dName)) - #if($pDoc.getAttachmentList().size() > 0) - #set($photo = $pDoc.getAttachmentList().get(0)) - #if($photo.isImage()) - #set($filename = $photo.filename) - #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=73")) - <img src="${imageurl}" width="80" height="73"/> - #set($photo_index = $photo_index + 1) - #end - #end - #end - #end - #set($glry = $galDoc.getObject('XWSCode.PhotoGalleryClass')) - #set($desc = $glry.display("description","view")) - #if($desc.length() > 80) - #set($desc = $desc.substring(0,79)) - #end - <span class="gallery-desc">$desc</span> - </a> - #end - #end - </div> - <div class="clearfloats"></div> -#else -#info("$msg.get('space.photos.galleries.nogallery')") -#end +## ============================================ +## Photos entry point for Space +## ============================================ +## Displays list of photo galleries for a space +## Mandatory input : $space +## ============================================ +#if($request.do) + #if($request.do=="upload") + #includeInContext('XWSCode.PhotoUpload') + #elseif($request.do=="delete" && $request.which && $request.which!="") + ## ---------------- + ## Delete a gallery + ## ---------------- + #set($url=$xwiki.xwsmgr.getApplicationURL(${workspace.spaceName},"Photos")) + #set($gallery=$request.which) + #set($gDoc=$xwiki.getDocument($gallery)) + #if($request.confirm && $request.confirm=="1") + ## Perform deletion + ## $doc.deleteDocument() + #set($msgdeleted = $xwiki.arrayList) + #set($ok = $msgdeleted.add("<u>$gDoc.title</u>")) + <div class="infomessage"> + <h2>$msg.get("space.photos.galleries.gallerydeleted", $msgdeleted)</h2> + <a class="button" href="$url">$msg.get("space.photos.galleries.returntogalleries")</a + #set($hql = "where doc.web='${doc.space}' and doc.parent='$gallery'") + #set($photoList = $xwiki.searchDocuments($hql)) + <ul> + #foreach($dName in $photoList) + #set($pDoc = $xwiki.getDocument($dName)) + #if($pDoc.getAttachmentList().size() > 0) + #set($photo = $pDoc.getAttachmentList().get(0)) + #set($filename = $photo.filename) + $pDoc.delete() + <li>$filename $msg.get("space.photos.galleries.photodeleted")</li> + #end + #end + </ul> + $gDoc.delete() + <div class="clearfloats"></div> + <div> + #else + ## Ask for the confirmation + #set($url=$doc.getURL("view","do=delete&confirm=1&which=${gallery}")) + #set($msgparams = $xwiki.arrayList) + #set($ok = $msgparams.add("<u>$gDoc.title</u>")) + <div class="infomessage"> + <h2>$msg.get("space.photos.galleries.confirmdeletegalleries", $msgparams)</h2> + <a class="button" href="$url">$msg.get("space.photos.galleries.confirmdelete")</a> + #set($hql = "where doc.web='${doc.space}' and doc.parent='${gallery}'") + #set($photoList = $xwiki.searchDocuments($hql)) + <div id="gallery"> + #foreach($dName in $photoList) + #set($pDoc = $xwiki.getDocument($dName)) + #if($pDoc.getAttachmentList().size() > 0) + #set($photo = $pDoc.getAttachmentList().get(0)) + #if($photo.isImage()) + #set($filename = $photo.filename) + #set($width=$xwiki.image.getWidth($pDoc.fullName,${filename})) + #set($height=$xwiki.image.getHeight($pDoc.fullName,${filename})) + #set($maxsize=100) + #if($width > $height) + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"width=$maxsize")) + #else + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=$maxsize")) + #end + #if($filename.length() > 16) + #set($abbr = "${filename.substring(0,15)}...") + #else + #set($abbr = $filename) + #end + <div class="gallery-item-edit"> + <a class="gallery-item" href="$pDoc.getURL('view','viewer=photo')" style="width: 120px; height: 120px;"> + <em>$abbr</em> <img src="${imageurl}"/> + </a> + </div> + #end + #end + #end + <div class="clearfloats"></div> + </div> + </div> + #end + #else + #error("$msg.get('service.common.error.badrequest')") + #end +#else +#set($hql = ", BaseObject as obj where doc.web='${doc.space}' and obj.name=doc.fullName and obj.className='XWSCode.PhotoGalleryClass'") +#set($galleries = $xwiki.searchDocuments($hql)) +#if($galleries && $galleries.size()>0) + 1 $msg.get('space.photos.galleries') + <div id="gallery"> + #set($index = 0) + #foreach($gallery in $galleries) + #set($index = $index + 1) + #set($galDoc = $xwiki.getDocument($gallery)) + #if($galDoc && $galDoc.title != "") + #set($hql = "where doc.name like '${galDoc.name}_%' and doc.parent='${galDoc.fullName}'") + #set($photoList = $xwiki.searchDocuments($hql)) + #set($link = $galDoc.fullName) + #set($id = "gallery_" + $index) + <a id="$id" class="gallery-item" href="$!xwiki.getURL("${link}", "view")"> + #if($galDoc.title.length() > 15) + #set($title=$galDoc.title.substring(0,14)+"...") + #else + #set($title=$galDoc.title) + #end + <span class="heading-1-1"> $title</span> + #set($photo_index = 1) + #foreach($dName in $photoList) + #if($photo_index <= 4) + #set($pDoc = $xwiki.getDocument($dName)) + #if($pDoc.getAttachmentList().size() > 0) + #set($photo = $pDoc.getAttachmentList().get(0)) + #if($photo.isImage()) + #set($filename = $photo.filename) + #set($imageurl=$pDoc.getAttachmentURL(${filename},'download',"height=73")) + <img src="${imageurl}" width="80" height="73"/> + #set($photo_index = $photo_index + 1) + #end + #end + #end + #end + #set($glry = $galDoc.getObject('XWSCode.PhotoGalleryClass')) + #set($desc = $glry.display("description","view")) + #if($desc.length() > 80) + #set($desc = $desc.substring(0,79)) + #end + <span class="gallery-desc">$desc</span> + </a> + #end + #end + </div> + <div class="clearfloats"></div> +#else +#info("$msg.get('space.photos.galleries.nogallery')") +#end #end