A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 4.6KB

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. $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
  39. switch ($tumble->getType($register["id_post"])) {
  40. case "1":
  41. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
  42. $output = array($register["date"], $permalink, $register["title"], $register["description"], $conf->urlGelato);
  43. $template->cargarPlantilla($input, $output, "template_regular_post");
  44. $template->mostrarPlantilla();
  45. break;
  46. case "2":
  47. $input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{URL_Tumble}");
  48. $output = array($register["date"], $permalink, $register["url"], "", $register["description"], $conf->urlGelato);
  49. $template->cargarPlantilla($input, $output, "template_photo");
  50. $template->mostrarPlantilla();
  51. break;
  52. case "3":
  53. $input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
  54. $output = array($register["date"], $permalink, $register["description"], $register["title"], $conf->urlGelato);
  55. $template->cargarPlantilla($input, $output, "template_quote");
  56. $template->mostrarPlantilla();
  57. break;
  58. case "4":
  59. $input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
  60. $output = array($register["date"], $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
  61. $template->cargarPlantilla($input, $output, "template_url");
  62. $template->mostrarPlantilla();
  63. break;
  64. case "5":
  65. $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
  66. $output = array($register["date"], $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
  67. $template->cargarPlantilla($input, $output, "template_conversation");
  68. $template->mostrarPlantilla();
  69. break;
  70. case "6":
  71. $input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
  72. $output = array($register["date"], $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
  73. $template->cargarPlantilla($input, $output, "template_video");
  74. $template->mostrarPlantilla();
  75. break;
  76. case "7":
  77. $input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
  78. $output = array($register["date"], $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
  79. $template->cargarPlantilla($input, $output, "template_mp3");
  80. $template->mostrarPlantilla();
  81. break;
  82. }
  83. }
  84. echo pagination($tumble->getPostsNumber(), $limit, isset($_GET['page']) ? $_GET['page'] : 1, "index.php", 2); // Shows the pagination
  85. } else {
  86. $template->renderizaEtiqueta("No posts in this tumblelog.", "div","error");
  87. }
  88. } else {
  89. /*
  90. $row = $tumble->obtenerArticulo($id_post);
  91. */
  92. }
  93. $input = array("{URL_Tumble}");
  94. $output = array($conf->urlGelato);
  95. $template->cargarPlantilla($input, $output, "template_footer");
  96. $template->mostrarPlantilla();
  97. ?>