--- ECHO_content/ECHO_helpers.py 2005/06/09 21:57:30 1.54 +++ ECHO_content/ECHO_helpers.py 2005/09/12 22:23:44 1.60 @@ -12,6 +12,8 @@ from Globals import package_home import Globals from AccessControl import ClassSecurityInfo import os.path +from OFS.Folder import Folder +import ECHO_collection displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','ECHO_movie'] @@ -36,6 +38,10 @@ class ECHO_basis: """basis eigenschaften fuer echo objekte""" security=ClassSecurityInfo() security.declarePublic('getImageTag') + + 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) + def getImageTag(self): """sollte uerberschrieben werden, falls von der Klasse eine imagetag zurueckkommt""" @@ -116,7 +122,17 @@ class ECHO_basis: def getTitle(self): """title""" - return self.decode(self.title) + lang=self.getLanguage() + locale=None + if lang and not (lang =="de"): + locale=self.ZopeFind(self,obj_ids=["locale_"+lang]) + + if locale: + return self.decode(locale[0][1].title) + else: + return self.decode(self.title) + + try: return self.title.encode('utf-8','ignore') except: @@ -125,6 +141,15 @@ class ECHO_basis: def getLabel(self): """title""" + lang=self.getLanguage() + locale=None + if lang and not (lang=="de"): + locale=self.ZopeFind(self,obj_ids=["locale_"+lang]) + + if locale: + return self.decode(locale[0][1].label) + + if not hasattr(self,'label'): self.label="" @@ -178,8 +203,19 @@ class ECHO_basis: def getMapAreas(self): """returns the list of MapAreas""" + forcetypes = self.REQUEST.get('map_force_types', None) + if forcetypes: + typelist = forcetypes.split(',') + else: + typelist = None + areas = [] # get all contained MapAreas - areas = [res[1] for res in self.ZopeFind(self, obj_metatypes=('MapArea'))] + for res in self.ZopeFind(self, obj_metatypes=('MapArea')): + area = res[1] + # check the allowed types + if typelist is not None and area.getType() not in typelist: + continue + areas.append(area) return areas def addMapArea(self, newarea): @@ -197,7 +233,15 @@ class ECHO_basis: def getMapText(self): """returns the MapText""" # get (the first) contained MapText - res = self.ZopeFind(self, obj_metatypes=('ECHO_mapText')) + #lang="en" + lang=self.getLanguage() + res=None + if lang and not (lang=="de"): + resTmp = self.ZopeFind(self, obj_metatypes=('ECHO_mapText')) + res = self.ZopeFind(resTmp[0][1]) + + if not res: + res = self.ZopeFind(self, obj_metatypes=('ECHO_mapText')) if len(res) > 0: text = res[0][1] return text @@ -235,7 +279,7 @@ class ECHO_basis: area.setAngle(angle) area.setType(type) area.setPermanent(permanent) - # add new area + # add the "new" area if self.REQUEST.has_key('add'): coordstring = self.REQUEST.get('coords.new', '') coords = string.split(coordstring, ',') @@ -252,9 +296,15 @@ class ECHO_basis: def createJSAreas(self, areas): """create area calls for JavaScript""" + forceperm = self.REQUEST.get('map_force_permanent', None) js="\n" for ob in areas: - js+="""addArea('%s', 'overview', %s, '%s', '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType(),ob.isPermanent()) + # check for force-permanent + if forceperm is not None: + perm = forceperm + else: + perm = ob.isPermanent() + js+="""addArea('%s', 'overview', %s, '%s', '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType(),perm) return js def createMapHead(self): @@ -292,17 +342,17 @@ class ECHO_basis: tag = "" if bt.isN4: # N4 needs layer for highlighting - tag += '" else: # a-element - tag = '" 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"): + 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) id = ob.getFullId() @@ -318,10 +368,27 @@ class ECHO_basis: if ob.isTypeArrow(): # N4 - Arrow rot = ob.angle - marksrc = arrowsrc + + if hasattr(getattr(self,link),'link'): + cLink=getattr(self,link).link + # if existing delete virtuell path + cLink=cLink.replace('/'.join(self.REQUEST['VirtualRootPhysicalPath']),'') + + if backLink and hasattr(getattr(self,link),'link') and backLink==self.REQUEST['SERVER_URL']+cLink.lstrip(): + marksrc=alternativArrowsrc + else: + marksrc = arrowsrc + + if float(rot) < 0: marksrc = circlesrc tag += ''%(link,marksrc,rot) + elif ob.isTypeText(): + # N4 - Text + tag += '
'%(id,id,id,link,target) + tag = ''%(id,id,id,link,target) if ob.isTypeArrow(): # DOM - Arrow rot = ob.angle - marksrc = arrowsrc + + if hasattr(getattr(self,link),'link'): + cLink=getattr(self,link).link + # if existing delete virtuell path + cLink=cLink.replace('/'.join(self.REQUEST['VirtualRootPhysicalPath']),'') + + if backLink and hasattr(getattr(self,link),'link') and backLink==self.REQUEST['SERVER_URL']+cLink.lstrip(): + marksrc=alternativArrowsrc + else: + marksrc = arrowsrc + + try: + rot=float(rot) + except: + rot=0 + if float(rot) < 0: marksrc = circlesrc if bt.isIEWin and bt.versIE > 5: @@ -1043,14 +1125,15 @@ class MapArea(SimpleItem): Globals.InitializeClass(MapArea) -class MapText(ZopePageTemplate): +class MapText(Folder,ZopePageTemplate): """class to hold text for map areas""" meta_type = 'ECHO_mapText' # Create a SecurityInfo for this class. security = ClassSecurityInfo() security.setDefaultAccess("allow") - + + _default_content_fn = os.path.join(package_home(globals()), 'html', 'ECHO_mapText_default.html') @@ -1061,6 +1144,34 @@ class MapText(ZopePageTemplate): text = open(self._default_content_fn).read() self.pt_edit(text, content_type) + def createLocale(self): + """create locale""" + return ECHO_collection.manage_addECHO_localeForm(self) + + manage_main=ZopePageTemplate.pt_editForm + + def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): + """manage add echo locale in map""" + ECHO_collection.manage_addECHO_locale(self,lang,title,label,text,content_type) + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + def changeLocale(self): + """change locale""" + return self.locale_en.change_ECHO_localeForm() + + def change_ECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): + """change echo locale""" + + obj= self.locale_en.change_ECHO_locale(lang,title,label,text,content_type,RESPONSE) + + + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + # Product registration and Add support manage_addMapTextForm = PageTemplateFile( 'zpt/AddECHO_mapText', globals(), __name__='manage_addMapTextForm')