Exemplo n.º 1
0
    def setDesignInterface(self, name, blocks=[]):
        """ sets the new view interface """

        context = self.context
        context_expl = aq_inner(self.context).aq_explicit

        if not blocks:
            #remove grid infos
            if hasattr(context_expl, 'align_to_grid'):
                context.manage_changeProperties({'align_to_grid': '0'})

            if name not in VIEW_INTERFACES_MAP:
                new = VIEW_INTERFACES_MAP['normal']
            else:
                new = VIEW_INTERFACES_MAP[name]
            #remove current design interface
            for iface in VIEW_INTERFACES_MAP.values():
                if iface.providedBy(context):
                    noLongerProvides(context, iface)
            #set the new one
            alsoProvides(context, new)
            context.reindexObject(idxs=['object_provides'])

        #set init interfaces on blocks
        ifaces = []
        if name in INIT_INTERFACES_MAP:
            ifaces = INIT_INTERFACES_MAP[name]

        contents = blocks and blocks or context.getFolderContents(
            {'object_provides': BLOCK_INTERFACES},
            full_objects=True)

        for obj in contents:
            #remove given block heights
            blockconf = IBlockConfig(obj)
            blockconf.block_height = None

            #remove all related Interfaces
            for i in COLUMN_INTERFACES_MAP.values() + \
                SLOT_INTERFACES_MAP.values():

                if i.providedBy(obj):
                    noLongerProvides(obj, i)

            for iface in ifaces:
                alsoProvides(obj, iface)
            obj.reindexObject(idxs=['object_provides'])

            #calc new images sizes and store them
            try:
                converter = getUtility(IBlockControl, name='block-layout')
            except ComponentLookupError:
                pass
            converter.update(context, obj, obj.REQUEST)

        if not blocks:
            return self.request.RESPONSE.redirect(context.absolute_url())
Exemplo n.º 2
0
    def __call__(self, uids=[], slot="", column="", obj_uid=""):
        uids = uids.split(",")
        for i in range(len(uids)):
            uid = uids[i]
            uid = uid.replace("uid_", "")
            obj = self.context.reference_catalog.lookupObject(uid)
            # Condition for a special usecase (show the current content also
            # as block. But this block is no moveable)
            if obj == self.context:
                continue
            id_ = obj.id
            self.context.moveObject(id_, i)
            obj.reindexObject(idxs=["getObjPositionInParent"])

        # set the new interfaces
        o_uid = obj_uid.replace("uid_", "")
        o = self.context.reference_catalog.lookupObject(o_uid)

        iface_to_remove = []
        if SLOT_INTERFACES_MAP.has_key(slot):
            for i in SLOT_INTERFACES_MAP.values():
                if i.providedBy(o):
                    iface_to_remove.append(i)

            if SLOT_INTERFACES_MAP[slot] not in iface_to_remove:
                for iface in iface_to_remove:
                    noLongerProvides(o, iface)
                alsoProvides(o, SLOT_INTERFACES_MAP[slot])

        for col in column.split(" "):
            if col.find("column") != -1:
                new_col = col
        if COLUMN_INTERFACES_MAP.has_key(new_col):
            for i in COLUMN_INTERFACES_MAP.values():
                if i.providedBy(o):
                    noLongerProvides(o, i)
            alsoProvides(o, COLUMN_INTERFACES_MAP[new_col])
        o.reindexObject(idxs=["object_provides"])

        return "ok"
Exemplo n.º 3
0
    def getSizeAttributesByInterface(self, content, size):
        #XXX get infos by a given value or by request
        current_iface = None
        for iface in COLUMN_INTERFACES_MAP.values():
            if iface.providedBy(content):
                current_iface = iface

        if current_iface is None:
            return size

        if current_iface in IMAGE_SIZE_MAP_PER_INTERFACE:
            return IMAGE_SIZE_MAP_PER_INTERFACE[current_iface][size]

        return size
from simplelayout.base.config import (
    SLOT_INTERFACES_MAP as orig_slot_ifaces,
    COLUMN_INTERFACES_MAP as orig_column_ifaces,
    IMAGE_SIZE_MAP_PER_INTERFACE as orig_size_map,
    CONFIGLET_INTERFACE_MAP as orig_config_iface_map)


from config import SLOT_INTERFACES_MAP,  COLUMN_INTERFACES_MAP, \
                   IMAGE_SIZE_MAP_PER_INTERFACE, CONFIGLET_INTERFACE_MAP


orig_slot_ifaces.update(SLOT_INTERFACES_MAP)
orig_column_ifaces.update(COLUMN_INTERFACES_MAP)
orig_size_map.update(IMAGE_SIZE_MAP_PER_INTERFACE)
orig_config_iface_map.update(CONFIGLET_INTERFACE_MAP)