Beispiel #1
0
    def modif(self,path,data,msg=None,binary=False):
        self.log.debug("MODIF")
        path=format_path(path)
        if path=='':
            #la racine n'est pas un fichier.
            return
        pere=path_pere(path)
        name=name_from_path(path)

        fsreptmp=self.prepare_fstmp(pere)

        if binary:
            acces='wb'
        else:
            acces='w'

        f=open('%s/%s' % (fsreptmp,name),acces)
        f.write(data)
        f.close()

        actions=[]
        message=msg
        if not message:
            message = "Modifie fichier %s " % path
        tmpcommit=fsreptmp+'/'+name
        new_rev=self.commit(actions,message,tmpcommit,fsreptmp)

        return new_rev
Beispiel #2
0
    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)
Beispiel #3
0
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)
Beispiel #4
0
    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)
Beispiel #5
0
 def affiche(self):
     _=self.datas._
     self.socket.send_datas('<body><h1>'+_('SERVEUR HTTPDtekio : Repertoires et Fichiers Publics')+'</h1>\n')
     pathpere=path_pere(self.path_entier)
     parent=name_from_path(pathpere)
     if not parent:
         parent='Racine'
     self.socket.send_datas(_('Retour')+' : <a href="%s">%s</a> <br />' % (pathpere,parent))
     self.socket.send_datas('<br />')
     self.socket.send_datas(_("Contenu du Repertoire Actuel")+" : %s <br />" % self.path_entier)
     for elem in self.fs_svn.listdir(self.path_entier):
         path_obj="%s/%s" % (self.path_entier,elem)
         urlobj="%s/%s" % (self.datas.url_base,path_obj)
         admins_action=''
         if check_admin(self.datas,self.socket):
             typemime=mimetypes.guess_type(path_obj)[0]
             if typemime in self.type_edit:
                 admins_action='[<a href="http://%s/edit">E</a>] [<a href="http://%s/delete">D</a>]' % (urlobj,urlobj)
         self.socket.send_datas('<a href="http://%s">%s</a> %s<br />' % (urlobj,elem,admins_action))           
     return
Beispiel #6
0
    def add_folder(self,path,msg=None):
        self.log.debug("ADDFOLDER")
        path=format_path(path)
        if path=='':
            #on ne peux creer la racine (elle existe deja)
            return
        pere=path_pere(path)
        name=name_from_path(path)

        fsreptmp=self.prepare_fstmp(pere)

        system_no_ret("""mkdir "%s/%s" """  %  (fsreptmp,name))
        
        actions=[("""svn add "%s/%s" """  %  (fsreptmp,name)),]
        message=msg
        if not message:
            message = "Ajouter Repertoire %s " % path
        tmpcommit=fsreptmp+'/'+name
        new_rev=self.commit(actions,message,tmpcommit,fsreptmp)

        return new_rev
Beispiel #7
0
    def trash(self,path,msg=None): 
        self.log.debug("TRASH")
        path=format_path(path)
        if path=='':
            #on ne peux pas mettre la racine dans trash
            return
        pere=path_pere(path)
        name=name_from_path(path)

        dt=datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
        pathtrash="/trash/%s" % dt

        self.log.debug('create  %s' % pathtrash)
        new_rev=self.add_folder(pathtrash)

        pathtrashobj="%s/%s" % (pathtrash,name)
        message="Trash : %s => %s " % (path,pathtrashobj)
        self.log.debug(message)

        new_rev=self.move(path,pathtrashobj)
        
        return (new_rev,dt)
Beispiel #8
0
    def add_link(self,pathlinkinit,pathlinkfinal,msg=None):
        self.log.debug("ADDLINK")
        pathlinkinit=format_path(pathlinkinit)
        pathlinkfinal=format_path(pathlinkfinal)

        perefinal=path_pere(pathlinkfinal)
        namefinal=name_from_path(pathlinkfinal)

        fsreptmp = self.prepare_fstmp(perefinal)

        #TODO BEST : lien en relatif et pas en absolu
        # pour permettre le deplacement dans un autre repertoire du contenu.
        system_no_ret("""ln -s "%s/%s" "%s/%s" """  %  (self.dataread,pathlinkinit,fsreptmp,namefinal))

        actions=[("""svn add "%s/%s" """  %  (fsreptmp,namefinal)),]
        message=msg
        if not message:
            message="Ajout lien symbolique %s => %s " % (pathlinkinit,pathlinkfinal)
        tmpcommit=fsreptmp+'/'+namefinal
        new_rev=self.commit(actions,message,tmpcommit,fsreptmp)

        return new_rev
Beispiel #9
0
    def delete(self,path,msg=None):
        self.log.debug("DELETE")
        ### Ne pas appeler directemer dans les modules,
        ### prefere appeler trash pour garder le contenu.
        path=format_path(path)
        if path=='':
            #on ne peux detruire la racine
            return
        pere=path_pere(path)
        name=name_from_path(path)

        fsreptmp=self.prepare_fstmp(pere)

        system_no_ret("""cp -r "%s%s" "%s" """  % (self.dataread,path,fsreptmp))

        actions=[("""svn del "%s/%s" """   %  (fsreptmp,name)),]
        message=msg
        if not message:
            message="Detruit fichier %s " % path
        tmpcommit=fsreptmp+'/'+name
        new_rev=self.commit(actions,message,tmpcommit,fsreptmp)

        return new_rev
Beispiel #10
0
    def add(self,path,data,msg=None,binary=False):
        path=format_path(path)
        if path=='':
            return
        pere=path_pere(path)
        name=name_from_path(path)
        fsreptmp=self.prepare_fstmp(pere)
        if binary:
            acces='wb'
        else:
            acces='w'
        f=open('%s/%s' % (fsreptmp,name),acces)
        f.write(data)
        f.close()

        actions=[("""svn add "%s/%s" """  %  (fsreptmp,name)),]
        message=msg
        if not message:
            message="Ajouter fichier %s " % path
        tmpcommit=fsreptmp+'/'+name
        new_rev=self.commit(actions,message,tmpcommit,fsreptmp)

        return new_rev
Beispiel #11
0
def delete_page_confirm(self):
    _=self.datas._
    ido=self.id
    path_retour=path_pere(self.path)

    tpl="""
%s : <br />
%s : %s <br />
""" % (_('Etes vous sur que vous voulez detruire cette page'),
       self.id, self.path)

    tpl+="""

<div id="div_valid" class="invisible">
<center>
<a href="%s/enleve_element?id=%s"><h3>%s</h3></a>
</center>
</div>

<br />
""" % (path_retour,ido,_('Destruction de la page'))

    self.socket.send_datas(tpl)
    self.confirm_detruire()
Beispiel #12
0
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)