Esempio n. 1
0
    def affiche(self):
        if not check_admin(self.datas, self.socket, False):
            return
        typeactu = self.datas.objet_actu.name_class
        if (typeactu == 0) and (self.datas.objet_actu.action.__name__ != "affiche"):
            typeactu = -1

        active = self.get_propriete("active", "false")
        posx = self.get_propriete("initx", "0")
        posy = self.get_propriete("inity", "30")

        id_user = self.datas.my_session.id_user
        if id_user > -1:
            active = get_propriete(self.glob, id_user, "pal_active", active)
            posx = get_propriete(self.glob, id_user, "pal_initx", posx)
            posy = get_propriete(self.glob, id_user, "pal_inity", posy)

        if active != "false":
            self.socket.send_datas(
                """<div class="pere_palette">
<div id="palette" class="palette" alt="palette">
  Palette
</div>
<script language="javascript">
jsbox_init_box("palette",%s,%s,120,100,'white');
http_url_datas_to_fct("/%s/in/%s",load_palette);
</script>
</div>
"""
                % (posx, posy, self.get_name(), typeactu)
            )
Esempio n. 2
0
    def affiche(self):
	    _=self.datas._
	    if self.datas.my_session.user:
                    self.socket.send_datas('<h1>%s</h1>\n' % _('Compte utilisateur'))
		    self.socket.send_datas('<br /> %s : %s [<a href="%s/user/logout">%s</a>]<br />' % (_('Utilisateur'),self.datas.my_session.user,self.datas.url_base,_('Deconnection')))

                    pl=self.datas.my_session.langue

		    options_langues=''
		    for l in self.config.langues_interface:
			    selected=""
			    if l==pl:
				    selected=" SELECTED"
			    options_langues+='<option value="%s"%s>%s</option>' % (l,selected,tablang[l])

                    options_palette=""

                    if check_admin(self.datas,self.socket,alerte=False):

                        id_pal=self.glob.objets[0]['urls'][pl].get('palette')
                        id_user=self.datas.my_session.id_user
                        active=get_propriete(self.glob,id_pal,'active',"false")
                        posx=get_propriete(self.glob,id_pal,'initx','0')
                        posy=get_propriete(self.glob,id_pal,'inity',"30")
                        active=get_propriete(self.glob,id_user,'pal_active',active)
                        posx=get_propriete(self.glob,id_user,'pal_initx',posx)
                        posy=get_propriete(self.glob,id_user,'pal_inity',posy)
                        s1=""
                        s2=""
                        if active=='false':
                            s2=" SELECTED"
                        else:
                            s1=" SELECTED"
                        options_palette="""
<li>
<br />
                    %s <select name="pal_active">
                    <option value="true" %s>%s</option>
                    <option value="false" %s>%s</option>
                    </select>
                    / %s
                    X : <input type="text" name="pal_initx" value="%s" size="4" />
                    Y : <input type="text" name="pal_inity" value="%s" size="4" /><br />
</li>
                    """ % (_('Activation de la palette'),s1,_('Activer'),s2,_('Desactiver'),
                           _('Coordonees'),posx,posy)


                    ordre_infos=self.get_propriete('ordre_infos','').split(',')

                    infos=self.get_dico_proprietes('infos')

                    for k in infos.keys():
                        if not k in  ordre_infos:
                            ordre_infos.append(k)
                    
                    infos_html=""
                    pl=self.datas.my_session.langue
                    id_user=self.datas.my_session.id_user
                    for elem in ordre_infos:
                        if elem in infos.keys():
                            info=infos[elem]
                            type_info=""
                            if type(info)==type({}):
                                type_info=info.keys()[0]
                                info=info[type_info]
                            else:
                                type_info='textr'
                              
                            if type(info)==type({}):
                                langs=info.keys()
                                if 'all' in langs:
                                    value=info['all']
                                elif pl in langs:
                                    value=info[pl]
                                elif len(langs)>0:
                                    value=info[langs[0]]
                                else:                               
                                    value=''
                            else:
                                value=str(info)
                               
                            if type_info=='textr':
                                if value:
                                    infos_html+="<li><br /><p>%s</p></li>" % value
                            if type_info=='textu':
                                uservalue=get_propriete(self.glob,id_user,elem,"")
                                if uservalue:
                                    infos_html+="<li><br />"
                                    if value:
                                        infos_html+=value+" : "
                                    infos_html+=uservalue+"</li>"
                            elif type_info=="textw":
                                uservalue=get_propriete(self.glob,id_user,elem,"")
                                infos_html+="""<li><br />
%s : <input type="text" name="%s" value="%s" /></li>""" % (value,elem,uservalue)
                            

                    self.socket.send_datas("""
<form action="%s/user/edit" method="post">
<ul>
<li>
<br />%s : 
<select name="monlanguage">
%s
</select>
</li>
%s
%s
<li>
<br /><input type="submit" value="%s">
</li>
</ul>
</form>
""" % (       self.datas.url_base,_("Votre language"),options_langues,options_palette,infos_html,_("Valider"))) 

	    else:
		    self.socket.send_datas ( """
<h1>%s</h1>
<form action="%s/user/verify" method="post">
<input type="hidden" name="ie" value="e">
<ul>
<li>
<br />%s : <input type="text" name="openid" value="">
</li>
<li>
<li>
<br /><input type="checkbox" name="autoconnect" value="yes"> %s
</li>
<br /><input type="submit" value="%s">
</li>
</ul>
</form>
""" % (_('Connection'),
       self.datas.url_base, _('Identifiant tekio ou Open ID'),
       _('Se connecter automatiquement la prochaine fois'),
       _('se connecter'))
)
Esempio n. 3
0
def dispo_add_elem(glob,database,idp,id,placement):

    colonne_max=4

    dispo_normal=get_propriete(glob,idp,'dispo_normal','=')

    ## recuperation du contenu de la page (entre = et -) 
    wikitmp2=dispo_normal
    h=''
    if dispo_normal.find('=')!=-1:
        (h,wikitmp2)=dispo_normal.split('=',1)
        if len(wikitmp2)>0 and wikitmp2[0]==',':
            wikitmp2=wikitmp2[1:]

    # decoupe les ligne mais reste la ligne init !att: reste le premier [line: sans la ','
    linesbruts=wikitmp2.split(',[line:') 
    lines=[]   
    for linebrut in linesbruts:
        # on vire le [line: restant et les ] qui leur correspondaient
        line=linebrut.replace('[line:','')[:-1].strip()
        if line:
            lines.append(line)

    if placement not in ["top","topleft","topright",
                         "bottomleft","bottomright","bottom"]:
        placement="bottom"

    # baseline pour : 0 => avant le tableau
    # baseline pour : X => dans la ligne X (notation humaine qui commence par 1)
    # baseline pour : -1 => apres le tableau

    if len(lines)==0:
        baseline=0
    elif placement=="top":
        baseline=0
    elif placement=="bottom":
        baseline=-1
    elif placement in ["topleft","topright"]:
        baseline=1
    elif placement in ["bottomleft","bottomright"]:
        baseline=len(lines)


    if baseline < 1 :
        #inser une nouvelle ligne au debut ou a la fin.
        newline="[col1:[elem:%s]]" % id
        if baseline==0:
            lines.insert(0,newline)
        else:
            lines.append(newline)

    else:
        varline=lines[baseline-1]
        colsbruts=varline.split(',[col')
        cols=[]   
        for colbrut in colsbruts:
            if colbrut:
                try:
                    col=colbrut.replace('[col','').split(":",1)[1][:-1]
                    cols.append(col)
                except:
                    log.err("erreur colbrut %s " % colbrut)
        newcol="[elem:%s]" % id
        if placement in ["topleft","bottomleft"]:
            cols.insert(0,newcol)
        if placement in ["topright","bottomright"]:
            cols.append(newcol)

        nbcols=len(cols)
        col4join=[]
        for c in cols:
            col4join.append('[col%s:%s]' % (nbcols,c))
        
        lines[baseline-1]=','.join(col4join)


    # recolage des lignes
    line4join=[]
    for l in lines:
        line4join.append('[line:%s]' % l)
    newdispo=h+'=,'+','.join(line4join)

    # ecriture nouvelle disppo
    set_propriete(glob,database,idp,'dispo_normal',newdispo)