--- ECHO_content/ECHO_helpers.py 2011/10/13 07:48:27 1.103.2.1
+++ ECHO_content/ECHO_helpers.py 2012/09/03 14:48:22 1.103.2.7
@@ -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))
@@ -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)
@@ -248,6 +252,7 @@ class ECHO_basis:
return self.unicodify(getattr(self,'description',''));
+
def getTitle(self):
"""title"""
if hasattr(self,'getLanguage'):
@@ -260,12 +265,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 +294,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 +326,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 +371,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 +441,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 +458,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 +479,9 @@ class ECHO_basis:
text = "link"
tiptext = ob.getTip()
+
tag = ""
- if bt.isN4:
+ if bt['isN4']:
# N4 needs layer for highlighting
tag += '" + text + ""
@@ -489,12 +490,15 @@ class ECHO_basis:
tag = '" + text + ""
+
+ 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 +513,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 +578,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 +593,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 +1275,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 +1304,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"""