From: zapata Date: Mon, 28 Apr 2003 00:44:05 +0000 (+0000) Subject: multiple file-editable directories X-Git-Tag: BEFORE_MERGE_1_1~138 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=da98183e311156246d826104eb4af70ec24c6273;hp=f0f8f85e69c74d10a86f3c0f7ec6e70b6abd72ff;p=mir.git multiple file-editable directories deletions can be turned off small bugfixes --- diff --git a/bundles/admin_de.properties b/bundles/admin_de.properties index fda0df09..b92a927f 100755 --- a/bundles/admin_de.properties +++ b/bundles/admin_de.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: deutsch / german -# $Id: admin_de.properties,v 1.28 2003/04/26 23:20:24 zapata Exp $ +# $Id: admin_de.properties,v 1.29 2003/04/28 00:44:05 zapata Exp $ languagename=Deutsch @@ -322,7 +322,7 @@ start.breaking.title=breaking news start.content.title=ARTIKEL start.administer.title=AUFRÄUMEN start.list.title=LIST -start.fileedit.title=Includes editieren +start.fileedit.includes.title=Includes editieren start.addandedit.title=NEU / ÄNDERN start.extra.title=EXTRA start.search.title=SUCHEN diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index caa631c1..ad25f776 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: english -# $Id: admin_en.properties,v 1.45 2003/04/26 23:20:24 zapata Exp $ +# $Id: admin_en.properties,v 1.46 2003/04/28 00:44:05 zapata Exp $ languagename=English @@ -308,7 +308,7 @@ start.breaking.title=breaking news start.content.title=ARTICLES start.administer.title=ADMINISTER start.list.title=LIST -start.fileedit.title=edit include files +start.fileedit.includes.title=edit include files start.addandedit.title=ADD / EDIT start.extra.title=EXTRA start.search.title=SEARCH diff --git a/bundles/admin_es.properties b/bundles/admin_es.properties index e3832328..569eab03 100755 --- a/bundles/admin_es.properties +++ b/bundles/admin_es.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: spanish -# $Id: admin_es.properties,v 1.26 2003/04/26 23:20:24 zapata Exp $ +# $Id: admin_es.properties,v 1.27 2003/04/28 00:44:05 zapata Exp $ languagename = Castellano @@ -326,7 +326,7 @@ start.breaking.title = \u00faltimas noticias start.content.title = ART\u00cdCULOS start.administer.title = ADMINISTRAR start.list.title = LISTA -start.fileedit.title = editar ficheros +start.fileedit.includes.title = editar ficheros start.addandedit.title = A\u00d1ADIR / EDITAR start.extra.title = EXTRA start.search.title = BUSCAR diff --git a/bundles/admin_eu.properties b/bundles/admin_eu.properties index b8011bd9..0c316742 100755 --- a/bundles/admin_eu.properties +++ b/bundles/admin_eu.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: euskera / basque -# $Id: admin_eu.properties,v 1.10 2003/04/26 23:20:24 zapata Exp $ +# $Id: admin_eu.properties,v 1.11 2003/04/28 00:44:05 zapata Exp $ languagename = Euskera @@ -392,7 +392,7 @@ start.administer.title = # missing (master value = "LIST") start.list.title = # missing (master value = "edit include files") -start.fileedit.title = +start.fileedit.includes.title = # missing (master value = "ADD / EDIT") start.addandedit.title = # missing (master value = "EXTRA") diff --git a/bundles/admin_fr.properties b/bundles/admin_fr.properties index 1e24d626..fd8d54fe 100755 --- a/bundles/admin_fr.properties +++ b/bundles/admin_fr.properties @@ -320,7 +320,7 @@ start.breaking.title = DERNI\u00c8RES NOUVELLES start.content.title = ARTICLES start.administer.title = ADMINISTRER start.list.title = LISTES -start.fileedit.title = \u00c9diter les fichiers include (.inc) +start.fileedit.includes.title = \u00c9diter les fichiers include (.inc) start.addandedit.title = AJOUTER / EDITER start.extra.title = EXTRA start.search.title = CHERCHER diff --git a/bundles/admin_nl.properties b/bundles/admin_nl.properties index 924b2204..d4ec235a 100755 --- a/bundles/admin_nl.properties +++ b/bundles/admin_nl.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: dutch -# $Id: admin_nl.properties,v 1.6 2003/04/26 23:20:24 zapata Exp $ +# $Id: admin_nl.properties,v 1.7 2003/04/28 00:44:05 zapata Exp $ languagename = Nederlands @@ -324,7 +324,7 @@ start.breaking.title = Breaking news start.content.title = Artikelen start.administer.title = OPRUIMEN start.list.title = LIJST -start.fileedit.title = Include bestanden bewerken +start.fileedit.includes.title = Include bestanden bewerken start.addandedit.title = VOEG TOE / BEWERK start.extra.title = EXTRA start.search.title = ZOEKEN diff --git a/bundles/admin_tr.properties b/bundles/admin_tr.properties index a2ca84a7..57b228bc 100755 --- a/bundles/admin_tr.properties +++ b/bundles/admin_tr.properties @@ -1,5 +1,5 @@ ########## admin ########## -# $Id: admin_tr.properties,v 1.10 2003/04/09 02:06:06 zapata Exp $ +# $Id: admin_tr.properties,v 1.11 2003/04/28 00:44:05 zapata Exp $ languagename = T\u00fcrk\u00e7e @@ -409,7 +409,7 @@ start.administer.title = # missing (master value = "LIST") start.list.title = # missing (master value = "edit include files") -start.fileedit.title = +start.fileedit.includes.title = # missing (master value = "ADD / EDIT") start.addandedit.title = # missing (master value = "EXTRA") diff --git a/source/Mir.java b/source/Mir.java index 4f904451..01af8f37 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -63,7 +63,7 @@ import mircoders.entity.EntityUsers; import mircoders.global.MirGlobal; import mircoders.module.ModuleMessage; import mircoders.module.ModuleUsers; -import mircoders.servlet.ServletHelper; +import mircoders.servlet.*; import mircoders.storage.DatabaseUsers; import org.apache.struts.util.MessageResources; @@ -79,8 +79,8 @@ import freemarker.template.TemplateModel; /** * Mir.java - main servlet, that dispatches to servletmodules * - * @author $Author: idfx $ - * @version $Id: Mir.java,v 1.45 2003/04/21 12:42:46 idfx Exp $ + * @author $Author: zapata $ + * @version $Id: Mir.java,v 1.46 2003/04/28 00:44:05 zapata Exp $ * */ public class Mir extends AbstractServlet { @@ -462,6 +462,9 @@ public class Mir extends AbstractServlet { new CachingRewindableIterator( new EntityIteratorAdapter( "", "webdb_create desc", 10, MirGlobal.localizer().dataModel().adapterModel(), "internalMessage", 10, 0))); + + mergeData.put("fileeditentries", ((ServletModuleFileEdit) ServletModuleFileEdit.getInstance()).getEntries()); + mergeData.put("searchvalue", null); mergeData.put("searchfield", null); mergeData.put("searchispublished", null); diff --git a/source/default.properties b/source/default.properties index e4d232ce..c4882154 100755 --- a/source/default.properties +++ b/source/default.properties @@ -103,6 +103,10 @@ Mir.Localizer.Admin.TopicListColumns=3 # In which order should the topic appear? Mir.Localizer.Admin.TopicListOrder=title +# enable deletion of comments/articles? +Mir.Localizer.Admin.AllowDeleteComment=1 +Mir.Localizer.Admin.AllowDeleteArticle=1 + # Which producers need to be called after an article (resp. a comment) is posted Mir.Localizer.OpenPosting.ContentProducers= media.new;articles.changed;startpage.generate;synchronization.run Mir.Localizer.OpenPosting.CommentProducers= articles.changed;synchronization.run @@ -143,12 +147,13 @@ Producer.ProductionHost=http://indy.code-fu.de # the generated HTML pages will be stored Producer.StorageRoot=/pub/Dokumente/Indymedia/de-tech/Mir/produced -# for FileEdit module -# -# where do we find the files? absolute path -ServletModule.FileEdit.FileDirectory=/pub/Dokumente/Indymedia/de-tech/Mir/produced -ServletModule.FileEdit.ExtFilter=.*\.inc$ -ServletModule.FileEdit.Recursive=0 +# FileEdit module +# a list of directories to edit +# format: +# :::<0|1 (recursion off or on)> [, ....] + +ServletModule.FileEdit.Configuration= \ + includes:/pub/Dokumente/Indymedia/de-tech/Mir/produced:.*\\.inc:1 # # diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java index 594ba234..0a09ffb4 100755 --- a/source/mir/storage/Database.java +++ b/source/mir/storage/Database.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.storage; @@ -76,7 +76,7 @@ import freemarker.template.SimpleList; * Treiber, Host, User und Passwort, ueber den der Zugriff auf die * Datenbank erfolgt. * - * @version $Id: Database.java,v 1.39 2003/04/21 12:42:47 idfx Exp $ + * @version $Id: Database.java,v 1.40 2003/04/28 00:44:06 zapata Exp $ * @author rk * */ @@ -1280,7 +1280,7 @@ public class Database implements StorageObject { logger.debug((System.currentTimeMillis() - startTime) + "ms. for: " + sql); } catch (SQLException e) { - logger.debug("Failed: " + (System.currentTimeMillis() - startTime) + "ms. for: " + sql); + logger.error("Failed: " + (System.currentTimeMillis() - startTime) + "ms. for: " + sql); throw e; } diff --git a/source/mir/util/FileFunctions.java b/source/mir/util/FileFunctions.java index 862145d9..4df80588 100755 --- a/source/mir/util/FileFunctions.java +++ b/source/mir/util/FileFunctions.java @@ -18,24 +18,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.util; -import gnu.regexp.RE; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Vector; + +import gnu.regexp.RE; public class FileFunctions { protected static final int FILE_COPY_BUFFER_SIZE = 65536; @@ -135,4 +138,13 @@ public class FileFunctions { } + public static List getDirectoryContentsAsList(File aDirectory, FilenameFilter aFilter) { + Object[] contents = aDirectory.list(aFilter); + if (contents==null) + return new Vector(); + else + return Arrays.asList(contents); + } + + } \ No newline at end of file diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java index 89ad6ae4..c9c288f7 100755 --- a/source/mircoders/servlet/ServletModuleComment.java +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -35,7 +35,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -46,6 +45,7 @@ import mir.log.LoggerWrapper; import mir.servlet.ServletModule; import mir.servlet.ServletModuleExc; import mir.servlet.ServletModuleFailure; +import mir.servlet.ServletModuleUserExc; import mir.util.CachingRewindableIterator; import mir.util.HTTPRequestParser; import mir.util.JDBCStringRoutines; @@ -88,6 +88,13 @@ public class ServletModuleComment extends ServletModule } } + public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure { + if (!configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1")) + throw new ServletModuleExc("Operation not permitted"); + + super.delete(req, res); + } + public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc { String idParam = req.getParameter("id"); diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index cfc02e73..01e6abea 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -71,7 +71,7 @@ import freemarker.template.SimpleHash; * ServletModuleContent - * deliver html for the article admin form. * - * @version $Id: ServletModuleContent.java,v 1.50 2003/04/21 12:42:51 idfx Exp $ + * @version $Id: ServletModuleContent.java,v 1.51 2003/04/28 00:44:06 zapata Exp $ * @author rk, mir-coders * */ @@ -202,6 +202,9 @@ public class ServletModuleContent extends ServletModule public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc { + if (!configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1")) + throw new ServletModuleExc("Operation not permitted"); + EntityUsers user = _getUser(req); String idParam = req.getParameter("id"); diff --git a/source/mircoders/servlet/ServletModuleFileEdit.java b/source/mircoders/servlet/ServletModuleFileEdit.java index 2fef2b9b..63218edc 100755 --- a/source/mircoders/servlet/ServletModuleFileEdit.java +++ b/source/mircoders/servlet/ServletModuleFileEdit.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -36,12 +36,11 @@ import java.io.FileWriter; import java.io.FilenameFilter; import java.io.StringReader; import java.io.StringWriter; -import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Vector; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -51,6 +50,7 @@ import mir.servlet.ServletModuleExc; import mir.servlet.ServletModuleFailure; import mir.util.FileFunctions; import mir.util.HTTPRequestParser; +import mir.util.StringRoutines; import mir.util.URLBuilder; /* @@ -58,8 +58,8 @@ import mir.util.URLBuilder; * Allows one to do a basic edit of a file in a directory specified * in the config file. * - * @author $Author: idfx $ - * @version $Revision: 1.10 $ $Date: 2003/04/21 12:42:51 $ + * @author $Author: zapata $ + * @version $Revision: 1.11 $ $Date: 2003/04/28 00:44:06 $ * */ @@ -68,20 +68,79 @@ public class ServletModuleFileEdit extends ServletModule private static ServletModuleFileEdit instance = new ServletModuleFileEdit(); public static ServletModule getInstance() { return instance; } - private File rootDirectory; - private FilenameFilter filter; + private Map directories; + private List directoryNames; + private FilenameFilter dirFilter; - private boolean recurse; + + private class FileEditDirectory { + private String name; + private FileFunctions.RegExpFileFilter filter; + private File rootDirectory; + private boolean recursive; + + public FileEditDirectory(String aName, String aRootDirectory, String aFilter, boolean aRecursive) { + name = aName; + rootDirectory = new File(aRootDirectory); + filter = new FileFunctions.RegExpFileFilter(aFilter); + recursive = aRecursive; + } + + public String getName() { + return name; + } + + public FileFunctions.RegExpFileFilter getFilter() { + return filter; + } + + public File getRootDirectory() { + return rootDirectory; + } + + public boolean getRecursive() { + return recursive; + } + } private ServletModuleFileEdit() { super(); logger = new LoggerWrapper("ServletModule.FileEdit"); - rootDirectory = new File(configuration.getString("ServletModule.FileEdit.FileDirectory")); - recurse = configuration.getString("ServletModule.FileEdit.Recursive", "").equals("1"); + directories = new HashMap(); + directoryNames = new Vector(); + + String settings[] = configuration.getStringArray("ServletModule.FileEdit.Configuration"); +/* +ServletModule.FileEdit.FileDirectory=/pub/Dokumente/Indymedia/de-tech/Mir/produced +ServletModule.FileEdit.ExtFilter=.*\.inc$ +ServletModule.FileEdit.Recursive=0 +*/ + + if (settings!=null) { + for (int i = 0; i < settings.length; i++) { + String setting = settings[i].trim(); + + if (setting.length() > 0) { + List parts = StringRoutines.splitString(setting, ":"); + if (parts.size() != 4) { + logger.error("config error: " + settings[i] + ", 4 parts expected"); + } + else { + String name = (String) parts.get(0); + String directory = (String) parts.get(1); + String filter = (String) parts.get(2); + String recursive = (String) parts.get(3); + + directories.put(name, new FileEditDirectory(name, directory, filter, + recursive.equals("1") || recursive.toLowerCase().equals("y"))); + directoryNames.add(name); + } + } + } + } - filter = new FileFunctions.RegExpFileFilter(configuration.getString("ServletModule.FileEdit.ExtFilter")); dirFilter = new FileFunctions.DirectoryFilter(); templateListString =configuration.getString("ServletModule.FileEdit.ListTemplate"); @@ -89,22 +148,35 @@ public class ServletModuleFileEdit extends ServletModule templateConfirmString =configuration.getString("ServletModule.FileEdit.ConfirmTemplate"); } + public List getEntries() { + return directoryNames; + } + + public FileEditDirectory getDirectory(HttpServletRequest aRequest) throws ServletModuleExc { + FileEditDirectory result = (FileEditDirectory) directories.get(aRequest.getParameter("entry")); + if (result == null) + throw new ServletModuleExc("Unknown entry: " + aRequest.getParameter("entry")); + + return result; + } + public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { - listSubDirectory("/", aRequest, aResponse); + listSubDirectory(getDirectory(aRequest), "/", aRequest, aResponse); } public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { try { HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); + String filename = requestParser.getParameter("filename"); String subDirectory = requestParser.getParameterWithDefault("subdirectory", ""); if (filename == null) throw new ServletModuleExc("No filename specified"); - editFile(filename, subDirectory, aRequest, aResponse); + editFile(getDirectory(aRequest), filename, subDirectory, aRequest, aResponse); } catch (Throwable e) { throw new ServletModuleFailure(e); @@ -115,28 +187,32 @@ public class ServletModuleFileEdit extends ServletModule { try { HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); + String directoryName = requestParser.getParameter("directory"); String subDirectoryName = requestParser.getParameter("subdirectory"); if (directoryName==null | subDirectoryName==null) throw new ServletModuleExc("No directory/subDirectory specified"); - listSubDirectory(subDirectoryName+File.separator+directoryName, aRequest, aResponse); + listSubDirectory(getDirectory(aRequest), subDirectoryName+File.separator+directoryName, aRequest, aResponse); } catch (Throwable e) { throw new ServletModuleFailure(e); } } + public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { - String filename = aRequest.getParameter("filename"); - String subDirectory = aRequest.getParameter("subdirectory"); - String text = aRequest.getParameter("text"); + HTTPRequestParser requestParser = new HTTPRequestParser(aRequest); + String filename = requestParser.getParameter("filename"); + String subDirectory = requestParser.getParameter("subdirectory"); + String text = requestParser.getParameter("text"); + FileEditDirectory directory = getDirectory(aRequest); try { - File f = new File(new File(rootDirectory, subDirectory), filename); + File f = new File(new File(directory.getRootDirectory(), subDirectory), filename); - if (validateDirectory(f)) { + if (validateDirectory(directory, f)) { StringReader in = new StringReader(text); FileWriter out = new FileWriter(f); @@ -146,7 +222,7 @@ public class ServletModuleFileEdit extends ServletModule in.close(); out.close(); - editFile(filename, subDirectory, aRequest, aResponse); + editFile(directory, filename, subDirectory, aRequest, aResponse); } } catch (Throwable e) { @@ -154,25 +230,25 @@ public class ServletModuleFileEdit extends ServletModule } } - public void listSubDirectory(String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc + public void listSubDirectory(FileEditDirectory aDirectory, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { try { Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); - File dir = new File(rootDirectory, aSubDirectory); + File dir = new File(aDirectory.getRootDirectory(), aSubDirectory); - if (!validateDirectory(dir) || !dir.isDirectory()) { - dir = rootDirectory; + if (!validateDirectory(aDirectory, dir) || !dir.isDirectory()) { + dir = aDirectory.getRootDirectory(); aSubDirectory = ""; } - responseData.put("filelist", Arrays.asList(dir.list(filter))); + responseData.put("filelist", FileFunctions.getDirectoryContentsAsList(dir, aDirectory.getFilter())); - if (recurse) { + if (aDirectory.getRecursive()) { List dirs = new Vector(); - if (!dir.getCanonicalPath().equals(rootDirectory.getCanonicalPath())) + if (!dir.getCanonicalPath().equals(aDirectory.getRootDirectory().getCanonicalPath())) responseData.put("updir", new File(aSubDirectory).getParent()); - dirs.addAll(Arrays.asList(dir.list(dirFilter))); + dirs.addAll(FileFunctions.getDirectoryContentsAsList(dir, dirFilter)); responseData.put("dirlist", dirs); } @@ -182,6 +258,7 @@ public class ServletModuleFileEdit extends ServletModule } responseData.put("subdirectory", aSubDirectory); + responseData.put("entry", aDirectory.getName()); ServletHelper.generateResponse(aResponse.getWriter(), responseData, templateListString); } @@ -190,13 +267,13 @@ public class ServletModuleFileEdit extends ServletModule } } - public void editFile(String aFileName, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc + public void editFile(FileEditDirectory aDirectory, String aFileName, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc { try { - File f = new File(new File(rootDirectory, aSubDirectory), aFileName); + File f = new File(new File(aDirectory.getRootDirectory(), aSubDirectory), aFileName); - if (!validateDirectory(f) || f.isDirectory() || !validateFile(f)) { - listSubDirectory("", aRequest, aResponse); + if (!validateDirectory(aDirectory, f) || f.isDirectory() || !validateFile(aDirectory, f)) { + listSubDirectory(aDirectory, "", aRequest, aResponse); } else { Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}); @@ -204,6 +281,7 @@ public class ServletModuleFileEdit extends ServletModule urlBuilder.setValue("module", "FileEdit"); urlBuilder.setValue("do", "enter"); + urlBuilder.setValue("entry", aDirectory.getName()); urlBuilder.setValue("directory", ""); urlBuilder.setValue("subdirectory", aSubDirectory); @@ -216,6 +294,7 @@ public class ServletModuleFileEdit extends ServletModule in.close(); out.close(); + responseData.put("entry", aDirectory.getName()); responseData.put("text", out.toString()); responseData.put("filename", aFileName); responseData.put("subdirectory", aSubDirectory); @@ -229,18 +308,18 @@ public class ServletModuleFileEdit extends ServletModule } } - protected boolean validateDirectory(File aFile) { + protected boolean validateDirectory(FileEditDirectory aDirectory, File aFile) { try { - return (aFile.getCanonicalPath().startsWith(rootDirectory.getCanonicalPath())); + return (aFile.getCanonicalPath().startsWith(aDirectory.getRootDirectory().getCanonicalPath())); } catch (Throwable t) { return false; } } - protected boolean validateFile(File aFile) { + protected boolean validateFile(FileEditDirectory aDirectory, File aFile) { try { - return filter.accept(aFile.getParentFile(), aFile.getName()); + return aDirectory.getFilter().accept(aFile.getParentFile(), aFile.getName()); } catch (Throwable t) { return false; diff --git a/templates/admin/breakinglist.template b/templates/admin/breakinglist.template index fa9764b6..2c074688 100755 --- a/templates/admin/breakinglist.template +++ b/templates/admin/breakinglist.template @@ -34,7 +34,7 @@ -

${lang("no-matches_found")}

+

${lang("no_matches_found")}

diff --git a/templates/admin/commentlist.template b/templates/admin/commentlist.template index 33b73de1..3cba7fad 100755 --- a/templates/admin/commentlist.template +++ b/templates/admin/commentlist.template @@ -131,7 +131,7 @@ [ ${lang("edit")} - | + | ${lang("start.show")} | @@ -151,7 +151,8 @@ ${utility.encodeHTML(entry.description)}
URL: ${entry.main_url}
-

+
+ [ ${lang("comment.operation."+op)} ] @@ -172,12 +173,14 @@  |  ${lang("edit")} -
+   - [${lang("delete")}] + + [${lang("delete")}] + @@ -208,7 +211,7 @@ -

${lang("no-matches_found")}

+

${lang("no_matches_found")}

diff --git a/templates/admin/confirm.template b/templates/admin/confirm.template index 946cf263..4411e3c0 100755 --- a/templates/admin/confirm.template +++ b/templates/admin/confirm.template @@ -9,7 +9,7 @@
@@ -131,7 +133,7 @@ -

${lang("no-matches_found")}

+

${lang("no_matches_found")}

diff --git a/templates/admin/fileedit.template b/templates/admin/fileedit.template index 97cfada5..6317856e 100755 --- a/templates/admin/fileedit.template +++ b/templates/admin/fileedit.template @@ -18,6 +18,7 @@ +   diff --git a/templates/admin/fileeditlist.template b/templates/admin/fileeditlist.template index 3cd22d48..cfbac44a 100755 --- a/templates/admin/fileeditlist.template +++ b/templates/admin/fileeditlist.template @@ -8,82 +8,83 @@ -
-

${lang("confirm.really-delete")}

+

${lang("confirm.really_delete")}

diff --git a/templates/admin/contentlist.template b/templates/admin/contentlist.template index fb34ef00..52d2271b 100755 --- a/templates/admin/contentlist.template +++ b/templates/admin/contentlist.template @@ -104,7 +104,9 @@

- [${lang("delete")}] + + [${lang("delete")}] +
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
${lang("fileeditlist.dirname")} 
 .. ${lang("edit")}
${entry} ${lang("edit")}
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
${lang("fileeditlist.filename")} 
${entry} ${lang("edit")}
- -
- - -

- -

${lang("no-matches_found")}

- - - + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
${lang("fileeditlist.dirname")} 
 .. ${lang("edit")}
${item} ${lang("edit")}
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
${lang("fileeditlist.filename")} 
${item} ${lang("edit")}
+

${lang("no_matches_found")}

+
+
+ +

+ + + diff --git a/templates/admin/hiddenlist.template b/templates/admin/hiddenlist.template index da572552..537e0c36 100755 --- a/templates/admin/hiddenlist.template +++ b/templates/admin/hiddenlist.template @@ -102,7 +102,7 @@ -

${lang("no-matches_found")}
+
${lang("no_matches_found")}
diff --git a/templates/admin/imagelist.template b/templates/admin/imagelist.template index 8b1c66f5..08e99707 100755 --- a/templates/admin/imagelist.template +++ b/templates/admin/imagelist.template @@ -94,7 +94,7 @@ function openWin(url) { - ${lang("no-matches_found")} + ${lang("no_matches_found")} diff --git a/templates/admin/mediafolderlist.template b/templates/admin/mediafolderlist.template index 7cbe8bd8..e5e7efd0 100755 --- a/templates/admin/mediafolderlist.template +++ b/templates/admin/mediafolderlist.template @@ -43,7 +43,7 @@ ${lang("list.next")} -

${lang("no-matches_found")}

+

${lang("no_matches_found")}

diff --git a/templates/admin/start_admin.template b/templates/admin/start_admin.template index c285cbd3..3cd1c905 100755 --- a/templates/admin/start_admin.template +++ b/templates/admin/start_admin.template @@ -39,8 +39,11 @@

${lang("start.extra.title")}

- > ${lang("start.content.hidden")}
- > ${lang("start.fileedit.title")} + > ${lang("start.content.hidden")} + +
+ > ${lang("start.fileedit."+e+".title")} +