Changeset 1194 in products


Ignore:
Timestamp:
Jul 30, 2009 3:06:20 PM (15 years ago)
Author:
piv
Message:

make viewlet work with portal_actions (though need some fixes yet), add manifest, add css w/o dtml injections, fix settings interface

Location:
quintagroup.dropdownmenu/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/configure.zcml

    r1182 r1194  
    3131 
    3232  <!-- Register resources --> 
    33  
     33  <browser:resource 
     34      name="drop_down.css" 
     35      file="resources/drop_down.css" 
     36      /> 
    3437 
    3538</configure> 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/resources/drop_down.css

    r1182 r1194  
    1 /* <dtml-with base_properties> (do not remove this :) */ 
    2 /* <dtml-call "REQUEST.set('portal_url', portal_url())"> (not this either :) */ 
     1/* DropDown Menu Styles */ 
    32 
    43body { 
     
    1615 
    1716#portal-globalnav li { 
    18         margin: 0;   
     17        margin: 0; 
    1918        padding: 0; 
    20         border: 0;  
     19        border: 0; 
    2120        display: inline; 
    2221        float: left; 
     
    8786#portal-globalnav .csshover ul li ul li a:hover, 
    8887#portal-globalnav .csshover ul li ul li:hover a { 
    89         color: &dtml-globalFontColor;; 
     88        color: #436976; 
    9089} 
    9190 
     
    9695 
    9796#portal-globalnav ul li ul { 
    98         border: &dtml-borderWidth; &dtml-borderStyle; &dtml-globalBorderColor;; 
     97        border: 1px solid #8cacbb; 
    9998        padding-bottom: 1px; 
    10099        overflow: hidden; 
     
    102101 
    103102#portal-globalnav .csshover ul li:hover ul li:hover ul  a { 
    104         color: &dtml-globalFontColor;; 
     103        color: #436976; 
    105104} 
    106105 
     
    108107 
    109108#portal-globalnav ul { 
    110         font-size:8pt; 
    111         list-style-type:none; 
    112         list-style-image:none; 
     109        font-size: 8pt; 
     110        list-style-type: none; 
     111        list-style-image: none; 
    113112} 
    114113 
    115114#portal-globalnav ul li { 
    116         padding:0; 
    117         margin:0; 
    118         line-height:normal; 
     115        padding: 0; 
     116        margin: 0; 
     117        line-height: normal; 
    119118} 
    120119 
    121120#portal-globalnav ul li.selected a, 
    122121#portal-globalnav .csshover ul li a:hover { 
    123         background-color:&dtml-globalBackgroundColor;; 
    124         color:&dtml-globalFontColor;; 
     122        background-color: #dee7ec; 
     123        color: #436976; 
    125124} 
    126125 
    127126#portal-globalnav .csshover ul li:hover ul { 
    128         margin:0; 
    129         border: &dtml-borderWidth; &dtml-borderStyle; &dtml-globalBorderColor;; 
    130         background-color: &dtml-backgroundColor;; 
    131         overflow:visible; 
     127        margin: 0; 
     128        border: 1px solid #8cacbb; 
     129        background-color: White; 
     130        overflow: visible; 
    132131} 
    133132 
    134133#portal-globalnav .csshover ul li:hover ul li { 
    135         padding:0; 
    136         margin:0; 
     134        padding: 0; 
     135        margin: 0; 
    137136} 
    138137 
    139138#portal-globalnav .csshover ul li:hover ul li a { 
    140         color: &dtml-globalFontColor; !important; 
    141         margin:0; 
    142         line-height:normal; 
    143         width:auto; 
     139        color: #436976 !important; 
     140        margin: 0; 
     141        line-height: normal; 
     142        width: auto; 
    144143} 
    145144 
    146145#portal-globalnav .csshover ul li ul li a:hover { 
    147         background-image:none; 
     146        background-image: none; 
    148147} 
    149148 
     
    154153/*Configlet styles************************************************************/ 
    155154 
    156 .ieVisible {display:none;} 
     155.ieVisible {display: none;} 
    157156 
    158157* html .ieHidden {display: none;} 
    159158 
    160159* html .ieVisible {display: block;} 
    161  
    162  
    163 /* </dtml-with> (do not remove this either :) */ 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/templates/sections.pt

    r1182 r1194  
    1 <tal:tabs i18n:domain="plone"> 
     1<tal:tabs tal:condition="view/portal_tabs" 
     2          i18n:domain="plone"> 
    23    <h5 class="hiddenStructure" i18n:translate="heading_sections">Sections</h5> 
    34    <div id="portal-globalnav"> 
    45        <div class="csshover"> 
    5             <ul> 
    6                <span tal:replace="structure context/portal_properties/dropdownmenu_properties/menu|string:qPloneDropDownMenu broken" /> 
    7                <li class="invisibleHeightKeeper">&nbsp;</li> 
     6            <ul class="globalSections"> 
     7                <li tal:replace="structure view/createMenu"> 
     8                    DropDown Menu 
     9                </li> 
     10                <li class="invisibleHeightKeeper">&nbsp;</li> 
    811            </ul> 
    912        </div> 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py

    r1182 r1194  
    1 from zope.component import getMultiAdapter 
     1# -*- coding: utf-8 -*- 
     2from Acquisition import aq_inner 
     3 
     4from zope.component import getMultiAdapter, queryUtility 
    25 
    36from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 
     7from Products.CMFCore.utils import getToolByName 
     8from Products.CMFCore.interfaces import IAction, IActionCategory 
     9from Products.CMFCore.ActionInformation import ActionInfo 
    410 
     11from plone.memoize.instance import memoize 
    512from plone.app.layout.viewlets import common 
     13from plone.registry.interfaces import IRegistry 
     14 
     15from quintagroup.dropdownmenu.interfaces import IDropDownMenuSettings 
    616 
    717 
    818class GlobalSectionsViewlet(common.GlobalSectionsViewlet): 
    919    index = ViewPageTemplateFile('templates/sections.pt') 
     20    recurse = ViewPageTemplateFile('templates/sections_recurse.pt') 
    1021 
    1122    def update(self): 
    12         super(GlobalSectionsViewlet, self).update() 
     23        # we may need some previously defined variables 
     24        #super(GlobalSectionsViewlet, self).update() 
     25 
     26        # prepare to gather portal tabs 
     27        tabs = [] 
     28        context = aq_inner(self.context) 
     29        self.conf = conf = self._settings() 
     30        self.tool = getToolByName(context, 'portal_actions') 
     31 
     32        # fetch actions-based tabs? 
     33        if conf.show_actions_tabs: 
     34            tabs.extend(self._actions_tabs()) 
     35 
     36        # fetch content structure-based tabs? 
     37        if conf.show_content_tabs: 
     38            # put content-based actions before content structure-based ones? 
     39            if conf.content_before_actions_tabs: 
     40                tabs = self._content_tabs() + tabs 
     41            else: 
     42                tabs.extend(self._content_tabs()) 
     43 
     44        # assign collected tabs eventually 
     45        self.portal_tabs = tabs 
     46 
     47    def _actions_tabs(self): 
     48        """Return tree of tabs based on portal_actions tool configuration""" 
     49        conf = self.conf 
     50        tool = self.tool 
     51        context = aq_inner(self.context) 
     52 
     53        # check if we have required root actions category inside tool 
     54        if conf.actions_category not in tool.objectIds(): 
     55            return [] 
     56 
     57        #category_ids = category.objectIds() 
     58        #selectedTabs = self.context.restrictedTraverse('selectedTabs') 
     59        ## try to find out selected subtab 
     60        #if tab['id'] == self.selected_portal_tab: 
     61            #selection = selectedTabs(None, None, tab['subtabs']) 
     62            #self.selected_sub_tab = selection['portal'] 
     63        return self._subactions(tool._getOb(conf.actions_category), context) 
     64 
     65    def _subactions(self, category, object, level=0): 
     66        tabs = [] 
     67        for info in self._actionInfos(category, object): 
     68            # prepare data for action 
     69            # TODO: implement current element functionality, maybe should be 
     70            #       done on a template level because of separate content and  
     71            #       actions tabs are rendered separately 
     72            currentItem = False 
     73            currentParent = False 
     74            # TODO: adjust img tag 
     75            icon = info['icon'] and '<img src="%s" />' % info['icon'] or '' 
     76 
     77            # look up children for a given action 
     78            children = [] 
     79            if level <= self.conf.actions_tabs_level: 
     80                # try to find out appropriate subcategory 
     81                subcat_id = self.conf.nested_category_prefix + info['id'] + \ 
     82                         self.conf.nested_category_sufix 
     83                if subcat_id in category.objectIds(): 
     84                    subcat = category._getOb(subcat_id) 
     85                    if IActionCategory.providedBy(subcat): 
     86                        children = self._subactions(subcat, object, level+1) 
     87 
     88            # make up final tab dictionary 
     89            tab = {'Title': info['title'], 
     90                   'Description': info['description'], 
     91                   'getURL': info['url'], 
     92                   'show_children': len(children) > 0, 
     93                   'children': children, 
     94                   'currentItem': currentItem, 
     95                   'currentParent': currentParent, 
     96                   'item_icon': {'html_tag': icon}, 
     97                   'normalized_review_state': 'visible'} 
     98            tabs.append(tab) 
     99        return tabs 
     100 
     101    def _actionInfos(self, category, object, check_visibility=1, 
     102                     check_permissions=1, check_condition=1, max=-1): 
     103        """Return action infos for a given category""" 
     104        context = aq_inner(self.context) 
     105        ec = self.tool._getExprContext(object) 
     106        actions = [ActionInfo(action, ec) for action in category.objectValues() 
     107                    if IAction.providedBy(action)] 
     108 
     109        action_infos = [] 
     110        for ai in actions: 
     111            if check_visibility and not ai['visible']: 
     112                continue 
     113            if check_permissions and not ai['allowed']: 
     114                continue 
     115            if check_condition and not ai['available']: 
     116                continue 
     117            action_infos.append(ai) 
     118            if max + 1 and len(action_infos) >= max: 
     119                break 
     120        return action_infos 
     121 
     122    def _content_tabs(self): 
     123        """Return tree of tabs based on content structure""" 
     124        return [] 
     125 
     126    @memoize 
     127    def _settings(self): 
     128        """Fetch dropdown menu settings registry""" 
     129        registry = queryUtility(IRegistry) 
     130        return registry.forInterface(IDropDownMenuSettings) 
     131 
     132    def createMenu(self): 
     133        return self.recurse(children=self.portal_tabs, level=1) 
     134 
     135    def _old_update(self): 
    13136        context_state = getMultiAdapter((self.context, self.request), 
    14137                                        name=u'plone_context_state') 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py

    r1181 r1194  
    5757                      u"nested menu stops. 0 means no limit. 1 only includes " 
    5858                      u"the root folder."), 
    59         default=0) 
     59        default=0, 
     60        required=False) 
    6061 
    6162    actions_category = schema.TextLine( 
     
    7576                      u"to 'pre_index_html_sub' will be looked up on the same " 
    7677                      u"level to get nested menu for 'index_html' action."), 
    77         default=u"") 
     78        default=u"", 
     79        required=False) 
    7880 
    7981    nested_category_sufix = schema.TextLine( 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/profiles/default/cssregistry.xml

    r1182 r1194  
    11<?xml version="1.0"?> 
    22<object name="portal_css" meta_type="Stylesheets Registry"> 
    3  <stylesheet title="DropDownMenu" cacheable="True" compression="safe" cookable="True" 
     3 <stylesheet title="DropDown Menu" cacheable="True" compression="safe" cookable="True" 
    44     enabled="1" expression="" id="++resource++drop_down.css" media="screen" 
    55     rel="stylesheet" rendering="import"/> 
Note: See TracChangeset for help on using the changeset viewer.