blob: 1c9f58cdc05740d2c5d7abecad4b6d9257203214 [file] [log] [blame]
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id: insertAsset.jx 508032 2007-02-15 17:41:53Z andreas $ -->
<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
<page:head>
<script type="text/javascript" src="/modules/editors/javascript/org.apache.lenya.editors.js">&#160;</script>
<script type="text/javascript" src="/modules/editors/javascript/insertAsset.js">&#160;</script>
</page:head>
<!-- This view can handle both insertAsset and insertImage,
depending on the setting of the mode parameter ("Asset"|"Image") -->
<jx:set var="mode" value="${usecase.getParameterAsString('mode')}"/>
<page:title>
<i18n:text>insertAsset.heading<jx:out value="${mode}"/></i18n:text>
</page:title>
<page:body>
<form method="POST" name="insertAsset">
<jx:import uri="fallback://lenya/modules/usecase/templates/messages.jx"/>
<input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
<input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
<div class="lenya-box">
<div class="lenya-box-title">
<i18n:text>insertAsset.available<jx:out value="${mode}"/></i18n:text>
</div>
<div class="lenya-box-body">
<table class="lenya-table-list" style="border: none">
<tr>
<th style="background: none;"/>
<th style="background: none;"><i18n:text>insertAsset.file</i18n:text></th>
<th style="background: none;"><i18n:text>insertAsset.preview</i18n:text></th>
<th style="background: none;"><i18n:text>insertAsset.title</i18n:text></th>
<th style="background: none;"><i18n:text>insertAsset.fileSize</i18n:text></th>
<th style="background: none;"><i18n:text>insertAsset.imageSize</i18n:text></th>
<th style="background: none;"><i18n:text>insertAsset.creationDate</i18n:text></th>
</tr>
<jx:set var="asset2proxyUrl" value="${usecase.getParameter('asset2proxyUrl')}"/>
<jx:forEach var="asset" items="${usecase.getParameter('assets')}">
<jx:set var="mimeType" value="${asset.getMimeType()}"/>
<!-- Images are displayed in both "Asset" and "Image" mode. Other resources
are displayed only in "Asset" mode. -->
<jx:if test="${mode.equals('Asset') || mimeType.startsWith('image/')}">
<!-- We must differenciate between images and assets here:
images get a path-based URL to allow WYSIWYG editors to render them
(they will be converted to lenya-document: UR later).
Assets get a UUID-based lenya-document URL.
-->
<jx:choose>
<jx:when test="${mode.equals('Image')}">
<jx:set var="url" value="${asset2proxyUrl.get(asset)}"/>
</jx:when>
<jx:otherwise>
<jx:set var="url" value="${('lenya-document:' + asset.getUUID() + ',lang=' + asset.getLanguage())}"/>
</jx:otherwise>
</jx:choose>
<tr>
<td>
<!-- The "+''" construction is to avoid nulls (it forces them to be cast to the empty string).
Undefined values would cause the form field to be disabled.
-->
<input type="radio" name="asset" value="${asset.getPath()}"
onClick="updateData(
'${url}',
'${asset.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title') + ''}',
'${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('height') + ''}',
'${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('width') + ''}',
'${asset.getMimeType() + ''}'
)"
/>
</td>
<td>
<jx:out value="${asset.getPath()}"/>
</td>
<td>
<jx:choose>
<jx:when test="${mimeType.startsWith('image/')}">
<!-- ??? --><jx:set var="doc" value="${usecase.getParameter('document')}"/>
<img src="${url}" style="height: 32px; vertical-align: middle; margin: 3px 0px;"/>&#160;
</jx:when>
<jx:otherwise>
<jx:out value="${mimeType}"/>
</jx:otherwise>
</jx:choose>
</td>
<td>
<jx:out value="${asset.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title')}"/>
</td>
<td align="right">
<jx:out value="${asset.getContentLength() / 1000}"/> kB
</td>
<td align="right">
<jx:if test="${mimeType.startsWith('image/')}">
<jx:out value="${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('width')}"/> x <jx:out value="${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('height')}"/></jx:if>
</td>
<td align="right">
<jx:out value="${java.text.DateFormat.getDateInstance().format(asset.getLastModified())}"/>
</td>
</tr>
</jx:if>
</jx:forEach>
</table>
<br/>
<input type="hidden" name="url" value=""/>
<input type="hidden" name="type" value=""/>
<input type="hidden" name="ratio" value=""/>
<table class="lenya-table-noborder">
<tr>
<td class="lenya-entry-caption">
<label for="text"><i18n:text>insertAsset.caption<jx:out value="${mode}"/></i18n:text></label>:
</td>
<td>
<input class="lenya-form-element" type="text" name="text" title=""/>
</td>
</tr>
<tr>
<td class="lenya-entry-caption">
<label for="title"><i18n:text>insertAsset.title</i18n:text></label>:
</td>
<td>
<input class="lenya-form-element" type="text" name="title" title=""/>
</td>
</tr>
<jx:if test="${mode.equals('Image')}">
<tr>
<td class="lenya-entry-caption">
<label for="width"><i18n:text>insertAsset.width</i18n:text></label>:
</td>
<td>
<input class="lenya-form-element" type="text" name="width" title="" onchange="scaleHeight(this.value)"/>
</td>
</tr>
<tr>
<td class="lenya-entry-caption">
<label for="height"><i18n:text>insertAsset.height</i18n:text></label>:
</td>
<td>
<input class="lenya-form-element" type="text" name="height" title="" onchange="scaleWidth(this.value)"/>
</td>
</tr>
</jx:if>
<tr>
<td colspan="2">
<input
i18n:attr="value"
type="submit"
value="insertAsset.insert${mode}"
onclick="org.apache.lenya.editors.handleFormSubmit('insertAsset');"
/>
&#160;
<input
i18n:attr="value"
type="submit"
name="cancel"
value="Cancel"
onClick="window.close();"
/>
&#160;
<input
i18n:attr="value"
type="button"
value="insertAsset.createResource"
onclick="location.href='?doctype=resource&amp;lenya.usecase=editors.createResource&amp;lenya.exitUsecase=${usecase.getName()}'"
/>
</td>
</tr>
</table>
</div>
</div>
</form>
</page:body>
</page:page>