# (C) 2003 by Christian Scholz/MrTopf of COM.lounge

from Products.CMFCore.TypesTool import TypesTool, typeClasses
from Products.CMFCore.DirectoryView import registerDirectory
from ttwtypeinformation import TTWTypeInformation
from ttwtypeinformation import manage_addTTWTypeInformationForm
from ttwtypeinformation import manage_addTTWTypeInformation
from ttwobject import TTWObject, manage_addTTWObject

from ttwfoldertypeinformation import TTWFolderTypeInformation
from ttwfoldertypeinformation import manage_addTTWFolderTypeInformationForm
from ttwfoldertypeinformation import manage_addTTWFolderTypeInformation
from ttwfolder import TTWFolder, manage_addTTWFolder

ttwtype_globals=globals()

def initialize(context):

    # register skin directory
    registerDirectory('skins', globals())

    # add our type to the typeClasses list
    typeClasses.append(
	{'class'	    : TTWTypeInformation,
	 'name'	    : TTWTypeInformation.meta_type,
	 'action'	    : 'manage_addTTWTypeInformationForm',
	 'permission'   : 'Manage portal'}
	)

    # add our type to the typeClasses list
    typeClasses.append(
	{'class'	    : TTWFolderTypeInformation,
	 'name'	    : TTWFolderTypeInformation.meta_type,
	 'action'	    : 'manage_addTTWFolderTypeInformationForm',
	 'permission'   : 'Manage portal'}
	)

    ### now some patching (don't see any other possibility)
    # add the form to the types tool as it's no product
    TypesTool.manage_addTTWTypeInformationForm= \
	manage_addTTWTypeInformationForm
    TypesTool.manage_addTTWTypeInformation= \
	manage_addTTWTypeInformation

    ### now some patching (don't see any other possibility)
    # add the form to the types tool as it's no product
    TypesTool.manage_addTTWFolderTypeInformationForm= \
	manage_addTTWFolderTypeInformationForm
    TypesTool.manage_addTTWFolderTypeInformation= \
	manage_addTTWFolderTypeInformation

    ### register the class for copysupport
    context.registerClass(
	TTWObject,
	constructors=(manage_addTTWObject,)
	)

    ### register the class for copysupport
    context.registerClass(
	TTWFolder,
	constructors=(manage_addTTWFolder,)
	)

    ### register the icon
    from Products.CMFCore import utils, cmfcore_globals
    utils.registerIcon(TTWTypeInformation,
	    'images/typeinfo.gif', cmfcore_globals)

    ### register the icon
    from Products.CMFCore import utils, cmfcore_globals
    utils.registerIcon(TTWFolderTypeInformation,
	    'images/typeinfo.gif', cmfcore_globals)
