}
if (key.equals("to_media_content")) {
try {
+ /** @todo why this loggin to System.err and not
+ * theLog.printDebugInfo() ? / rk */
System.err.println("ASKED FOR MEDIA");
SimpleList t = getUploadedMediaForContent();
//SimpleHash o = t.next();
SimpleHash o = (SimpleHash)t.next();
System.err.println("SCALAR: "+o.get("url"));
}
-
+
t.rewind();
//return getUploadedMediaForContent();
return t;
*
* @return freemarker.template.SimpleList
*/
- public SimpleList getComments() throws StorageObjectException {
+ private SimpleList getComments() throws StorageObjectException {
return ((DatabaseContent)theStorageObject).getComments(this);
}
upMedia = currentMediaList.elementAt(n);
//upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia);
mediaType = ((EntityMedia)upMedia).getMediaType();
-
+
try {
// ############### TODO: merge these and the getURL call into one
// getURL helper call that just takes the Entity as a parameter
private SimpleList getUploadedMediaForContent()
throws StorageObjectException, TemplateModelException
{
- SimpleList returnList=null;
- EntityList currentMediaList =
- DatabaseContentToMedia.getInstance().getUploadedMedia(this);
- if (currentMediaList!=null && currentMediaList.getCount()>=1)
- {
- System.err.println("LIST NOT NULL "+this.getId());
- Entity upMedia,mediaType;
- SimpleHash upMediaSimpleHash;
- MirMedia mediaHandler=null;
- Database mediaStorage=null;
-
- returnList = new SimpleList();
-
- for (int n=0; n < currentMediaList.size();n++) {
- upMedia = currentMediaList.elementAt(n);
- //upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia);
- mediaType = ((EntityMedia)upMedia).getMediaType();
- try {
- // ############### TODO: merge these and the getURL call into one
- // getURL helper call that just takes the Entity as a parameter
- // along with media_type
- mediaHandler = MediaHelper.getHandler( mediaType );
- mediaStorage = MediaHelper.getStorage( mediaType,
- "mircoders.storage.Database");
- } catch (MirMediaException ex) {
- throw new TemplateModelException(ex.toString());
- }
-
- // ########## TODO: this should be transparent
- //we most likely need further info
- upMedia = mediaStorage.selectById(upMedia.getId());
- SimpleHash modelRoot = new SimpleHash();
- try {
- //upMediaSimpleHash.put("url", mediaHandler.getURL(upMedia, mediaType));
- // ################# TODO: this is broken cause of field checking
- // in Entity. must find a workaround
- modelRoot.put("url", new SimpleScalar(mediaHandler.getURL(upMedia, mediaType)));
- modelRoot.put("is_published", upMedia.getValue("is_published"));
- //upMedia.setValueForProperty("url",
- //mediaHandler.getURL(upMedia, mediaType));
- System.err.println("URL "+mediaHandler.getURL(upMedia, mediaType));
- System.err.println("URK'ED? "+modelRoot.get("url"));
- System.err.println("PUB'ED? "+modelRoot.get("is_published"));
- }
- catch (Exception ex) {
- throw new TemplateModelException(ex.toString());
- }
- //upMediaSimpleHash.put("type",mediaType.getValue("classname"));
- //upMedia.setValueForProperty("type",mediaType.getValue("classname"));
- modelRoot.put("type",mediaType.getValue("classname"));
- returnList.add(modelRoot);
- } //end for
- } //end if currentMediaList != null
- return returnList;
+ /** @todo all logic related to uploaded media should be moved
+ * to EntityUploadedMedia, selection should just take place
+ * on published media! .. will fix it later / rk
+ *
+ * ok i moved it... let's see what happens...
+ *
+ * */
+
+ return HTMLTemplateProcessor.makeSimpleList(
+ DatabaseContentToMedia.getInstance().getUploadedMedia(this) );
}
}