ANT_HOME=/usr/share/ant
-CP=$LIB_HOME/servlet-2.2.jar
+CP=$LIB_HOME/servlet.jar
CP=$CP:$LOCALCLASSPATH
CP=$CP:$LIB_HOME/xerxes.jar:$TOMCAT_HOME/lib/tomcat.jar
CP=$CP:$LIB_HOME/gnu-regexp-1.0.8.jar
confed = getConfig(req);
}
-
+ HttpSession session = req.getSession(true);
+
if (req.getServerPort() == 443) http="https"; else http="http";
res.setContentType("text/html");
String moduleName = req.getParameter("module");
- HttpSession session = req.getSession(true);
+
if(session.getAttribute("Language")==null){
setLanguage(req,getAcceptLanguage(req));
if (userEntity==null) {
// login failed: redirecting to login
theLog.printWarning("--login: failed!");
- _sendLoginPage(req,res.getWriter());
+ _sendLoginPage(res,req,res.getWriter());
return;
} else {
// login successful
+ res.encodeURL(http +"://" + req.getServerName() +":"+ serverPort + target)
+ "\"></head><body>going " + target + "</body></html>";
}
- res.getWriter().println(redirect);
+ //res.getWriter().println(redirect);
+
+ res.encodeRedirectURL(http + "://" + req.getServerName()
+ + ":" +req.getServerPort() + target);
+
} else {
+ theLog.printDebugInfo("testurl: "+res.encodeURL(""));
+ theLog.printDebugInfo("querystring: "+req.getQueryString());
// redirecting to default target
//theLog.printDebugInfo("--login: no target - redirecting to default");
- _sendStartPage(req, res.getWriter(),userEntity);
+ _sendStartPage(res,req, res.getWriter(),userEntity);
}
return;
} // if login succesful
if (moduleName!=null && moduleName.equals("logout")) {
theLog.printDebugInfo("--logout");
session.invalidate();
- _sendLoginPage(req,res.getWriter());
+ _sendLoginPage(res,req,res.getWriter());
return;
}
if (req.getQueryString()!=null) redirectString += "?" + req.getQueryString();
theLog.printDebugInfo("STORING: " + redirectString);
session.setAttribute("login.target", redirectString);
- _sendLoginPage(req,res.getWriter());
+ _sendLoginPage(res,req,res.getWriter());
return;
}
// Bei blossem Serveltaufruf redirect auf Standardstarttemplate
if (moduleName == null || moduleName.equals("")) {
- _sendStartPage(req, res.getWriter(),userEntity);
+ _sendStartPage(res,req, res.getWriter(),userEntity);
return;
}
smod = (ServletModule)m.invoke(null,null);
ServletModuleDispatch.dispatch(smod,req,res);
}
- catch (NoSuchMethodException e) { handleError( res.getWriter(), "ServletModule" + moduleName + " getInstance() nicht gefunden."); }
- catch (InvocationTargetException e) { handleError( res.getWriter(), "ServletModule" + moduleName + " target nicht gefunden."); }
- catch (ClassNotFoundException e) { handleError( res.getWriter(), "ServletModule" + moduleName + " nicht gefunden."); }
- catch (IllegalArgumentException e) { handleError( res.getWriter(), "ServletModule" + moduleName + " nicht gefunden."); }
- catch (ServletModuleException e){ handleError(res.getWriter(), "ServletException in Module ServletModule" + moduleName + " -- " + e.toString()); }
+ catch (NoSuchMethodException e) { handleError( res,res.getWriter(), "ServletModule" + moduleName + " getInstance() nicht gefunden."); }
+ catch (InvocationTargetException e) { handleError( res,res.getWriter(), "ServletModule" + moduleName + " target nicht gefunden."); }
+ catch (ClassNotFoundException e) { handleError(res, res.getWriter(), "ServletModule" + moduleName + " nicht gefunden."); }
+ catch (IllegalArgumentException e) { handleError( res,res.getWriter(), "ServletModule" + moduleName + " nicht gefunden."); }
+ catch (ServletModuleException e){ handleError(res,res.getWriter(), "ServletException in Module ServletModule" + moduleName + " -- " + e.toString()); }
catch (IllegalAccessException e){
- handleError(res.getWriter(), "Kein Zugriff auf Klasse ServletModule" + moduleName + " -- " + e.toString()); }
+ handleError(res,res.getWriter(), "Kein Zugriff auf Klasse ServletModule" + moduleName + " -- " + e.toString()); }
// timing...
sessionConnectTime = new java.util.Date().getTime() - startTime;
theLog.printInfo("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms");
}
- private void handleError(PrintWriter out, String errorString) {
+ private void handleError(HttpServletResponse res, PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
+ HTMLTemplateProcessor.process(res,Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
out.close();
}
catch (Exception e) {
}
// Redirect-methods
- private void _sendLoginPage(HttpServletRequest req, PrintWriter out) {
+ private void _sendLoginPage(HttpServletResponse res,HttpServletRequest req, PrintWriter out) {
String loginTemplate = "login.template";
try {
theLog.printDebugInfo("login: "+lang);
if(lang==null){
lang=getAcceptLanguage(req);
}
- HTMLTemplateProcessor.process(lang+"/"+loginTemplate, new SimpleHash(), out);
+ HTMLTemplateProcessor.process(res,lang+"/"+loginTemplate, new SimpleHash(), out);
} catch(HTMLParseException e) {
- handleError( out, "fehler in logintemplate.");
+ handleError(res, out, "fehler in logintemplate.");
}
}
- private void _sendStartPage(HttpServletRequest req,PrintWriter out, EntityUsers userEntity) {
+ private void _sendStartPage(HttpServletResponse res, HttpServletRequest req,PrintWriter out, EntityUsers userEntity) {
String startTemplate = "start_admin.template";
+ String sessionUrl=res.encodeURL("");
+ theLog.printDebugInfo("testurl: "+sessionUrl);
try {
// merge with logged in user and messages
SimpleHash mergeData = new SimpleHash();
+ mergeData.put("session",sessionUrl);
mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(userEntity));
if (messageModule == null) messageModule = new ModuleMessage(DatabaseMessages.getInstance());
mergeData.put("messages", HTMLTemplateProcessor.makeSimpleList(messageModule.getByWhereClause(null, "webdb_create desc",0,10)));
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+startTemplate, mergeData,out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+startTemplate, mergeData,out);
}
catch(Exception e) {
- handleError( out, "error while trying to send startpage. " + e.toString());
+ handleError( res,out, "error while trying to send startpage. " + e.toString());
}
}
try {
ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
}
- catch (ServletModuleException e){ handleError(res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); }
+ catch (ServletModuleException e){ handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); }
// timing...
sessionConnectTime = new java.util.Date().getTime() - startTime;
theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
}
- private void handleError(PrintWriter out, String errorString) {
+ private void handleError(HttpServletResponse res,PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
+ HTMLTemplateProcessor.process(res,Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
out.close();
}
catch (Exception e) {
import freemarker.template.*;
import mir.entity.*;
import mir.storage.*;
+import javax.servlet.http.*;
/**
private static String imageHost;
private static String openAction;
protected static String producerDocRoot = Configuration.getProperty("Producer.DocRoot");
- protected static String producerStorageRoot = Configuration.getProperty("Producer.StorageRoot");
+ protected static String producerStorageRoot = Configuration.getProperty("Producer.StorageRoot");
//
* @param out
* @exception HTMLParseException
*/
- public static void process(String templateFilename, EntityList entList, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename, EntityList entList, PrintWriter out)
throws HTMLParseException {
- process( templateFilename, entList, (String)null, (TemplateModelRoot)null, out);
+ process(res, templateFilename, entList, (String)null, (TemplateModelRoot)null, out);
}
/**
* @param out
* @exception HTMLParseException
*/
- public static void process(String templateFilename, EntityList entList, String additionalModelName,
+ public static void process(HttpServletResponse res,String templateFilename, EntityList entList, String additionalModelName,
TemplateModelRoot additionalModel, PrintWriter out)
throws HTMLParseException {
if (entList == null) {
//theLog.printInfo("Keine Daten! Suche erfolglos.");
- process(templateFilename, modelRoot, out);
+ process(null,templateFilename, modelRoot, out);
} else {
try {
modelRoot = makeSimpleHashWithEntitylistInfos(entList);
if (additionalModelName != null && additionalModel != null)
modelRoot.put(additionalModelName, additionalModel);
- process(templateFilename, modelRoot, out);
+ process(res,templateFilename, modelRoot, out);
} catch (StorageObjectException e) {
throw new HTMLParseException(e.toString());
}
* @param out
* @exception HTMLParseException
*/
- public static void process(String templateFilename, HashMap mergeData, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename, HashMap mergeData, PrintWriter out)
throws HTMLParseException {
- process(templateFilename, makeSimpleHash(mergeData), out);
+ process(res,templateFilename, makeSimpleHash(mergeData), out);
}
/**
*/
public static void process(String templateFilename, PrintWriter out)
throws HTMLParseException {
- process(templateFilename, (TemplateModelRoot)null, out);
+ process(null,templateFilename, (TemplateModelRoot)null, out);
}
* @param out
* @exception HTMLParseException
*/
- public static void process(String templateFilename, TemplateModelRoot tmr, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename, TemplateModelRoot tmr, PrintWriter out)
throws HTMLParseException {
if (out==null) throw new HTMLParseException("KEIN OUTPUTSTREAM");
Template tmpl = getTemplateFor(templateFilename);
if (tmpl == null) throw new HTMLParseException("KEIN TEMPLATE: " + templateFilename);
if (tmr==null) tmr = new SimpleHash();
-
- //some utilities
- SimpleHash utilityHash = new SimpleHash();
- utilityHash.put("htmlEscape",new freemarker.template.utility.HtmlEscape());
+ String session=null;
+ if (res!=null) {
+ session=res.encodeURL("");
+ }
// put standard configuration into tempalteRootmodel
SimpleHash configHash = new SimpleHash();
tmr.put("docRoot", new SimpleScalar(docRoot));
tmr.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- tmr.put("actionRoot", new SimpleScalar(actionRoot));
+ tmr.put("actionRoot", new SimpleScalar(actionRoot+session));
tmr.put("openAction", new SimpleScalar(openAction));
tmr.put("productionHost", new SimpleScalar(productionHost));
tmr.put("videoHost", new SimpleScalar(videoHost));
tmr.put("imageHost", new SimpleScalar(imageHost));
tmr.put("config", configHash);
- tmr.put("utility",utilityHash);
tmpl.process(tmr, out);
}
* Get the session-binded language
*/
protected String getLanguage(HttpServletRequest req){
- HttpSession session = req.getSession();
+ HttpSession session = req.getSession(true);
String lang = (String)session.getAttribute("Language");
if(lang==null || lang==""){
return getAcceptLanguage(req);
theLog.printDebugInfo("Language: " + lang);
return lang;
}
-}
\ No newline at end of file
+}
* get the session binded language
*/
public String getLanguage(HttpServletRequest req){
- HttpSession session = req.getSession();
+ HttpSession session = req.getSession(true);
String language = (String)session.getAttribute("Language");
if(language==null){
language=Configuration.getProperty("StandardLanguage");
theList = mainModule.getByWhereClause(null, offset);
//theList = mainModule.getByWhereClause((String)null, offset);
if (theList == null || theList.getCount() == 0 || theList.getCount()>1){
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, theList, out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, theList, out);
} else {
deliver(req, res, theList.elementAt(0), templateObjektString);
}
try {
//PrintWriter out = new LineFilterWriter(res.getWriter());
PrintWriter out = res.getWriter();
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateFilename, rtm , out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
out.close();
} catch (HTMLParseException e) {
throw new ServletModuleException(e.toString());
* @param tmpl Name des Templates
* @exception ServletModuleException
*/
- private void deliver(HttpServletRequest req, PrintWriter out, TemplateModelRoot rtm, String templateFilename)
+ private void deliver(HttpServletResponse res,HttpServletRequest req, PrintWriter out, TemplateModelRoot rtm, String templateFilename)
throws HTMLParseException {
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateFilename, rtm , out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
}
/**
String value = (yesno) ? "1":"0";
String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";
try {
- con = theStorageObject.getPooledCon();
- /** @todo should be preparedStatement: faster!! */
- stmt = con.createStatement();
- theStorageObject.executeUpdate(stmt,sql);
+ con = theStorageObject.getPooledCon();
+ /** @todo should be preparedStatement: faster!! */
+ stmt = con.createStatement();
+ theStorageObject.executeUpdate(stmt,sql);
} catch (StorageObjectException e) {
theLog.printDebugInfo(e.toString() + "\n -- set produced failed");
} catch (SQLException e) {
* dettach from media
*/
- public void dettach()
+ public void dettach(String cid,String mid)
{
- String sql = "update content set to_media=null, is_produced='0' where id='" + getId()+"'";
- try {
- theStorageObject.executeUpdate(sql);
- } catch (StorageObjectException e) {
- theLog.printError(e.toString() + "dettach failed");
- } catch (SQLException e) {
- theLog.printError(e.toString() + "dettach failed");
+ if (mid!=null){
+ try{
+ DatabaseContentToMedia.getInstance().delete(cid,mid);
+ } catch (Exception e){
+ theLog.printError("failed to get instance");
+ }
+ //set Content to unproduced
+ setProduced(false);
}
}
public void attach(String mid)
{
if (mid!=null) {
- String sql = "update content set to_media='" + mid + "', is_produced='0' where id='" + getId()+"'";
- try {
- theStorageObject.executeUpdate(sql);
- } catch (StorageObjectException e) {
- theLog.printError(e.toString() + "attach failed");
- } catch (SQLException e) {
- theLog.printError(e.toString() + "attach failed");
+ //write media-id mid and content-id in table content_x_media
+ try{
+ DatabaseContentToMedia.getInstance().addMedia(getId(),mid);
+ } catch(StorageObjectException e){
+ theLog.printError("attach: could not get the instance");
}
- }
- else
+ //set Content to unproduced
+ setProduced(false);
+ } else {
theLog.printError("EntityContent: attach without mid");
+ }
}
/**
import mir.storage.*;
import mircoders.entity.*;
+import mircoders.storage.*;
/*
* ContentObjekt -
}
if(whereClause.equals("media")) {
- whereClause="to_media > 0"; orderBy="webdb_lastchange desc";
+ return DatabaseContentToMedia.getInstance().getContent();
}
}
return theStorage.selectByWhereClause(whereClause, orderBy, offset);
outStream = new PrintWriter(outputFile);
}
- HTMLTemplateProcessor.process(template, model, outStream);
+ HTMLTemplateProcessor.process(null,template, model, outStream);
outputFile.close();
outStream.close();
SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues);
// get the images
+ EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(currentContent);
+ if (currentMedia!=null && currentMedia.getCount()>=1) {
+ SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+ mergeData.put("to_media", mediaList);
+ }
+ /**
currentMediaId = currentContent.getValue("to_media");
if (currentMediaId!=null && !currentMediaId.equals("")) {
imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
}
mergeData.put("images", imageHash);
-
+ */
// get the comments for the article
mergeData.put("comments", currentContent.getComments());
for (int k=0; k < list.size();k++) {
currentContent = (EntityContent)list.elementAt(k);
//images to content
- currentMediaId = currentContent.getValue("to_media");
- if (currentMediaId!=null && !currentMediaId.equals("")) {
- imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
+ EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(currentContent);
+ if (currentMedia!=null && currentMedia.getCount()>=1) {
+ SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+ mergeData.put("to_media", mediaList);
}
//content to html
if(currentContent.getValue("is_html").equals("0")){
} //end handle
abstract public void setAdditional(String key, TemplateModel value);
-}
\ No newline at end of file
+}
mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
// raus damit
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
catch (IOException e) {throw new ServletModuleException(e.toString());}
}
}
// raus damit
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
catch (IOException e) {throw new ServletModuleException(e.toString());}
catch(ModuleException e) {
theLog.printError("smod content :: attach :: could not get entityContent");
}
-
- try{
- DatabaseContentToMedia.getInstance().setMedia(idParam,mediaIdParam);
- } catch(Exception e){
- theLog.printError("set media failed");
- }
_showObject(idParam, req, res);
}
public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
{
- String idParam = req.getParameter("cid");
- if (idParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");
+ String cidParam = req.getParameter("cid");
+ String midParam = req.getParameter("mid");
+ if (cidParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");
+ if (midParam == null) throw new ServletModuleException("smod content :: dettach :: mid missing");
- //1-1-relation
- //schould be deleted soon
try {
- EntityContent entContent = (EntityContent)mainModule.getById(idParam);
- entContent.dettach();
+ EntityContent entContent = (EntityContent)mainModule.getById(cidParam);
+ entContent.dettach(cidParam,midParam);
}
catch(ModuleException e) {
theLog.printError("smod content :: dettach :: could not get entityContent");
}
-
- //1-n-relation
- try{
- DatabaseContentToMedia.getInstance().deleteByContentId(idParam);
- } catch(Exception e){
- theLog.printError("remove media failed");
- }
- _showObject(idParam, req, res);
+ _showObject(cidParam, req, res);
}
public void newswire(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
theLog.printError("language-popup could not be fetched.");
}
// get the images
- String currentMediaId = entContent.getValue("to_media");
- SimpleHash imageHash = new SimpleHash();
- if (currentMediaId!=null && !currentMediaId.equals("")) {
- imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
- mergeData.put("images", imageHash);
+ EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(entContent);
+ if (currentMedia!=null && currentMedia.getCount()>=1) {
+ SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+ mergeData.put("to_media", mediaList);
}
}
}
// raus damit
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
catch (IOException e) {throw new ServletModuleException(e.toString());}
mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
// raus damit
- HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
con = getPooledCon();
// should be a preparedStatement because is faster
stmt = con.createStatement();
- ResultSet rs = executeSql(stmt,sql);
+ int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set topics failed -- insert");
} finally {
}
}
-
+ public void addMedia(String contentId, String mediaId) {
+ if (contentId == null && mediaId == null) {
+ return;
+ }
+
+ Connection con=null;Statement stmt=null;
+ //now insert
+
+ String sql = "insert into "+ theTable +" (content_id,media_id) values ("
+ + contentId + "," + mediaId + ")";
+ try {
+ con = getPooledCon();
+ // should be a preparedStatement because is faster
+ stmt = con.createStatement();
+ int rs = executeUpdate(stmt,sql);
+ } catch (Exception e) {
+ theLog.printDebugInfo("-- add media failed -- insert");
+ } finally {
+ freeConnection(con,stmt);
+ }
+ }
+
public void setMedia(String contentId, String mediaId) {
if (contentId == null && mediaId == null) {
return;
con = getPooledCon();
// should be a preparedStatement because is faster
stmt = con.createStatement();
- ResultSet rs = executeSql(stmt,sql);
+ int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
//theLog.printDebugInfo("-- delete topics failed ");
} finally {
return;
}
//delete all row with content_id=contentId
- String sql = "delete from "+ theTable +" where topic_id=" + mediaId;
+ String sql = "delete from "+ theTable +" where media_id=" + mediaId;
Connection con=null;Statement stmt=null;
try {
con = getPooledCon();
// should be a preparedStatement because is faster
stmt = con.createStatement();
- ResultSet rs = executeSql(stmt,sql);
+ int rs = executeUpdate(stmt,sql);
theLog.printDebugInfo("-- delete media success ");
} catch (Exception e) {
theLog.printDebugInfo("-- delete media failed ");
freeConnection(con,stmt);
}
}
+
+ public void delete(String contentId, String mediaId) {
+ if (mediaId == null || contentId==null) {
+ theLog.printDebugInfo("-- delete media failed -- missing parameter");
+ return;
+ }
+ //delete all row with content_id=contentId and media_id=mediaId
+ String sql = "delete from "+ theTable +" where media_id=" + mediaId + " and content_id= "+contentId;
+
+ Connection con=null;Statement stmt=null;
+ try {
+ con = getPooledCon();
+ // should be a preparedStatement because is faster
+ stmt = con.createStatement();
+ int rs = executeUpdate(stmt,sql);
+ theLog.printDebugInfo("-- delete content_x_media success ");
+ } catch (Exception e) {
+ theLog.printDebugInfo("-- delete content_x_media failed ");
+ } finally {
+ freeConnection(con,stmt);
+ }
+ }
public EntityList getContent(EntityMedia media) {
}
return returnList;
}
+
+/**
+ * Returns a EntityList with all content-objects having a relation to a media
+ */
+
+public EntityList getContent() {
+ EntityList returnList=null;
+
+ String select = "select distinct content_id from " + theTable;
+ // execute select statement
+ Connection con=null;Statement stmt=null;
+ try {
+ con = getPooledCon();
+ // should be a preparedStatement because is faster
+ stmt = con.createStatement();
+ ResultSet rs = executeSql(stmt,select);
+ if (rs!=null) {
+ String mediaSelect= "id IN (";
+ boolean first=true;
+ while (rs.next()) {
+ if (first==false) mediaSelect+=",";
+ mediaSelect += rs.getString(1);
+ first=false;
+ }
+ mediaSelect+=")";
+ if (first==false)
+ returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,"webdb_lastchange desc");
+ }
+ }
+ catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+ finally { freeConnection(con,stmt);}
+
+ return returnList;
+ }
}
</tr>
<tr><td bgcolor="Pink" colspan="5">Attachments</td></tr>
-<!-- image stuff -->
-<if images[to_media] && images[to_media]["is_published"]=="1">
+<!-- image stuff -->
+<list to_media as m>
<tr>
<td align=right valign=top bgcolor="#aaaaaa">
<B><font color="#ffffff">Bilder:</B><br></td>
<td colspan="4" align="left" valign="top">
- <a href="${actionRoot}?module=Images&do=edit&id=${images[to_media]["id"]}"><img src="${actionRoot}?module=Images&do=showicon&id=${images[to_media]["id"]}" alt="edit image" border="0"></a>
- <a href="${actionRoot}?module=Content&do=dettach&cid=${id}">entfernen</a>
+ <a href="${actionRoot}?module=Images&do=edit&id=${m["id"]}"><img src="${actionRoot}?module=Images&do=showicon&id=${m["id"]}" alt="edit image" border="0"></a>
+ <a href="${actionRoot}?module=Content&do=dettach&cid=${id}&mid=${m["id"]}">entfernen</a>
</td>
</tr>
-<else>
+</list>
<tr>
<td align=right valign=top bgcolor="#aaaaaa">
<B><font color="#ffffff">Medien:</B><br></td>
<a href="${actionRoot}?module=Images&do=list&cid=${id}">bild hinzufügen</a>
</td>
</tr>
-</if>
-
</table>
</form>
<include "foot.template">
<b>OPENPOSTINGS</b></font>
<p>
- <a href="${actionRoot}?module=Content&do=listop&order=webdb_create+desc">
+ <a href="${actionRoot}${session}?module=Content&do=listop&order=webdb_create+desc">
<img src="${docRoot}/img/pointgris.gif" border=0>bearbeiten</a>
<p>
\r
<tr><td bgcolor="Pink" colspan="5">Attachments</td></tr>\r
<!-- image stuff -->\r
-<if images[to_media] && images[to_media]["is_published"]=="1">\r
-<tr>\r
- <td align=right valign=top bgcolor="#aaaaaa">\r
- <B><font color="#ffffff">Bilder:</B><br></td>\r
- <td colspan="4" align="left" valign="top">\r
- <a href="${actionRoot}?module=Images&do=edit&id=${images[to_media]["id"]}"><img src="${actionRoot}?module=Images&do=showicon&id=${images[to_media]["id"]}" alt="edit image" border="0"></a>\r
- <a href="${actionRoot}?module=Content&do=dettach&cid=${id}">entfernen</a>\r
- </td>\r
-</tr>\r
-<else>\r
-<tr>\r
- <td align=right valign=top bgcolor="#aaaaaa">\r
- <B><font color="#ffffff">media:</B><br></td>\r
- <td colspan="4" align="left" valign="top">\r
- <a href="${actionRoot}?module=Images&do=list&cid=${id}">add picture</a>\r
- </td>\r
-</tr>\r
-</if>\r
+<list to_media as m>
+<tr>
+ <td align=right valign=top bgcolor="#aaaaaa">
+ <B><font color="#ffffff">Images:</B><br></td>
+ <td colspan="4" align="left" valign="top">
+ <a href="${actionRoot}?module=Images&do=edit&id=${m["id"]}"><img src="${actionRoot}?module=Images&do=showicon&id=${m["id"]}" alt="edit image" border="0"></a>
+ <a href="${actionRoot}?module=Content&do=dettach&cid=${id}&mid=${m["id"]}">delete</a>
+ </td>
+</tr>
+</list>
+<tr>
+ <td align=right valign=top bgcolor="#aaaaaa">
+ <B><font color="#ffffff">Medien:</B><br></td>
+ <td colspan="4" align="left" valign="top">
+ <a href="${actionRoot}?module=Images&do=list&cid=${id}">add image</a>
+ </td>
+</tr>
\r
</table>\r
</form>\r
<p><font size="+1">${title}</font></p>
- <p><font size="-1"><b>${description}</b></font></p>\r
- <if images[to_media]&&images[to_media]["is_published"]=="1">\r
- <img src="${imageHost}${images[to_media]["id"]}.jpg" width="${images[to_media]["img_width"]}" height="${images[to_media]["img_height"]}" alt="${images[to_media]["description"]}"><br>\r
- </if>\r
+ <p><font size="-1"><b>${description}</b></font></p>
+ <list to_media as m>\r
+ <if m&&m["is_published"]=="1">\r
+ <img src="${imageHost}${m["id"]}.jpg" width="${m["img_width"]}" height="${m["img_height"]}" alt="${m["description"]}"><br>\r
+ </if>
+ </list>\r
\r
<p><font size="-1">\r
${content_data}\r