diff --git a/ccm-cms/web/assets/xinha/CCMcmsXinhaConfig.js b/ccm-cms/web/assets/xinha/CCMcmsXinhaConfig.js
index 32ceedbdf..98e39ec0f 100644
--- a/ccm-cms/web/assets/xinha/CCMcmsXinhaConfig.js
+++ b/ccm-cms/web/assets/xinha/CCMcmsXinhaConfig.js
@@ -13,7 +13,7 @@ xinha_init=xinha_init?xinha_init:function(){
xinha_editors=xinha_editors?xinha_editors:["myTextArea","anotherOne"];
xinha_plugins=xinha_plugins?xinha_plugins:["CharacterMap","CharCounter",
"ContextMenu","DefinitionList","FindReplace","ListType","QuickTag",
- "SmartReplace","Stylist","TableOperations","UnFormat","Equation"];
+ "SmartReplace","Stylist","TableOperations","UnFormat","Equation","OpenCCM"];
if(!Xinha.loadPlugins(xinha_plugins,xinha_init)){
return;
}
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/OpenCCM.js b/ccm-cms/web/assets/xinha/plugins/OpenCCM/OpenCCM.js
new file mode 100644
index 000000000..7a828f206
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/OpenCCM.js
@@ -0,0 +1,114 @@
+/** xinha editor plugin for OpenCCM **/
+
+OpenCCM._pluginInfo = {
+ name : "OpenCCM",
+ version : "0.3",
+ developer : "Sören Bernstein",
+ developer_url : "http://",
+ sponsor : "",
+ sponsor_url : "",
+ license : "htmlArea"
+}
+
+function OpenCCM(editor)
+{
+ this.editor = editor;
+ this.dialogs = new Array();
+
+ var cfg = editor.config;
+ var self = this;
+
+ var hasLinkButton = false;
+ var hasImageButton = false;
+
+ cfg.registerButton(
+ {
+ id : "createlink",
+ tooltip : this._lc("OpenCCMInsertLink"),
+ image : ["ed_buttons_main.png", 6, 1],
+ textMode : false,
+ action : function(e, objname, obj) { self.showLinkDialog(self._getSelectedAnchor()); }
+ }
+ );
+
+ cfg.registerButton(
+ {
+ id : "insertimage",
+ tooltip : this._lc("OpenCCMInsertImage"),
+ image : ["ed_buttons_main.png", 6, 3],
+ textMode : false,
+ action : function(e, objname, obj) { self.showImageDialog(); }
+ }
+ );
+
+ if(this.findButton("createlink"))
+ {
+ hasLinkButton = true;
+ cfg.addToolbarElement("createlink", "createlink", 0);
+ } else {
+ cfg.addToolbarElement("createlink", "undo", -1);
+ }
+
+ if(this.findButton("insertimage"))
+ {
+ hasImageButton = true;
+ cfg.addToolbarElement("insertimage", "insertimage", 0);
+ }
+ else
+ {
+ cfg.addToolbarElement("insertimage", "createlink", 1);
+ }
+
+ if(!hasLinkButton && !hasImageButton)
+ {
+ cfg.addToolbarElement(["separator"], "insertimage", 1);
+ }
+
+ // Register double click action
+ cfg.dblclickList["a"][0] = function(e, target) { self.showLinkDialog(self._getSelectedAnchor()); };
+}
+
+OpenCCM.prototype.findButton = function(string) {
+ var toolbar = this.editor.config.toolbar;
+
+ for(i = 0; i < toolbar.length; i++)
+ {
+ for(j = 0; j < toolbar[i].length; j++)
+ {
+ if(toolbar[i][j] == string)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+OpenCCM.prototype._lc = function(string) {
+ return Xinha._lc(string, 'OpenCCM');
+}
+
+OpenCCM.prototype.onGenerateOnce = function ()
+{
+ this.loadAssets();
+}
+
+OpenCCM.prototype.loadAssets = function() {
+ var self = OpenCCM;
+
+ if (self.loading)
+ {
+ return;
+ }
+ self.loading = true;
+
+ // Link
+ Xinha._getback(Xinha.getPluginDir("OpenCCM") + '/links/links.js', function(getback) { eval(getback); self.linksMethodsReady = true; });
+ Xinha._getback(Xinha.getPluginDir("OpenCCM") + '/links/links.html', function(getback) { OpenCCM.linksHtml = getback; self.linksDialogReady = true; } );
+
+ // Image
+ Xinha._getback(Xinha.getPluginDir("OpenCCM") + '/images/images.js', function(getback) { eval(getback); self.imagesMethodsReady = true; } );
+ Xinha._getback(Xinha.getPluginDir("OpenCCM") + '/images/images.html', function(getback) { OpenCCM.imagesHtml = getback; self.imagesDialogReady = true; } );
+}
+
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html b/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html
new file mode 100644
index 000000000..49114e70e
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html
@@ -0,0 +1,83 @@
+
Insert Image
+
+
+
+Image Preview:
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js b/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js
new file mode 100644
index 000000000..0e5b53caa
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js
@@ -0,0 +1,196 @@
+OpenCCM.prototype.showImageDialog = function(image)
+{
+ if (!this.dialogs["images"]) this.prepareImageDialog();
+
+ var editor = this.editor;
+ if ( typeof image == "undefined" )
+ {
+ image = editor.getParentElement();
+ if ( image && image.tagName.toLowerCase() != 'img' )
+ {
+ image = null;
+ }
+ }
+
+ if ( image )
+ {
+ function getSpecifiedAttribute(element,attribute)
+ {
+ var a = element.attributes;
+ for (var i=0;i 0) ? newHeightForPreview : 0) + "px"; // no-go beyond 0
+
+ this.getElementById("ipreview").style.width = this.width - 2 + 'px'; // and the width
+
+ }
+*/
+
+ this.imageDialogReady = true;
+};
+
+// and finally ... take some action
+OpenCCM.prototype.imageApply = function()
+{
+ var param = this.dialogs["images"].hide();
+ if (!param.f_url)
+ {
+ return;
+ }
+ var editor = this.editor;
+ var img = this.image;
+ if ( !img )
+ {
+ if ( Xinha.is_ie )
+ {
+ var sel = editor.getSelection();
+ var range = editor.createRange(sel);
+ editor._doc.execCommand("insertimage", false, param.f_url);
+ img = range.parentElement();
+ // wonder if this works...
+ if ( img.tagName.toLowerCase() != "img" )
+ {
+ img = img.previousSibling;
+ }
+ }
+ else
+ {
+ img = document.createElement('img');
+ img.src = param.f_url;
+ editor.insertNodeAtSelection(img);
+ if ( !img.tagName )
+ {
+ // if the cursor is at the beginning of the document
+ img = range.startContainer.firstChild;
+ }
+ }
+ }
+ else
+ {
+ img.src = param.f_url;
+ }
+
+ for ( var field in param )
+ {
+ var value = param[field];
+ switch (field)
+ {
+ case "f_alt":
+ if (value)
+ img.alt = value;
+ else
+ img.removeAttribute("alt");
+ break;
+ case "f_border":
+ if (value)
+ img.border = parseInt(value || "0");
+ else
+ img.removeAttribute("border");
+ break;
+ case "f_align":
+ if (value.value)
+ img.align = value.value;
+ else
+ img.removeAttribute("align");
+ break;
+ case "f_vert":
+ if (value != "")
+ img.vspace = parseInt(value || "0");
+ else
+ img.removeAttribute("vspace");
+ break;
+ case "f_horiz":
+ if (value != "")
+ img.hspace = parseInt(value || "0");
+ else
+ img.removeAttribute("hspace");
+ break;
+ case "f_width":
+ if (value)
+ img.width = parseInt(value || "0");
+ else
+ img.removeAttribute("width");
+ break;
+ case "f_height":
+ if (value)
+ img.height = parseInt(value || "0");
+ else
+ img.removeAttribute("height");
+ break;
+ }
+ }
+
+};
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js b/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js
new file mode 100644
index 000000000..c8c81b0e7
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js
@@ -0,0 +1,6 @@
+// I18N constants
+// LANG: "de", ENCODING: UTF-8
+{
+ "OpenCCMInsertLink" : "Link einfügen / bearbeiten",
+ "OpenCCMInsertImage" : "Bild einfügen / bearbeiten",
+}
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js b/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js
new file mode 100644
index 000000000..2d5a34873
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js
@@ -0,0 +1,6 @@
+// I18N constants
+// LANG: "de", ENCODING: UTF-8
+{
+ "OpenCCMInsertLink" : "Create / modify link",
+ "OpenCCMInsertImage" : "Insert / modify image",
+}
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.html b/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.html
new file mode 100644
index 000000000..ed98e9ee1
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.html
@@ -0,0 +1,154 @@
+
+
+ Insert/Modify Link
+
+
+
+
diff --git a/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.js b/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.js
new file mode 100644
index 000000000..3df8dce22
--- /dev/null
+++ b/ccm-cms/web/assets/xinha/plugins/OpenCCM/links/links.js
@@ -0,0 +1,237 @@
+OpenCCM.prototype.showLinkDialog = function(link)
+{
+ if (!this.dialogs["links"])
+ {
+ this.prepareLinkDialog();
+ }
+
+ var editor = this.editor;
+ this.link = link;
+ if(!link && this.editor.selectionEmpty(this.editor.getSelection()))
+ {
+ alert(this._lc("You need to select some text before creating a link"));
+ return false;
+ }
+
+ var data =
+ {
+ title : '',
+ type : 'internal',
+ ci_name : '',
+ ci_href : '',
+ href : ''
+ };
+
+ if(link && link.tagName.toLowerCase() == 'a')
+ {
+ var href =this.editor.fixRelativeLinks(link.getAttribute('href'));
+ var internal = href.match(/^(\/.*)$/);
+ var external = href.match(/^http(.*)$/);
+/*
+ var mailto = href.match(/^mailto:(.*@[^?&]*)(\?(.*))?$/);
+ var anchor = href.match(/^#(.*)$/);
+*/
+ data.title = link.title;
+
+ if(internal)
+ {
+ data.type = 'internal';
+ data.ci_name = link.alt;
+ data.ci_href = href;
+ }
+
+ if(external)
+ {
+ data.type = 'external';
+ data.href = href;
+ }
+
+ }
+
+ // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog
+ this.dialogs["links"].show(data);
+
+};
+
+// Prepare the link dialog
+OpenCCM.prototype.prepareLinkDialog = function()
+{
+ var self = this;
+ var editor = this.editor;
+
+ var dialog = this.dialogs["links"] = new Xinha.Dialog(editor, OpenCCM.linksHtml, 'Xinha',{width:400})
+
+ // Connect the OK and Cancel buttons
+ dialog.getElementById('ok').onclick = function() { self.linkApply(); };
+ dialog.getElementById('clear').onclick = function() { self.linkRemove(); };
+ dialog.getElementById('cancel').onclick = function() { self.dialogs["links"].hide()};
+
+ // Connect the Browse and Search button
+ dialog.getElementById('ci_browse').onclick = function() { self.linkBrowse(window); };
+/* Suche deaktivert, bis eine bessere JSP / Java-Klasse vorhanden ist
+ dialog.getElementById('ci_search').onclick = function() { alert("Das geht auch noch nicht.");};
+*/
+
+ this.linkDialogReady = true;
+};
+
+//
+OpenCCM.prototype.linkApply = function()
+{
+
+ var values = this.dialogs["links"].hide();
+ var link = this.link;
+ var editor = this.editor;
+
+ var linkAttr =
+ {
+ href : '',
+ alt : '',
+ title : '',
+ class : ''
+ };
+
+ // Read needed form values
+ switch(values.type)
+ {
+ case "internal": //alert("Internal");
+ linkAttr.href = values.ci_href;
+ /* Deaktiviert bis es eine bessere JSP / Java-Klasse gibt
+ linkAttr.alt = values.ci_name;
+ */
+ linkAttr.title = values.title;
+ linkAttr.class = "linkInternal";
+ break;
+
+ case "external": //alert("External");
+ linkAttr.href = values.href;
+ linkAttr.title = values.title;
+ linkAttr.class = "linkExternal";
+
+ // Make absolute url
+
+ break;
+
+ default: //alert("Mist");
+ return false;
+ }
+
+ // If not all mandatory informations are set
+ if(linkAttr.href == "" || linkAttr.title == "")
+ {
+ // don't do anything at all
+ return false;
+ }
+
+ // Modify Link
+ if(link && link.tagName.toLowerCase() == "a")
+ {
+
+ for(var i in linkAttr)
+ {
+ link.setAttribute(i, linkAttr[i]);
+ }
+
+/* from Linker-Plugin
+ // If we change a mailto link in IE for some hitherto unknown
+ // reason it sets the innerHTML of the link to be the
+ // href of the link. Stupid IE.
+ if(Xinha.is_ie)
+ {
+ if(/mailto:([^?<>]*)(\?[^<]*)?$/i.test(link.innerHTML))
+ {
+ link.innerHTML = RegExp.$1;
+ }
+ }
+*/
+
+ }
+ // Add Link
+ else
+ {
+
+ // Insert a link, we let the editor do this, we figure it knows best
+ var tmp = Xinha.uniq("http://www.example.com/Link");
+ editor._doc.execCommand("createlink", false, tmp);
+
+ // Fix it up
+ var anchors = editor._doc.getElementsByTagName('a');
+ for(var i = 0; i < anchors.length; i++)
+ {
+ var anchor = anchors[i];
+ if(anchor.href == tmp)
+ {
+ // Found one.
+ if (!link) link = anchor;
+ for(var j in linkAttr)
+ {
+ anchor.setAttribute(j, linkAttr[j]);
+ }
+ }
+ }
+
+ }
+
+ editor.selectNodeContents(link);
+ editor.updateToolbar();
+};
+
+// Remove a link
+OpenCCM.prototype.linkRemove = function()
+{
+
+ var values = this.dialogs["links"].hide();
+ var link = this.link;
+ var editor = this.editor;
+
+ if(link && link.tagName.toLowerCase() == 'a')
+ {
+ if(confirm(this._lc('Are you sure you wish to remove this link?')))
+ {
+ var parent = link.parentNode;
+ while(link.hasChildNodes())
+ {
+ parent.insertBefore(link.removeChild(link.childNodes[0]), link);
+ }
+
+ parent.removeChild(link);
+ editor.updateToolbar();
+ return true;
+ }
+ }
+};
+
+OpenCCM.prototype.linkBrowse = function(window)
+{
+ baseURL = window.location.href;//.pathname;
+ offset = baseURL.lastIndexOf("/");
+ destURL = baseURL.slice(0, offset+1) + "search.jsp?useURL=true&widget=getElementById('" + this.dialogs["links"].id["ci_href"] + "')";
+
+// var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true});
+// searchDialog.show();
+ window.open(destURL, "_blank", "directories=no,toolbar=no,width=600,height=400,status=no,menubar=no");
+
+ return false;
+}
+
+// Get selected anchor
+OpenCCM.prototype._getSelectedAnchor = function()
+{
+ var sel = this.editor.getSelection();
+ var rng = this.editor.createRange(sel);
+ var link = this.editor.activeElement(sel);
+
+ if(link != null && link.tagName.toLowerCase() == 'a')
+ {
+ return link;
+ }
+ else
+ {
+ link = this.editor._getFirstAncestor(sel, 'a');
+ if(link != null)
+ {
+ return link;
+ }
+ }
+ return null;
+};