|
From: Alexander G. <gaf...@us...> - 2006-02-01 20:37:53
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/wiki In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12716/src/org/cobricks/portal/wiki Modified Files: UtilityTest.java Utility.java Log Message: Index: UtilityTest.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/wiki/UtilityTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- UtilityTest.java 31 Jan 2006 19:59:20 -0000 1.2 +++ UtilityTest.java 1 Feb 2006 20:37:38 -0000 1.3 @@ -347,36 +347,4 @@ //System.out.println(retValue); assertTrue(result.equals(retValue)); } - - public void testInsertEditLink() { - String parse, result, retValue; - int itemid = 3; - //Insert the edit link - parse = "Edit this page: "; - - result = "Edit this page: " - + "<a href=\"portal/edit.html?itemid=3\">Edit</a>"; - - retValue = Utility.insertEditLink(itemid, parse, parse.length()); - //System.out.println(result); - //System.out.println(retValue); - assertTrue(result.equals(retValue)); - } - - public void testInsertHistoryLink() { - String parse, result, retValue, lang = "en"; - int itemid = 3; - //Insert the edit link - parse = "History of the page: "; - - result = "History of the page: " - + "<a href=\"portal/historywiki.html?itemid=3&lang=en\">" - + "History</a>"; - - retValue = Utility.insertHistoryLink(itemid, lang, parse, parse - .length()); - //System.out.println(result); - //System.out.println(retValue); - assertTrue(result.equals(retValue)); - } } Index: Utility.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/wiki/Utility.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Utility.java 31 Jan 2006 19:59:20 -0000 1.3 +++ Utility.java 1 Feb 2006 20:37:38 -0000 1.4 @@ -36,17 +36,17 @@ //Default ending of a file private final static String DEFAULTENDING = "html"; - private final static String ITEMID = "%ITEMID%"; - private final static String LANG = "%LANG%"; +// private final static String ITEMID = "%ITEMID%"; +// private final static String LANG = "%LANG%"; //Link to edit the page - the itemid must be replaced - private final static String EDITLINK = "<a href=\"portal/edit.html?itemid="+ - ITEMID+"\">Edit</a>"; +// private final static String EDITLINK = "<a href=\"portal/edit.html?itemid="+ +// ITEMID+"\">Edit</a>"; //Link to history of the page - private final static String HISTORYLINK = "<a href=\"" + - "portal/historywiki.html?" + - "itemid="+ITEMID+"&lang="+LANG+"\">History</a>"; +// private final static String HISTORYLINK = "<a href=\"" + +// "portal/historywiki.html?" + +// "itemid="+ITEMID+"&lang="+LANG+"\">History</a>"; //Indicate the begin of the text, that will not be changed private final static String BEGINNOWIKITEXT = "<nowiki>"; @@ -834,92 +834,6 @@ } /** - * Insert the link to the edit side with the right itemid. - * @param itemid Itemid of the page which should be edited. - * @param content Content where the link will be inserted. - * @param position Position where the link will be inserted. - * @return The content with the edit-link. - */ - public static String insertEditLink(int itemid, String content, int position) - { - if(content == null) - return null; - - StringBuffer tmp = new StringBuffer(content); - - tmp.insert(position, replaceItemid(itemid)); - - return tmp.toString(); - } - - /** - * Search the place holder of the itemid and replace it with the real - * itemid of the content. - * @param itemid The itemid that will be inserted. - * @return The edit-link with the right itemid. - */ - private static String replaceItemid(int itemid) - { - if(EDITLINK == null) - return EDITLINK; - - StringBuffer tmp = new StringBuffer(EDITLINK); - int pos = tmp.indexOf(ITEMID); - if(pos > -1) { - tmp = tmp.replace(pos, pos+ITEMID.length(), ""+itemid); - } - - return tmp.toString(); - } - - /** - * Insert the history link into the content at the specific position. - * @param itemid Itemid of the side which history should be shown. - * @param lang Language of the side - * @param content Content where the history list should be inserted - * @param position Position where the link should be inserted - * @return Content with the inserted history link. - */ - public static String insertHistoryLink(int itemid, String lang, String content, int position) - { - if(content == null) - return null; - - StringBuffer tmp = new StringBuffer(content); - - tmp.insert(position, replaceItemidAndLanguage(itemid, lang)); - - return tmp.toString(); - } - - /** - * Search the place holder of the itemid and language in the history - * and replace it with the real values. - * @param itemid Itemid of the page. - * @param lang Language of the page. - * @return The history link with the right itemid and language. - */ - private static String replaceItemidAndLanguage(int itemid, String lang) - { - if(HISTORYLINK == null) - return null; - - StringBuffer tmp = new StringBuffer(HISTORYLINK); - - int pos = tmp.indexOf(ITEMID); - if(pos > -1) { - tmp = tmp.replace(pos, pos+ITEMID.length(), ""+itemid); - } - - pos = tmp.indexOf(LANG); - if(pos > -1) { - tmp = tmp.replace(pos, pos+LANG.length(), lang); - } - - return tmp.toString(); - } - - /** * Load the porperties from the property file in 'org.cobrcks.portal'. */ private static void loadProperties() { |