A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. // My approach to MVC
  10. require(dirname(__FILE__)."/config.php");
  11. include("classes/configuration.class.php");
  12. include("classes/gelato.class.php");
  13. include("classes/templates.class.php");
  14. include("classes/pagination.php");
  15. $conf = new configuration();
  16. $tumble = new gelato();
  17. $template = new plantillas($conf->template);
  18. $param_url = explode("/",$_SERVER['PATH_INFO']);
  19. if (isset($_GET["post"])) {
  20. $id_post = $_GET["post"];
  21. } else {
  22. if (isset($param_url[1]) && $param_url[1]=="post") {
  23. $id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
  24. } else {
  25. $id_post = NULL;
  26. }
  27. }
  28. if (isset($_GET["page"])) {
  29. $page_num = $_GET["page"];
  30. } else {
  31. if (isset($param_url[1]) && $param_url[1]=="page") {
  32. $page_num = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
  33. } else {
  34. $page_num = NULL;
  35. }
  36. }
  37. $input = array("{Title}", "{Description}", "{URL_Tumble}");
  38. $output = array($conf->title, $conf->description, $conf->urlGelato);
  39. $template->cargarPlantilla($input, $output, "template_header");
  40. $template->mostrarPlantilla();
  41. if (!$id_post) {
  42. $limit=$conf->postLimit;
  43. if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric?
  44. $from = (($page_num-1) * $limit);
  45. } else {
  46. $from = 0;
  47. }
  48. $rs = $tumble->getPosts($limit, $from);
  49. if ($tumble->contarRegistros()>0) {
  50. while($register = mysql_fetch_array($rs)) {
  51. $formatedDate = date("M d", strtotime($register["date"]));
  52. $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  53. switch ($tumble->getType($register["id_post"])) {
  54. case "1":
  55. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
  56. $output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
  57. $template->cargarPlantilla($input, $output, "template_regular_post");
  58. $template->mostrarPlantilla();
  59. break;
  60. case "2":
  61. $input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{URL_Tumble}");
  62. $output = array($formatedDate, $permalink, $register["url"], "", $register["description"], $conf->urlGelato);
  63. $template->cargarPlantilla($input, $output, "template_photo");
  64. $template->mostrarPlantilla();
  65. break;
  66. case "3":
  67. $input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
  68. $output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
  69. $template->cargarPlantilla($input, $output, "template_quote");
  70. $template->mostrarPlantilla();
  71. break;
  72. case "4":
  73. $input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
  74. $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
  75. $template->cargarPlantilla($input, $output, "template_url");
  76. $template->mostrarPlantilla();
  77. break;
  78. case "5":
  79. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
  80. $output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
  81. $template->cargarPlantilla($input, $output, "template_conversation");
  82. $template->mostrarPlantilla();
  83. break;
  84. case "6":
  85. $input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
  86. $output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
  87. $template->cargarPlantilla($input, $output, "template_video");
  88. $template->mostrarPlantilla();
  89. break;
  90. case "7":
  91. $input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
  92. $output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
  93. $template->cargarPlantilla($input, $output, "template_mp3");
  94. $template->mostrarPlantilla();
  95. break;
  96. }
  97. }
  98. echo pagination($tumble->getPostsNumber(), $limit, isset($page_num) ? $page_num : 1, array($conf->urlGelato."/index.php/page/[...]/","[...]"), 2);
  99. } else {
  100. $template->renderizaEtiqueta("No posts in this tumblelog.", "div","error");
  101. }
  102. } else {
  103. $register = $tumble->getPost($id_post);
  104. $formatedDate = date("M d", strtotime($register["date"]));
  105. $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  106. switch ($tumble->getType($register["id_post"])) {
  107. case "1":
  108. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
  109. $output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
  110. $template->cargarPlantilla($input, $output, "template_regular_post");
  111. $template->mostrarPlantilla();
  112. break;
  113. case "2":
  114. $input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{URL_Tumble}");
  115. $output = array($formatedDate, $permalink, $register["url"], "", $register["description"], $conf->urlGelato);
  116. $template->cargarPlantilla($input, $output, "template_photo");
  117. $template->mostrarPlantilla();
  118. break;
  119. case "3":
  120. $input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
  121. $output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
  122. $template->cargarPlantilla($input, $output, "template_quote");
  123. $template->mostrarPlantilla();
  124. break;
  125. case "4":
  126. $input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
  127. $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
  128. $template->cargarPlantilla($input, $output, "template_url");
  129. $template->mostrarPlantilla();
  130. break;
  131. case "5":
  132. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
  133. $output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
  134. $template->cargarPlantilla($input, $output, "template_conversation");
  135. $template->mostrarPlantilla();
  136. break;
  137. case "6":
  138. $input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
  139. $output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
  140. $template->cargarPlantilla($input, $output, "template_video");
  141. $template->mostrarPlantilla();
  142. break;
  143. case "7":
  144. $input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
  145. $output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
  146. $template->cargarPlantilla($input, $output, "template_mp3");
  147. $template->mostrarPlantilla();
  148. break;
  149. }
  150. }
  151. $input = array("{URL_Tumble}");
  152. $output = array($conf->urlGelato);
  153. $template->cargarPlantilla($input, $output, "template_footer");
  154. $template->mostrarPlantilla();
  155. ?>