/opac_css/classes/collection.class.php

https://github.com/fatjonakroni/pmb-albania · PHP · 161 lines · 108 code · 20 blank · 33 comment · 14 complexity · 2b68d36a34de1dae8b2733e3ae4a6323 MD5 · raw file

  1. <?php
  2. // +-------------------------------------------------+
  3. // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
  4. // +-------------------------------------------------+
  5. // $Id: collection.class.php,v 1.9 2010-11-02 16:20:29 ngantier Exp $
  6. // définition de la classe de gestion des collections
  7. // inclure :
  8. // classes/publisher.class.php
  9. if ( ! defined( 'COLLECTION_CLASS' ) ) {
  10. define( 'COLLECTION_CLASS', 1 );
  11. class collection {
  12. // ---------------------------------------------------------------
  13. // propriétés de la classe
  14. // ---------------------------------------------------------------
  15. // note : '//' signifie appartenant à la table concernée
  16. // '////' signifie deviné avec des requêtes sur d'autres tables
  17. var $id; // MySQL id in table 'collections'
  18. var $name; // collection name
  19. var $parent; // MySQL id of parent publisher
  20. var $publisher_libelle; //// name of parent publisher
  21. var $publisher_isbd; //// isbd form of publisher
  22. var $display; //// usable form for displaying ( _name_ (_publisher_) )
  23. var $isbd_entry; //// isbd form
  24. var $issn; // ISSN of collection
  25. var $collection_web; // web de collection
  26. var $collection_web_link; // lien web de collection
  27. var $comment;
  28. // ---------------------------------------------------------------
  29. // collection($id) : constructeur
  30. // ---------------------------------------------------------------
  31. function collection($id) {
  32. // on regarde si on a une collection-objet ou un id de collection
  33. if (is_object($id))
  34. $this->get_primaldatafrom($id);
  35. else {
  36. $this->id = $id;
  37. $this->get_primaldata();
  38. }
  39. $this->get_otherdata();
  40. }
  41. // ---------------------------------------------------------------
  42. // get_primaldata() : récupération infos collection à partir de l'id
  43. // ---------------------------------------------------------------
  44. function get_primaldata() {
  45. global $dbh;
  46. $requete = "SELECT * FROM collections WHERE collection_id=$this->id LIMIT 1 ";
  47. $result = @mysql_query($requete, $dbh);
  48. if(mysql_num_rows($result)) {
  49. $obj = mysql_fetch_object($result);
  50. mysql_free_result($result);
  51. $this->get_primaldatafrom($obj);
  52. } else {
  53. // pas de collection avec cette clé
  54. $this->id = 0;
  55. $this->name = '';
  56. $this->parent = '';
  57. $this->publisher_libelle = '';
  58. $this->publisher_isbd = '';
  59. $this->display = '';
  60. $this->issn = '';
  61. $this->isbd_entry = '';
  62. $this->collection_web = '';
  63. $this->collection_web_link = "" ;
  64. $this->comment = "" ;
  65. }
  66. }
  67. // ---------------------------------------------------------------
  68. // get_primaldatafrom($obj) : récupération infos collection à partir d'un collection-objet
  69. // ---------------------------------------------------------------
  70. function get_primaldatafrom($obj) {
  71. global $charset;
  72. $this->id = $obj->collection_id;
  73. $this->name = $obj->collection_name;
  74. $this->parent = $obj->collection_parent;
  75. $this->issn = $obj->collection_issn;
  76. $this->collection_web= $obj->collection_web;
  77. $this->comment= $obj->collection_comment;
  78. if($obj->collection_web)
  79. $this->collection_web_link = " <a href='$obj->collection_web' target=_blank title='".htmlentities($obj->collection_web,ENT_QUOTES,$charset)."' alt='".htmlentities($obj->collection_web,ENT_QUOTES,$charset)."' ><img src='./images/globe.gif' border=0 /></a>";
  80. else
  81. $this->collection_web_link = "" ;
  82. }
  83. // ---------------------------------------------------------------
  84. // get_otherdata() : calcul des données n'appartenant pas à la table
  85. // ---------------------------------------------------------------
  86. function get_otherdata() {
  87. $publisher = new publisher($this->parent);
  88. $this->publisher_isbd = $publisher->isbd_entry;
  89. $this->publisher_libelle = $publisher->name;
  90. $this->isbd_entry = $this->issn ? $this->name.', ISSN '.$this->issn : $this->name;
  91. $this->display = $this->name.' ('.$this->publisher_libelle.')';
  92. }
  93. // ---------------------------------------------------------------
  94. // print_resume($level) : affichage d'informations sur la collection
  95. // ---------------------------------------------------------------
  96. function print_resume($level = 2,$css) {
  97. global $css;
  98. global $msg;
  99. if(!$this->id)
  100. return;
  101. // adaptation par rapport au niveau de détail souhaité
  102. switch ($level) {
  103. // case x :
  104. case 2 :
  105. default :
  106. global $collection_level2_display;
  107. global $collection_level2_no_issn_info;
  108. $collection_display = $collection_level2_display;
  109. $collection_no_issn_info = $collection_level2_no_issn_info;
  110. break;
  111. }
  112. $print = $collection_display;
  113. // remplacement des champs statiques
  114. $print = str_replace("!!name!!", $this->name." ".$this->collection_web_link, $print);
  115. $print = str_replace("!!issn!!", $this->issn ? $this->issn : $collection_no_issn_info, $print);
  116. $print = str_replace("!!publ!!", $this->publisher_libelle, $print);
  117. $print = str_replace("!!publ_isbd!!", $this->publisher_isbd, $print);
  118. $print = str_replace("!!isbd!!", $this->isbd_entry, $print);
  119. $print = str_replace("!!comment!!", $this->comment, $print);
  120. // remplacement des champs dynamiques
  121. if (ereg("!!publisher!!", $print)) {
  122. $remplacement = "<a href='index.php?lvl=publisher_see&id=$this->parent'>$this->publisher_libelle</a>";
  123. $print = str_replace("!!publisher!!", $remplacement, $print);
  124. }
  125. if (ereg("!!subcolls!!", $print)) {
  126. global $dbh;
  127. $query = "select sub_coll_id, sub_coll_name from sub_collections where sub_coll_parent=".$this->id;
  128. $result = mysql_query($query, $dbh);
  129. if(mysql_num_rows($result)) {
  130. $remplacement = $msg["subcollection_attached"]."\n<ul>\n";
  131. while ($obj = mysql_fetch_object($result))
  132. $remplacement .= "<li><a href='index.php?lvl=subcoll_see&id=".$obj->sub_coll_id."'>".$obj->sub_coll_name."</a></li>\n";
  133. mysql_free_result($result);
  134. $remplacement .= "</ul>\n";
  135. } else $remplacement = "";
  136. $print = str_replace("!!subcolls!!", $remplacement, $print);
  137. }
  138. return $print;
  139. }
  140. } # fin de définition de la classe collection
  141. } # fin de délaration