--- ECHO_content/ECHO_helpers.py 2011/10/13 07:48:27 1.103.2.1 +++ ECHO_content/ECHO_helpers.py 2012/08/27 09:45:33 1.103.2.5 @@ -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 @@ -131,6 +132,9 @@ class ECHO_basis: """return utf-8 encoded string object for string or unicode object s""" return utf8ify(s) + def getBrowserType(self): + """returns browserType object""" + return browserType(self) def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): return ECHO_collection.manage_addECHO_locale(self,lang,title,label) @@ -260,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""" @@ -292,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""" @@ -324,9 +325,7 @@ class ECHO_basis: def getOverview(self): """map overview graphics""" #return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] - if self.hasOverview(): - return getattr(self, 'overview') - return None + return getattr(self, 'overview', None) def getMapAreas(self): """returns the list of MapAreas""" @@ -371,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): @@ -441,10 +440,10 @@ class ECHO_basis: def createMapImg(self): """generate img-tag for map""" - bt = BrowserCheck(self) + bt = browserType(self) tag = "" src = self.getOverview().absolute_url() - if bt.isN4: + if bt['isN4']: # N4 needs ilayer to create an id tag += ''%src else: @@ -458,7 +457,7 @@ class ECHO_basis: def createMapLink(self, ob, text=None, target="_blank"): """generate map link""" - bt = BrowserCheck(self) + bt = browserType(self) id = ob.getFullId() url = ob.getTargetUrl() if url == "": @@ -479,8 +478,9 @@ class ECHO_basis: text = "link" tiptext = ob.getTip() + tag = "" - if bt.isN4: + if bt['isN4']: # N4 needs layer for highlighting tag += '" @@ -489,12 +489,15 @@ 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"): """generate map link image, text and other stuff""" - bt = BrowserCheck(self) + bt = browserType(self) id = ob.getFullId() link = ob.getLinkId() url = ob.getTargetUrl() @@ -509,9 +512,9 @@ class ECHO_basis: else: targetattr = 'target="%s"'%target tiptext = ob.getTip() - tag = "" - if bt.isN4: + tag = "" + if bt['isN4']: # # N4 needs layer and img elements # @@ -574,7 +577,7 @@ class ECHO_basis: if float(rot) < 0: marksrc = circlesrc - if bt.isIEWin and bt.versIE > 5: + if bt['isIEWin'] and bt['versIE'] > 5: # IE/Win 5.5 has "feature" for PNG transparency tag += ''%(id,marksrc,rot,marksrc,rot) else: @@ -589,7 +592,7 @@ class ECHO_basis: tag += '' else: # DOM - Area - if bt.isIE: + if bt['isIE']: # IE needs transparent img for area tag += ' -1: - self.isIE = True - else: - self.isN4 = string.find(self.ua, 'Mozilla/4.') > -1 - try: - self.nav = self.ua[string.find(self.ua, '('):] - ie = string.split(self.nav, "; ")[1] - if string.find(ie, "MSIE") > -1: - self.versIE = string.split(ie, " ")[1] - except: pass - self.isMac = string.find(self.ua, 'Macintosh') > -1 - self.isWin = string.find(self.ua, 'Windows') > -1 - self.isIEWin = self.isIE and self.isWin - self.isIEMac = self.isIE and self.isMac + bt = {} + ua = zope.REQUEST.get_header("HTTP_USER_AGENT") + bt['ua'] = ua + bt['isN4'] = False + bt['isIE'] = False + if string.find(ua, 'MSIE') > -1: + bt['isIE'] = True + else: + bt['isN4'] = string.find(ua, 'Mozilla/4.') > -1 + try: + nav = ua[string.find(ua, '('):] + bt['nav'] = nav + ie = string.split(nav, "; ")[1] + if string.find(ie, "MSIE") > -1: + bt['versIE'] = string.split(ie, " ")[1] + except: pass + + bt['isMac'] = string.find(ua, 'Macintosh') > -1 + bt['isWin'] = string.find(ua, 'Windows') > -1 + bt['isIEWin'] = bt['isIE'] and bt['isWin'] + bt['isIEMac'] = bt['isIE'] and bt['isMac'] + return bt def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,xmlfrag=None,digiliburlprefix=None): @@ -1234,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() @@ -1256,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"""