--- ECHO_content/ECHO_helpers.py 2012/01/17 18:39:07 1.103.2.3 +++ ECHO_content/ECHO_helpers.py 2012/08/29 07:53:31 1.103.2.6 @@ -11,6 +11,7 @@ from OFS.SimpleItem import SimpleItem from Globals import package_home import Globals from AccessControl import ClassSecurityInfo +from Acquisition import aq_parent,aq_chain,aq_base import os.path from OFS.Folder import Folder import ECHO_collection @@ -33,7 +34,7 @@ def normalizeCt(str): #str= str.replace(" ","_") return str.replace("-"," ").lower() -#decode and compress for xmlrpc communication with OSAS_server +#decode and compress for xmlrpc communication def encodeRPC(string): return base64.encodestring(bz2.compress(string)) @@ -263,12 +264,9 @@ class ECHO_basis: locale=self.ZopeFind(self,obj_ids=["locale_"+lang]) if locale: - return self.decode(locale[0][1].title) - else: - try: - return self.decode(self.title) - except: - return self.title + return unicodify(locale[0][1].title) + + return unicodify(self.title) def getLabel(self): """title""" @@ -295,7 +293,7 @@ class ECHO_basis: ret=self.getId() return ret - return self.decode(self.label) + return unicodify(self.label) def changeECHOEntriesForm(self): """change Entries for the ECHO Navigation environment""" @@ -372,7 +370,7 @@ class ECHO_basis: res = self.ZopeFind(self, obj_metatypes=('ECHO_mapText')) if len(res) > 0: text = res[0][1] - return text + return unicodify(text) return None def ECHO_graphicEntry(self): @@ -480,6 +478,7 @@ class ECHO_basis: text = "link" tiptext = ob.getTip() + tag = "" if bt['isN4']: # N4 needs layer for highlighting @@ -490,7 +489,10 @@ class ECHO_basis: tag = '" + + logging.debug("createMapLink: text=%s"%repr(text)) + tag += ">%s"%text + return tag def createMapAux(self, ob, arrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil", circlesrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/kreis", target="_blank",backLink=None,alternativArrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil_blau"): @@ -510,8 +512,8 @@ class ECHO_basis: else: targetattr = 'target="%s"'%target tiptext = ob.getTip() - tag = "" + tag = "" if bt['isN4']: # # N4 needs layer and img elements @@ -694,6 +696,41 @@ def checkOnlyOneInGroup(object): else: return object + +def getCrumb(self): + """returns breadcrumb for this object""" + # ignore this object if title is empty + if not self.title: + return None + + crumb = {'obj': self, + 'url': self.absolute_url(), + 'label': self.getLabel()} + return crumb + +# roots of the ECHO hierarchy +rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] + +def getHierCrumbs(self): + """returns a list of hierarchical breadcrumbs from self to the ECHO_root""" + crumbs = [] + # walk the acquisition chain + for obj in aq_chain(self): + #logging.debug("getHiercrumbs: obj=%s"%(obj)) + # test if the object really has a getCrumb method + if hasattr(aq_base(obj), 'getCrumb'): + crumb = obj.getCrumb() + #logging.debug("getHiercrumbs: got %s from %s"%(crumb,obj)) + if crumb is not None: + crumbs.insert(0, crumb) + + if obj.meta_type in rootMetaTypes: + # stop when we reach the ECHO root + return crumbs + + return crumbs + + def getSubCols(self, sortfield=None, subColTypes=displayTypes, sortFieldMD=None, @@ -1237,16 +1274,23 @@ class MapArea(SimpleItem): if self.tip is None: if hasattr(self, 'aq_parent'): parent = self.aq_parent + # text-popup type if parent.contentType == 'text-popup': - return parent.description - return self.tip + return unicodify(parent.description) + + # use map-text + text = parent.getMapText() + if text is not None: + return text() + + return unicodify(self.tip) def setTip(self, text): """sets the text""" self.tiptext = text def getText(self): - """returns the text fpr the area""" + """returns the text for the area""" if hasattr(self, 'aq_parent'): parent = self.aq_parent text = parent.getMapText() @@ -1259,8 +1303,8 @@ class MapArea(SimpleItem): """returns the link label""" if self.label is None: if hasattr(self, 'aq_parent'): - return self.aq_parent.label or self.aq_parent.id - return self.label + return unicodify(self.aq_parent.label or self.aq_parent.id) + return unicodify(self.label) def getTargetUrl(self): """returns the URL of the linked object"""