/classe/caffiche_graphe.php

https://github.com/gmarchault/GmdGraphe · PHP · 232 lines · 117 code · 43 blank · 72 comment · 18 complexity · b477362cbf215da3f3440394511d7282 MD5 · raw file

  1. <?php
  2. class CAffiche_graphe
  3. {
  4. var $prefix;
  5. var $path_web;
  6. var $path_appli;
  7. function __construct()
  8. {
  9. global $DOCUMENT_ROOT, $PATH_WEB_RELATIF, $PREFIX_BDD;
  10. $this->prefix = $PREFIX_BDD;
  11. $this->path_appli = "$PATH_WEB_RELATIF/releve/graphe/bitmap";
  12. $this->path_web = "$DOCUMENT_ROOT$this->path_appli";
  13. }
  14. /**
  15. * Destructeur
  16. */
  17. function destruct()
  18. {
  19. return 0;
  20. }
  21. /**
  22. *
  23. * NON OPERATIONNEL !!!!!!!!!!!!!!!
  24. *
  25. * Recherche des graphes deja generes
  26. *
  27. * SORTIE :
  28. * $exist=0|1 : precise l'existance prealable ou non du fichier sur disk.
  29. * Si oui, positionne alors $this->nom_disk et $this->nom_web
  30. */
  31. function recherche_graphe( &$exist )
  32. {
  33. global $erreur, $cnx, $DOCUMENT_ROOT;
  34. $exist = 0;
  35. $t_f_exclure = array( ".", ".." );
  36. $t_info = array();
  37. $fichier_present = 0;
  38. // Formattage du nom en recherche d'image :
  39. $nom = "{$this->num_data}_{$this->type}_{$this->t_image['nbre']}_";
  40. //print "recherche de $nom...<br>";
  41. // Recherche si user possede une image
  42. if ( @is_dir($this->path_web) )
  43. {
  44. if ( $dh=@opendir($this->path_web) )
  45. {
  46. while ( ($filee=@readdir($dh))!==false )
  47. {
  48. if ( in_array($filee, $t_f_exclure ) ) continue;
  49. // Recherche de l'image
  50. if ( substr($filee, 0, strlen($nom))==$nom )
  51. {
  52. $fichier_present = 1;
  53. // Positionnement du nom_web a partir du nom_disk trouv�
  54. $this->set_nom_image( "$this->path_web/$filee" );
  55. // Recherche du texte car image trouvee
  56. // Formattage du nom du fichier texte en recherche d'image :
  57. $nom_txt = "$this->path_web/{$filee}.{$lang_d[0]}.txt.inc";
  58. if ( @is_file( $nom_txt ) )
  59. {
  60. $txt_image = implode( " ", @file( $nom_txt ));
  61. if ( $txt_image!="" ) $this->titre = stripslashes(strip_tags($txt_image));
  62. }
  63. break;
  64. }
  65. }
  66. @closedir($dh);
  67. }
  68. }
  69. @clearstatcache();
  70. $exist = $fichier_present;
  71. return 0;
  72. }
  73. /**
  74. *
  75. * NON OPERATIONNEL !!!!!!!!
  76. *
  77. * Suppression d'une illustration d'un num_data et nbre donn�
  78. *
  79. * REM :
  80. * $t_image::image_mode doit �tre a "maj"
  81. *
  82. * SORTIE :
  83. * $msg : message de suppression ok ou nok.
  84. * Retourne -1 si parametres image non existante
  85. * Retourne -2 si echec de suppression
  86. */
  87. function supprime( &$msg )
  88. {
  89. global $erreur, $cnx, $DOCUMENT_ROOT;
  90. // Suppression de l'image b
  91. $resultat = @unlink( $this->nom_disk );
  92. if ( $resultat==false ) { $msg.= "[$this->nom_disk]"; return -2; }
  93. // Suppression eventuelle de l'image s
  94. $nom_disk_s = eregi_replace( "_b_", "_s_", $this->nom_disk);
  95. $resultat = @unlink( $nom_disk_s );
  96. // REM : il faudrait supprimer toutes les langues !!!!!
  97. // A faire plus tard.
  98. $nom_txt = "{$this->nom_disk}.{$lang_d[0]}.txt.inc";
  99. $resultat = @unlink( $nom_txt );
  100. $this->titre = "";
  101. //$erreur->add_log( "cimage_annonce::supprime() : del de $this->nom_disk et $nom_disk_s et $nom_txt" );
  102. @clearstatcache();
  103. return 0;
  104. }
  105. /**
  106. * Suppression de toutes les illustrations d'un $module (sans prefix)
  107. * ex: electricite => rel_electricite_* ou velo_gm
  108. * --- OU ---
  109. * Suppression de tous les graphes du $this->prefix
  110. *
  111. * SORTIE :
  112. * Retourne le total de graphes supprimes
  113. */
  114. function purge_images( $module="" )
  115. {
  116. $t_f_exclure = array( ".", ".." );
  117. $total_del = 0;
  118. // Format de recherche des images a purger.
  119. $nom = $this->prefix.$module;
  120. // Recherche si user possede une image
  121. if ( @is_dir($this->path_web) )
  122. {
  123. if ( $dh=@opendir($this->path_web) )
  124. {
  125. while ( ($filee=@readdir($dh))!==false )
  126. {
  127. if ( in_array($filee, $t_f_exclure ) ) continue;
  128. //$res = substr($filee, 0, strlen($nom));
  129. //print "comparaison : [$filee]=[$res]=[$nom]<br>";
  130. if ( substr($filee, 0, strlen($nom))==$nom )
  131. {
  132. @unlink( "$this->path_web/$filee" );
  133. $total_del++;
  134. }
  135. }
  136. @closedir($dh);
  137. }
  138. }
  139. @clearstatcache();
  140. return $total_del;
  141. }
  142. /**
  143. * Recherche sur disk toutes les illustrations d'un $module (sans prefix)
  144. * ex: electricite => rel_electricite_* ou velo_gm
  145. * --- OU ---
  146. * Recherche sur disk de tous les graphes du $this->prefix
  147. *
  148. * ENTREE :
  149. * $t_module : tableau des modules recherches
  150. * REM : ne marche que pour le 1er actuellement !!!!!!!!
  151. *
  152. *
  153. * SORTIE :
  154. * Retourne les graphes trouves avec les cles : [nom], [nom_web], [nom_physique] en param de sortie
  155. * et le nombre de graphes trouves en sortie de fonction.
  156. */
  157. function recherche_disk( &$t_res, $t_module=array() )
  158. {
  159. $t_res = array();
  160. $t_f_exclure = array( ".", ".." );
  161. $total_found = 0;
  162. // Format de recherche des images a purger.
  163. $nom = $this->prefix.$t_module[0];
  164. //print "<br>recherche de $this->path_web/$nom<br>";
  165. // Recherche si user possede une image
  166. if ( @is_dir($this->path_web) )
  167. {
  168. if ( $dh=@opendir($this->path_web) )
  169. {
  170. while ( ($filee=@readdir($dh))!==false )
  171. {
  172. if ( in_array($filee, $t_f_exclure ) ) continue;
  173. //$res = substr($filee, 0, strlen($nom));
  174. //print "comparaison : [$filee]=[$res]=[$nom]<br>";
  175. if ( substr($filee, 0, strlen($nom))==$nom )
  176. {
  177. $t_res['nom'][$total_found] = $filee;
  178. $t_res['nom_physique'][$total_found] = "$this->path_web/$filee";
  179. $t_res['nom_web'][$total_found] = "$this->path_appli/$filee";
  180. $total_found++;
  181. }
  182. }
  183. @closedir($dh);
  184. }
  185. }
  186. @clearstatcache();
  187. return $total_found;
  188. }
  189. }