diff bibliography.py @ 0:bca61e893fcc

first checkin of MPIWGWeb r2 branch from CVS into mercurial
author casties
date Thu, 10 Jan 2013 17:52:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bibliography.py	Thu Jan 10 17:52:13 2013 +0100
@@ -0,0 +1,95 @@
+#TO DO author_semi_kolon etc. ersetzen durch Funktionen
+def formatBibliography(self,found):
+    ret=""
+    if found.id_institutsbibliographie and (not found.id_institutsbibliographie==''):
+        ret+=formatBiblHelp(self,found,table='institutsbiblio',id=found.id_institutsbibliographie)
+    else:
+        ret+=formatBiblHelp(self,found,table='bibliography',id=found.id_gen_bib)
+    return ret
+
+def CRListToSemicolon(list):
+    if list:
+        return "; ".join(list.split("\n"))
+    else:
+        return None
+    
+def getBib(value):
+    if value:
+        return value
+    else:
+        return ""
+    
+def formatBiblHelp(self,found,table,id,foundIB=None):
+    ret=""
+    if not foundIB:
+        try:
+            foundIB=self.ZSQLInlineSearch(_table=table,id=id,_op_id="eq")[0]
+
+        except:
+            return ret
+    
+    if foundIB.reference_type.lower()=='journal article':
+        ret+=getBib(CRListToSemicolon(foundIB.author))+". &quot;"+getBib(foundIB.title)+". &quot; "+"<i>%s</i>"%getBib(foundIB.secondary_title)+" "+getBib(foundIB.volume)+" ("
+        if not self.ZSQLisEmpty(foundIB.number):
+            ret+=foundIB.number+"&nbsp;"
+
+        if foundIB.year:
+            ret+=getattr(foundIB,'year','')
+        ret+=")"
+        if foundIB.pages and (not foundIB.pages)=='':
+            ret+=": "+foundIB.pages+"."
+
+    elif foundIB.reference_type.lower()=='edited book':
+        if foundIB.author:
+            ret+=CRListToSemicolon(foundIB.author)+" (Editor/s). " 
+        if foundIB.title and (not foundIB.title==""):
+            ret+="<i>"+foundIB.title+"</i>. "
+        if foundIB.place_published and (not foundIB.place_published==''):
+            ret+=foundIB.place_published+": "
+        if foundIB.publisher and (not foundIB.publisher==''):
+            ret+=foundIB.publisher+", "
+        ret+=getBib(foundIB.year)+"."
+
+    elif foundIB.reference_type.lower()=='book section' or foundIB.reference_type.lower()=='in book':
+        ret+=getBib(CRListToSemicolon(foundIB.author))+". &quot;"+getBib(foundIB.title)+".&quot; In: <i>"+getBib(foundIB.secondary_title)+"</i>"
+        if (CRListToSemicolon(foundIB.secondary_author)) and (not CRListToSemicolon(foundIB.secondary_author)==''):
+            ret+=", eds.: "+CRListToSemicolon(foundIB.secondary_author)
+        ret+=". "
+        if foundIB.pages and (not foundIB.pages)=='':
+            ret+=foundIB.pages+". "
+        if foundIB.place_published and (not foundIB.place_published==''):
+            ret+=foundIB.place_published+": "
+        if foundIB.publisher and (not foundIB.publisher==''):
+            ret+=foundIB.publisher+", "
+        ret+=getBib(foundIB.year)+"."
+
+   
+    elif foundIB.reference_type.lower()=='book':
+        ret+=getBib(CRListToSemicolon(foundIB.author))+". <i>"+getBib(foundIB.title)+"</i>. "
+#       if foundIB.pages and (not foundIB.pages==''):
+#%            ret+=foundIB.pages+". "
+        if foundIB.place_published and (not foundIB.place_published==''):
+            ret+=foundIB.place_published+": "
+        if foundIB.publisher and (not foundIB.publisher==''):
+            ret+=foundIB.publisher+", "
+        ret+=getBib(foundIB.year)+"."
+
+    elif foundIB.reference_type.lower()=='newspaper article':
+        ret+=CRListToSemicolon(foundIB.author)+". &quot;"+foundIB.title+".&quot; <i>"+foundIB.secondary_title+"</i>, "
+        ret+=foundIB.date+"."+foundIB.year+","
+        if foundIB.pages and (not foundIB.pages==''):
+            ret+=foundIB.pages+". "
+    elif foundIB.reference_type.lower()=='magazine article':
+        ret+=CRListToSemicolon(getBib(foundIB.author))+". &quot;"+getBib(foundIB.title)+".&quot; <i>"+getBib(foundIB.secondary_title)+"</i>, "
+	if foundIB.date:
+	        ret+=getBib(foundIB.date)+"."
+	if foundIB.year:
+		ret+=foundIB.year+","
+        if foundIB.pages and (not getBib(foundIB.pages)==''):
+            ret+=foundIB.pages+". "
+
+
+
+            
+            
+    return ret