<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:profilehook="http://namespaces.zope.org/profilehook"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    i18n_domain="ftw.book">

    <include package="Products.CMFCore" file="permissions.zcml" />
    <include package="Products.DataGridField" />
    <include package="ftw.profilehook" />

    <five:registerPackage package="." initialize=".initialize" />

    <i18n:registerTranslations directory="locales" />

    <!-- Include the sub-packages that use their own configure.zcml files. -->
    <include file="permissions.zcml" />
    <include package=".latex" />
    <include package=".browser" />
    <include package=".content" />
    <include package=".portlets" />
    <include package=".upgrades" />
    <include package=".keyword" />
    <include package=".footnote" />
    <include package=".tinymce" />

    <include zcml:condition="installed ftw.lawgiver" file="lawgiver.zcml" />
    <include zcml:condition="installed ftw.publisher.core" package=".publisher" />

    <include file="skins.zcml" />

    <genericsetup:registerProfile
        name="default"
        title="ftw.book"
        directory="profiles/default"
        description=""
        provides="Products.GenericSetup.interfaces.EXTENSION"
        />

    <profilehook:hook
        profile="ftw.book:default"
        handler=".hooks.installed"
        />

    <genericsetup:registerProfile
        name="uninstall"
        title="Uninstall ftw.book"
        directory="profiles/uninstall"
        description=""
        provides="Products.GenericSetup.interfaces.EXTENSION"
        for="Products.CMFPlone.interfaces.IMigratingPloneSiteRoot"
        />

    <profilehook:hook
        profile="ftw.book:uninstall"
        handler=".hooks.uninstalled"
        />

    <adapter factory=".bookadapter.find_book" />

    <!-- We register only ObjectMoved here. We also would require ObjectAdded but it is called with both events.
         If we would follow the python way and add ObjectAdded explicit we only end up with the handler called twice,
         which is unnessesary and inefficient. -->

    <subscriber
        for=".interfaces.IBook
             zope.lifecycleevent.interfaces.IObjectMovedEvent"
        handler=".eventhandler.add_navigation_portlet" />

    <subscriber
        for=".interfaces.IBook
             Products.Archetypes.interfaces.IObjectInitializedEvent"
        handler=".eventhandler.add_navigation_portlet" />

    <adapter factory="ftw.book.layer.BookTraverse" />

    <!-- ILaTeXCodeInjectionEnabled schema extender adapter -->
    <adapter
        name="ftw.book.latexcodeinjection"
        factory=".latexinjection.LaTeXCodeInjectionExtender"
        provides="archetypes.schemaextender.interfaces.ISchemaExtender" />

    <class class="Products.Archetypes.BaseObject.BaseObject">
        <implements interface="ftw.book.interfaces.ILaTeXCodeInjectionEnabled" />
    </class>

    <configure zcml:condition="installed ftw.zipexport">
        <adapter factory=".zipexport.BookZipRepresentation" />
    </configure>
</configure>
