def add_boxes(self, xml_page, page_content, tag): # add the boxes contained in the given tag to the given page_content elements = xml_page.getElementsByTagName(tag) for element in elements: # check if the box belongs to the current page if not self.belongs_to(element, page_content.page): continue type = element.getAttribute("jcr:primaryType") # the "epfl:faqBox" element contains one or more "epfl:faqList" if "epfl:faqBox" == type: faq_list_elements = element.getElementsByTagName("faqList") for faq_list_element in faq_list_elements: box = Box(site=self, page_content=page_content, element=faq_list_element) page_content.boxes.append(box) else: # TODO remove the multibox parameter and check for combo boxes instead # Check if xml_box contains many boxes multibox = element.getElementsByTagName("text").length > 1 box = Box(site=self, page_content=page_content, element=element, multibox=multibox) page_content.boxes.append(box)
def parse_sidebar(self): """ Parse sidebar """ # search the sidebar in the page xml content children = self.element.childNodes for child in children: if child.nodeName == "extraList": for extra in child.childNodes: if extra.ELEMENT_NODE != extra.nodeType: continue box = Box(site=self.site, page_content=self, element=extra) self.sidebar.boxes.append(box) nb_boxes = len(self.sidebar.boxes) # if we don't have boxes in this sidebar we check the parents if nb_boxes == 0: parent = self.page.parent while parent: sidebar = parent.contents[self.language].sidebar # we found a sidebar with boxes, we stop if len(sidebar.boxes) > 0: self.sidebar = sidebar break # otherwise we continue in the hierarchy parent = parent.parent
def add_boxes(self, xml_page, page_content, tag): # add the boxes contained in the given tag to the given page_content elements = xml_page.getElementsByTagName(tag) for element in elements: # check if the box belongs to the current page if not self.belongs_to(element, page_content.page): continue # TODO remove the multibox parameter and check for combo boxes instead # Check if xml_box contains many boxes multibox = element.getElementsByTagName("text").length > 1 box = Box(site=self, page_content=page_content, element=element, multibox=multibox) page_content.boxes.append(box)
def parse_sidebar(self): """ Parse sidebar """ # search the sidebar in the page xml content children = self.element.childNodes for child in children: if child.nodeName == "extraList": for extra in child.childNodes: if extra.ELEMENT_NODE != extra.nodeType: continue # If we have to skip this box, if extra.getAttribute("jahia:acl") == "break": continue multibox = extra.getElementsByTagName("text").length > 1 box = Box(site=self.site, page_content=self, element=extra, multibox=multibox, is_in_sidebar=True) self.sidebar.boxes.append(box) nb_boxes = len(self.sidebar.boxes) # if we don't have boxes in this sidebar we check the parents if nb_boxes == 0: parent = self.page.parent while parent: # Check if parent have a content in current lang if self.language in parent.contents: sidebar = parent.contents[self.language].sidebar # we found a sidebar with boxes, we stop if len(sidebar.boxes) > 0: self.sidebar = sidebar break # otherwise we continue in the hierarchy parent = parent.parent