Social.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["helper"] . "text.php");
  4. /**
  5. * Social, contains a button to a social network.
  6. *
  7. * Represents an object from the table 'social'.
  8. */
  9. class Social extends Entity{
  10. /**
  11. * Identifier.
  12. */
  13. public $id;
  14. /**
  15. * Indicates the order position among other social buttons.
  16. */
  17. public $idx;
  18. /**
  19. * Indicates wether the object must or mustn's be displayed.
  20. */
  21. public $visible;
  22. /**
  23. * Name of the social network.
  24. */
  25. public $title;
  26. /**
  27. * Icon of the social network.
  28. */
  29. public $icon;
  30. /**
  31. * URL to the profile in the social network.
  32. */
  33. public $url;
  34. /**
  35. * Constructor.
  36. *
  37. * Searches the database and retrieves the information about the
  38. * object, populating it.
  39. *
  40. * @param MySQL_connection $db Connection to the database.
  41. * @param string $lang Lowercase, two-letter language code.
  42. * @param int $id Database identifier of the social network.
  43. */
  44. public function __construct($db, $lang, $id){
  45. parent::__construct($db, $lang);
  46. $s =
  47. "SELECT " .
  48. " id, " .
  49. " idx, " .
  50. " visible, " .
  51. " title, " .
  52. " icon, " .
  53. " url " .
  54. "FROM social " .
  55. "WHERE " .
  56. " id = $id; ";
  57. $q = mysqli_query($this->db, $s);
  58. if (mysqli_num_rows($q) > 0){
  59. $r = mysqli_fetch_array($q);
  60. $this->id = $r["id"];
  61. $this->idx = $r["idx"];
  62. $this->visible = $r["visible"];
  63. $this->title = text($this, $r["title"]);
  64. $this->icon = $r["icon"];
  65. $this->url = $r["url"];
  66. }
  67. }
  68. }
  69. ?>