# Path: nive_cms/i18n.py

# 
# Path: nive_cms/baseobjects.py
# class PageElementBase(ObjCopy, PageElement, ObjectBase):
#     """
#     *Page element* 
#     
#     - stored in database
#     - does not store subobjects
#     - stored in element containers 
#     - cut, copy and paste support
#     
#     Interfaces: ``INonContainer, IObject, IPageElement``
#     """
#     implements(IPageElement)


from nive_cms.i18n import _
from nive.utils.utils import ConvertHTMLToText, CutText
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase



class text(PageElementBase):
    """
    basic text class
    """
    
    titleLen = 20

    def Init(self):
        self.ListenEvent("commit", "TextToTitle")


    def TextToTitle(self, **kw):
        text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True)
        self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
        return True


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "text",
    name = _(u"Text"),
    dbparam = "texts",
    context = "nive_cms.text.text",
    template = "text.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/text.png",

# Path: nive_cms/i18n.py

# 
# Path: nive_cms/baseobjects.py
# class PageElementBase(ObjCopy, PageElement, ObjectBase):
#     """
#     *Page element* 
#     
#     - stored in database
#     - does not store subobjects
#     - stored in element containers 
#     - cut, copy and paste support
#     
#     Interfaces: ``INonContainer, IObject, IPageElement``
#     """
#     implements(IPageElement)


# Path: nive_cms/text.py
from nive_cms.i18n import _
from nive.utils.utils import ConvertHTMLToText, CutText
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase




class text(PageElementBase):
    """
    basic text class
    """
    
    titleLen = 20

    def Init(self):
        self.ListenEvent("commit", "TextToTitle")


    def TextToTitle(self, **kw):
        text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True)
        self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
        return True


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "text",
    name = _(u"Text"),
    dbparam = "texts",
    context = "nive_cms.text.text",
    template = "text.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/text.png",

    description = _(u"Text element for the web page. Can be used to add headers, preformatted text and paragraphs to the web page. ")