# Copyright (c) 2002-2007 Infrae. All rights reserved.
# See also LICENSE.txt
# Zope
from AccessControl import ModuleSecurityInfo, allow_module
# Zope3
from zope.app import zapi
from zope.component.presentation import SkinRegistration

# Helpers to integrate Zope3, Five and SilvaLayout functionality
# with Zope2 and Silva

__allow_access_to_unprotected_subobjects__ = 1

module_security = ModuleSecurityInfo('Products.SilvaLayout.helpers')

module_security.declareProtected(
    'Access Contents Information', 'getAvailableSkins')
def getAvailableSkins():
    # Taken (and adapted) from zope3 apidoc.viewmodule.getSkins...
    presentationservice = zapi.getGlobalService('Presentation')
    registrations = presentationservice.registrations()
    skins = [
        reg.skin for reg in registrations if isinstance(reg, SkinRegistration)]
    skins.sort()
    return skins
        