A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 8.0KB

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