def new_ElementGalerie(fs_svn,socket,pere_id,pere_path, titre,description,fileitem_image, fileitem_mini=None,fileitem_download=None, lang='all'): pathpage=config.path['files']+pere_path name=fileitem_image.filename if not name: name=fileitem_image.name pathfile_image=pathpage+'/normal/'+name pathfile_mini=pathpage+'/mini/mini_'+name pathfile_download=pathpage+'/download/download_'+name pathfile_info=pathpage+'/info/'+name+'.info' fileitem_to_pathfire(pathfile_image,fileitem_image) if fileitem_mini != None: fileitem_to_pathfire(pathfile_mini,fileitem_mini) else: copy_file(pathfile_image,pathfile_mini) if fileitem_download != None: fileitem_to_pathfire(pathfile_download,fileitem_download) else: copy_file(pathfile_image,pathfile_download) f= open (pathfile_info, 'wb') f.write(titre+'\n'+description) f.close() redirect_ok(socket,datas)
def new_Galerie(glob,database,datas,socket,pere_id,pere_path, name=None,titre='Galerie',textnav='Galerie',description='', placement_wiki=None,lang='all'): if not check_edit(datas,socket): return pathgalerie=config.path['files']+pere_path+'/'+name os.system('mkdir -p "%s"' % pathgalerie) os.system('mkdir -p "%s/mini"' % pathgalerie) os.system('mkdir -p "%s/normal"' % pathgalerie) os.system('mkdir -p "%s/info"' % pathgalerie) os.system('mkdir -p "%s/download"' % pathgalerie) proprietes={ 'titre' : titre.strip(), 'textnav' : textnav.strip(), 'description' : description.strip(), } obj_id=create_element(glob,database,4,pere_id,{'all':name,},proprietes) if placement_wiki: dispo_add_elem(glob,database,pere_id,obj_id, placement_wiki) redirect_ok(socket,datas)
def affiche_user(self): name_moule_user=self.get_propriete('moule_user','') id_user=self.datas.my_session.id_user id_user_piece=self.get_fils_by_name('user_%s' % id_user) if id_user_piece==-1: id_user_piece=create_piece(self.interfaces,self.id,name_moule_user,'user_%s' % id_user,{}) user_piece=get_instance_from_id(self.interfaces,id_user_piece) self.datas.my_session.set_new_url(self.path+'/user_'+str(id_user)+self.path_r) redirect_ok(self.socket,self.datas)
def delete(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return self.path_obj=self.path_entier.split('/delete')[0] pathpere=path_pere(self.path_obj) self.fs_svn.trash(self.path_obj) self.datas.my_session.set_new_url(pathpere) redirect_ok(self.socket,self.datas)
def admin_users_new(self): if not check_admin(self.datas,self.socket): return _=self.datas._ newuser=self.socket.input_text_value('newopenid') self.datas.my_session.set_new_url('/admin/users/') if newuser in self.glob.openids.keys(): redirect_ok(self.socket,self.datas) create_element(self.glob,self.database,40,0,{},{'openid':newuser,}) redirect_ok(self.socket,self.datas)
def enleve_element(self): # BUG lors de enleve element Page au niveau de la racine !!!! if not check_edit(self.datas,self.socket): return i=int(self.socket.args["id"]) if i==0: return url_ret=self.path if self.id==i: url_ret=path_pere(url_ret) self.datas.my_session.set_new_url(url_ret) if i!=0: detruire_element(self.interfaces,i) redirect_ok(self.socket,self.datas)
def edit_text_ok(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return urlobj="%s/%s" % (self.datas.url_base,self.path_obj) text=self.socket.input_text_value('text') if text: self.fs_svn.trash(self.path_obj) self.fssvn.modif(self.path_obj) pathpere=path_pere(self.path_obj) self.datas.my_session.set_new_url(pathpere) redirect_ok(self.socket,self.datas)
def element_move(self): idelem=int(self.socket.args["id"]) posline=int(self.socket.args["line"]) poscol=int(self.socket.args["col"]) solostr=self.socket.args["solo"] solo=False if solostr=='y': solo=True dispo_normal=self.get_propriete('dispo_normal','=') print "MOVE" print dispo_normal print (idelem,posline,poscol,solo) new_dispo=move_id_wiki(dispo_normal,idelem,posline,poscol,solo) print new_dispo self.set_propriete('dispo_normal',new_dispo) self.datas.my_session.set_new_url(self.path) redirect_ok(self.socket,self.datas)
def move_page(self): if not check_edit(self.datas,self.socket): return chemin=format_path_list(self.socket.args["pere"].split('__')[1:-1]) idpere=int(self.socket.args["pere"].split('__')[-1]) pos=int(self.socket.args["pos"]) my_obj=self.glob.objets[self.id] oldpere=my_obj['pere'] oldpere_obj=self.glob.objets[oldpere] newpere_obj=self.glob.objets[idpere] if (oldpere!=idpere): self.se_deplacer(idpere) self.datas.my_session.set_new_url(oldpere_obj['path'][self.glob.langues[0]]) else: self.datas.my_session.set_new_url(self.path) # reordoner les sous pages pages=newpere_obj['proprietes']['ordre_sous_pages'] newordre=[] j=0 posok=False for (idpage) in pages: if j==pos: newordre.append(self.id) j+=1 posok=True if idpage!=self.id: newordre.append(idpage) j+=1 if not posok: newordre.append(self.id) newordrestr='/'.join(map(str,newordre)) set_propriete(self.glob,self.database,idpere,'ordre_sous_pages',newordrestr) newpere_obj['proprietes']['ordre_sous_pages']=newordre for lang in self.glob.langues: self.glob.get_infos_sous_pages(lang,idpere) redirect_ok(self.socket,self.datas)
def ajoute_page(self): _=self.datas._ if not check_edit(self.datas,self.socket): return init_datas={} for code in self.config.langues: init_datas[code]={} init_datas[code]['url']=check_char_idpage(self.socket.input_text_value('urlpage_%s' % code)) init_datas[code]['textnav']=self.socket.input_text_value('textnav_%s' % code) init_datas[code]['titre']=self.socket.input_text_value('titrepage_%s' % code) new_Page(self,init_datas) self.datas.my_session.set_new_url(self.path) redirect_ok(self.socket,self.datas)
def admin_users_delete(self): if not check_admin(self.datas,self.socket): return _=self.datas._ elem=self.datas.action_params[0] iduser=int(elem) self.datas.my_session.set_new_url('/admin/users/') openid=self.glob.utilisateurs[elem]['proprietes']['openid'] del(self.glob.openids[openid]) del(self.glob.utilisateurs[elem]) for (idg,groupe) in self.glob.groupes.items(): if elem in groupe.responsables: groupe.responsable.remove(elem) if elem in groupe.membres: groupe.membres.remove(elem) detruire_element(self.interfaces,iduser) redirect_ok(self.socket,self.datas)
def edit_ok(self): _=self.datas._ if not check_edit(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return text_modif={} for code in self.config.langues: namefile = self.path+'.%s.txt' % code text=self.socket.input_text_value('text_%s' % code) oldtext=self.get_text_lang(code) if text!=oldtext: text_modif[code]=text change_Text(self.glob,self.fs_svn,self.id,text_modif) urlparent='/'.join(self.path.split('/')[:-1]) self.datas.my_session.set_new_url(urlparent) redirect_ok(self.socket,self.datas)
def admin_users_valid_edit(self): if not check_admin(self.datas,self.socket): return iduser=int(self.socket.input_text_value('iduser')) for g in self.glob.utilisateurs[iduser].groupes: self.glob.groupes[g].membres.remove(iduser) self.glob.utilisateurs[iduser].groupes=[] self.database.write('del_my_groupes',(iduser,)) listgr=[] for k in self.socket.input_text_value: if k.find('groupe_')!=-1: listgr.append(int(k.split('groupe_')[1])) for gr in listgr: self.database.write('add_liaison',(int(gr),iduser,3)) self.glob.groupes[gr].membres.append(iduser) self.glob.utilisateurs[iduser].groupes.append(gr) self.datas.my_session.set_new_url('/admin/users/') redirect_ok(self.socket,self.datas)
def ajoute_text(self): _=self.datas._ if not check_edit(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return pere_id=self.datas.objet_actu.id pere_path=self.datas.objet_actu.path text={} placement=self.socket.input_text_value('placement') for code in self.config.langues: try: text[code]=self.socket.input_text_value('text_%s' % code) except: text[code]='' new_Text(self.glob,self.database,self.fs_svn,self.socket,self.config,pere_id,pere_path, text=text,placement_wiki=placement) self.datas.my_session.set_new_url(self.path) redirect_ok(self.socket,self.datas)
def edit_page(self): if not check_edit(self.datas,self.socket): return if self.id!=0: pereurl=path_pere(self.path)+'/%s' firstname="" oldnames=self.glob.objets[self.id]['names'] newnames={} i=0 for code in self.glob.langues: newnames[code]=check_char_idpage(self.socket.input_text_value('urlpage_%s' % code,'').strip()) if i==0: if newnames[code]=='': self.socket.send_datas('necessite url pour la page !!!') return else: namebase=newnames[code] else: if newnames[code]=='': newnames[code]=namebase names=[] flagmodifbase=False for code in self.config.langues: pathpageold=pereurl % oldnames[code] pathpagenew=pereurl % newnames[code] if len(names)==0: if oldnames[code]!=newnames[code]: flagmodifbase=True if newnames[code] in oldnames.values(): for c in oldnames: if oldnames[c]==newnames[code]: oldnames[c]=None pass #self.fs_svn.trash(pathpagenew) else: while (self.fs_svn.exist(pathpagenew)): (pathpagenew,newnames[code])=new_name_file(pathpagenew) pass #self.fs_svn.move(pathpageold,pathpagenew) else: if flagmodifbase or oldnames[code]!=newnames[code]: if pathpageold!=None and not oldnames[code] in names: pass #self.fs_svn.trash(pathpageold) if not newnames[code] in names: newlink=pereurl % names[0] while (self.fs_svn.exist(pathpagenew)): (pathpagenew,newnames[code])=new_name_file(pathpagenew) pass #self.fs_svn.add_link(newlink,pathpagenew) names.append(newnames[code]) self.rename(newnames) newlink=pereurl % names[0] self.datas.my_session.set_new_url(newlink) else: self.datas.my_session.set_new_url('') for code in self.config.langues: if self.id!=0: textnav=self.socket.input_text_value('textnav_%s' % code,'').strip() if textnav=='': textnav=newnames[code] self.set_propriete('textnav_%s' % code,textnav) titre=self.socket.input_text_value('titrepage_%s' % code,'').strip() self.set_propriete('titre_%s' % code,titre) self.glob.reinit(self.database,self.id) redirect_ok(self.socket,self.datas)