Package: collective.plonefinder
Ajax popup to browse and select plone contents, suitable to anyplone.formilbform (portlets, control panels, …)This code is an extraction with some refactoring, of PloneArticle explorer used
for referencables proxies.The intent is to make it usable in various situations:to store selected contents inplone.formlibbased Plone forms (portlet or
control panel forms as example)forcollective.ckeditoror 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 tocollective.quickupload)for referencable fields inside AT edit forms (future)for links fields (as remoteUrl in ATLink) to reference internal links (future)This work has been started at Ingeniweb in 2007 by Christophe Bosse (for the
jQuery code) and Jean-Mat Grimaldi (everything else) for PloneArticle product.Plone add-ons developers onlyThis is a component for Plone add-ons developers. Do not expect to add
anything more in yous site if you install only this component to your Zope
instance.RequirementsPlone (tested with Plone 3.3.5 and Plone 4)collective.quickuploadInstallationNothing to do if you have installedcollective.ckeditor(Plone 4 only
today)Otherwise install it as any Zope package using buildout :addcollective.plonefinderin youreggssectionaddcollective.plonefinderin yourzcmlsection of theplone.recipe.zope2instancepart definition if on Plone 3.0 or 3.1Runbin/buildoutNothing else.How to use it as a reference widget in formlib formsBasic usageA 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 "
                                            u"with a plone finder window."),
                               default=()
                               )

form_fields['target_contents'].custom_widget = FinderSelectWidgetTweaking some propertiesYou can use theFinderSelectWidgetwith some properties set using the update
method in yourAddFormorEditForm. In example for a portletAddForm: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 theupdatemethod:assignment = aq_parent(aq_inner(self.context))
self.widgets['targets'].base = aq_parent(aq_inner(assignment))There are also two customized widgets 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 "
                                         u"with a plone finder window. "
                                         u"You can upload new files."),
                            default=()
                            )

form_fields['target_files'].custom_widget = FinderSelectFileWidgetExample 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 "
                                           u"with a plone finder window. "
                                           u"You can select different image sizes. "
                                           u"You can upload new images."),
                              default= ()
                              )

form_fields['target_images'].custom_widget = FinderSelectImageWidgetNote 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_extensioncould be'image_thumb'or'image_preview'…So use something like this to display a referenced image:uid, variant = data.split('/')
'<img src="%s/resolveuid/%s/%s" />' % (portal_url, uid, variant)Full list of customization attributesAttributeDefault valueDescriptionfinderlabel_(u'Browse for contents')Customize the title of the Browser window. i.e."Find the pictures"moveuplabel_(u'Move up')Label associated with the up arrow widget that raises the order of the
reference. i.e."Increase priority".movedownlabel_(u'Move down')Label associated with the down arrow widget that lowers the order of the
reference. i.e."Decrease priority".deleteentrylabel_(u'Remove item')Label associated with the “Remove from list” widget. i.e."Remove this video".types() # All typesList of selectable portal types to show in the selection
panel. i.e.['Document']typeview'file'Possible values are'file','image'and'selection'. Tuning
on selection panel layout.imagetypes('Image', 'News Item')Sequence of portal types that can handle images (seeTodo)selectiontype'uid'Selected items are returned to the application (form) as UIDs. Other
possible value is'url'.showsearchboxTrueDo we show the searchbox?allowuploadFalseDo we enable upload files through our widget if the user has appropriate
permission? SeeUploadding in custom folderish typeopenuploadwidgetdefaultFalseDo we display the upload widget by default?allowaddfolderFalseDo we enable adding new folders through our widget if the user has
appropriate permission?allowimagesizeselectionFalseIf the image has multiple sizes, do we enable the selection of a
particular size? (See the above note)forcecloseoninsertFalseDo we close the finder when an element is selected?baseNoneThe folderish object used as root of the finder when opening.Nonemeans the Plone site.Note thatby nature, this attribute cannot be
set statically, in aFinderSelectWidgetpersonal subclass for example
as other can be. See the example in simple customizations on how to
change the widgetbaseattribute dynamically from the form class
code.Developer HowtoHow to use it in a WYSIWYG editorThe 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 negociations with the browser.Seecollective.ckeditorpackage as example.Uploadding in custom folderish typeIf you want to let the plone finder users upload files in your custom or third
party folderish content types, you need to mark these types with theIFinderUploadCapablemarker interface. As in this self-speaking ZCML
sample:<class class="my.content.folderish.MyFolderish">
  <implements
     interface="collective.plonefinder.browser.interfaces.IFinderUploadCapable" />
</class>Out of the box,collective.plonefinderenables upload in the Plone site
itself as well as inATFolderandATBTreeFolder.TodoFunctional doctestsi18n supportFinder 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
panelremove items from selection list in finder windowImprove zope3 reference widget propertiesadd 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 sessionadd option to change finder catalog.New zope3 widget to store urls (for a string field)Archetypes support:ATPloneFinderWidget for Reference fields (not a big challenge, just need to
use ATReferenceBrowserWidget as base to start the work)ATLinkWidget to store internal linksDexterity support (z3c.form)Supplementtypesandimagetypesattributes with others uning
interfaces for a better flexibility.Provide as parameter a factory that provides the results in the desired
format. i.e You need a particular attribute of the target or some computed
value.Componentize the code for more flexibility.Any contribution is welcome, contactsupport@ingeniweb.com.AuthorsJean-mat Grimaldi - Alter Way SolutionsCode repositoryhttps://github.com/collective/collective.plonefinderSupportQuestions and comments tosupport@ingeniweb.comChangelog1.3.1 (2018-03-26)Fix thumb sizes choice: full size image is now correctly set.
[bsuttor]1.3.0 (2017-10-02)Use plone.api instead of IDirectoryFactory to create Folder, it’s prevent dexterity creation Folder error.
DEPENDENCY ADDED: plone.api.
[bsuttor]1.2.3 (2017-01-10)FinderImageWidget: enable quickupload
[gotcha]1.2.2 (2016-08-15)FinderImageWidget: store selector instead of absolute_url
[gotcha]1.2.1 (2016-07-25)Add missing semicolons to avoid JS issue whenportal_javascriptis in prod mode.
[gotcha]Add check for when value is None (when you remove image after adding it).
[spereverde]Some refactoring for cleaner HTML inFinderImageWidget.
[gotcha]1.2.0 (2016-07-08)Add formlibFinderImageWidget; use with# in interface class
picture = schema.TextLine(title=_(u'Picture'),
                           description=_(u'Optional picture'),
                           required=False)
# in form class
form_fields['picture'].custom_widget = FinderImageWidget[gotcha]1.1.4 (2016-03-30)Fix bug in finder’s query form serialization with special characters.
[pgrunewald]1.1.3 (2016-03-24)Added optionopenuploadwidgetdefaultto be able to specify if we want
the upload widget to be opened by default without having to click on the
‘Files quick upload’ button.
[gbastien]1.1.2 (2016-03-15)Added optionshowsearchboxto be able to display/hide the search box easily.
[gbastien]1.1.1 (2016-02-23)Reapply fixes from 1.0.2 that were lost
maybe in the migration to github
[gotcha]1.1.0 (2016-02-16)Use new way to get images. Call/@@images/image/previewinstead of/image_preview.
[bsuttor]Add implmentation of plone.app.contenttypes.content.Folder by IFinderUploadCapable.
[bsuttor]basic support for plone.app.contenttypes images
[kiorky]1.0.7 (2014-09-15)Fix: with ckeditor, link to News item does not link to its image anymore.
Fix from 1.0.4 was lost in 1.0.5.
[gotcha]1.0.6 (2014-03-05)Fix bad quotted test.
[bsuttor]1.0.5 (2014-03-05)Fix scope container when a object is created. Container is first
non portal_factory object.
[bsuttor]Lots of code simplifications (yet not finished, grep for “FIXME:”)
[glenfant]More doc in the README (explain all releavant usages)
[glenfant]SVN marker in all possible files
[glenfant]Lots of optims (yet not finished, grep for “FIXME:”)
[glenfant]Commented obscure features in the code
[glenfant]Fix case whereimagefield is of the typereference[toutpt]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.1CSS IE7 fixes
macadames - 2010/09/22finder.pt : template fix
doctype was missing
macadames - 2010/09/22finder.pt : Remove lang attribute on html tag- we don’t need it
and it’s difficult to maintain between Plone3 / Plone4
macadames - 2010/09/261.0.0use Plone Quick Upload as upload tool - new dependency to
collective.quickupload added
macadames - 2010/091.0.0-b2fix 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 = Falsefix selectItem when there were quotes in titlesadded 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 referencewidgetadded a generated css for plone3 content-types iconsadded new property self.filestypes in browseradded mime-type icons for filestypes in finderFinderSelectWidget : 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/21Fix enable/disable browsing using request or self.browse = False
macadames - 2010/07/22no search on another path, when browsing is disable
macadames - 2010/07/22title fields added to multiple upload using jquery.uploadify
macadames - 2010/07/24authentication for flash upload is done using cookie
when possible (same method as collective.uploadify)
otherwise using a ticket (method PloneFlashUpload)
macadames - 2010/07/28use standard archetypes method “invokeFactory”, to
create new objects using uploaded files, to respect
the complete plone createObject process.
macadames - 2010/07/28added new mediaupload key in request to set content-type
for upload (very useful with jquery.uploadify)
macadames - 2010/07/28improve jquery.uploadify process with errors handling
macadames - 2010/07/29added new css class required to show icons on plone4
‘icons-on’
macadames - 2010/07/31fix upload buttons styles on plone4
macadames - 2010/07/31fix some css styles on Plone3 or Plone4 + classic Theme
macadames - 2010/07/31design improvements
macadames - 2010/07/31french translation in progress
macadames - 2010/07/31use InavigationRoot for the finder root no more IPloneSiteRot
macadames - 2010/08/01design improvements
blue is the new color
macadames - 2010/08/01added new view attributes root and rootpath
used to change the browser root
macadames - 2010/08/02Added a real left navigation tree
macadames - 2010/08/02replace persistent objects in attribute views
by a data dict ie self.data[‘root’] in place of self.root
macadames - 2010/08/04use topic queryCatalog when the scope is a topic
macadames - 2010/08/04added support for z3c.autoinclude
macadames - 2010/08/201.0.0-bimages sizes displayed in finder are taken from portal properties
imaging properties when existschoose image sizes : contextual menus addedmany IE fixes and cosmetic changesplone4 icons style used also under plone3reference objects widget added for zope3 forms (can be used in portlets)1.0.0-aInitial release