Author: jmorliaguet Date: Wed Jun 14 16:44:54 2006 New Revision: 3408 Added: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/add-pageblock.png (contents, props changed) cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/views.py (contents, props changed) Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/configure.zcml cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/configure.zcml cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/themepage.pt
Log: - added an 'add page block' button in layout mode as in CPSSkins v2 Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py (original) +++ cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py Wed Jun 14 16:44:54 2006 @@ -269,6 +269,7 @@ self.tmutil.addPage(theme, page) response.redirect('.') + ### Presentation ################################################# def clonePresentation(self, perspective=None): @@ -353,7 +354,7 @@ view = Contents(container, request) view.pasteObjects() - def insertElement(self, id, type_name, order): + def insertElement(self, id, type_name, order=0): """Insert an element inside a container at a given position. Return the id of inserted element. """ Modified: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/configure.zcml ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/configure.zcml (original) +++ cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/configure.zcml Wed Jun 14 16:44:54 2006 @@ -18,4 +18,17 @@ </browser:pages> + <browser:pages + for="*" + layer="cpsskins.browser.skin.cpsskins" + permission="zope.ManageContent" + class=".views.PageDesigner"> + + <page + name="addPageBlock" + attribute="addPageBlock" + /> + + </browser:pages> + </configure> Added: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/add-pageblock.png ============================================================================== Binary file. No diff available. Modified: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/configure.zcml ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/configure.zcml (original) +++ cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/configure.zcml Wed Jun 14 16:44:54 2006 @@ -5,8 +5,12 @@ <include file="engine.zcml" /> <browser:resource - name="layout-mode.css" - file="layout_mode.css" + name="layout-mode.css" file="layout_mode.css" + layer="cpsskins.browser.skin.cpsskins" + /> + + <browser:resource + name="add-pageblock.png" file="add-pageblock.png" layer="cpsskins.browser.skin.cpsskins" /> Modified: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/themepage.pt ============================================================================== --- cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/themepage.pt (original) +++ cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/layout/themepage.pt Wed Jun 14 16:44:54 2006 @@ -1,3 +1,11 @@ <div tal:define="id context/identifier" - tal:attributes="id id" - tal:content="structure options/markup" /> + tal:attributes="id id"> + + <a title="Add a page block" + tal:attributes="href string:@@addPageBlock?id=$id"> + <img style="border: 0; padding: 0.2em; width: 46px; height: 18px" + src="++resource++add-pageblock.png" /></a> + + <div tal:content="structure options/markup" /> + +</div> Added: cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/views.py ============================================================================== --- (empty file) +++ cpsskins/branches/paris-sprint-2006/ui/screens/pagedesigner/views.py Wed Jun 14 16:44:54 2006 @@ -0,0 +1,63 @@ +############################################################################## +# +# Copyright (c) 2005-2006 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" +__docformat__ = "reStructuredText" + +from zope.component import createObject, getMultiAdapter +from zope.event import notify +from zope.i18nmessageid import MessageFactory +from zope.lifecycleevent import ObjectCreatedEvent +from zope.security.proxy import removeSecurityProxy + +from cpsskins.browser.tree.interfaces import INodeAdding, INodeOrdering +from cpsskins.elements.interfaces import IDisplayable, IFormattable +from cpsskins.utils import getThemeManager + +_ = MessageFactory('cpsskins') + +class PageDesigner(object): + + def __init__(self, context, request): + self.context = context + self.request = request + self.tmutil = getThemeManager(context) + + def addPageBlock(self, id): + """Add a page block containing one cell at the top of a given page + """ + request = self.request + page = self.tmutil.getElementById(id) + page = removeSecurityProxy(page) + + pageblock = createObject(u'cpsskins.canvas.pageblock') + notify(ObjectCreatedEvent(pageblock)) + + cell = createObject(u'cpsskins.canvas.cell') + notify(ObjectCreatedEvent(cell)) + + getMultiAdapter((page, request), INodeAdding).add(pageblock) + getMultiAdapter((pageblock, request), INodeAdding).add(cell) + + ordering = getMultiAdapter((page, request), INodeOrdering) + ordering.setOrder(pageblock, 0) + + display = IDisplayable(pageblock).getDisplay() + IFormattable(display).getFormat(u'layout')[u'width'] = u'100%' + + pageblock.title = _(u'no title') + cell.title = _(u'no title') + -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins