A tumblelog CMS built on AJAX, PHP and MySQL.

gelato.class.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?
  2. /* ===========================
  3. gelato CMS development version
  4. http://www.gelatocms.com/
  5. gelato CMS is a free software licensed under GPL (General public license)
  6. =========================== */
  7. ?>
  8. <?
  9. require_once("configuration.class.php");
  10. require_once("functions.php");
  11. class gelato extends Conexion_Mysql {
  12. var $conf;
  13. function gelato() {
  14. parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
  15. $this->conf = new configuration();
  16. }
  17. function addPost($fieldsArray) {
  18. if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
  19. return true;
  20. } else {
  21. return false;
  22. }
  23. }
  24. function saveMP3($remoteFileName) {
  25. if (getMP3File($remoteFileName)) {
  26. return true;
  27. } else {
  28. return false;
  29. }
  30. }
  31. function savePhoto($remoteFileName) {
  32. if (getPhotoFile($remoteFileName)) {
  33. return true;
  34. } else {
  35. return false;
  36. }
  37. }
  38. function getPosts($limit="10", $from="0") {
  39. $sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
  40. $this->ejecutarConsulta($sqlStr);
  41. return $this->mid_consulta;
  42. }
  43. function getType($id) {
  44. if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
  45. if ($this->contarRegistros()>0) {
  46. while($registro = mysql_fetch_array($this->mid_consulta)) {
  47. return $registro[0];
  48. }
  49. }
  50. } else {
  51. return "0";
  52. }
  53. }
  54. function formatConversation($text) {
  55. $formatedText = "";
  56. $odd=true;
  57. $lines = explode("\n", $text);
  58. $formatedText .= "<ul>\n";
  59. foreach ($lines as $line) {
  60. $pos = strpos($line, ":") + 1;
  61. $label = substr($line, 0, $pos);
  62. $desc = substr($line, $pos, strlen($line));
  63. if ($odd) {
  64. $cssClass = "odd";
  65. } else {
  66. $cssClass = "even";
  67. }
  68. $odd=!$odd;
  69. $formatedText .= " <li class=\"".$cssClass."\">\n";
  70. $formatedText .= " <span class=\"label\">".$label."</span>\n";
  71. $formatedText .= " ".$desc."\n";
  72. $formatedText .= " </li>\n";
  73. }
  74. $formatedText .= "</ul>\n";
  75. return $formatedText;
  76. }
  77. function getVideoPlayer($url) {
  78. if (isYoutubeVideo($url)) {
  79. $id_video = getYoutubeVideoUrl($url);
  80. return "\t\t\t<div class=\"enlacevideo\"><object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object></div>\n";
  81. } elseif (isVimeoVideo($url)) {
  82. $id_video = getVimeoVideoUrl($url);
  83. return "\t\t\t<div class=\"enlacevideo\"><object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object></div>\n";
  84. } else {
  85. return "This URL is not a supported video (YouTube or Vimeo)";
  86. }
  87. }
  88. function getMp3Player($url) {
  89. if (isMP3($url)) {
  90. $playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
  91. return "\t\t\t<div class=\"enlacemp3\"><object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object></div>\n";
  92. } else {
  93. return "This URL is not a supported video (YouTube or Vimeo)";
  94. }
  95. }
  96. function getPostsNumber() {
  97. $this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
  98. $row = mysql_fetch_assoc($this->mid_consulta);
  99. return $row['total'];
  100. }
  101. }
  102. ?>