// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne. while ($row = mysql_fetch_array($resultat)) { $ccv = explode('?', $_SERVER['REQUEST_URI']); if (count($ccv) > 1) { $cc = '&'; } else { $cc = '?'; } //bouton de suppression qu'on rajoute à la fin de la ligne if ($username == $row['username']) { $suppression = '<input type="button" name="refresh" value="X" onclick="location.replace(\'' . $_SERVER['REQUEST_URI'] . $cc . 'suppr=' . $row['ID'] . '\');">'; } else { $suppression = ''; } echo '<tr class=commentitems valign=top width=10%><td><b>' . $row['username'] . "</b> (" . $row['jour'] . "):</td><td width=80%>" . '"<i>' . remove_popo($row['commentaire']) . '</i>"</td><td width=10%>' . $suppression . '</td>'; echo '</tr>' . "\n"; } echo '</tr></table><table width=97.5%><tr><td width=100% style="background-color:cyan;"></td></tr></table>'; } mysql_close(); ?> <table><tr><td class=commentitems valign=top><b>utilisateur "<? echo $username;?>"</b><br>ajoutez votre<br>commentaire ici:</td><td width=2.5%></td> <td><form id="test2" method="POST" action="<?php echo fetch_url(); ?> "> <textarea rows="4" cols="80" name="commentaire" wrap="physical" MAXLENGTH="1000"></textarea></td> <td>
function query2streamgraphData($query, $first_period, $last_period, $dT, $time_steps) { // transforme un ensemble de données de partition d'une requête sur la table partition en un streamgraph par partition $resultat = mysql_query($query) or die("<b>Requête non exécutée (récupération des principales thématiques)</b>."); $year_String = 'var years = ['; for ($i = $first_period; $i <= $last_period; $i += $time_steps) { $year_String .= $i . ', '; } $year_String = substr($year_String, 0, -2) . '];'; echo $year_String; // ajout des var pour chaque branche $streamgraphString = $year_String . 'var dynamics= {'; while ($partition_resultat = mysql_fetch_array($resultat)) { //infos sur la partition $id_partition = $partition_resultat[id_partition]; $partition_label = $partition_resultat[label]; if (strcmp(substr($partition_label, -1), ',') == 0) { $lab = substr($partition_label, 0, -1); } $streamgraphString .= '"' . remove_popo(substr($partition_label, 0, -1)) . '":' . partition2JSON($id_partition, $first_period, $last_period, $dT, $time_steps); } $streamgraphString = substr($streamgraphString, 0, -1) . '};'; return $streamgraphString; }
function display_cluster_title ($s, $direction) { global $dico_termes,$mainloc,$arraykey,$last_display_periode,$jscriptmp,$my_period,$nav; $label1=$s['label1']; $label2=$s['label2']; $lettre=$s['lettre']; $shref='cluster.php?id_cluster='.$s['id']."&periode=".arrange_periode($s['periode']).'&nav='.$nav; $speriode=get_short_string_periode(arrange_periode($s['periode']),0,1); $stitle='"<b>'.remove_popo($dico_termes[$label1]).'</b> - '.remove_popo($dico_termes[$label2]).'"'; // $periodchange indique si on a un changement de période par rapport au dernier champ thématique affiché $periodchange=($last_display_periode!=$s['periode']); $ecart=floor(abs(compute_periode(derange_periode($my_period))-compute_periode($s['periode']))/7001000); //if ($periodchange && $last_display_periode!="") // echo '<tr style="background:white;"><td></td><td></td><td></td><td><hr class="dashed"></td></tr>'; //else { //if (!$periodchange) echo '<tr style="height:4px;font-size:0pt;'.($ecart>0?' background:white;':'').'"><td> </td><td></td><td></td><td></td></tr>'; } echo '<tr width=100% valign=top'.($ecart>0?' style="background:white;"':'').'>'; echo '<td class=commentitems style="font-size:xx-small;">'; if ($ecart>0 && $periodchange) echo ("<b>...</b> "); echo '</td>'; echo '<td class=commentitems style="font-size:xx-small;">'; if ($last_display_periode!=$s['periode']) echo $speriode." "; if ($ecart>0 && $periodchange) echo "<br/><b> [".($direction=="succ"?"+":"-").($ecart+1)." sem.] </b>"; echo '</td>'; $sbox=selective_column_tt($arraykey,$s['termes'],$s['plus'],$s['minus']); $sid=$s['id']."_".str_replace(" ","_",$s['periode']); if ($direction=="succ") { if (intval($s['fils'])>0) $sarrow='↓ '; } else { if (intval($s['pere'])>0) $sarrow='↑ '; } echo '<td>'; $jscriptmp.=display_helper('(période '.get_string_periode(arrange_periode($s['periode'])).')','<div style="font-variant:small-caps;"><a href='.$shref.'>'.$sarrow.$stitle.'</a></div><br>'.$sbox,$sid,"magnify-wide.png","resizable: true"); echo '</td>'; echo ' <td class=tableitems style="font-variant:small-caps; size:small; font-style:italic;">'; echo ' <span onMouseOver="ShowContent(\'box'.$sid.'\'); ShowContent(\'title'.$sid.'\'); HideContent(\'mainbox\'); HideContent(\'maintitle\');" onMouseOut="HideContent(\'box'.$sid.'\'); HideContent(\'title'.$sid.'\'); ShowContent(\'mainbox\'); ShowContent(\'maintitle\');">'; echo '<a id="'.$sid.'" href="'.$shref.'">'; echo '<span style="font-style:normal;">'.$sarrow.'</span>'.$stitle; if ($lettre!="") echo ' ('.$lettre.')'; echo '</a>'; echo '</span>'; //echo '<a id="'.$sid.'" class="questionMark jTip jTip_element_'.$sid.'S jTip_width_300" name="Détails" href="'.$shref.'">'; //echo '<span id="'.$sid.'S" class="JT_hidden">'; //echo $sbox; //echo '</span>'; echo '</td>'; echo '</tr>'; echo '<tr style="height:4px;font-size:0pt;'.($ecart>0?' background:white;':'').'"><td> </td><td></td><td></td><td></td></tr>'; echo '</td>'; $last_display_periode=$s['periode']; }
fputs($gexfFile,'<attvalues> <attvalue for="0" value="Document"/>'."\n"); fputs($gexfFile,'<attvalue for="1" value="10"/>'."\n"); fputs($gexfFile,'<attvalue for="4" value="10"/>'."\n"); fputs($gexfFile,'</attvalues></node>'."\n"); } // liste des termes $conceptIds=array_keys($termsList); for ($j=0;$j<count($conceptIds);$j++) { $nodeId=$conceptIds[$j]; $nodesInfo=mysql_query("SELECT * FROM concepts WHERE id=".$nodeId); while ($ligne=mysql_fetch_array($nodesInfo)) { $nodeLabel=$ligne[forme_principale]; } fputs($gexfFile,'<node id="N::'.$nodeId.'" label="'.remove_popo($nodeLabel).'">'."\n"); fputs($gexfFile,'<viz:color b="0" g="0" r="255"/>'."\n"); fputs($gexfFile,'<viz:position x="'.rand(0,3).'" y="'.rand(0,3).'" z="0" />'."\n"); fputs($gexfFile,'<attvalues> <attvalue for="0" value="NGram"/>'."\n"); fputs($gexfFile,'<attvalue for="1" value="'.$termsList[$nodeId][occ].'"/>'."\n"); fputs($gexfFile,'<attvalue for="4" value="'.$termsList[$nodeId][occ].'"/>'."\n"); fputs($gexfFile,'</attvalues></node>'."\n"); } fputs($gexfFile,'</nodes><edges>'."\n"); $edgeid=1; // ecriture des liens de filiation for ($i=0;$i<count($fieldsList);$i++) { $nodeId1='D::'.str_replace(" ", "#", $fieldsList[$i][periode]).'_'.$fieldsList[$i][id]; echo $nodeId1.'<br/>';
foreach($listenew as $l) { $odd+=1; if ($odd%2==0) $bckclr=$backdark; else $bckclr=$backdarker; echo '<tr valign=top style="background-color:'.$bckclr.';">'; echo '<td>'; $label1=$l["label1"]; $label2=$l["label2"]; $lids=$l["ids"]; $lfirst=$lids[0]; if (count($lids)>1) $localhref="<a href=meta12.php?label1=".$label1."&label2=".$label2; else $localhref="<a href=cluster.php?id_cluster=".$lfirst["id"]; $localhref.="&periode=".arrange_periode($periode).">"; echo $localhref."<b>".remove_popo($dico_termes[$label1])."</b> - ".remove_popo($dico_termes[$label2]); if (count($lids)==1) { $arrows=arrow_make($lfirst); if ($lfirst["lettre"]!="") echo " (".$lfirst["lettre"].$arrows.")</a>"; else echo "</a>".$arrows; } else { echo "</a> ("; $lastid=end($lids);$lastid=$lastid["id"]; foreach ($lids as $lid) { $arrows=arrow_make($lid); echo "<a href=cluster.php?id_cluster=".$lid["id"]."&periode=".arrange_periode($periode).">".$lid["lettre"]."</a>".$arrows;
function get_concept_string($liste) { global $dico_termes; foreach ($liste as $i) { $liste_out[] = remove_popo($dico_termes[$i]); } return $liste_out; }
} $sql=$sql.' ) '; } $res = mysql_query($sql); while ($sql_liens=mysql_fetch_array($res)) { $aut1 = $sql_liens['auteur1']; $aut2 = $sql_liens['auteur2']; if ($aut1 ==$aut2) {} else {//$liens[$aut1]=$aut2; $liens_from[]=remove_popo($aut1); $liens_to[]=remove_popo($aut2); // echo 'lien de '.$legende[$aut1].' à '.$legende[$aut2].'<br>'; } } $tmpfile= ecrire_json($liste_auteur_unique,$legende,$aut_occ,$liens_from,$liens_to,$cluster_name,1);} ///////FIN DES CALCULS FICHIERS JSON DU RESEAU SOCIAL ECRIT // PORTION CONCERNANT L'AFFICHAGE EN FLEX DU RESEAU SOCIAL
create_concept_string(); while ($ligne=mysql_fetch_array($resultat)) { $evo = array(); $semaines = explode(',',$ligne['distances']); foreach ($semaines as $sem) //astuce à la con pour passer des jours à des semaines. {$evo[]=$sem;$evo[]=$sem;$evo[]=$sem;$evo[]=$sem;$evo[]=$sem;$evo[]=$sem;$evo[]=$sem; } //print_r($evo); $evo_texte = implode(',',$evo); //echo $evo_texte; //echo $liste_termes[$ligne['term2']]." ".$ligne['force_moy']." ".$ligne['direction']; //echo '<br>'; $json_data =$json_data.'"'.strval(remove_popo($liste_termes[$ligne['term2']])).'": { activity: ['.$evo_texte.'] },'; } $delcaract = substr($string,0,strlen($string)-1); $json_data=substr($json_data,0,strlen($json_data)-1).'};'; //version antérieure du script d'import avec importation des données depuis la table term_neighborhood // $resultat=mysql_query("select idx,js FROM term_neighborhood WHERE idx=$id_concept"); // $temp_neighborhood=mysql_fetch_array($resultat); // $myabove='<script type="text/javascript">'.$temp_neighborhood['js'].'</script>'.' $myabove='<script type="text/javascript">'.$json_data.'</script>'.' <hr> <table class=tableitems width="100%"> <tr valign=bottom> <td align="left"> ACTIVITÉ DES TERMES PROCHES </td><td align="right" style="font-variant:small-caps;"> <label for="query">rechercher: </label>
function group_list($branch_list, $depth, $min_similarity) { $min_similarity = 2; $depth = 2; // $branch_list est un array de labels composés de ngrammes séparés par des virgules /// retour un array contenant // ['grouped_indexes']: un array de groupes d'indices mentionnant les labels similaires // ['Ngram_arrays']: un array contenant pour chaque groupe d'indices, un array pour labelliser le groupe dont les clés sont des NGram pris jusqu'à une profondeur $depth et les valeurs leur nombre d'occurrences dans les labels // calcul des similarités entre labels de branches $label_rows_groups = array(); $label_groups = array(); $nb_labels_treated = 0; $label_rows_remaining_to_process = array(); // index des labels non encore catégorisés // initialisation de ce tableau for ($i = 0; $i < count($branch_list); $i++) { array_push($label_rows_remaining_to_process, $i); } while (count($label_rows_remaining_to_process) > 0) { $target_row = array_pop($label_rows_remaining_to_process); $target_label_raw = array(); // liste des rangs groupés avec target_row $target_labels = array(); // liste des labels des rangs associés array_push($target_labels, $branch_list[$target_row][label]); array_push($target_label_raw, $target_row); $label_rows_remaining_to_process_second_pass = $label_rows_remaining_to_process; while (count($label_rows_remaining_to_process_second_pass) > 0) { $candidate_row = array_pop($label_rows_remaining_to_process_second_pass); $candidate_label = remove_popo($branch_list[$candidate_row][label]); $exit_here = 0; $j = 0; while ($j < count($target_labels) && exit_here == 0) { $p = similarity($candidate_label, remove_popo($target_labels[$j])); // echo 'candidate labels'.$candidate_label.'<br/>'; // echo 'target labels'.$target_labels[$j].'<br/>'; // echo $p.'<br/>'; //similar_text ( $candidate_label,$target_labels[$j],$p ); if ($p > $min_similarity) { $exit_here = 1; // echo 'similarity: '.$p.'<br/>'; // echo 'candidate labels '.$candidate_label.'<br/>'; // echo 'target labels' .$target_labels[$j].'<br/><br/> '; } $j++; } if ($exit_here == 1) { //echo $branch_list[$candidate_row][label].'<br/>'; array_push($target_labels, $branch_list[$candidate_row][label]); array_push($target_label_raw, $candidate_row); $label_rows_remaining_to_process = array_diff($label_rows_remaining_to_process, $target_label_raw); array_push($target_branches, $candidate_branch); array_push($target_label_raw, $candidate_row); } } array_push($label_rows_groups, $target_label_raw); ///////////////// // on reconstruit l'array des labels_id de branche $target_branches_label_ids = array(); for ($i = 0; $i < count($target_labels); $i++) { array_push($target_branches_label_ids, $target_labels[$i]['label_ids']); } if (count($target_branches_label_ids) > 3) { array_push($label_groups, groups_labels($target_branches_label_ids, 4, $target_label_raw, $branch_list)); } else { array_push($label_groups, groups_labels($target_branches_label_ids, $depth, $target_label_raw, $branch_list)); } ///////////////// array_push($label_groups, label_label_group($target_labels, $depth)); $resultat = array(); } /// on réordonne par nombre de sujets groupés $groups_sizes = array(); for ($i = 0; $i < count($label_rows_groups); $i++) { array_push($groups_sizes, count($label_rows_groups[$i])); } uasort($groups_sizes, 'compare'); $new_order = array_keys($groups_sizes); // $label_rows_groups_temp = array(); for ($i = 0; $i < count($label_rows_groups); $i++) { array_push($label_rows_groups_temp, $label_rows_groups[$new_order[$i]]); } $label_rows_groups = $label_rows_groups_temp; // $label_groups_temp = array(); for ($i = 0; $i < count($label_groups); $i++) { array_push($label_groups_temp, $label_groups[$new_order[$i]]); } $label_groups = $label_groups_temp; // $resultat['grouped_indexes'] = $label_rows_groups; $resultat['Ngram_arrays'] = $label_groups; return $resultat; }