A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 7.4KB

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