Example #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())
    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"
Example #3
0
def blockMoved(obj, event):
    reindexContainer(obj, event, parent=event.oldParent)
    reindexContainer(obj, event, parent=event.newParent)

    if obj != event.object:
        # Moving the parent, so we do not reset the layout.
        return

    # remove slote interfaces
    for key, iface in SLOT_INTERFACES_MAP.items():
        if iface.providedBy(obj):
            noLongerProvides(obj, iface)

    # set current view config interfaces (slot and colum interface)
    for name, iface in VIEW_INTERFACES_MAP.items():
        if iface.providedBy(event.newParent):
            alsoProvides(obj, INIT_INTERFACES_MAP.get(name))
            break
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)