package net.sourceforge.phpeclipse.wiki.actions.mediawiki;
+
//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
//http://www.djini.de/software/wikipedia/index.html
//
//with permission from the original author: Daniel Wunsch
import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.MediaWikiConnector;
import net.sourceforge.phpeclipse.wiki.editor.WikiEditor;
import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
private IWorkbenchWindow window;
-
-
public void dispose() {
}
- public String generateUrl(Configuration config, String template, String wikiname) {
+ public String generateUrl(IWikipedia wikipediaProperties, Configuration config, String template, String wikiname) {
/* first, we init the runtime engine. Defaults are fine. */
try {
Velocity.init();
+ if (template == null || template.equals("")) {
+ // fall back to default settings
+ // Example:
+ // http://en.wikipedia.org/w/index.php?title=$text.wikiname&action=raw
+ template = wikipediaProperties.getActionUrl() + "?title=$text.wikiname&action=raw";
+ }
+
/* lets make a Context and put data into it */
VelocityContext context = new VelocityContext();
return template;
}
- protected Configuration getConfiguration(){
+ protected Configuration getConfiguration() {
List allConfigsList = ConfigurationManager.getInstance().getConfigurations();
ArrayList configsList = new ArrayList();
for (int i = 0; i < allConfigsList.size(); i++) {
IConfiguration temp = (IConfiguration) allConfigsList.get(i);
- if (temp.getType().equals(WikiEditorPlugin.WIKIPEDIA_GET_TEXT)) {
+ if (temp.getType().startsWith(WikiEditorPlugin.PREFIX_LOAD)) {
configsList.add(temp);
}
}
action.setEnabled(window.getActivePage().getActivePart().getClass().equals(WikiEditor.class));
}
}
-
+
private void selectWiki(String wikiName) {
Configuration configuration = getConfiguration();
if (configuration != null && !configuration.equals("")) {
- String url = generateUrl(configuration, configuration.getURL(), wikiName);
- String wikiContent = MediaWikiConnector.getWikiRawText(wikiName, url);
- if (wikiContent != null) {
- IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
- doc.set(wikiContent);
+ try {
+ String wikiLocale = configuration.getType().substring(WikiEditorPlugin.PREFIX_LOAD.length());
+ IWikipedia wikipediaProperties = WikiEditorPlugin.getWikiInstance(wikiLocale);
+
+ String url = generateUrl(wikipediaProperties, configuration, configuration.getURL(), wikiName);
+ String wikiContent = MediaWikiConnector.getWikiRawText(wikiName, url);
+ if (wikiContent != null) {
+ IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ doc.set(wikiContent);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ WikiEditorPlugin.getDefault().reportError("Exception occured: ",
+ e.getMessage() + "\nSee stacktrace in /.metadata/.log file.");
}
}
}
ArrayList configsList = new ArrayList();
for (int i = 0; i < allConfigsList.size(); i++) {
IConfiguration temp = (IConfiguration) allConfigsList.get(i);
- if (temp.getType().equals(WikiEditorPlugin.WIKIPEDIA_GET_TEXT)) {
+ if (temp.getType().equals(WikiEditorPlugin.WIKIPEDIA_SQL)) {
configsList.add(temp);
}
}
public interface IWikipedia {
/**
+ * @return Returns the default actionUrl.
+ */
+ public String getActionUrl();
+ /**
* @return Returns the actionPath.
*/
public String getActionPath();
private ResourceBundle fgResourceBundle = null;
protected WikiProperties(String locale) {
- RESOURCE_BUNDLE = PACKAGE_NAME + ".WikiProperties" + locale;
+ RESOURCE_BUNDLE = PACKAGE_NAME + "." + locale;
fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
}
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+
+public class WikibooksDE extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] {
+ "Media",
+ "Spezial",
+ "",
+ "Diskussion",
+ "Benutzer",
+ "Benutzer Diskussion",
+ "Wikibooks",
+ "Wikibooks Diskussion",
+ "Bild",
+ "Bild Diskussion",
+ "MediaWiki",
+ "MediaWiki Diskussion",
+ "Vorlage",
+ "Vorlage Diskussion",
+ "Hilfe",
+ "Hilfe Diskussion",
+ "Kategorie",
+ "Kategorie Diskussion"
+ };
+ private static WikibooksDE instance = new WikibooksDE();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikibooksDE() {
+ super(new WikiProperties("WikibooksDE"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://de.wikibooks.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Spezial
+metaNs=Wikibooks
+loginSuccess=(?s).*?Sie sind jetzt als ".*?" bei .*? angemeldet.*
+loginWrongPw=(?s).*?Das Passwort ist falsch.*? Bitte versuchen Sie es erneut.*
+loginNoUser=(?s).*?Der Benutzername ".*?" existiert nicht.*?Überprüfen Sie die Schreibweise, oder melden Sie sich als neuer Benutzer an.*
+logoutSuccess=(?s).*?Sie sind nun abgemeldet.*?Sie können .*? jetzt anonym weiterbenutzen, oder sich unter dem selben oder einem anderen Benutzernamen wieder anmelden.*
+uploadSuccess=(?s).*?Erfolgreich hochgeladen.*
+uploadNoLogin=(?s).*?Sie müssen .*?angemeldet sein.*?um Dateien hochladen zu können.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikibooksEN extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Special", "", "Talk", "User", "User talk", "Wikibooks",
+ "Wikibooks talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk",
+ "Category", "Category talk" };
+
+ private static WikibooksEN instance = new WikibooksEN();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikibooksEN() {
+ super(new WikiProperties("WikibooksEN"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://en.wikibooks.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Special
+metaNs=Wikibooks
+loginSuccess=(?s).*?You are now logged in to .*? as ".*?".*
+loginWrongPw=(?s).*?The password you entered is incorrect.*? Please try again.*
+loginNoUser=(?s).*?There is no user by the name ".*?".*?Check your spelling, or use the form below to create a new user account.*
+logoutSuccess=(?s).*?You are now logged out.*?You can continue to use .*? anonymously, or you can log in.*?again as the same or as a different user.*? Note that some pages may.*?continue to be displayed as if you were still logged in, until you clear.*?your browser cache.*
+uploadSuccess=(?s).*?Successful upload.*
+uploadNoLogin=(?s).*?You must be .*?logged in.*?to upload files.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikinewsDE extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Spezial", "", "Diskussion", "Benutzer",
+ "Benutzer Diskussion", "Wikinews", "Wikinews Diskussion", "Bild", "Bild Diskussion", "MediaWiki", "MediaWiki Diskussion",
+ "Vorlage", "Vorlage Diskussion", "Hilfe", "Hilfe Diskussion", "Kategorie", "Kategorie Diskussion" };
+
+ private static WikinewsDE instance = new WikinewsDE();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikinewsDE() {
+ super(new WikiProperties("WikinewsDE"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://de.wikinews.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Spezial
+metaNs=Wikinews
+loginSuccess=(?s).*?Sie sind jetzt als ".*?" bei .*? angemeldet.*
+loginWrongPw=(?s).*?Das Passwort ist falsch.*? Bitte versuchen Sie es erneut.*
+loginNoUser=(?s).*?Der Benutzername ".*?" existiert nicht.*?Überprüfen Sie die Schreibweise, oder melden Sie sich als neuer Benutzer an.*
+logoutSuccess=(?s).*?Sie sind nun abgemeldet.*?Sie können .*? jetzt anonym weiterbenutzen, oder sich unter dem selben oder einem anderen Benutzernamen wieder anmelden.*
+uploadSuccess=(?s).*?Erfolgreich hochgeladen.*
+uploadNoLogin=(?s).*?Sie müssen .*?angemeldet sein.*?um Dateien hochladen zu können.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikinewsEN extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Special", "", "Talk", "User", "User talk", "Wikinews",
+ "Wikinews talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk",
+ "Category", "Category talk" };
+
+ private static WikinewsEN instance = new WikinewsEN();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikinewsEN() {
+ super(new WikiProperties("WikinewsEN"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://en.wikinews.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Special
+metaNs=Wikinews
+loginSuccess=(?s).*?You are now logged in to .*? as ".*?".*
+loginWrongPw=(?s).*?The password you entered is incorrect.*? Please try again.*
+loginNoUser=(?s).*?There is no user by the name ".*?".*?Check your spelling, or use the form below to create a new user account.*
+logoutSuccess=(?s).*?You are now logged out.*?You can continue to use .*? anonymously, or you can log in.*?again as the same or as a different user.*? Note that some pages may.*?continue to be displayed as if you were still logged in, until you clear.*?your browser cache.*
+uploadSuccess=(?s).*?Successful upload.*
+uploadNoLogin=(?s).*?You must be .*?logged in.*?to upload files.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaAR extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "ملف", "خاص", "", "نقاش", "مستخدم", "نقاش المستخدم", "ويكيبيديا",
+ "نقاش ويكيبيديا", "صورة", "نقاش الصورة", "ميدياويكي", "نقاش ميدياويكي", "Template", "نقاش Template", "مساعدة",
+ "نقاش المساعدة", "تصنيف", "نقاش التصنيف" };
+
+ private static WikipediaAR instance = new WikipediaAR();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaAR() {
+ super(new WikiProperties("WikipediaAR"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://ar.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=%D8%AE%D8%A7%D8%B5
+metaNs=Wikipedia
+loginSuccess=(?s).*???? ??? ?????? ?????? ?????????? ???? ".*?".*
+loginWrongPw=(?s).*????? ???? ???? ??????? ??? ?????? ???? ????? ????????.*
+loginNoUser=(?s).*??? ???? ?????? ?????? ".*?".*????? ?? ????? ?????? ?? ?????? ??????? ??????? ?? ?????? ?????? ?????? ????.*
+logoutSuccess=(?s).*???? ???? ??? ???? ?????? ??????.*??????? ???????? ???????? ????????? ??????? ?? ?????? ??? ???? ???? ????? ?? ???? ???.*? ?? ?????? ?? ??? ??? ??????? ?? ???????? ??? ???? ???? ?? ??????.*?? ???? ???? ??????? ??????? ??????? Cache ?? ???????? ????.*
+uploadSuccess=(?s).*?????? ????? ?????.*
+uploadNoLogin=(?s).*???? ?? ???? .*?????? ??????.*??????? ?? ????? ???????.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaCA extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Especial", "", "Discussió", "Usuari", "Usuari Discussió",
+ "Wikipedia", "Wikipedia Discussió", "Imatge", "Imatge Discussió", "MediaWiki", "MediaWiki Discussió", "Template",
+ "Template Discussió", "Ajuda", "Ajuda Discussió", "Categoria", "Categoria Discussió" };
+
+ private static WikipediaCA instance = new WikipediaCA();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaCA() {
+ super(new WikiProperties("WikipediaCA"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://ca.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Especial
+metaNs=Wikipedia
+loginSuccess=(?s).*?Heu iniciat la sessió a .*? com a ".*?".*
+loginWrongPw=(?s).*?La contrasenya que heu ingressat és incorrecta.*? Torneu-ho a provar.*
+loginNoUser=(?s).*?No hi ha cap usuari amb el nom ".*?".*?Reviseu-ne l'ortografia, o empreu el formulari d'avall per crear un nou compte d'usuari.*
+logoutSuccess=(?s).*?Heu acabat la vostra sessió.*?Podeu continuar emprant la .*? de forma anònima, o podeu.*?iniciar sessió un altre cop amb el mateix o un altre nom d'usuari.*
+uploadSuccess=(?s).*?L'arxiu s'ha carregat amb èxit.*
+uploadNoLogin=(?s).*?Deveu haver .*?entrat.*?per carregar arxius.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaDA extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Speciel", "", "Diskussion", "Bruger", "Bruger diskussion",
+ "Wikipedia", "Wikipedia diskussion", "Billede", "Billede diskussion", "MediaWiki", "MediaWiki diskussion", "Skabelon",
+ "Skabelon diskussion", "Hjælp", "Hjælp diskussion", "Kategori", "Kategori diskussion" };
+
+ private static WikipediaDA instance = new WikipediaDA();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaDA() {
+ super(new WikiProperties("WikipediaDA"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://da.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=ISO-8859-1
+specialNs=Speciel
+metaNs=Wikipedia
+loginSuccess=(?s).*?Du er nu logget på .*? som ".*?".*
+loginWrongPw=(?s).*?Den indtastede adgangskode var forkert.*? Prøv igen.*
+loginNoUser=(?s).*?Der er ingen bruger med navnet ".*?".*?Kontrollér stavemåden igen, eller brug formularen herunder til at oprette en ny brugerkonto.*
+logoutSuccess=(?s).*?Du er nu logget af.*?Du kan fortsætte med at bruge .*? anonymt, eller du kan logge på.*?igen som den samme eller en anden bruger.*
+uploadSuccess=(?s).*?Oplægning er gennemført med succes.*
+uploadNoLogin=(?s).*?Du skal være .*? for at kunne lægge filer op.*
private static WikipediaDE instance = new WikipediaDE();
- /*
+ /**
* Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
*/
public static IWikipedia getInstance() {
return instance;
// private constructor
private WikipediaDE() {
- super(new WikiProperties("DE"));
+ super(new WikiProperties("WikipediaDE"));
}
/**
metaNs=Wikipedia
loginSuccess=(?s).*?Du bist jetzt als ".*?" bei Wikipedia angemeldet.*
loginWrongPw=(?s).*?Das Passwort ist falsch.*? Bitte versuche es erneut.*
-loginNoUser=(?s).*?Der Benutzername \".*?\" existiert nicht.*?Überprüfen Sie die Schreibweise, oder melden Sie sich als neuer Benutzer an.*
+loginNoUser=(?s).*?Der Benutzername ".*?" existiert nicht.*?Überprüfen Sie die Schreibweise, oder melden Sie sich als neuer Benutzer an.*
logoutSuccess=(?s).*?Du bist nun abgemeldet.*?Du kannst die Wikipedia jetzt weiter mit deiner IP-Adresse benutzen, oder dich unter demselben oder einem anderen Benutzernamen wieder anmelden.*
uploadSuccess=(?s).*?Erfolgreich hochgeladen.*
uploadNoLogin=(?s).*?Sie müssen .*?angemeldet sein.*?um Dateien hochladen zu können.*
private static WikipediaEN instance = new WikipediaEN();
- /*
+ /**
* Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
*/
public static IWikipedia getInstance() {
return instance;
// private constructor
private WikipediaEN() {
- super(new WikiProperties("EN"));
+ super(new WikiProperties("WikipediaEN"));
}
/**
metaNs=Wikipedia
loginSuccess=(?s).*?You are now logged in to .*? as ".*?".*
loginWrongPw=(?s).*?The password you entered is incorrect.*? Please try again.*
-loginNoUser=(?s).*?There is no user by the name \".*?\".*?Check your spelling, or use the form below to create a new user account.*? If there is no form below, account creation is temporarily disabled.*? In this case, please accept our apologies and try again later.*
+loginNoUser=(?s).*?There is no user by the name ".*?".*?Check your spelling, or use the form below to create a new user account.*? If there is no form below, account creation is temporarily disabled.*? In this case, please accept our apologies and try again later.*
logoutSuccess=(?s).*?You are now logged out.*? This computer may be used to browse and edit Wikipedia without a user name, or for another user to log on.*? Note that some pages may continue to be displayed as if you were still logged in; this can be fixed by clearing your browser cache.*
uploadSuccess=(?s).*?Successful upload.*
uploadNoLogin=(?s).*?You must be .*?logged in.*?to upload files.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaEO extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Speciala", "", "Diskuto", "Vikipediisto",
+ "Vikipediista diskuto", "Vikipedio", "Wikipedia diskuto", "Dosiero", "Dosiera diskuto", "MediaWiki", "MediaWiki diskuto",
+ "Ŝablono", "Ŝablona diskuto", "Helpo", "Helpa diskuto", "Kategorio", "Kategoria diskuto" };
+
+ private static WikipediaEO instance = new WikipediaEO();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaEO() {
+ super(new WikiProperties("WikipediaEO"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://eo.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Speciala
+metaNs=Wikipedia
+loginSuccess=(?s).*?Vi nun estas en la .*? kiel uzulo ".*?".*
+loginWrongPw=(?s).*?Vi tajpis mal?ustan pasvorton.*? Bonvolu provi denove.*
+loginNoUser=(?s).*?Neniu uzulo nomi?as ".*?".*?Bonvolu kontroli vian literumadon, a? uzu la malsupran formularon por krei novan konton.*
+logoutSuccess=(?s).*?Vi elsalutis kaj finis vian seancon.*?Vi rajtas da?re Vikipediumi sennome, a? vi povas reensaluti.*?kiel la sama a? kiel alia uzulo.*
+uploadSuccess=(?s).*?Al?uto sukcesis!.*
+uploadNoLogin=(?s).*?Se vi volas al?uti dosierojn, vi devas .*?ensaluti.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaES extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Especial", "", "Discusión", "Usuario", "Usuario Discusión",
+ "Wikipedia", "Wikipedia Discusión", "Imagen", "Imagen Discusión", "MediaWiki", "MediaWiki Discusión", "Plantilla",
+ "Plantilla Discusión", "Ayuda", "Ayuda Discusión", "Categoría", "Categoría Discusión" };
+
+ private static WikipediaES instance = new WikipediaES();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaES() {
+ super(new WikiProperties("WikipediaES"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://es.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Especial
+metaNs=Wikipedia
+loginSuccess=(?s).*?Has iniciado tu sesión en Wikipedia como ".*?".*
+loginWrongPw=(?s).*?La contraseña que ingresaste es incorrecta.*? Por favor inténtalo de nuevo.*
+loginNoUser=(?s).*?No existe ningún usuario llamado ".*?".*?Asegúrate de que lo has escrito correctamente, o usa el formulario de abajo para crear una nueva cuenta de usuario.*
+logoutSuccess=(?s).*?Has terminado tu sesión.*?Puedes continuar usando Wikipedia en forma anónima, o puedes.*?iniciar sesión otra vez como el mismo u otro usuario.*
+uploadSuccess=(?s).*?Subida exitosa.*
+uploadNoLogin=(?s).*?Tienes que .*?iniciar sesión.*?para subir archivos.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaET extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] { "Media", "Eri", "", "Arutelu", "Kasutaja", "Kasutaja arutelu",
+ "Wikipedia", "Wikipedia arutelu", "Pilt", "Pildi arutelu", "MediaWiki", "MediaWiki arutelu", "Template", "Template talk",
+ "Help", "Help talk", "Category", "Category talk" };
+
+ private static WikipediaET instance = new WikipediaET();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaET() {
+ super(new WikiProperties("WikipediaET"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://et.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Eri
+metaNs=Wikipedia
+loginSuccess=(?s).*?Te olete sisse loginud.*? Teie kasutajanimi on ".*?".*
+loginWrongPw=(?s).*?Vale parool.*? Proovige uuesti.*
+loginNoUser=(?s).*?Ei ole kasutajat nimega ".*?".*?Kontrollige kirjapilti või kasutage alljärgnevat vormi uue kasutajakonto loomiseks.*
+logoutSuccess=(?s).*?Te olete välja loginud.*?Võite kasutada Vikipeediat anonüümselt või uuesti sisse logida sama või teise kasutajana.*
+uploadSuccess=(?s).*?Üleslaadimine õnnestus.*
+uploadNoLogin=(?s).*?Kui Te soovite faile üles laadida, peate .*?sisse logima.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaFI extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] {
+ "Media",
+ "Toiminnot",
+ "",
+ "Keskustelu",
+ "Käyttäjä",
+ "Keskustelu käyttäjästä",
+ "Wikipedia",
+ "Wikipedia talk",
+ "Kuva",
+ "Keskustelu kuvasta",
+ "MediaWiki",
+ "MediaWiki talk",
+ "Template",
+ "Template talk",
+ "Ohje",
+ "Keskustelu ohjeesta",
+ "Luokka",
+ "Keskustelu luokasta"
+};
+
+ private static WikipediaFI instance = new WikipediaFI();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaFI() {
+ super(new WikiProperties("WikipediaFI"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://fi.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Toiminnot
+metaNs=Wikipedia
+loginSuccess=(?s).*?Olet nyt kirjautunut .*?}} käyttäjänä ".*?".*
+loginWrongPw=(?s).*?Syöttämäsi salasana ei ole oikein.*? Ole hyvä ja yritä uudelleen.*
+loginNoUser=(?s).*?Käyttäjänimeä ".*?" ei ole olemassa.*?Tarkista kirjoititko nimen oikein, tai käytä alla olevaa lomaketta uuden käyttäjätunnuksen luomiseksi.*
+logoutSuccess=(?s).*?Olet nyt kirjautunut ulos .*?}}.*?Voit jatkaa .*?}} käyttöä nimettömänä, tai.*?kirjautua uudelleen sisään samana tai eri käyttäjänä.*
+uploadSuccess=(?s).*?Tallennus onnistui.*
+uploadNoLogin=(?s).*?Sinun pitää olla .*?kirjautuneena sisään.*?tallentaaksesi tiedoston.*
--- /dev/null
+package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
+//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
+//http://www.djini.de/software/wikipedia/index.html
+//
+//The modified sources are available under the "Common Public License"
+//with permission from the original author: Daniel Wunsch
+
+public class WikipediaFR extends AbstractWikipedia {
+
+ final private static String[] nameSpaces = new String[] {
+ "Media",
+ "Special",
+ "",
+ "Discuter",
+ "Utilisateur",
+ "Discussion Utilisateur",
+ "Wikipédia",
+ "Discussion Wikipedia",
+ "Image",
+ "Discussion Image",
+ "MediaWiki",
+ "Discussion MediaWiki",
+ "Modèle",
+ "Discussion Modèle",
+ "Aide",
+ "Discussion Aide",
+ "Catégorie",
+ "Discussion Catégorie"
+};
+
+ private static WikipediaFR instance = new WikipediaFR();
+
+ /**
+ * Get the singleton instance
+ *
+ * @see net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin#getWikiInstance()
+ */
+ public static IWikipedia getInstance() {
+ return instance;
+ }
+
+ // private constructor
+ private WikipediaFR() {
+ super(new WikiProperties("WikipediaFR"));
+ }
+
+ /**
+ * @return Returns the nameSpaces.
+ */
+ public String[] getNameSpaces() {
+ return nameSpaces;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+baseURL=http://fr.wikipedia.org
+actionPath=/w/index.php
+actionPath2=/w/wiki.phtml
+readPath=/wiki/
+charSet=UTF-8
+specialNs=Special
+metaNs=Wikipedia
+loginSuccess=(?s).*?Vous êtes actuellement connecté sur Wikipédia en tant que « .*? ».*
+loginWrongPw=(?s).*?Le mot de passe est incorrect.*? Essayez à nouveau.*
+loginNoUser=(?s).*?L'utilisateur « .*? » n'existe pas.*?Vérifiez que vous avez bien orthographié le nom, ou utilisez le formulaire ci-dessous pour créer un nouveau compte utilisateur.*
+logoutSuccess=(?s).*?Vous êtes à présent déconnecté.*?e.*?Vous pouvez continuer à utiliser .*? de façon anonyme, ou vous reconnecter, éventuellement sous un autre nom.*
+uploadSuccess=(?s).*?Copie réussie.*
+uploadNoLogin=(?s).*?Vous devez être .*?connecté.*?pour copier des fichiers sur le serveur.*
//with permission from the original author: Daniel Wunsch
import java.io.StringWriter;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
-import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.WikipediaEN;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.WikipediaDE;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.Content;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.MediaWikiConnector;
import net.sourceforge.phpeclipse.wiki.editor.WikiEditor;
ArrayList configsList = new ArrayList();
for (int i = 0; i < allConfigsList.size(); i++) {
IConfiguration temp = (IConfiguration) allConfigsList.get(i);
- if (temp.getType().equals(WikiEditorPlugin.WIKIPEDIA_SET_TEXT)) {
+ if (temp.getType().startsWith(WikiEditorPlugin.PREFIX_STORE)) {
configsList.add(temp);
}
}
try {
IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
String url = generateUrl(configuration, configuration.getURL(), wikiName);
- IWikipedia w = WikipediaEN.getInstance();
+ String wikiLocale = configuration.getType().substring(WikiEditorPlugin.PREFIX_STORE.length());
+ IWikipedia wikipediaProperties = WikiEditorPlugin.getWikiInstance(wikiLocale);
+
MediaWikiConnector connector = new MediaWikiConnector();
+ String actionUrl = configuration.getURL();
+ if (actionUrl == null || actionUrl.equals("")) {
+ // fall back to default settings
+ actionUrl = wikipediaProperties.getActionUrl();
+ }
Date d = new Date();
Content content = new Content(String.valueOf(d.getTime()), doc.get());
- boolean success = connector.login(w, configuration.getURL(), configuration.getUser(), configuration.getPassword(), false);
+ boolean success = connector.login(wikipediaProperties, actionUrl, configuration.getUser(), configuration.getPassword(), false);
if (success) {
- connector.store(w, configuration.getURL(), wikiName, content, "", false, false);
- connector.logout(w, configuration.getURL());
+ connector.store(wikipediaProperties, actionUrl, wikiName, content, "", false, false);
+ connector.logout(wikipediaProperties, actionUrl);
}
} catch (Exception e) {
e.printStackTrace();
WikiEditorPlugin.getDefault()
- .reportError("Exception occured", e.getMessage() + "\nSee stacktrace in /.metadata/.log file.");
+ .reportError("Exception occured: ", e.getMessage() + "\nSee stacktrace in /.metadata/.log file.");
}
}
}
package net.sourceforge.phpeclipse.wiki.editor;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
import net.sourceforge.phpeclipse.wiki.internal.ConfigurationManager;
import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy;
import net.sourceforge.phpeclipse.wiki.sql.WikipediaDB;
public static final String HTTP_QUERY = "HTTP Query";
- public static final String WIKIPEDIA_GET_TEXT = "Wikipedia-Load Text";
-
- public static final String WIKIPEDIA_SET_TEXT = "Wikipedia-Store Text";
-
+ // public static final String WIKIPEDIA_GET_TEXT = "Load WikipediaEN";
+ //
+ // public static final String WIKIPEDIA_SET_TEXT = "Store WikipediaEN";
public static final String WIKIPEDIA_SQL = "Wikipedia SQL access";
-
+
public static final String BLOG_A_WIKI = "Blog as Wiki Text";
public static final String BLOG_A_HTML = "Blog as HTML Text";
- public static final String[] CONFIGURATION_TYPES = { HTTP_QUERY, WIKIPEDIA_GET_TEXT, WIKIPEDIA_SET_TEXT, WIKIPEDIA_SQL, BLOG_A_WIKI, BLOG_A_HTML };
+ public static final String[] PREDEFINED_TYPES = { HTTP_QUERY, WIKIPEDIA_SQL, BLOG_A_WIKI, BLOG_A_HTML };
+
+ public static final String[] PREDEFINED_WIKIS = {
+ "WikibooksDE",
+ "WikibooksEN",
+ "WikinewsDE",
+ "WikinewsEN",
+ "WikipediaAR",
+ "WikipediaCA",
+ "WikipediaDE",
+ "WikipediaEN",
+ "WikipediaEO",
+ "WikipediaES",
+ "WikipediaET",
+ "WikipediaFI",
+ "WikipediaFR" };
+
+ public static final String PREFIX_LOAD = "Load ";
+
+ public static final String PREFIX_STORE = "Store ";
+
+ public static final ArrayList CONFIGURATION_TYPES = new ArrayList();
//image paths
public static final String ICON_PATH = "icons/full/"; //$NON-NLS-1$
public final static String EXPORT_CSS_URL = "__export_css_url";
- public final static String PREF_STRING_CONFIGURATIONS = "__configurations1";
+ public final static String PREF_STRING_CONFIGURATIONS = "__configurations2";
public final static String CONFIG_MEMENTO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<configurations>"
+ "<config name=\"Google Search\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
+ "<config name=\"Koders.com Search\" type-id=\"HTTP Query\" url=\"http://koders.com/?s=$text.selection\"/>"
+ "<config name=\"Leo.org Translation\" type-id=\"HTTP Query\" url=\"http://dict.leo.org/?search=$text.selection\"/>"
- + "<config name=\"Wikipedia-en\" type-id=\"Wikipedia-Load Text\" url=\"http://en.wikipedia.org/w/index.php?title=$text.wikiname&action=raw\"/>"
- + "<config name=\"Wikibooks-en\" type-id=\"Wikipedia-Load Text\" url=\"http://en.wikibooks.org/w/index.php?title=$text.wikiname&action=raw\"/>"
+ + "<config name=\"WikipediaEN Dwonload\" type-id=\"Load WikipediaEN\" url=\"http://en.wikipedia.org/w/index.php?title=$text.wikiname&action=raw\"/>"
+ + "<config name=\"WikibooksEN Download\" type-id=\"Load WikibooksEN\" url=\"http://en.wikibooks.org/w/index.php?title=$text.wikiname&action=raw\"/>"
+ + "<config name=\"WikipediaEN Upload\" type-id=\"Store WikipediaEN\" url=\"http://en.wikipedia.org/w/index.php\"/>"
+ + "<config name=\"WikibooksEN Upload\" type-id=\"Store WikibooksEN\" url=\"http://en.wikibooks.org/w/index.php\"/>"
+ "<config name=\"Wikipedia-SQL\" type-id=\"Wikipedia SQL access\" user=\"root\" url=\"jdbc:mysql://localhost/wikidb\"/>"
+ "</configurations>";
super(descriptor);
initializeImages();
fgPlugin = this;
+ for (int i = 0; i < PREDEFINED_TYPES.length; i++) {
+ CONFIGURATION_TYPES.add(PREDEFINED_TYPES[i]);
+ }
+
+ for (int i = 0; i < PREDEFINED_WIKIS.length; i++) {
+ CONFIGURATION_TYPES.add(PREFIX_LOAD + PREDEFINED_WIKIS[i]);
+ }
+ for (int i = 0; i < PREDEFINED_WIKIS.length; i++) {
+ CONFIGURATION_TYPES.add(PREFIX_STORE + PREDEFINED_WIKIS[i]);
+ }
manager = ConfigurationManager.getInstance();
try {
fResourceBundle = ResourceBundle.getBundle("net.sourceforge.phpeclipse.wiki.editor.WikiEditorMessages");
return manager.createConfiguration();
}
- public static String[] getTypes() {
+ public static ArrayList getTypes() {
return CONFIGURATION_TYPES;
}
+ public static void addType(String type) {
+ CONFIGURATION_TYPES.add(type);
+ }
+
/*
* (non-Javadoc)
*
}
super.shutdown();
}
-
+
public static void log(int severity, String message) {
Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null);
log(status);
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
}
+ /**
+ * Get a IWikpedia singleton instance through reflection (i.e. Method#invoke() )
+ *
+ * @param wikiLocale
+ * @return
+ * @throws NoSuchMethodException
+ * @throws IllegalAccessException
+ * @throws ClassNotFoundException
+ * @throws InvocationTargetException
+ */
+ public static IWikipedia getWikiInstance(String wikiLocale) throws NoSuchMethodException, IllegalAccessException,
+ ClassNotFoundException, InvocationTargetException {
+ String className = "net.sourceforge.phpeclipse.wiki.actions.mediawiki.config." + wikiLocale;
+ Class cls = Class.forName(className);
+ Method method = cls.getMethod("getInstance", new Class[0]);
+ return (IWikipedia) method.invoke(null, new Object[0]);
+ }
+
+ // test code
+ // public static void main(String[] args) {
+ // try {
+ // getWikiInstance("WikipediaEN");
+ // } catch (NoSuchMethodException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // } catch (IllegalAccessException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // } catch (ClassNotFoundException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // } catch (InvocationTargetException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ // }
+
}
\ No newline at end of file
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
+ �*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
package net.sourceforge.phpeclipse.wiki.ui.internal;
+import java.util.ArrayList;
+
import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy;
-import net.sourceforge.phpeclipse.wiki.preferences.Messages;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
return text;
}
- protected Combo createTypeCombo(Composite comp, final String[] types, String sel, final TypeModifyListener listener) {
+ protected Combo createTypeCombo(Composite comp, final ArrayList types, String sel, final TypeModifyListener listener) {
final Combo combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
- int size = types.length;
+ int size = types.size();
String[] items = new String[size];
int index = -1;
for (int i = 0; i < size; i++) {
- items[i] = types[i];
- if (types[i].equals(sel))
+ items[i] = (String)types.get(i);
+ if (items[i].equals(sel))
index = i;
}
combo.setItems(items);
if (listener != null)
combo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- listener.valueChanged(types[combo.getSelectionIndex()]);
+ listener.valueChanged((String)types.get(combo.getSelectionIndex()));
}
public void widgetDefaultSelected(SelectionEvent e) {