version 1.2, 2004/04/14 16:43:30
|
version 1.3, 2004/04/23 16:25:09
|
Line 14 from Products.PageTemplates.ZopePageTemp
|
Line 14 from Products.PageTemplates.ZopePageTemp
|
import os |
import os |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
import string |
import string |
import urllib |
import urllib |
import xml.dom.minidom |
import xml.dom.minidom |
|
from urllib import quote |
|
|
|
|
### G L O B A L S ### |
### G L O B A L S ### |
Line 91 class lise(Folder):
|
Line 93 class lise(Folder):
|
manage_addliseForm = DTMLFile('dtml/manage_addliseForm', globals()) |
manage_addliseForm = DTMLFile('dtml/manage_addliseForm', globals()) |
|
|
|
|
|
class MAIN_layoutTemplate(ZopePageTemplate): |
|
"""Create a layout Template""" |
|
|
|
meta_type="MAIN_layoutTemplate" |
|
|
|
def __init__(self, id, text=None, content_type=None, MainType=None): |
|
self.id = str(id) |
|
|
|
self.ZBindings_edit(self._default_bindings) |
|
if text is None: |
|
self._default_content_fn = os.path.join(package_home(globals()), |
|
'dtml/main.zpt') |
|
text = open(self._default_content_fn).read() |
|
self.pt_edit(text, content_type) |
|
|
|
|
|
"""change form""" |
|
|
|
|
|
def manage_addNAIN_layoutTemplateForm(self): |
|
"""Form for adding""" |
|
pt = PageTemplateFile('Products/lise/dtml/main.zpt').__of__(self) |
|
return pt() |
|
|
|
|
def manage_addlise(self, id, title, pictpath, baseurl, file, RESPONSE = None): |
def manage_addlise(self, id, title, pictpath, baseurl, file, RESPONSE = None): |
"add a lise instance in a folder." |
"add a lise instance in a folder." |
global allobjects |
global allobjects |
Line 124 def manage_addlise(self, id, title, pict
|
Line 151 def manage_addlise(self, id, title, pict
|
fnames = [] |
fnames = [] |
id = str(id) |
id = str(id) |
title = str(title) |
title = str(title) |
if IsStr(gbaseurl): |
|
gbaseurl = str(baseurl) |
|
gpictpath = str(pictpath) |
gpictpath = str(pictpath) |
|
|
thelen = len(gpictpath) |
thelen = len(gpictpath) |
Line 136 def manage_addlise(self, id, title, pict
|
Line 162 def manage_addlise(self, id, title, pict
|
for i in fnames: |
for i in fnames: |
if i[0] <> '.': |
if i[0] <> '.': |
normalize_whitespace(i) |
normalize_whitespace(i) |
|
# filenames.append('file://' + gpictpath + '/' + i) |
|
if gpictpath[-1] == '/': |
|
filenames.append('file://' + gpictpath + i) |
|
else: |
filenames.append('file://' + gpictpath + '/' + i) |
filenames.append('file://' + gpictpath + '/' + i) |
|
else: |
|
filenames.append('no_fuckingPicture') |
|
|
newObj = lise(id, title) # create new lise object |
newObj = lise(id, title) # create new lise object |
self._setObject(id, newObj) # put it into zope |
self._setObject(id, newObj) # put it into zope |
Line 170 def manage_addlise(self, id, title, pict
|
Line 202 def manage_addlise(self, id, title, pict
|
p.CharacterDataHandler = taghandler.characters |
p.CharacterDataHandler = taghandler.characters |
p.Parse(str(object2.data)) |
p.Parse(str(object2.data)) |
|
|
|
if IsStr(baseurl): |
|
gbaseurl = str(baseurl) |
|
|
|
#### lšschen nicht vergessen ### |
|
# gbaseurl = 'http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=permanent/shipbuilding/bougu_traite_1746&dw=400&dh=400&pn=' |
|
|
for i in allobjects: |
for i in allobjects: |
if hasattr(i, 'typestr'): |
if hasattr(i, 'typestr'): |
if i.typestr == 'chapter': |
if i.typestr == 'chapter': |
Line 181 def manage_addlise(self, id, title, pict
|
Line 219 def manage_addlise(self, id, title, pict
|
if i.typestr == 'chapter': |
if i.typestr == 'chapter': |
i.CreateChapter() |
i.CreateChapter() |
if i.typestr == 'page': |
if i.typestr == 'page': |
i.CreatePage() |
i.CreatePage(i.chapterindex) |
|
|
|
|
pacount = 0 |
pacount = 0 |
for i in pagearray: |
for i in pagearray: |
Line 195 def manage_addlise(self, id, title, pict
|
Line 234 def manage_addlise(self, id, title, pict
|
break |
break |
if IsInt(pagearray[j].pictindex): |
if IsInt(pagearray[j].pictindex): |
i.pictindex = pagearray[j].pictindex |
i.pictindex = pagearray[j].pictindex |
i.picturelink = '' |
|
break |
break |
pacount = pacount + 1 |
pacount = pacount + 1 |
|
|
Line 500 def IsStr(str):
|
Line 538 def IsStr(str):
|
class PageObject: |
class PageObject: |
def __init__(self): |
def __init__(self): |
self.name = "" |
self.name = "" |
self.index = "" |
self.index = 0 |
self.pictindex = 0 |
self.pictindex = 0 |
self.url = "" |
self.url = "" |
self.isselected = False |
self.isselected = False |
Line 510 class PageObject:
|
Line 548 class PageObject:
|
self.nextref = 0 |
self.nextref = 0 |
self.chapref = 0 |
self.chapref = 0 |
|
|
def CreatePage(self): |
def CreatePage(self, level): |
global counter |
global counter |
global counterid |
global counterid |
global gbaseurl |
global gbaseurl |
Line 518 class PageObject:
|
Line 556 class PageObject:
|
global pagearray |
global pagearray |
global errstr |
global errstr |
|
|
|
self.chapterindex = level |
pageelement = PageElement() |
pageelement = PageElement() |
pageelement.id = str(counterid) |
pageelement.id = str(counterid) |
pageelement.type = "P" |
pageelement.type = "P" |
pageelement.name = self.name |
pageelement.name = self.name |
if IsStr(self.url): |
if IsStr(self.url): |
if len(self.url) > 0: |
if len(self.url) > 0: |
|
if IsStr(gbaseurl): |
|
if len(gbaseurl) > 0: |
|
if gbaseurl[-1] == '/': |
|
pageelement.picturelink = gbaseurl + self.url |
|
else: |
pageelement.picturelink = gbaseurl + '/' + self.url |
pageelement.picturelink = gbaseurl + '/' + self.url |
|
else: |
|
pageelement.picturelink = self.url |
|
else: |
|
if IsStr(gbaseurl): |
|
pageelement.picturelink = gbaseurl |
|
else: |
|
pageelement.picturelink = gbaseurl |
|
|
pageelement.level = self.chapterindex |
pageelement.level = self.chapterindex |
|
|
if IsInt(self.index): |
if IsInt(self.index): |
if int(self.index) > 0: |
if int(self.index) >= 0: |
pageelement.pictindex = int(self.index) - 1 |
pageelement.pictindex = int(self.index) |
|
if IsStr(pageelement.picturelink): |
|
if len(pageelement.picturelink) > 0: |
|
pageelement.picturelink = pageelement.picturelink + str(self.index + 1) |
|
|
else: |
else: |
pageelement.pictindex = '9999' |
pageelement.pictindex = '9999' |
else: |
else: |
Line 601 class ChapterObject:
|
Line 657 class ChapterObject:
|
def CreateChapter(self): |
def CreateChapter(self): |
global counter |
global counter |
global counterid |
global counterid |
global baseurl |
global gbaseurl |
global pagearray |
global pagearray |
global errstr |
global errstr |
|
|
Line 622 class ChapterObject:
|
Line 678 class ChapterObject:
|
count += 1 |
count += 1 |
if hasattr(self, 'typestr'): |
if hasattr(self, 'typestr'): |
if i.typestr == 'page': |
if i.typestr == 'page': |
i.CreatePage() |
i.CreatePage(self.chapterindex + 1) |
if i.typestr == 'chapter': |
if i.typestr == 'chapter': |
i.CreateChapter() |
i.CreateChapter() |
if i.typestr == 'start': |
if i.typestr == 'start': |
Line 655 class ChapterObject:
|
Line 711 class ChapterObject:
|
pageelement.type = "P" |
pageelement.type = "P" |
pageelement.open = 0 |
pageelement.open = 0 |
pageelement.pictindex = j |
pageelement.pictindex = j |
|
pageelement.picturelink = gbaseurl + str(j) |
pagearray.append(pageelement) |
pagearray.append(pageelement) |
currlen = len(pagearray) |
currlen = len(pagearray) |
if pagearray[currlen - 2].type == 'C': |
if pagearray[currlen - 2].type == 'C': |
pagearray[currlen - 2].pictindex = j |
pagearray[currlen - 2].pictindex = j |
|
pagearray[currlen - 2].picturelink = gbaseurl + str(j) |
counter = counter + 1 |
counter = counter + 1 |
counterid = counterid + 1 |
counterid = counterid + 1 |
currcount = currcount + 1 |
currcount = currcount + 1 |
Line 693 class ChapterObject:
|
Line 751 class ChapterObject:
|
pageelement.type = "P" |
pageelement.type = "P" |
pageelement.open = 0 |
pageelement.open = 0 |
pageelement.pictindex = j |
pageelement.pictindex = j |
|
pageelement.picturelink = gbaseurl + str(j) |
pagearray.append(pageelement) |
pagearray.append(pageelement) |
|
|
counter = counter + 1 |
counter = counter + 1 |