Update of /var/cvs/applications/richtext/src/org/mmbase/richtext/processors/xml
In directory 
james.mmbase.org:/tmp/cvs-serv3713/src/org/mmbase/richtext/processors/xml

Modified Files:
        MmxfGetString.java Wiki.java 
Log Message:
support for <strong>, also in wiki


See also: 
http://cvs.mmbase.org/viewcvs/applications/richtext/src/org/mmbase/richtext/processors/xml


Index: MmxfGetString.java
===================================================================
RCS file: 
/var/cvs/applications/richtext/src/org/mmbase/richtext/processors/xml/MmxfGetString.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- MmxfGetString.java  22 Apr 2008 14:47:13 -0000      1.11
+++ MmxfGetString.java  22 Apr 2008 16:00:49 -0000      1.12
@@ -30,13 +30,14 @@
  * This class implements the `get' for `mmxf' fields.
  *
  * @author Michiel Meeuwissen
- * @version $Id: MmxfGetString.java,v 1.11 2008/04/22 14:47:13 michiel Exp $
+ * @version $Id: MmxfGetString.java,v 1.12 2008/04/22 16:00:49 michiel Exp $
  * @since MMBase-1.8
  */
 
 public class MmxfGetString implements  Processor {
     public static String MODE_SHOWBROKEN    = 
"org.mmbase.richtext.wiki.show_broken";
     public static String MODE_LOADRELATIONS = 
"org.mmbase.richtext.wiki.load_relations";
+    public static String MODE_UNDECORATEIDS = 
"org.mmbase.richtext.wiki.undecorateids";
 
     private static final Logger log = 
Logging.getLoggerInstance(MmxfGetString.class);
 


Index: Wiki.java
===================================================================
RCS file: 
/var/cvs/applications/richtext/src/org/mmbase/richtext/processors/xml/Wiki.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Wiki.java   22 Apr 2008 14:47:13 -0000      1.4
+++ Wiki.java   22 Apr 2008 16:00:50 -0000      1.5
@@ -28,7 +28,7 @@
  * id of the node).
  *
  * @author Michiel Meeuwissen
- * @version $Id: Wiki.java,v 1.4 2008/04/22 14:47:13 michiel Exp $
+ * @version $Id: Wiki.java,v 1.5 2008/04/22 16:00:50 michiel Exp $
  * @todo something goes wrong if same node relation multiple times.
  */
 
@@ -38,8 +38,10 @@
     private static final Logger log = Logging.getLoggerInstance(Wiki.class);
     private static final long serialVersionUID = 1L;
 
-
-    Node findById(NodeList links, String id) {
+    /**
+     * Searches in the existsing relations for a relation with the given id
+     */
+    Node findById(Element a, NodeList links, String id) {
         NodeIterator ni = links.nodeIterator();
         while (ni.hasNext()) {
             Node relation = ni.nextNode();
@@ -60,8 +62,10 @@
                 } else {
                     if (destination.getStringValue("number").equals(id)) {
                         log.debug("Setting relation id of " + 
relation.getNumber() + " to " + destination.getNumber());
-                        relation.setStringValue("id", "" + 
destination.getNumber());
+                        String decoratedId = decorateId("" + 
destination.getNumber());
+                        relation.setStringValue("id", decoratedId);
                         relation.commit();
+                        a.setAttribute("id", decoratedId);
                         log.debug("relation " + relation + " " + 
relation.getCloud());
                         return relation;
                     }
@@ -71,6 +75,17 @@
         return null; // not found
     }
 
+    String cleanId(String id) {
+        if (id.startsWith("n_")) {
+            return id.substring(2);
+        } else {
+            return id;
+        }
+    }
+    String decorateId(String id) {
+        return "n_" + cleanId(id);
+    }
+
    /**
      * Simply considers the id the node-number, but this could be 
sophisitcated on.
      */
@@ -86,7 +101,6 @@
      */
     Document parse(Node editedNode, Document source) {
 
-
         Map<Integer, Node> usedLinks = new HashMap<Integer, Node>();
         // reolve anchors. Allow to use nodenumber as anchor.
         if (log.isDebugEnabled()) {
@@ -106,14 +120,18 @@
             if (log.isDebugEnabled()) {
                 log.debug("Found " + XMLWriter.write(a, true));
             }
-            Node link = findById(links, id);
+            Node link = findById(a, links, id);
             if (link == null) {
                 log.service("No relation found with id'" + id + "'. 
Implicitely creating one now.");
-                Node node = getNode(cloud, id);
+                Node node = getNode(cloud, cleanId(id));
                 Relation newRel = editedNode.createRelation(node, 
cloud.getRelationManager(editedNode.getNodeManager(), node.getNodeManager(), 
"idrel"));
-                newRel.setStringValue("id", id);
+                String decoratedId = decorateId(id);
+                newRel.setStringValue("id", decoratedId);
                 newRel.commit();
+                a.setAttribute("id", decoratedId);
+
             }
+
         }
 
         return source;
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to