def portlets(self): ''' Renders the first paragraph of all ghost objects and documents contained in the site root. ''' view = self.context root = rw_layout.getLocalSite(view, self.request) portlets = [] index = root.get_default() for portlet in root.get_ordered_publishables(): model = None if IGhost.providedBy(portlet): model = portlet.getLastVersion().get_haunted() elif IDocument.providedBy(portlet): model = portlet if not model: continue view.REQUEST.model = model version = model.get_viewable() content = None if version: content = self._renderVersion(version, portlet.get_title(), model.absolute_url()) if content: portlets.append(content) return portlets and portlets or []
def showSFLogo(self): context = self.context localSite = rw_layout.getLocalSite(self.context.get_publication(), self.request) metadata = IMetadata(localSite) try: value = metadata(metadata_id, "plain_layout") return not value and 1 or 0 except: pass return 0
def render(self): ''' Returns the search widget ''' tmpl = """ <form action="%s/search/"> <input class="search-field" type="text" name="fulltext" size="22" /> <input type="hidden" name="search_submit" value="Suchen" /> <input class="button" type="submit" value="Suche" /> </form>""" localSite = rw_layout.getLocalSite(self.context.get_publication(), self.request) return tmpl %localSite.absolute_url()
def get_menu_items(self): context = self.context localSite = rw_layout.getLocalSite(self.context.get_publication(), self.request) metadata = IMetadata(localSite) try: main_menu = metadata(metadata_id, "main_menu") if main_menu: return self._process(main_menu, localSite, context.absolute_url()) except: pass return []
def render(self): tmpl = u""" <script language="JavaScript" type="text/javascript"> function printpage() { if (window.print) window.print(); else alert("Please use the printfunction in your browser.\\n\\nBitte benutzen Sie die Printfunktion Ihres Webbrowsers."); } </script> <a href="%s/contact/">Kontakt</a> | <a href="%s/sitemap/">Übersicht</a> | <a href="javascript:printpage()">Drucken</a> | <a href="%s/edit">Login</a> """ root_url = rw_layout.getLocalSite(self.context.get_publication(), self.request).absolute_url() return tmpl %(root_url, root_url, root_url)
def get_portlets(self): view = self.context root = rw_layout.getLocalSite(view.get_publication(), self.request) #we show the portlets only on the site root if (view != root) and (view != root.get_default()): return [] folder = getattr(root, portlets_id, None) if not folder: return [] portlets = [] for portlet in folder.get_ordered_publishables(): portlets.append(portlet) return portlets
def menu_items(self): context = self.context site_root = rw_layout.getLocalSite(context.get_publication(), self.request) out = [] model_url = context.absolute_url() for item in site_root.get_ordered_publishables(): if not item.meta_type in _menu_objects: continue if item.getId() in infrastructure: continue item_url = item.absolute_url() out.append({'state':model_url.startswith(item_url) and 'active' or 'default', 'url':item_url, 'label':item.get_short_title(), }) return out
def items(self): out = [] context = self.context container = context.get_container() site_root = rw_layout.getLocalSite(container, self.request) if container == site_root: for item in container.get_ordered_publishables(): if not item.meta_type in _menu_objects: continue if item.getId() in infrastructure: continue out.append({'url':item.absolute_url(), 'label':item.get_short_title(), 'state':"category-default"}) else: model_url = context.absolute_url() for item in container.get_ordered_publishables(): out.append({'url':item.absolute_url(), 'label':item.get_short_title(), 'state':model_url.startswith(item.absolute_url()) and "category-active" or "category-default"}) return out
def render(self): to_ignore = [entry.strip() for entry in self.to_ignore.split(',')] public = not IPreviewLayer.providedBy(self.request) is_displayable = public and self.is_public_displayable or self.is_preview_displayable html = [] a_templ = '<a href="%s">%s</a>' isIndented = int(self.list_type) localRoot = getLocalSite(self.model, self.request) depth = -1 prev_depth = [-1] item = None for (depth, item) in self.list_toc_items(localRoot, 0, is_displayable, to_ignore): pd = prev_depth[-1] if pd < depth: #down one level if depth == 0 or isIndented: html.append('<ul>') prev_depth.append(depth) elif pd > depth: #up one level for i in range(pd-depth): prev_depth.pop() if isIndented: html.append('</ul></li>') elif pd == depth: #same level html.append('</li>') css_class = (IContainer.providedBy(item) and depth == 0) and ' class="topContainer"' or '' html.append('<li%s>' %css_class) title = (public and item.get_title() or item.get_title_editable()) or item.id html.append(a_templ % (absoluteURL(item, self.request), escape(title)) + self._add(item)) else: #do this when the loop is finished, to #ensure that the lists are ended properly #the last item in the list could part of a nested list (with depth 1,2,3+, etc) #so need to loop down the depth and close all open lists while depth >= 0: html.append('</li></ul>') depth -= 1 if not isIndented: html.append('</ul>') return u'\n'.join(html)
def get_site_title(self): return rw_layout.getLocalSite(self.context.get_publication(), self.request).get_title()