Changeset 778
- Timestamp:
- 01/29/07 10:09:45
- Files:
-
- qPloneTabs/trunk/Extensions/Install.py (modified) (4 diffs)
- qPloneTabs/trunk/HISTORY.txt (modified) (1 diff)
- qPloneTabs/trunk/TODO.txt (modified) (1 diff)
- qPloneTabs/trunk/__init__.py (modified) (1 diff)
- qPloneTabs/trunk/config.py (modified) (1 diff)
- qPloneTabs/trunk/skins/qPloneTabs/getPageTitle.py (added)
- qPloneTabs/trunk/skins/qPloneTabs/javascripts/qplonetabs.js (modified) (7 diffs)
- qPloneTabs/trunk/skins/qPloneTabs/prefs_tabs_form.cpt (modified) (5 diffs)
- qPloneTabs/trunk/skins/qPloneTabs/qpt_add.py (modified) (2 diffs)
- qPloneTabs/trunk/skins/qPloneTabs/qpt_delete.py (modified) (2 diffs)
- qPloneTabs/trunk/skins/qPloneTabs/qpt_edit.py (modified) (1 diff)
- qPloneTabs/trunk/skins/qPloneTabs/qpt_gettabslist.pt (modified) (1 diff)
- qPloneTabs/trunk/skins/qPloneTabs/qpt_reorder.py (modified) (1 diff)
- qPloneTabs/trunk/utils.py (modified) (3 diffs)
- qPloneTabs/trunk/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneTabs/trunk/Extensions/Install.py
r777 r778 5 5 from Products.CMFCore.DirectoryView import addDirectoryViews 6 6 7 from Products.CMFPlone.migrations.migration_util import safeEditProperty 7 8 from Products.qPloneTabs.config import * 8 9 9 configlets = ({'id':PROJECT _NAME,10 configlets = ({'id':PROJECTNAME, 10 11 'name':'Plone Tabs', 11 12 'action':'string:${portal_url}/prefs_tabs_form', … … 13 14 'category':'Products', 14 15 'visible':1, 15 'appId':PROJECT _NAME,16 'appId':PROJECTNAME, 16 17 'permission':VIEW_PERMISSION, 17 18 'imageUrl':'qplonetabs.gif' },) 19 20 def addPropertySheet(self, out): 21 """ Add tabs_properties property sheet to portal_properties and some needed field to it """ 22 portal_props = getToolByName(self, 'portal_properties') 23 if not hasattr(portal_props, PROPERTY_SHEET): 24 portal_props.addPropertySheet(PROPERTY_SHEET, SHEET_TITLE) 25 out.write('Added %s property sheet to portal_properties\n' % PROPERTY_SHEET) 26 else: 27 out.write('Skipped adding %s property sheet to portal_properties\n' % PROPERTY_SHEET) 28 sheet = getattr(portal_props, PROPERTY_SHEET) 29 30 if not hasattr(sheet, FIELD_NAME): 31 safeEditProperty(sheet, FIELD_NAME, PROPERTY_FIELD, 'lines') 32 out.write('Added %s property field to %s property sheet\n' % (FIELD_NAME, PROPERTY_SHEET)) 33 else: 34 out.write('Skipped adding %s property field to %s property sheet\n' % (FIELD_NAME, PROPERTY_SHEET)) 18 35 19 36 def setupSkin(self, out, skinFolder): … … 79 96 skinstool = getToolByName(self, 'portal_skins') 80 97 addDirectoryViews(skinstool, SKINS_DIR, GLOBALS) 81 setupSkin(self, out, PROJECT _NAME)98 setupSkin(self, out, PROJECTNAME) 82 99 83 100 mtool = getToolByName(self, 'portal_migration') 84 101 plone_version = mtool.getFileSystemVersion() 85 102 if plone_version == '2.0.5': 86 setupSkin(self, out, PROJECT_NAME+'/2.0.5') 87 out.write('Added %s/2.0.5 Layer to portal_skins\n' % PROJECT_NAME) 103 setupSkin(self, out, PROJECTNAME+'/2.0.5') 104 out.write('Added %s/2.0.5 Layer to portal_skins\n' % PROJECTNAME) 105 106 addPropertySheet(self, out) 88 107 89 108 addConfiglet(self, out) … … 99 118 100 119 out.write('removeSkin... \n') 101 removeSkin(self, [PROJECT _NAME, PROJECT_NAME+'/2.0.5'])120 removeSkin(self, [PROJECTNAME, PROJECTNAME+'/2.0.5']) 102 121 103 122 return out.getvalue() qPloneTabs/trunk/HISTORY.txt
r777 r778 1 0.3.0 2 3 * added support for any actions category 4 5 * fixed reordering bug on server with empty list 6 7 * hidden reordering controls when the list of actions is empty 8 1 9 0.2.2 2 10 qPloneTabs/trunk/TODO.txt
r777 r778 1 1 * Opera compatibility 2 2 * 'portal-globalnav' visualization without page reloading 3 * using kukit framework qPloneTabs/trunk/__init__.py
r777 r778 5 5 6 6 allow_module('Products.qPloneTabs.utils') 7 allow_module('Products.qPloneTabs.config') 7 8 registerDirectory(SKINS_DIR, GLOBALS) 8 9 9 from Products.qPloneTabs.utils import getPortal Tabs10 from Products.qPloneTabs.utils import getPortalActions 10 11 from Products.qPloneTabs.utils import getRootTabs qPloneTabs/trunk/config.py
r777 r778 3 3 VIEW_PERMISSION = CMFCorePermissions.ManagePortal 4 4 5 PROJECT _NAME = 'qPloneTabs'5 PROJECTNAME = 'qPloneTabs' 6 6 SKINS_DIR = 'skins' 7 7 8 8 GLOBALS = globals() 9 10 PROPERTY_SHEET = 'tabs_properties' 11 SHEET_TITLE = 'Portal Tabs Properties' 12 FIELD_NAME = 'titles' 13 PROPERTY_FIELD = ['portal_tabs|Portal Tabs Configuration', 'portal_footer|Portal Footer Configuration'] qPloneTabs/trunk/skins/qPloneTabs/javascripts/qplonetabs.js
r777 r778 3 3 var gBeforeReorderFragment = null; // document fragment for insertion in UL after clicking cancel button after reorder 4 4 var gBeforeEditData = {}; // hash for storage tabs fields before editing 5 var category = 'portal_tabs'; 5 6 6 7 /* Main part - rules for element on our form */ … … 20 21 '#app #save' : function(el){ 21 22 el.onclick = function(ev){ 22 var ev = ev?ev:window.event, params = ' ';23 $A($('tabslist').getElementsByTagName('INPUT')).findAll(function(h){return h.type=='hidden';}).each(function(f,idx){params += idx==0?'idxs='+f.value:'&idxs='+f.value;});23 var ev = ev?ev:window.event, params = 'category='+category; 24 $A($('tabslist').getElementsByTagName('INPUT')).findAll(function(h){return h.type=='hidden';}).each(function(f,idx){params += '&idxs='+f.value;}); 24 25 new Ajax.Request('qpt_reorder', 25 26 {method: 'post', … … 82 83 } 83 84 else { 84 params['parameters'] = ' num='+num+'&visibility='+el.checked+'&'+Form.serialize(li.getElementsByTagName('FORM')[0]);85 params['parameters'] = 'category='+category+'&num='+num+'&visibility='+el.checked+'&'+Form.serialize(li.getElementsByTagName('FORM')[0]); 85 86 new Ajax.Request('qpt_edit', params); 86 87 }; … … 95 96 num = $A($('tabslist').getElementsByTagName('LI')).indexOf(item); 96 97 new Ajax.Request('qpt_delete', 97 {parameters:' idx='+num+'&id=' + item.id.replace('tabslist_', ''),98 {parameters:'category='+category+'&idx='+num+'&id=' + item.id.replace('tabslist_', ''), 98 99 onComplete: function(request) { 99 100 new Effect.Fade(item, {duration: 0.3, afterFinish: function(){ … … 151 152 var num = $A($('tabslist').getElementsByTagName('LI')).indexOf(li); 152 153 new Ajax.Request('qpt_edit', 153 {parameters:' num='+num+'&'+Form.serialize(Event.findElement(ev, 'FORM')),154 {parameters:'category='+category+'&num='+num+'&'+Form.serialize(Event.findElement(ev, 'FORM')), 154 155 onSuccess: function(request){ 155 156 new Effect.BlindUp(dd, { … … 223 224 var idx = $('tabslist').getElementsByTagName('LI').length; 224 225 new Ajax.Request('qpt_add', 225 {parameters:' idx='+idx+'&'+Form.serialize('addaction'),226 {parameters:'category='+category+'&idx='+idx+'&'+Form.serialize('addaction'), 226 227 onSuccess: function(request){ 227 228 var dl = $('addaction').getElementsByTagName('DL')[3], dd = dl.getElementsByTagName('DD')[0]; … … 302 303 303 304 Event.observe(window, 'load', collapseAdvanced); 305 Event.observe(window, 'load', function() { 306 var category_input = document.getElementById('actions_category'); 307 if (category_input && typeof(category_input.value) != 'undefined') { 308 category_input.value ? category = category_input.value : {}; 309 }; 310 }); 304 311 Event.observe(window, 'unload', function(){gBeforeReorderFragment = null; gBeforeEditData = null;}); 305 312 qPloneTabs/trunk/skins/qPloneTabs/prefs_tabs_form.cpt
r777 r778 22 22 <body> 23 23 <div metal:fill-slot="prefs_configlet_main" 24 tal:define="errors python:request.get('errors', {})"> 25 24 tal:define="errors python:request.get('errors', {}); 25 category here/REQUEST/category|nothing; 26 category python:test(category and category!='', category, 'portal_tabs')"> 26 27 <div id="app" class="viewing"> 27 <h1 i18n:translate="heading_plonetabs">Plone Tabs Configuration <span id="busy"><img src='busy_icon.gif' alt="" /></span></h1> 28 <h1 i18n:translate="heading_plonetabs"> 29 <span tal:content="python:context.getPageTitle(category)" /><span id="busy"><img src='busy_icon.gif' alt="" /></span></h1> 28 30 <a href="" 29 31 class="link-parent" … … 32 34 Up to Site Setup 33 35 </a> 36 <input type="hidden" name="category" value="portal_tabs" id="actions_category" 37 tal:attributes="value category" /> 34 38 <div class="reorder-controls"> 35 39 <a href="#" id="reorder">Reorder</a> … … 40 44 </div> 41 45 <ul class="csshover" 42 id="tabslist" tal:content="structure here/qpt_gettabslist" />46 id="tabslist" tal:content="structure python:here.qpt_gettabslist(category=category)" /> 43 47 <form id="addaction" 44 48 method="post" … … 76 80 error errors/generated_tabs | nothing;" 77 81 tal:attributes="class python:test(error, 'field error', 'field')" 78 tal:on-error="string:"> 82 tal:on-error="string:" 83 tal:condition="python:category == 'portal_tabs'"> 79 84 <input type="checkbox" 80 85 id="generated_tabs" … … 91 96 <ul class="csshover" id="roottabs" 92 97 tal:on-error="string:" 93 tal:content="structure here/qpt_getroottabs" /> 98 tal:content="structure here/qpt_getroottabs" 99 tal:condition="python:category == 'portal_tabs'" /> 94 100 </div> 95 101 qPloneTabs/trunk/skins/qPloneTabs/qpt_add.py
r777 r778 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= idx, name, action='', id, c ondition='', visible=False7 ##parameters= idx, name, action='', id, category='portal_tabs', condition='', visible=False 8 8 ##title= 9 9 ## … … 23 23 visible = False 24 24 params = {'id':id, 'name':name, 'action':action, 'condition':condition, 25 'permission':'View', 'category': 'portal_tabs', 'visible':visible}25 'permission':'View', 'category':category, 'visible':visible} 26 26 act_tool = getToolByName(context, 'portal_actions') 27 27 act_tool.addAction(**params) qPloneTabs/trunk/skins/qPloneTabs/qpt_delete.py
r777 r778 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= idx, id 7 ##parameters= idx, id, category='portal_tabs' 8 8 ##title= 9 9 ## … … 11 11 from Products.qPloneTabs.utils import deleteAction 12 12 13 return deleteAction(context, idx, id )13 return deleteAction(context, idx, id, category) qPloneTabs/trunk/skins/qPloneTabs/qpt_edit.py
r777 r778 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= idx, num, visibility=[] 7 ##parameters= idx, num, visibility=[], category='portal_tabs' 8 8 ##title= 9 9 ## 10 10 11 11 req = context.REQUEST 12 params = {'self':context,'num':num }12 params = {'self':context,'num':num, 'category':category} 13 13 fields = ['name', 'action', 'id', 'condition'] 14 14 if visibility != []: params['visibility'] = visibility qPloneTabs/trunk/skins/qPloneTabs/qpt_gettabslist.pt
r777 r778 1 <tal:tabs tal:define="dummy python:request.RESPONSE.setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')" 2 tal:repeat="tab python:modules['Products.qPloneTabs'].getPortalTabs(here)"> 1 <tal:tabs tal:define="dummy python:request.RESPONSE.setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'); 2 category python:options.get('category', None) or 'portal_tabs'" 3 tal:repeat="tab python:modules['Products.qPloneTabs'].getPortalActions(here, category)"> 3 4 <li tal:define="id tab/id; 4 5 visible tab/visible|nothing; qPloneTabs/trunk/skins/qPloneTabs/qpt_reorder.py
r777 r778 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= idxs 7 ##parameters= idxs=[], category='portal_tabs' 8 8 ##title= 9 9 ## 10 10 11 if not idxs: return 'No items' 12 11 13 from Products.qPloneTabs.utils import reorderActions 12 14 13 return reorderActions(context, idxs )15 return reorderActions(context, idxs, category) qPloneTabs/trunk/utils.py
r777 r778 5 5 from Products.CMFCore.utils import getToolByName 6 6 7 def getPortal Tabs(self):7 def getPortalActions(self, category='portal_tabs'): 8 8 """ Return all portal actions with 'portal_tabs' category """ 9 return filter(lambda a: a.category == 'portal_tabs', getToolByName(self, 'portal_actions')._cloneActions())9 return filter(lambda a: a.category == category, getToolByName(self, 'portal_actions')._cloneActions()) 10 10 11 def editAction(self, num, name, id, action='', condition='', visibility=[] ):11 def editAction(self, num, name, id, action='', condition='', visibility=[], category='portal_tabs'): 12 12 """ Function for editing given action """ 13 13 actions = getToolByName(self, 'portal_actions')._actions 14 tabs = filter(lambda a: a.category == 'portal_tabs', actions)14 tabs = filter(lambda a: a.category == category, actions) 15 15 tab = tabs[int(num)] 16 16 if visibility != []: … … 25 25 return True 26 26 27 def reorderActions(self, idxs ):27 def reorderActions(self, idxs, category='portal_tabs'): 28 28 """ Reorder portal_tabs actions in given order """ 29 29 idxs = list(map(int,idxs)) 30 30 portal_actions = getToolByName(self, 'portal_actions') 31 31 actions = portal_actions._cloneActions() 32 tabs = [[action, actions.index(action)] for action in actions if action.category == 'portal_tabs']32 tabs = [[action, actions.index(action)] for action in actions if action.category == category] 33 33 for idx in range(len(idxs)): 34 34 actions[tabs[idx][1]] = tabs[idxs[idx]][0] … … 36 36 return idxs 37 37 38 def deleteAction(self, idx, id ):38 def deleteAction(self, idx, id, category='portal_tabs'): 39 39 """ Delete portal_tabs action with given index """ 40 40 portal_actions = getToolByName(self, 'portal_actions') 41 41 actions = portal_actions._cloneActions() 42 tabs = filter(lambda a: a.category == 'portal_tabs', actions)42 tabs = filter(lambda a: a.category == category, actions) 43 43 if tabs[int(idx)].id == id: 44 44 portal_actions.deleteActions([actions.index(tabs[int(idx)]),]) qPloneTabs/trunk/version.txt
r777 r778 1 0. 2.21 0.3.0
