
net.sourceforge.openutils.mgnlmedia.media.dialog.DialogFileVideo Maven / Gradle / Ivy
/**
*
* SimpleMedia Module for Magnolia CMS (http://www.openmindlab.com/lab/products/media.html)
* Copyright(C) 2008-2012, Openmind S.r.l. http://www.openmindonline.it
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package net.sourceforge.openutils.mgnlmedia.media.dialog;
import info.magnolia.cms.beans.config.MIMEMapping;
import info.magnolia.cms.gui.control.File;
import info.magnolia.cms.gui.dialog.DialogFile;
import info.magnolia.cms.gui.misc.CssConstants;
import info.magnolia.cms.gui.misc.Spacer;
import java.io.IOException;
import java.io.Writer;
import javax.jcr.PropertyType;
import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager;
/**
* @author molaschi
* @version Id:
*/
public class DialogFileVideo extends DialogFile
{
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void initImageExtensions()
{
this.getImageExtensions().add("flv");
this.getImageExtensions().add("mp4");
this.getImageExtensions().add("m4v");
this.getImageExtensions().add("ogv");
}
/**
* {@inheritDoc}
*/
@Override
public void drawHtml(Writer out) throws IOException
{
File control = getFileControl();
control.setType(this.getConfigValue("type", PropertyType.TYPENAME_STRING)); //$NON-NLS-1$
control.setSaveInfo(false); // set manualy below
control.setCssClass(CssConstants.CSSCLASS_FILE);
control.setCssClassFileName(CssConstants.CSSCLASS_EDIT);
control.setCssStyles("width", this.getConfigValue("width", "100%")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.drawHtmlPre(out);
String width = this.getConfigValue("width", "100%"); //$NON-NLS-1$ //$NON-NLS-2$
final boolean preview = Boolean.valueOf(getConfigValue("preview", "true")).booleanValue();
final boolean extensionIsDisplayableImage = this.getImageExtensions().contains(
control.getExtension().toLowerCase());
final boolean showImage = extensionIsDisplayableImage && preview;
String htmlControlBrowse = control.getHtmlBrowse();
StringBuffer htmlControlFileName = new StringBuffer();
htmlControlFileName.append("" //$NON-NLS-1$
+ getMessage("dialog.file.filename") //$NON-NLS-1$
+ ""); //$NON-NLS-1$
htmlControlFileName.append(Spacer.getHtml(1, 1));
htmlControlFileName.append(control.getHtmlFileName() + "." //$NON-NLS-1$
+ control.getExtension()
+ ""); //$NON-NLS-1$
String htmlContentEmpty = htmlControlBrowse + Spacer.getHtml(0, 0) + htmlControlFileName;
out.write(""); //$NON-NLS-1$ //$NON-NLS-2$
boolean exists = false;
if (this.getStorageNode() != null)
{
exists = this.getStorageNode().getNodeData(this.getName()).isExist();
}
if (!exists)
{
out.write(htmlContentEmpty);
out.write(""); //$NON-NLS-1$
}
else
{
if (showImage)
{
out.write("\n"); //$NON-NLS-1$ //$NON-NLS-2$
out.write(""); //$NON-NLS-1$ //$NON-NLS-2$
if ("swf".equals(control.getExtension().toLowerCase()))
{
out.write("\nGet the Flash Player to see this player.");
out.write("");
out.write("\n");
out.write("\n");
}
else
{
out.write("\nGet the Flash Player to see this player.");
out.write("");
out.write("\n");
out.write("\n");
}
out.write(" "); //$NON-NLS-1$
}
out.write(htmlControlFileName.toString());
if (!showImage)
{
String iconPath = MIMEMapping.getMIMETypeIcon(control.getExtension());
out.write(Spacer.getHtml(0, 0));
out.write(""); //$NON-NLS-1$ //$NON-NLS-2$
out.write("
"); //$NON-NLS-1$
out.write(control.getFileName() + "." + control.getExtension() + ""); //$NON-NLS-1$ //$NON-NLS-2$
}
out.write(Spacer.getHtml(12, 12));
out.write(control.getHtmlRemove("mgnlDialogFileRemove('" + this.getName() + "');")); //$NON-NLS-1$ //$NON-NLS-2$
if (showImage)
{
out.write("
"); //$NON-NLS-1$
}
out.write("