COPY "media_type" FROM stdin;
2 unknown application/octet-stream -- UploadedMedia \N
3 jpg image/gif ImagesGif Images \N
-4 mp3 audio/mp3 Generic UploadedMedia \N
+4 mp3 audio/mp3 Audio UploadedMedia \N
\.
-- Enable triggers
UPDATE pg_class SET reltriggers = (SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid) WHERE relname = 'media_type';
# relativ directory, where the thumbnails will be saved
Producer.Image.IconPath=/icon
+# Tiny Icons for the media types on the newswire summary.
+# (right hand side of start page)
+Producer.Icon.TinyImage=photo_small.gif
+Producer.Icon.TinyAudio=audio_small.gif
+Producer.Icon.TinyVideo=video_small.gif
+Producer.Icon.TinyText=text_small.gif
+
#
--- /dev/null
+/*
+ * put your module comment here
+ */
+
+
+package mir.media;
+
+import java.util.*;
+
+import mir.entity.*;
+import mir.misc.*;
+import mir.storage.*;
+
+
+/**
+ * Interfacedefinition für Datenbank-Adpatoren. Die Adaptoren legen
+ * jeweils das Verhalten und die Befehlsmächtigkeit der Datenbank
+ * fest.
+ *
+ * @author <mh>
+ * @version 24.09.2001
+ */
+
+public class MediaHandlerAudio extends MediaHandlerGeneric implements MirMedia
+{
+
+ public String getTinyIcon()
+ {
+ return MirConfig.getProp("Producer.Icon.TinyAudio");
+ }
+
+ public String getIconAlt()
+ {
+ return "Audio";
+ }
+
+ public boolean isAudio()
+ {
+ return true;
+ }
+}
{
return MirConfig.getProp("Producer.Media.Host");
}
+
+ public String getTinyIcon()
+ {
+ return MirConfig.getProp("Producer.Icon.TinyText");
+ }
+
+ public String getIconAlt()
+ {
+ return "Generic media";
+ }
+
+ public boolean isVideo()
+ {
+ return false;
+ }
+
+ public boolean isAudio()
+ {
+ return false;
+ }
+
+ public boolean isImage()
+ {
+ return false;
+ }
+
}
{
return MirConfig.getProp("Producer.Image.Host");
}
-
+
+ public String getTinyIcon ()
+ {
+ return MirConfig.getProp("Producer.Icon.TinyImage");
+ }
+
+ public String getIconAlt ()
+ {
+ return "Image";
+ }
+
+ public boolean isVideo ()
+ {
+ return false;
+ }
+
+ public boolean isAudio ()
+ {
+ return false;
+ }
+
+ public boolean isImage ()
+ {
+ return true;
+ }
+
}
* @return Adaptorklasse als String
*/
public abstract boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt );
-
-
public abstract byte[] get (Entity ent, Entity mediaTypeEnt);
-
+ public abstract byte[] getIcon (Entity ent);
+ //public abstract String getURL (Entity ent);
public String getStoragePath ();
public String getIconStoragePath ();
public String getPublishHost ();
-
-
- /**
- * Liefert die URL für JDBC zurück, in den die Parameter user, pass und host
- * eingefügt werden. Die URL wird aus der Konfiguration geholt.
- *
- * @param user user als String
- * @param pass passwort als String
- * @param host host als String
- * @return url als String
- */
- //public abstract String makeURL (Entity ent);
-
-
- /**
- * Gibt zurück, ob das SQL der Datenbank den <code>limit</code>-Befehl beherrscht.
- * @return true wenn ja, sonst false
- */
- public abstract byte[] getIcon (Entity ent);
+ public String getTinyIcon ();
+ public String getIconAlt ();
+ public boolean isVideo ();
+ public boolean isAudio ();
+ public boolean isImage ();
}
super.setValues(theStringValues);
}
+ /**
+ * fetches the MediaType entry assiciated w/ this media
+ *
+ * @return mir.entity.Entity
+ */
+ public Entity getMediaType() {
+ return ((DatabaseUploadedMedia)theStorageObject).getMediaType(this);
+ }
+
+
+
public void finalize() {
instances--;
super.finalize();
import freemarker.template.*;
import mir.misc.*;
+import mir.media.*;
import mir.storage.*;
import mir.module.*;
import mir.entity.*;
SimpleHash startPageModel;
SimpleList contentList;
String currentMediaId;
+ EntityList upMediaEntityList;
EntityList imageEntityList;
+ Entity mediaType;
+ EntityUploadedMedia uploadedMedia;
+ Class mediaHandlerClass;
+ MirMedia mediaHandler;
+ String mediaHandlerName;
+ String tinyIcon;
+ String iconAlt;
+ Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Producer.Logfile"));
+
SimpleList mediaList;
SimpleHash contentHash;
whereClause="is_published=true AND to_article_type >= 1";
entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,newsPerPage);
SimpleList newsWireList = HTMLTemplateProcessor.makeSimpleList(entityList);
+ for (int i=0; i < entityList.size();i++) {
+ currentContent = (EntityContent)entityList.elementAt(i);
+ //fetching/setting the images
+ upMediaEntityList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
+ if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) {
+ tinyIcon = null;
+ iconAlt = null;
+ mediaHandler = null;
+ mediaHandlerName = null;
+ for (int n=0; n < upMediaEntityList.size();n++) {
+ uploadedMedia = (EntityUploadedMedia)upMediaEntityList.elementAt(n);
+ mediaType = uploadedMedia.getMediaType();
+
+ //must of had a non-existant to_media_type entry..
+ //let's save our ass.
+ if (mediaType != null) {
+ /*
+ * grrr. why doesn't getId return an int! if It
+ * did I could just compare the value of getId and
+ * pick the biggest one. or is there
+ * another way around this that I am missing?
+ * can we make getIdasInt() or can we just have
+ * another getId() that returns an Int and the VM
+ * will handle it transparantly? -mh
+ */
+ try {
+ mediaHandlerName = mediaType.getValue("classname");
+ mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName);
+ mediaHandler = (MirMedia)mediaHandlerClass.newInstance();
+ } catch (Exception e) {
+ theLog.printError("ProducerStartpage:problem in reflection: "+mediaHandlerName);
+ }
+
+ //the best media type
+ if (mediaHandler.isVideo()) {
+ tinyIcon = MirConfig.getProp("Producer.Icon.TinyVideo");
+ iconAlt = "Video";
+ break;
+ } else if (mediaHandler.isAudio()) {
+ tinyIcon = MirConfig.getProp("Producer.Icon.TinyAudio");
+ iconAlt = "Audio";
+ } else if (tinyIcon == null && !mediaHandler.isImage()) {
+ tinyIcon = mediaHandler.getTinyIcon();
+ iconAlt = mediaHandler.getIconAlt();
+ }
+ }
+ }
+ //it only has image(s)
+ if (tinyIcon == null) {
+ tinyIcon = MirConfig.getProp("Producer.Icon.TinyImage");
+ iconAlt = "Image";
+ }
+
+ // uploadedMedia Entity list is empty.
+ // we only have text
+ } else {
+ tinyIcon = MirConfig.getProp("Producer.Icon.TinyText");
+ iconAlt = "Text";
+ }
+
+ try{
+ //mediaList = HTMLTemplateProcessor.makeSimpleList(upMediaEntityList);
+ contentHash = (SimpleHash)newsWireList.get(i);
+ contentHash.put("tiny_icon", imageRoot+"/"+tinyIcon);
+ contentHash.put("icon_alt", iconAlt);
+ } catch (Exception e){}
+ }
// get the startarticle and the related images
whereClause="is_published=true AND to_article_type=4";
}
+ /**
+ * get all the uploaded Media belonging to a content entity
+ *
+ */
+ public EntityList getUploadedMedia(EntityContent content) {
+ EntityList returnList=null;
+ if (content != null) {
+ // get all to_topic from media_x_topic
+ String id = content.getId();
+ //this is not supported by mysql
+ String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
+
+ try {
+ returnList = DatabaseUploadedMedia.getInstance().selectByWhereClause(subselect,-1);
+ } catch (Exception e) {
+ theLog.printDebugInfo("-- get uploadedMedia failed " + e.toString());
+ }
+ }
+ return returnList;
+ }
+
+
public void setMedia(String contentId, String[] mediaId) {
if (contentId == null){
return;
<!-- newswire -->
<p>
<list newswire as n>
- <img alt="[Text]" border="0" height="10" src="/images/text_small.gif" width="12">
+ <img alt=${n.icon_alt} border="0" height="10" src=${n.tiny_icon} width="12">
<a href="${config.docroot}${n.publish_path}${n.id}.shtml"><b>${n.title}</b></a><br>
<font size="-2"><b></b>${n.webdb_create_formatted}</font><br>
<br>