# Path: nive_cms/i18n.py

# 
# Path: nive_cms/baseobjects.py
# class PageElementFileBase(ObjCopy, PageElement, ObjectBase):
#     """
#     *Page element with file download support*
#     
#     - stored in database
#     - does not store subobjects
#     - stored in element containers 
#     - cut, copy and paste support
#     - contained files can be downloaded
# 
#     Interfaces: ``INonContainer, IObject, IPageElement, IFile``
#     """
#     implements(IPageElement, IFile)


from nive_cms.i18n import _
from nive.utils.utils import FormatBytesForDisplay
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementFileBase
        t = f["extension"]
        s = f["size"]
        if s:
            s = FormatBytesForDisplay(s)
        return u"%s (%s %s)" % (title, t, s)
    
     
    def Init(self):
        self.ListenEvent("commit", "FilenameToTitle")

    def FilenameToTitle(self, **kw):
        if self.files.get("file") and not self.meta["title"]:
            self.meta["title"] = self.files.get("file")["filename"]
        


# file type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "file",
    name = _(u"File"),
    dbparam = "files",
    context = "nive_cms.file.file",
    template = "file.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/file.png",
    description = _(u"The file element provides a simple file download with title and optional description.")
)

configuration.data = [

# Path: nive_cms/i18n.py

# 
# Path: nive_cms/baseobjects.py
# class PageElementFileBase(ObjCopy, PageElement, ObjectBase):
#     """
#     *Page element with file download support*
#     
#     - stored in database
#     - does not store subobjects
#     - stored in element containers 
#     - cut, copy and paste support
#     - contained files can be downloaded
# 
#     Interfaces: ``INonContainer, IObject, IPageElement, IFile``
#     """
#     implements(IPageElement, IFile)


# Path: nive_cms/file.py
from nive_cms.i18n import _
from nive.utils.utils import FormatBytesForDisplay
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementFileBase

        t = f["extension"]
        s = f["size"]
        if s:
            s = FormatBytesForDisplay(s)
        return u"%s (%s %s)" % (title, t, s)
    
     
    def Init(self):
        self.ListenEvent("commit", "FilenameToTitle")

    def FilenameToTitle(self, **kw):
        if self.files.get("file") and not self.meta["title"]:
            self.meta["title"] = self.files.get("file")["filename"]
        


# file type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "file",
    name = _(u"File"),
    dbparam = "files",
    context = "nive_cms.file.file",
    template = "file.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/file.png",
    description = _(u"The file element provides a simple file download with title and optional description.")
)

configuration.data = [

    FieldConf(id="file",       datatype="file",  size=0,     default=u"", fulltext=1, name=_(u"File"), description=u""),