From: Benoît Pin Date: Thu, 18 Aug 2011 12:20:04 +0000 (+0200) Subject: Début d'intégration de la boît de dialogue d'image de Plinn. Pour l'instant, on affic... X-Git-Tag: 3.6.1~11 X-Git-Url: https://scm.cri.ensmp.fr/git/ckeditor.git/commitdiff_plain/07784b9fcc5174d9d31afdd13d6921c82eaaabaf?ds=sidebyside Début d'intégration de la boît de dialogue d'image de Plinn. Pour l'instant, on affiche 3 × rien. --- diff --git a/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py b/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py new file mode 100644 index 0000000..9c0deb8 --- /dev/null +++ b/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py @@ -0,0 +1,54 @@ +##parameters=command, path, file='', Type='', redirUrl='' + +from Products.CMFCore.utils import getToolByName + +def replaceXMLEntities(text) : + for c, ent in (('<', '<'), ('>', '>'), ('&', '&')) : + text = text.replace(c, ent) + return text + +utool = getToolByName(context, 'portal_url') +atool = getToolByName(context, 'portal_attachment') + +portal = utool.getPortalObject() + +ob = portal +path = path.strip('/') + +ob = portal +path = path.strip('/') + +for name in path.split('/') : + ob = getattr(ob, name) + +if command == 'ls': + attachments = atool.getAttachmentsFor(ob) + attachments = attachments.objectValues() + + print '' + for o in attachments : + size = o.getThumbnailSize() + row = '%(title)s' % { + 'previewUrl' : '%s/getThumbnail' % o.absolute_url(), + 'url' : 'attachments/%s' % o.getId(), + 'meta_type' : o.meta_type, + 'title' : replaceXMLEntities(o.title_or_id()), + 'width' : size['width'], + 'height' : size['height'] + } + print row + print '' + +if command == 'upload' : + atool.uploadAttachmentFor(ob, file, typeName=Type) + return context.REQUEST.RESPONSE.redirect(redirUrl); + +if command == 'rm' : + ob = context.restrictedTraverse(path) + parent = ob.getParentNode() + parent.manage_delObjects(ob.getId()) + print '' + + +context.REQUEST.RESPONSE.setHeader('content-type', 'text/xml; charset=utf-8') +return printed \ No newline at end of file diff --git a/skins/ckeditor/plugins/plinn_image/dialog/embedded_images.html.pt b/skins/ckeditor/plugins/plinn_image/dialog/embedded_images.html.pt new file mode 100644 index 0000000..0efdcdd --- /dev/null +++ b/skins/ckeditor/plugins/plinn_image/dialog/embedded_images.html.pt @@ -0,0 +1,175 @@ + + + + + + + Embedded images + + + + + + + + + +
+ + + + + + +
+ + + + diff --git a/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.html.pt b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.html.pt new file mode 100644 index 0000000..cc5dcf1 --- /dev/null +++ b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.html.pt @@ -0,0 +1 @@ + Image selector <body></body> \ No newline at end of file diff --git a/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js new file mode 100644 index 0000000..424024a --- /dev/null +++ b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image.js @@ -0,0 +1,42 @@ +// (c) Benoît PIN 2006-2007 +// http://plinn.org +// Licence GPL + +var editor = window.dialogArguments.editor; +var FCK = editor.FCK ; +var FCKLang = editor.FCKLang ; +var FCKConfig = editor.FCKConfig ; +var FCKPlugins = editor.FCKPlugins; +var FCKDebug = editor.FCKDebug ; + +window.onload = function() { + var mainFrame = window.frames['main']; + mainFrame.src = FCKPlugins.Items['image'].Path + 'embedded_images.html'; + mainFrame.location.href = mainFrame.src; + + var tabsFrame = window.frames['tabs']; + tabsFrame.src = FCKPlugins.Items['image'].Path + 'plinn_image_tabs.html' + tabsFrame.location.href = FCKPlugins.Items['image'].Path + 'plinn_image_tabs.html' +} + +function updateOrInsertImage(url) { + var getSizeUrl = url + '/getResizedImageSize'; + var req = new XMLHttpRequest(); + req.open("POST", getSizeUrl, false); // synchrone + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); + var boxSize = FCKConfig.ImageMaxDefaultDimension + '_' + FCKConfig.ImageMaxDefaultDimension; + req.send("asXml:boolean=True&size=" + boxSize); + var doc = req.responseXML.documentElement; + + var width = doc.getElementsByTagName('width')[0].firstChild.nodeValue; + var height = doc.getElementsByTagName('height')[0].firstChild.nodeValue; + + + var img = FCK.CreateElement('img'); + img.src = url + '/getResizedImage?size=' + boxSize; + img.width = width; + img.height = height; + + //FCK.InsertElement(img); + window.close(); +} \ No newline at end of file diff --git a/skins/ckeditor/plugins/plinn_image/dialog/plinn_image_tabs.html.pt b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image_tabs.html.pt new file mode 100644 index 0000000..4beb51a --- /dev/null +++ b/skins/ckeditor/plugins/plinn_image/dialog/plinn_image_tabs.html.pt @@ -0,0 +1,93 @@ + + + + + + + Image tabs options + + + + + + + + + + + + diff --git a/skins/ckeditor/plugins/plinn_image/plugin.js b/skins/ckeditor/plugins/plinn_image/plugin.js index 442a2be..17658a9 100644 --- a/skins/ckeditor/plugins/plinn_image/plugin.js +++ b/skins/ckeditor/plugins/plinn_image/plugin.js @@ -23,6 +23,19 @@ function updateImageSizeUrlParameters(img) { } } +function openPlinnImageDialog(path, editor) { + var winOptions = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes" + + ",resizable=yes" + + ",width=801" + + ",height=600"; + //",top=" + iTop + + //",left=" + iLeft ; + + var win = open(path + 'dialog/plinn_image.html', 'PlinnImageDialog', winOptions); + win.dialogArguments = new Object(); + win.dialogArguments.editor = editor; +} + CKEDITOR.plugins.add( 'plinn_image', { @@ -42,21 +55,18 @@ CKEDITOR.plugins.add( 'plinn_image', } ); }); - + var pluginPath = this.path; var command = editor.addCommand('plinn_image', { - exec : function(editor) { - alert('Bonjour la France !'); - } + exec : function(editor){openPlinnImageDialog(pluginPath, editor);} }); editor.ui.addButton('PlinnImage', { label : editor.lang.common.image, - icon : this.path + 'dialog/plinn_image.gif', + icon : pluginPath + 'dialog/plinn_image.gif', command : 'plinn_image' }); - console.log(this.path); } });