def _table(border=0,cellpadding=1,cellspacing=1,bgcolor=None):
r = '
w:
w = 100.0/h*w
h = 100
else:
h = 100.0/w*h
w = 100
return h,w
def NuovoArticolo(self,REQUEST,RESPONSE):
r=''
r=r+ str(REQUEST)
gruppo = REQUEST.form.get('gruppo')
if gruppo:
next_art = self['prossimo_articolo'] # proprieta' del folder 'foto'
upload=self.upload.this()
id = 'art_%s'%next_art
newob=upload.Control_Panel.Products.MArticolo.ArtClass(id)
newob.id=id
upload._setObject(id,newob)
r=r+ 'Articolo %s aggiunto.' % next_art
next_art = next_art + 1
next_foto = self['prossima_foto']
for i in gruppo:
newob.manage_clone(upload[i],'foto_%s'%next_foto)
newob[next_foto].manage_changeProperties({'filename': i})
next_foto = next_foto + 1
self.manage_changeProperties({'prossimo_articolo': next_art})
self.manage_changeProperties({'prossima_foto': next_foto})
return r
def DisplayFotoConLink(img):
r=''
height = int(img.height)
width = int(img.width)
(h,w) = thumb_size(height,width)
r=r+ '' % img.absolute_url()
r=r+ ('
' %
(img.absolute_url(),w,h,img.__name__))
r=r+ ''
return r
def ViewPhotoSet(self,gruppo,tablewidth=5):
r= _table()
n = 0
for img in immagini:
if n%tablewidth==0:
r=r+ ''
r=r+ '| %s | ' % DisplayFotoConLink(img)
if (n%tablewidth) == (tablewidth-1) :
r=r+ '
'
n = n+1
r=r+ '
'
return r
def CancellaFoto(self,REQUEST,RESPONSE):
r=''
gruppo = REQUEST.get('gruppo')
if gruppo:
r=r+ ViewPhotoSet(gruppo)
def uploadMenu(self, REQUEST=None, RESPONSE=None, tablewidth=6):
sub = REQUEST.get('SUBMIT')
if sub=='Cancella foto':
return CancellaFoto(self,REQUEST,RESPONSE)
if sub=="Nuovo Articolo":
return NuovoArticolo(self,REQUEST,RESPONSE)
r=''
immagini = self.upload.objectValues('Image')
l = len(immagini)
r=r+ ''
r=r+ str(REQUEST)
return r