--- documentViewer/MpdlXmlTextServer.py 2010/12/23 15:38:41 1.217 +++ documentViewer/MpdlXmlTextServer.py 2010/12/23 16:12:23 1.218 @@ -120,6 +120,7 @@ class MpdlXmlTextServer(SimpleItem): def getNumTextPages (self, docinfo=None): """get list of pages from fulltext (texts without images) and put in docinfo""" + logging.debug("getNumTextPages") docpath = docinfo['textURLPath'] selfurl = self.absolute_url() #viewMode= pageinfo['viewMode'] @@ -137,35 +138,13 @@ class MpdlXmlTextServer(SimpleItem): def getTocEntries (self, docinfo=None): """ number of text entries""" - docpath = docinfo['textURLPath'] - selfurl = self.absolute_url() - if 'tocEntries' in docinfo: - # allredy there - return docinfo['tocEntries'] - if (docpath!=None): - text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) - dom =Parse(text) - pagedivs = dom.xpath("//div[@class='countTocEntries']") - #logging.debug ("pagedivs=%s"%(pagedivs)) - docinfo['tocEntries'] = getTextFromNode(pagedivs[0]) - #tc = int (originalPage) - return docinfo['tocEntries'] + self.getInfoFromPage(docinfo) + return docinfo['tocEntries'] def getFigureEntries (self, docinfo=None): """ number of figure entries""" - docpath = docinfo['textURLPath'] - selfurl = self.absolute_url() - if 'figureEntries' in docinfo: - # allredy there - return docinfo['figureEntries'] - if (docpath!=None): - text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) - dom = Parse(text) - pagedivs = dom.xpath("//div[@class='countFigureEntries']") - #logging.debug ("pagedivs=%s"%(pagedivs)) - docinfo['figureEntries'] = getTextFromNode(pagedivs[0]) - #tc = int (docinfo['figureEntries']) - return docinfo['figureEntries'] + self.getInfoFromPage(docinfo) + return docinfo['figureEntries'] def getGisPlaces(self, docinfo=None, pageinfo=None): """ Show all Gis Places of whole Page""" @@ -230,20 +209,31 @@ class MpdlXmlTextServer(SimpleItem): def getAllPlaces (self, docinfo=None): """Show all Places if no places than 0""" - docpath = docinfo['textURLPath'] - selfurl = self.absolute_url() + self.getInfoFromPage(docinfo) + return docinfo['allPlaces'] + + def getInfoFromPage(self, docinfo=None): + """ extract diverse info from page-fragment""" + docpath = docinfo['textURLPath'] if 'allPlaces' in docinfo: # allredy there - return docinfo['allPlaces'] + return docinfo - text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) - dom =Parse(text) - pagedivs = dom.xpath("//div[@class='countPlaces']") - logging.debug ("pagedivs=%s"%(pagedivs)) - if len(pagedivs)>0: + if (docpath is not None): + text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath'])) + dom = Parse(text) + # figureEntries + pagedivs = dom.xpath("//div[@class='countFigureEntries']") + docinfo['figureEntries'] = getTextFromNode(pagedivs[0]) + # tocEntries + pagedivs = dom.xpath("//div[@class='countTocEntries']") + docinfo['tocEntries'] = getTextFromNode(pagedivs[0]) + # allPlaces + pagedivs = dom.xpath("//div[@class='countPlaces']") docinfo['allPlaces']= getTextFromNode(pagedivs[0]) - #logging.debug ("docinfo['allPlaces']=%s"%(docinfo['allPlaces'])) - return docinfo['allPlaces'] + + return docinfo + def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization="reg", highlightQuery=None, sn=None, optionToggle=None): """returns single page from fulltext"""