A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. $id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : null) : null;
  23. }
  24. $input = array("{Title}", "{Description}", "{URL_Tumble}");
  25. $output = array($conf->title, $conf->description, $conf->urlGelato);
  26. $template->cargarPlantilla($input, $output, "template_header");
  27. $template->mostrarPlantilla();
  28. if (!$id_post) {
  29. $limit=$conf->postLimit;
  30. if(isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page']>0) { // Is defined the page and is numeric?
  31. $from = (($_GET['page']-1) * $limit);
  32. } else {
  33. $from = 0;
  34. }
  35. $rs = $tumble->getPosts($limit, $from);
  36. if ($tumble->contarRegistros()>0) {
  37. while($register = mysql_fetch_array($rs)) {
  38. $formatedDate = date("M d", strtotime($register["date"]));
  39. $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  40. switch ($tumble->getType($register["id_post"])) {
  41. case "1":
  42. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
  43. $output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
  44. $template->cargarPlantilla($input, $output, "template_regular_post");
  45. $template->mostrarPlantilla();
  46. break;
  47. case "2":
  48. $input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{URL_Tumble}");
  49. $output = array($formatedDate, $permalink, $register["url"], "", $register["description"], $conf->urlGelato);
  50. $template->cargarPlantilla($input, $output, "template_photo");
  51. $template->mostrarPlantilla();
  52. break;
  53. case "3":
  54. $input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
  55. $output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
  56. $template->cargarPlantilla($input, $output, "template_quote");
  57. $template->mostrarPlantilla();
  58. break;
  59. case "4":
  60. $input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
  61. $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
  62. $template->cargarPlantilla($input, $output, "template_url");
  63. $template->mostrarPlantilla();
  64. break;
  65. case "5":
  66. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
  67. $output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
  68. $template->cargarPlantilla($input, $output, "template_conversation");
  69. $template->mostrarPlantilla();
  70. break;
  71. case "6":
  72. $input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
  73. $output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
  74. $template->cargarPlantilla($input, $output, "template_video");
  75. $template->mostrarPlantilla();
  76. break;
  77. case "7":
  78. $input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
  79. $output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
  80. $template->cargarPlantilla($input, $output, "template_mp3");
  81. $template->mostrarPlantilla();
  82. break;
  83. }
  84. }
  85. echo pagination($tumble->getPostsNumber(), $limit, isset($_GET['page']) ? $_GET['page'] : 1, "index.php", 2); // Shows the pagination
  86. } else {
  87. $template->renderizaEtiqueta("No posts in this tumblelog.", "div","error");
  88. }
  89. } else {
  90. /*
  91. $row = $tumble->obtenerArticulo($id_post);
  92. */
  93. }
  94. $input = array("{URL_Tumble}");
  95. $output = array($conf->urlGelato);
  96. $template->cargarPlantilla($input, $output, "template_footer");
  97. $template->mostrarPlantilla();
  98. ?>