Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
plone.app.contentmenu.menu.FactoriesSubMenuItem Class Reference
Inheritance diagram for plone.app.contentmenu.menu.FactoriesSubMenuItem:
Inheritance graph
[legend]
Collaboration diagram for plone.app.contentmenu.menu.FactoriesSubMenuItem:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def extra
def title
def description
def action
def icon
def available
def selected

Public Attributes

 context_state

Static Public Attributes

string submenuId = 'plone_contentmenu_factory'
int order = 30

Private Member Functions

def _addContext
def _itemsToAdd
def _addableTypesInContext
def _addingToParent
def _showConstrainOptions
def _hideChildren

Detailed Description

Definition at line 393 of file menu.py.


Constructor & Destructor Documentation

def plone.app.contentmenu.menu.FactoriesSubMenuItem.__init__ (   self,
  context,
  request 
)

Definition at line 399 of file menu.py.

00399 
00400     def __init__(self, context, request):
00401         BrowserSubMenuItem.__init__(self, context, request)
00402         self.context_state = getMultiAdapter((context, request), name='plone_context_state')

Here is the caller graph for this function:


Member Function Documentation

Definition at line 481 of file menu.py.

00481 
00482     def _addableTypesInContext(self, addContext):
00483         allowed_types = _allowedTypes(self.request, addContext)
00484         constrain = IConstrainTypes(addContext, None)
00485         if constrain is None:
00486             return allowed_types
00487         else:
00488             locallyAllowed = constrain.getLocallyAllowedTypes()
00489             return [fti for fti in allowed_types if fti.getId() in locallyAllowed]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 473 of file menu.py.

00473 
00474     def _addContext(self):
00475         return self.context_state.folder()

Here is the caller graph for this function:

Definition at line 491 of file menu.py.

00491 
00492     def _addingToParent(self):
00493         return (self._addContext().absolute_url() != self.context.absolute_url())

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 506 of file menu.py.

00506 
00507     def _hideChildren(self):
00508         itemsToAdd = self._itemsToAdd()
00509         showConstrainOptions = self._showConstrainOptions()
00510         return (len(itemsToAdd) == 1 and not showConstrainOptions)
00511 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 477 of file menu.py.

00477 
00478     def _itemsToAdd(self):
00479         context=self.context_state.folder()
00480         return [(context, fti) for fti in self._addableTypesInContext(context)]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 495 of file menu.py.

00495 
00496     def _showConstrainOptions(self):
00497         addContext = self._addContext()
00498         constrain = ISelectableConstrainTypes(addContext, None)
00499         if constrain is None:
00500             return False
00501         elif constrain.canSetConstrainTypes() and constrain.getDefaultAddableTypes():
00502             return True
00503         elif len(constrain.getLocallyAllowedTypes()) < len(constrain.getImmediatelyAddableTypes()):
00504             return True

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 440 of file menu.py.

00440 
00441     def action(self):
00442         addContext = self._addContext()
00443         if self._hideChildren():
00444             (addContext, fti) = self._itemsToAdd()[0]
00445             baseUrl = addContext.absolute_url()
00446             addingview = queryMultiAdapter((addContext, self.request), name='+')
00447             if addingview is not None:
00448                 addview = queryMultiAdapter((addingview, self.request), name=fti.factory)
00449                 if addview is not None:
00450                     return '%s/+/%s' % (baseUrl, fti.factory,)
00451             return '%s/createObject?type_name=%s' % (baseUrl, quote_plus(fti.getId()),)
00452         else:
00453             return '%s/folder_factories' % self.context_state.folder().absolute_url()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 462 of file menu.py.

00462 
00463     def available(self):
00464         itemsToAdd = self._itemsToAdd()
00465         showConstrainOptions = self._showConstrainOptions()
00466         if self._addingToParent() and not self.context_state.is_default_page():
00467             return False
00468         return (len(itemsToAdd) > 0 or showConstrainOptions)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 429 of file menu.py.

00429 
00430     def description(self):
00431         itemsToAdd = self._itemsToAdd()
00432         showConstrainOptions = self._showConstrainOptions()
00433         if showConstrainOptions or len(itemsToAdd) > 1:
00434             return _(u'title_add_new_items_inside_item', default=u'Add new items inside this item')
00435         elif len(itemsToAdd) == 1:
00436             return itemsToAdd[0][1].Description()
00437         else:
00438             return _(u'title_add_new_items_inside_item', default=u'Add new items inside this item')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 404 of file menu.py.

00404 
00405     def extra(self):
00406         return {'id': 'plone-contentmenu-factories',
00407                 'hideChildren': self._hideChildren()}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 455 of file menu.py.

00455 
00456     def icon(self):
00457         if self._hideChildren():
00458             fti = self._itemsToAdd()[0][1]
00459             return fti.getIcon()
00460         else:
00461             return None

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 469 of file menu.py.

00469 
00470     def selected(self):
00471         return False

Definition at line 409 of file menu.py.

00409 
00410     def title(self):
00411         itemsToAdd = self._itemsToAdd()
00412         showConstrainOptions = self._showConstrainOptions()
00413         if showConstrainOptions or len(itemsToAdd) > 1:
00414             return _(u'label_add_new_item', default=u'Add new\u2026')
00415         elif len(itemsToAdd) == 1:
00416             fti=itemsToAdd[0][1]
00417             title = fti.Title()
00418             if isinstance(title, Message):
00419                 title = translate(title, context=self.request)
00420             else:
00421                 title = translate(_safe_unicode(title),
00422                                   domain='plone',
00423                                   context=self.request)
00424             return _(u'label_add_type', default='Add ${type}',
00425                      mapping={'type' : title})
00426         else:
00427             return _(u'label_add_new_item', default=u'Add new\u2026')

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 401 of file menu.py.

Definition at line 397 of file menu.py.

string plone.app.contentmenu.menu.FactoriesSubMenuItem.submenuId = 'plone_contentmenu_factory' [static]

Definition at line 396 of file menu.py.


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