make Menu a local utility

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@545 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2005-08-14 17:25:06 +00:00
parent ad7d8828a1
commit b6d61f557b
3 changed files with 75 additions and 4 deletions

View file

@ -5,7 +5,39 @@
xmlns="http://namespaces.zope.org/browser"
i18n_domain="zope"
>
<tool
interface="cybertools.interfaces.IMenu"
title="Menu"
description="A Menu allows you to add menu items that are then shown in a portlet"
/>
<addform
label="Add Menu"
name="AddMenu.html"
schema="cybertools.interfaces.IMenu"
content_factory="cybertools.menu.Menu"
fields="title"
permission="zope.ManageContent"
/>
<addMenuItem
class="cybertools.menu.Menu"
title="Menu"
permission="zope.ManageContent"
view="AddMenu.html"
/>
<editform
label="Edit Menu"
name="edit.html"
schema="cybertools.interfaces.IMenu"
for="cybertools.interfaces.IMenu"
permission="zope.ManageContent"
menu="zmi_views" title="Edit"
fields="title"
/>
<include package=".skin" />
</configure>

View file

@ -5,11 +5,33 @@
i18n_domain="zope"
>
<!-- Security definitions -->
<!-- Content declarations -->
<!-- Register various browser related components, including all views -->
<interface
interface=".interfaces.IMenu"
type="zope.app.content.interfaces.IContentType" />
<content class=".menu.Menu">
<implements
interface="zope.app.utility.interfaces.ILocalUtility
zope.app.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="cybertools.Menu"
description="A configurable menu" />
<require
permission="zope.View"
interface=".interfaces.IMenu" />
<require
permission="zope.ManageContent"
set_schema=".interfaces.IMenu" />
</content>
<!-- Register views and skin stuff -->
<include package=".browser" />
</configure>

View file

@ -24,6 +24,7 @@ $Id$
from zope.interface import Interface
from zope.app.container.interfaces import IOrderedContainer
from zope.app.component.interfaces.registration import IRegisterable
from zope.schema import Text, TextLine, List, Object, Int
@ -32,6 +33,12 @@ class IBaseMenuItem(IOrderedContainer):
""" Base interface with common methods for IMenu and IMenuItem.
"""
title = TextLine(
title=u'Title',
description=u'Title of the menu or text that will appear on the menu item',
default=u'',
required=True)
def getMenuItems():
""" Return sub-menu items contained in this menu or menu item.
"""
@ -59,7 +66,7 @@ class IBaseMenuItem(IOrderedContainer):
"""
class IMenu(IBaseMenuItem):
class IMenu(IBaseMenuItem, IRegisterable):
""" A Menu is a container for MenuItems and will be shown in a
menu portlet.
"""
@ -88,6 +95,16 @@ class IMenuItem(IBaseMenuItem):
with other MenuItem objects in a menu portlet.
"""
target = Object(Interface,
title=u'Target',
description=u'Target object this menu item should link to.',)
urlPath = TextLine(
title=u'URL or Path',
description=u'URL or path that this menu item should link to.',
default=u'',
required=True)
def getItemUrl():
""" Return the target URL of this menu item.
"""