當前位置: 首頁>>代碼示例>>Python>>正文


Python ISelectableBrowserDefault.getLayout方法代碼示例

本文整理匯總了Python中Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault.getLayout方法的典型用法代碼示例。如果您正苦於以下問題:Python ISelectableBrowserDefault.getLayout方法的具體用法?Python ISelectableBrowserDefault.getLayout怎麽用?Python ISelectableBrowserDefault.getLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault的用法示例。


在下文中一共展示了ISelectableBrowserDefault.getLayout方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _context_selected_layout

# 需要導入模塊: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 別名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 別名]
 def _context_selected_layout(self):
     """Return the current layout for the layout aware context if we
     are on the layout aware context
     """
     if not ILayoutAware(self.context, None):
         return ''
     selectable_layout = ISelectableBrowserDefault(self.context, None)
     if not selectable_layout:
         return ''
     return selectable_layout.getLayout()
開發者ID:ispires,項目名稱:plone.app.mosaic,代碼行數:12,代碼來源:widget.py

示例2: upgrade_9_to_10

# 需要導入模塊: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 別名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 別名]
def upgrade_9_to_10(context):
    from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault

    types_tool = getToolByName(context, 'portal_types')
    pc = getToolByName(context, 'portal_catalog')

    # Iterate through all Dexterity content type
    all_ftis = types_tool.listTypeInfo()
    dx_ftis = [x for x in all_ftis if getattr(x, 'behaviors', False)]
    for fti in dx_ftis:
        if not (LAYOUT_BEHAVIORS & set(fti.behaviors)):
            continue

        results = pc.unrestrictedSearchResults(portal_type=fti.id)
        for brain in results:
            ob = brain._unrestrictedGetObject()
            ob_default = ISelectableBrowserDefault(ob, None)
            if ob_default is None:
                continue
            if ob_default.getLayout() in ['view', '@@view']:
                ob_default.setLayout('layout_view')
開發者ID:neilferreira,項目名稱:plone.app.mosaic,代碼行數:23,代碼來源:upgrades.py

示例3: getMenuItems

# 需要導入模塊: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 別名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 別名]

#.........這裏部分代碼省略.........
                               utils.safe_unicode(obj.Title()))}),
                'description': '',
                'action': None,
                'selected': True,
                'icon': None,
                'extra': {
                    'id': 'folderDefaultPageDisplay',
                    'separator': 'actionSeparator',
                    'class': 'actionMenuSelected'},
                'submenu': None,
                })
            # Let the user change the selection
            if folderCanSetDefaultPage:
                results.append({
                    'title': _(u'label_change_default_item',
                               default=u'Change content item as default '
                                       u'view...'),
                    'description': _(u'title_change_default_view_item',
                                     default=u'Change the item used as default'
                                             u' view in this folder'),
                    'action': '%s/select_default_page' % (folderUrl,),
                    'selected': False,
                    'icon': None,
                    'extra': {
                        'id': 'folderChangeDefaultPage',
                        'separator': 'actionSeparator',
                        'class': 'pat-plone-modal'},
                    'submenu': None,
                })

        # 2. Render context options
        if context is not None:
            contextUrl = obj.absolute_url()
            selected = context.getLayout()
            defaultPage = context.getDefaultPage()
            layouts = context.getAvailableLayouts()

            if useSeparators:
                results.append({
                    'title': _(u'label_current_item_views',
                               default=u'Item display'),
                    'description': '',
                    'action': None,
                    'selected': False,
                    'icon': None,
                    'extra': {
                        'id': 'contextHeader',
                        'separator': 'actionSeparator',
                        'class': ''},
                    'submenu': None,
                })

            # If context is a default-page in a folder, that folder's views
            # will be shown. Only show context views if there are any to show.

            showLayouts = False
            if not isDefaultPage:
                showLayouts = True
            elif len(layouts) > 1:
                showLayouts = True

            if showLayouts and contextCanSetLayout:
                for id, title in contextLayouts:
                    is_selected = (defaultPage is None and id == selected)
                    results.append({
                        'title': title,
開發者ID:RBINS,項目名稱:plone.app.contentmenu,代碼行數:70,代碼來源:menu.py

示例4: getMenuItems

# 需要導入模塊: from Products.CMFDynamicViewFTI.interfaces import ISelectableBrowserDefault [as 別名]
# 或者: from Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault import getLayout [as 別名]
    def getMenuItems(self, context, request):
        # Check required parameters
        if context is None or request is None:
            return []

        # Get layout vocabulary factory
        vocab_factory = getUtility(IVocabularyFactory,
                                   name='plone.availableDisplayLayouts')

        # Get context state API
        context_state = getMultiAdapter((context, request),
                                        name='plone_context_state')

        # Get folder layout options when this is a default page
        folder_layout = ''
        folder_methods = []
        folder_results = []
        folder_url = ''
        folder_vocab = []
        if context_state.is_default_page():
            folder = parent(context)
            if folder is not None:
                folder_methods = getAvailableViewMethods(folder)
                folder_url = folder.absolute_url()
                folder_vocab = vocab_factory(folder)
                folder_default = ISelectableBrowserDefault(folder, None)
                if folder_default is not None:
                    folder_layout = folder_default.getLayout()
        for term in folder_vocab or []:
            if term.value in folder_methods:
                is_selected = term.value == folder_layout
                id_ = term.value.split('++')[-1]
                actionUrl = '%s/selectViewTemplate?templateId=%s' % (
                    folder_url, quote(term.value),),
                if HAS_PLONE_PROTECT:
                    actionUrl = addTokenToUrl(actionUrl, request)
                folder_results.append({
                    'title': term.title,
                    'description': '',
                    'action': actionUrl,
                    'selected': is_selected,
                    'icon': None,
                    'extra': {
                        'id': 'folder-layout-' + id_,
                        'separator': None,
                        'class': is_selected and 'actionMenuSelected' or ''},
                    'submenu': None,
                })

        # Get context layout options
        context_methods = getAvailableViewMethods(context)
        context_results = []
        context_url = context.absolute_url()
        context_vocab = vocab_factory(context)
        context_default = ISelectableBrowserDefault(context, None)
        if context_default is not None:
            context_layout = context_default.getLayout()
        for term in context_vocab:
            if term.value in context_methods:
                is_selected = term.value == context_layout
                id_ = term.value.split('++')[-1]
                actionUrl = '%s/selectViewTemplate?templateId=%s' % (
                    context_url, quote(term.value),)
                if HAS_PLONE_PROTECT:
                    actionUrl = addTokenToUrl(actionUrl, request)
                context_results.append({
                    'title': term.title,
                    'description': '',
                    'action': actionUrl,
                    'selected': is_selected,
                    'icon': None,
                    'extra': {
                        'id': 'plone-contentmenu-layout-' + id_,
                        'separator': None,
                        'class': is_selected and 'actionMenuSelected' or ''},
                    'submenu': None,
                })

        # Merge the results with the original display meny
        menu = getUtility(IBrowserMenu, 'plone_contentmenu_display')

        results = []
        for result in menu.getMenuItems(context, request):
            id_ = (result.get('extra') or {}).get('id')
            sep = (result.get('extra') or {}).get('separator')

            # Extend results with layouts
            if id_ in ('folderHeader', 'contextHeader'):
                pass
            elif sep and id_.startswith('folder') and folder_results:
                results.extend(folder_results)
                folder_results = []
            elif sep and id_.startswith('context') and context_results:
                results.extend(context_results)
                context_results = []

            # Move 'Custom layout' into bottom
            if id_ in ['folder-view', '[email protected]@view']:
                folder_results.append(result)
            elif id_ in ['plone-contentmenu-display-view',
#.........這裏部分代碼省略.........
開發者ID:amitsaroj001,項目名稱:plone.app.mosaic,代碼行數:103,代碼來源:layoutmenu.py


注:本文中的Products.CMFDynamicViewFTI.interfaces.ISelectableBrowserDefault.getLayout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。