Back to index

plone3  3.1.7
Public Member Functions
plone.app.content.browser.folderfactories.FolderFactoriesView Class Reference
Inheritance diagram for plone.app.content.browser.folderfactories.FolderFactoriesView:
Inheritance graph
[legend]
Collaboration diagram for plone.app.content.browser.folderfactories.FolderFactoriesView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__
def can_constrain_types
def add_context
def addable_types

Detailed Description

The folder_factories view - show addable types

Definition at line 25 of file folderfactories.py.


Member Function Documentation

Definition at line 29 of file folderfactories.py.

00029 
00030     def __call__(self):
00031         if 'form.button.Add' in self.request.form:
00032             url = self.request.form.get('url')
00033             self.request.response.redirect(url)
00034             return ''
00035         else:
00036             return self.index()
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file folderfactories.py.

00042 
00043     def add_context(self):
00044         context_state = getMultiAdapter((self.context, self.request), name='plone_context_state')
00045         return context_state.folder()
    

Here is the call graph for this function:

Here is the caller graph for this function:

Return menu item entries in a TAL-friendly form.

Pass a list of type ids to 'include' to explicitly allow a list of
types.

Definition at line 50 of file folderfactories.py.

00050 
00051     def addable_types(self, include=None):
00052         """Return menu item entries in a TAL-friendly form.
00053         
00054         Pass a list of type ids to 'include' to explicitly allow a list of
00055         types.
00056         """
00057         context = aq_inner(self.context)
00058         request = self.request
00059         
00060         results = []
00061         
00062         portal_state = getMultiAdapter((context, request), name='plone_portal_state')
00063         portal_url = portal_state.portal_url()
00064         
00065         addContext = self.add_context()
00066         baseUrl = addContext.absolute_url()
00067         
00068         allowedTypes = _allowedTypes(request, addContext)
00069         
00070         # XXX: This is calling a pyscript (which we encourage people to customise TTW)
00071         exclude = addContext.getNotAddableTypes()
00072 
00073         # If there is an add view available, use that instead of createObject
00074         # Note: that this depends on the convention that the add view and the
00075         # factory have the same name, and it still only applies where there
00076         # is an FTI in portal_types to begin with. Alas, FTI-less content
00077         # is pretty much a no-go in CMF.
00078         addingview = queryMultiAdapter((addContext, request), name='+')
00079         idnormalizer = queryUtility(IIDNormalizer)
00080         for t in allowedTypes:
00081             typeId = t.getId()
00082             if typeId not in exclude and (include is None or typeId in include):
00083                 cssId = idnormalizer.normalize(typeId)
00084                 cssClass = 'contenttype-%s' % cssId
00085                 factory = t.factory
00086                 if addingview is not None and \
00087                    queryMultiAdapter((addingview, self.request), name=factory) is not None:
00088                     url = '%s/+/%s' % (baseUrl, factory,)
00089                 else:
00090                     url = '%s/createObject?type_name=%s' % (baseUrl, quote_plus(typeId),)
00091                 icon = t.getIcon()
00092                 if icon:
00093                     icon = '%s/%s' % (portal_url, icon)
00094 
00095                 results.append({ 'id'           : typeId,
00096                                  'title'        : t.Title(),
00097                                  'description'  : t.Description(),
00098                                  'action'       : url,
00099                                  'selected'     : False,
00100                                  'icon'         : icon,
00101                                  'extra'        : {'id' : cssId, 'separator' : None, 'class' : cssClass},
00102                                  'submenu'      : None,
00103                                 })
00104 
00105         # Sort the addable content types based on their translated title
00106         results = [(translate(ctype['title'], context=request), ctype) for ctype in results]
00107         results.sort()
00108         results = [ctype[-1] for ctype in results]
00109 
00110         return results

Here is the call graph for this function:

Definition at line 37 of file folderfactories.py.

00037 
00038     def can_constrain_types(self):
00039         constrain_types = ISelectableConstrainTypes(self.add_context(), None)
00040         return constrain_types is not None and constrain_types.canConstrainTypes()
    

Here is the call graph for this function:


The documentation for this class was generated from the following file: