Skip to main content

A finder to search/select portal objects for Plone

Project description

collective.plonefinder

Ajax popup to browse and select plone contents.

This code is an extraction with some refactoring, of PloneArticle explorer used for referencables proxies.

The intent is to make it usable in different situations :

  • to store selected contents in zope3 forms (portlet forms as example)

  • for collective.ckeditor or any possible wysiwyg editor for referencing images or contents inside a rich text field, it’s also possible to upload files / images and create folders with this product (dependency to collective.quickupload)

  • for referencable fields inside AT edit forms

  • for links fields (as remoteUrl in ATLink) to reference internal links

This work has been started at Ingeniweb in 2007 by Christophe Bosse (for the jQuery code) & Jean-mat Grimaldi (everything else) for PloneArticle product.

Requirements :

  • Plone3 and more (tested under Plone 3.3.5 and Plone4)

Installation :

  • Nothing to do if you have installed collective.ckeditor (plone4 only at this time)

  • Otherwise install it as any zope package using buildout :

    • add collective.plonefinder in your eggs section

    • add collective.plonefinder in your zcml section

    • bin/buildout

Nothing else.

How to use it as a reference widget in zope3 forms :

A reference widget for zope3 forms (zope.app.form) is provided with this product.

The widget can be used to store objects references in a sequence field.

Example of use in a portlet form for a Tuple field named target_contents:

from collective.plonefinder.widgets.referencewidget import FinderSelectWidget

target_contents = schema.Tuple (title=u"Browse for contents",
                                description =u"Choose contents to display "
                                              "with a plone finder window. ",
                                default= ()
                                )

form_fields['target_contents'].custom_widget = FinderSelectWidget

You can use the FinderSelectWidget with some properties set using the update method in your AddForm or EditForm, example for a portlet AddForm:

class AddForm(base.AddForm):
    """Portlet add form.
    """
    form_fields = form.Fields(IReferencesPortlet)
    form_fields['targets'].custom_widget = FinderSelectWidget
    label = u"Add References Portlet"

    def update(self) :
        super(AddForm, self).update()
        self.widgets['targets'].typeview = 'image'
        self.widgets['targets'].forcecloseoninsert = 1

    def create(self, data):
        return Assignment(**data)

If you want, you can also pass a context as base for the widget, to get the current or parent folder open in the finder. Example in a portlet using the update method:

assignment = aq_parent(aq_inner(self.context))
self.widgets['targets'].base = aq_parent(aq_inner(assignment))

There are also two customized Widget for files and images. Look at the code to create your own specific widget.

Example of code for files referencing with files upload support:

from collective.plonefinder.widgets.referencewidget import FinderSelectFileWidget

target_files = schema.Tuple (title=u"Browse for images",
                              description =u"Choose files to display "
                                             "with a plone finder window. "
                                             "You can upload new files. ",
                              default= ()
                              )

form_fields['target_files'].custom_widget = FinderSelectFileWidget

Example of code for images referencing with images upload support:

from collective.plonefinder.widgets.referencewidget import FinderSelectImageWidget

target_images = schema.Tuple (title=u"Browse for images",
                              description =u"Choose images to display "
                                             "with a plone finder window. "
                                             "You can select different image sizes. "
                                             "You can upload new images. ",
                              default= ()
                              )

form_fields['target_images'].custom_widget = FinderSelectImageWidget

Note that in this last case the data store image uid and image thumb size like this:

'%s/%s' %(image.UID(), thumb_size_extension)

thumb_size_extension could be ‘image_thumb’ or ‘image_preview’ …

So use something like this to display a referenced image

'<img src="%s/resolveuid/%s/%s" />' %(portal_url, data.split('/')[0], data.split('/')[1])

How to use it in a wysiwyg editor :

The more easy way is creating a specific view, because you will often need to override the javascript method to select objects, and because each editor has its specific mechanism to dialog with browser.

See collective.ckeditor package as example.

Todo :

  • Functional doctests

  • i18N support

  • Finder improvements :

    • Ajax opening/moving/resizing and all window effects inside the same browser window (in progress, need some js refactoring)

    • improve contextual actions menu (change workflow state, rename, delete, copy, paste …)

    • add a finder menu action to show/hide the current selection list in right panel

    • remove items from selection list in finder window

  • Improve zope3 reference widget properties

    • add option to hide/show or just mark selected items in finder browsing results (just need to store the finder blacklist in session)

    • add option to set a specific catalog query stored in session

    • add option to change finder catalog.

  • New zope3 widget to store urls (for a string field)

  • ATPloneFinderWidget for Reference fields (not a big challenge, just need to use ATReferenceBrowserWidget as base to start the work)

  • ATLinkWidget to store internal links

Any contribution is welcome, contact support@ingeniweb.com.

Authors :

Jean-mat Grimaldi - Alter Way Solutions

Code repository :

https://svn.plone.org/svn/collective/collective.plonefinder/trunk

Support :

Changelog

1.0.4 (2013-09-09)

  • Fix: with ckeditor, link to News item does not link to its image anymore. [gotcha]

1.0.3 (2013-06-12)

  • Compatibility with Plone 4.3 [toutpt]

1.0.2 (2011-08-19)

  • Always show full site structure in navigation column. [spereverde, yulka, gotcha]

  • In breadcrumbs, avoid links to folders where the user does not have View permission. [spereverde, yulka, gotcha]

1.0.1

  • Css IE7 fixes macadames - 2010/09/22

  • finder.pt : template fix doctype was missing macadames - 2010/09/22

  • finder.pt : Remove lang attribute on html tag- we don’t need it and it’s difficult to maintain between Plone3 / Plone4 macadames - 2010/09/26

1.0.0

  • use Plone Quick Upload as upload tool - new dependency to collective.quickupload added macadames - 2010/09

1.0.0-b2

  • fix unauthorized error in edit forms using FinderSelectWidget when user don’t have the permission to access some referenced contents. In this case object is not removed from list, but a message is displayed in place of object title : ‘%s : %s ‘ %(_(u”You don’t have permission to access this object”),uid)

  • added : close window when self.multiselect = False or self.forcecloseonsinsert = False

  • fix selectItem when there were quotes in titles

  • added a base attribute to reference widget used for finder opening folder.

  • use unicode chars for up and down arrows in reference widget.

  • allow change imagetypes using request and referencewidget

  • added a generated css for plone3 content-types icons

  • added new property self.filestypes in browser

  • added mime-type icons for filestypes in finder

  • FinderSelectWidget : do not raise an error anymore when object is not found but just returns a message in place of title (object with uid doesn’t exist)

  • Fix regression on allowupload (was never allowed) macadames - 2010/07/21

  • Fix enable/disable browsing using request or self.browse = False macadames - 2010/07/22

  • no search on another path, when browsing is disable macadames - 2010/07/22

  • title fields added to multiple upload using jquery.uploadify macadames - 2010/07/24

  • authentication for flash upload is done using cookie when possible (same method as collective.uploadify) otherwise using a ticket (method PloneFlashUpload) macadames - 2010/07/28

  • use standard archetypes method “invokeFactory”, to create new objects using uploaded files, to respect the complete plone createObject process. macadames - 2010/07/28

  • added new mediaupload key in request to set content-type for upload (very useful with jquery.uploadify) macadames - 2010/07/28

  • improve jquery.uploadify process with errors handling macadames - 2010/07/29

  • added new css class required to show icons on plone4 ‘icons-on’ macadames - 2010/07/31

  • fix upload buttons styles on plone4 macadames - 2010/07/31

  • fix some css styles on Plone3 or Plone4 + classic Theme macadames - 2010/07/31

  • design improvements macadames - 2010/07/31

  • french translation in progress macadames - 2010/07/31

  • use InavigationRoot for the finder root no more IPloneSiteRot macadames - 2010/08/01

  • design improvements blue is the new color macadames - 2010/08/01

  • added new view attributes root and rootpath used to change the browser root macadames - 2010/08/02

  • Added a real left navigation tree macadames - 2010/08/02

  • replace persistent objects in attribute views by a data dict ie self.data[‘root’] in place of self.root macadames - 2010/08/04

  • use topic queryCatalog when the scope is a topic macadames - 2010/08/04

  • added support for z3c.autoinclude macadames - 2010/08/20

1.0.0-b

  • images sizes displayed in finder are taken from portal properties imaging properties when exists

  • choose image sizes : contextual menus added

  • many IE fixes and cosmetic changes

  • plone4 icons style used also under plone3

  • reference objects widget added for zope3 forms (can be used in portlets)

1.0.0-a

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.plonefinder-1.0.4.zip (110.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page