X-Git-Url: https://scm.cri.ensmp.fr/git/ckeditor.git/blobdiff_plain/e7f8fb547940c134de50db80ffaf54be1135ca7b..fbd145a2acd338b7bb7d152fa24692d8ff3e6b4c:/Products/ckeditor/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py?ds=sidebyside diff --git a/Products/ckeditor/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py b/Products/ckeditor/skins/ckeditor/plugins/plinn_image/connectors/plinn/connector.py new file mode 100644 index 0000000..9c0deb8 --- /dev/null +++ b/Products/ckeditor/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