def pageListWidget(self, page=None, pages=None, showCCP=False, defaultview=u""): """ Widget with existing pages list and edit options call with page = current page """ if not page: page = self.context html = u"""<div class="subpages"> %(blocks)s </div>""" pHtml = u"""<div class="element"> <div class="el_title">%(workflow)s <a href="%(url)s" title="%(aTitle)s">%(title)s </a> </div> <div class="el_options">%(options)s</div> <br style="clear:both"> </div>""" useworkflow = 1 localizer = translator(self.request) static = self.StaticUrl("nive_cms.workflow:static/exclamation.png") if not pages: pages = page.GetPages(includeMenu=1) blocks = StringIO() for p in pages: wf = u"" if useworkflow and not p.meta.pool_state: wf = u"""<a href="%(url)s@workflow" class="right" rel="niveOverlay"><img src="%(static)s" title="%(name)s"></a>""" % { u"static": static, u"url": self.FolderUrl(p), u"name": localizer(_(u"This page is not public.")) } title = p.meta.get(u"title") linkTitle = u"ID: %d, %s" % (p.id, title) options = self.editBlockList(obj=p, page=page, showCCP=showCCP, showWF=False) blocks.write( pHtml % { u"url": self.FolderUrl(p) + defaultview, u"aTitle": linkTitle, u"title": title, u"options": options, u"workflow": wf }) if not len(pages): blocks.write(u"""<div class="element">""") blocks.write(localizer(_(u"<p><i>no sub pages</i></p>"))) blocks.write(u"""</div>""") return html % {u"blocks": blocks.getvalue()}
def pageListWidget(self, page=None, pages=None, showCCP=False, defaultview=u""): """ Widget with existing pages list and edit options call with page = current page """ if not page: page=self.context html = u"""<div class="subpages"> %(blocks)s </div>""" pHtml = u"""<div class="element"> <div class="el_title">%(workflow)s <a href="%(url)s" title="%(aTitle)s">%(title)s </a> </div> <div class="el_options">%(options)s</div> <br style="clear:both"> </div>""" useworkflow = 1 localizer = translator(self.request) static = self.StaticUrl("nive_cms.workflow:static/exclamation.png") if not pages: pages = page.GetPages(includeMenu=1) blocks = StringIO() for p in pages: wf = u"" if useworkflow and not p.meta.pool_state: wf = u"""<a href="%(url)s@workflow" class="right" rel="niveOverlay"><img src="%(static)s" title="%(name)s"></a>""" % { u"static": static, u"url": self.FolderUrl(p), u"name": localizer(_(u"This page is not public.")) } title = p.meta.get(u"title") linkTitle = u"ID: %d, %s" % (p.id, title) options = self.editBlockList(obj=p, page=page, showCCP=showCCP, showWF=False) blocks.write(pHtml % {u"url": self.FolderUrl(p)+defaultview, u"aTitle": linkTitle, u"title": title, u"options": options, u"workflow": wf}) if not len(pages): blocks.write(u"""<div class="element">""") blocks.write(localizer(_(u"<p><i>no sub pages</i></p>"))) blocks.write(u"""</div>""") return html % {u"blocks": blocks.getvalue()}
def elementListWidget(self, obj=None, elements=None, addResponse=True, showCCP=True, defaultview=u"@edit"): """ Widget with existing elements list and edit options call with obj = current object / page """ #i18n? if not obj: obj=self.context html = u"""<div> <h4 onclick="$.fn.editblocks().toggleBlock('#elements%(id)s',event)">%(title)s</h4> %(blocks)s </div> """ elHtml = u"""<div class="element"> <div class="el_title"><a href="%(link)s" class="nivecms" rel="niveOverlay">%(title)s</a></div> <div class="el_options">%(options)s</div> <br style="clear:both"> </div>""" if not elements: elements = obj.GetPageElements() localizer = translator(self.request) blocks = StringIO() static = self.StaticUrl("nive_cms.cmsview:static/images/types/") for el in elements: t = el.GetTitle() if not t: t = u"<em>%s</em>" % (localizer(el.GetTypeName(), self.request)) if el.configuration.get('icon'): src = self.StaticUrl(el.configuration.get('icon')) else: src = '%s%s.png' % (static, el.GetTypeID()) if el.IsContainer(): title = u"<img src='%s' align='top'> %s: %s" % (src, localizer(el.GetTypeName()), t) blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(el)+defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP)}) for elb in el.GetPageElements(): if elb.configuration.get('icon'): srcb = self.StaticUrl(elb.configuration.get('icon')) else: srcb = '%s%s.png' % (static, elb.GetTypeID()) t = elb.GetTitle() if not t: t = u"<em>%s</em>" % (localizer(elb.GetTypeName())) title = u"> <img src='%s' align='top'> %s" % (srcb, t) blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(elb)+defaultview, u"options": self.editBlockList(obj=elb, showCCP=showCCP)}) else: title = u"<img src='%s' align='top'> %s" % (src, t) blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(el)+defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP)}) if not len(elements): blocks.write(localizer(_(u"<p><i>empty</i></p>"))) data = html % {u"blocks": blocks.getvalue(), u"id": str(obj.GetID()), u"title": localizer(_(u"Page elements"))} if addResponse: r = Response(content_type="text/html", conditional_response=True) r.unicode_body = data return r return data
def elementListWidget(self, obj=None, elements=None, addResponse=True, showCCP=True, defaultview=u"@edit"): """ Widget with existing elements list and edit options call with obj = current object / page """ #i18n? if not obj: obj = self.context html = u"""<div> <h4 onclick="$.fn.editblocks().toggleBlock('#elements%(id)s',event)">%(title)s</h4> %(blocks)s </div> """ elHtml = u"""<div class="element"> <div class="el_title"><a href="%(link)s" class="nivecms" rel="niveOverlay">%(title)s</a></div> <div class="el_options">%(options)s</div> <br style="clear:both"> </div>""" if not elements: elements = obj.GetPageElements() localizer = translator(self.request) blocks = StringIO() static = self.StaticUrl("nive_cms.cmsview:static/images/types/") for el in elements: t = el.GetTitle() if not t: t = u"<em>%s</em>" % (localizer(el.GetTypeName(), self.request)) if el.configuration.get('icon'): src = self.StaticUrl(el.configuration.get('icon')) else: src = '%s%s.png' % (static, el.GetTypeID()) if el.IsContainer(): title = u"<img src='%s' align='top'> %s: %s" % ( src, localizer(el.GetTypeName()), t) blocks.write( elHtml % { u"title": title, u"link": self.FolderUrl(el) + defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP) }) for elb in el.GetPageElements(): if elb.configuration.get('icon'): srcb = self.StaticUrl(elb.configuration.get('icon')) else: srcb = '%s%s.png' % (static, elb.GetTypeID()) t = elb.GetTitle() if not t: t = u"<em>%s</em>" % (localizer(elb.GetTypeName())) title = u"> <img src='%s' align='top'> %s" % (srcb, t) blocks.write( elHtml % { u"title": title, u"link": self.FolderUrl(elb) + defaultview, u"options": self.editBlockList(obj=elb, showCCP=showCCP) }) else: title = u"<img src='%s' align='top'> %s" % (src, t) blocks.write( elHtml % { u"title": title, u"link": self.FolderUrl(el) + defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP) }) if not len(elements): blocks.write(localizer(_(u"<p><i>empty</i></p>"))) data = html % { u"blocks": blocks.getvalue(), u"id": str(obj.GetID()), u"title": localizer(_(u"Page elements")) } if addResponse: r = Response(content_type="text/html", conditional_response=True) r.unicode_body = data return r return data