A tumblelog CMS built on AJAX, PHP and MySQL.

archive.php 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <?php
  2. if(!defined('entry'))define('entry', true);
  3. /* ===========================
  4. gelato CMS - A PHP based tumblelog CMS
  5. development version
  6. http://www.gelatocms.com/
  7. gelato CMS is a free software licensed under the GPL 2.0
  8. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  9. =========================== */
  10. ?>
  11. <?php
  12. require('entry.php');
  13. global $user, $tumble, $conf;
  14. $quote = array();
  15. $conversation = array();
  16. $link = array();
  17. $photo = array();
  18. $regular = array();
  19. $video = array();
  20. $rs = $tumble->getPosts($tumble->getPostsNumber());
  21. if ($db->contarRegistros()>0) {
  22. while($register = mysql_fetch_assoc($rs)) {
  23. $output = handleNode($register);
  24. $theType = util::type2Text($register["type"]);
  25. switch($theType) {
  26. case 'quote':
  27. $quote[] = $output;
  28. continue;
  29. case 'conversation':
  30. $conversation[] = $output;
  31. continue;
  32. case 'url':
  33. $link[] = $output;
  34. continue;
  35. case 'photo':
  36. $photo[] = $output;
  37. continue;
  38. case 'post':
  39. $regular[] = $output;
  40. continue;
  41. case 'video':
  42. $video[] = $output;
  43. continue;
  44. }
  45. }
  46. }
  47. function handleNode($node) {
  48. global $user, $tumble, $conf;
  49. $dateTmp = null;
  50. $formatedDate = gmdate("M d", strtotime($node["date"]) + util::transform_offset($conf->offsetTime));
  51. $output = array();
  52. $output['url'] = $tumble->getPermalink($node["id_post"]);
  53. $output['date'] = $formatedDate;
  54. $theType = util::type2Text($node["type"]);
  55. switch($theType) {
  56. case 'quote':
  57. $output['quote'] = $node["description"];
  58. $output['source'] = $node["title"];
  59. break;
  60. case 'conversation':
  61. $output['lines'] = $tumble->formatConversation($node["description"]);
  62. break;
  63. case 'url':
  64. $node["title"] = (empty($node["title"]))? $node["url"] : $node["title"];
  65. $output['text'] = $node["title"];
  66. $output['link'] = $node["url"];
  67. break;
  68. case 'photo':
  69. $fileName = "uploads/".getFileName($node["url"]);
  70. $x = @getimagesize($fileName);
  71. if ($x[0] > 500) {
  72. $photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$node["url"];
  73. } else {
  74. $photoPath = str_replace("../", $conf->urlGelato."/", $node["url"]);
  75. }
  76. $output['caption'] = $node["description"];
  77. $output['photo'] = $photoPath;
  78. break;
  79. case 'post':
  80. $output['title'] = $node["title"];
  81. $output['body'] = $node["description"];
  82. break;
  83. case 'video':
  84. $output['caption'] = $node["description"];
  85. $temp = $tumble->getVideoPlayer($node["url"]);
  86. $patterns[0] = "/width='[0-9]+'/";
  87. $patterns[1] = "/height='[0-9]+'/";
  88. $replace[0] = "width='100'";
  89. $replace[1] = "height='75'";
  90. $embed = preg_replace($patterns, $replace, $temp);
  91. $output['embed'] = $embed;
  92. }
  93. return $output;
  94. }
  95. ?>
  96. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  97. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  98. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  99. <head>
  100. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  101. <meta name="generator" content="gelato <?php echo util::codeName()." (".util::version().")"; ?>" />
  102. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  103. <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $conf->urlGelato.($conf->urlFriendly ? "/rss/" : "/rss.php"); ?>"/>
  104. <title><?php echo $conf->title." &raquo; ".__(" archive"); ?></title>
  105. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
  106. <link href="<?php echo $conf->urlGelato;?>/admin/css/archive.css" type="text/css" rel="stylesheet">
  107. <script type='text/javascript'>
  108. function select(object) {
  109. var sel_id = object.id;
  110. $("a.option").removeClass('selected');
  111. $(object).addClass('selected');
  112. $("#conversation_content, #quote_content, #link_content, #regular_content, #photo_content, #video_content").hide("slow");
  113. $("#"+sel_id+"_content").show("slow");
  114. };
  115. </script>
  116. </head>
  117. <body>
  118. <div id='dash'>
  119. <div id='options'>
  120. <ul id='option-list'>
  121. <li><a href='#' id='conversation' class='option selected' onclick="select(this);">Conversations</a></li>
  122. <li><a href='#' id='photo' class='option' onclick="select(this);">Photos</a></li>
  123. <li><a href='#' id='link' class='option' onclick="select(this);">Links</a></li>
  124. <li><a href='#' id='regular' class='option' onclick="select(this);">Posts</a></li>
  125. <li><a href='#' id='quote' class='option' onclick="select(this);">Quotes</a></li>
  126. <li><a href='#' id='video' class='option' onclick="select(this);">Videos</a></li>
  127. </ul>
  128. </div>
  129. <div id='content'>
  130. <div id='conversation_content'>
  131. <?php foreach($conversation as $item) { ?>
  132. <ul class='item_list'>
  133. <li>
  134. <div class='item'>
  135. <ul>
  136. <li><?php echo $item['lines']; ?></li>
  137. </ul>
  138. </div>
  139. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  140. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  141. </div>
  142. </li>
  143. </ul>
  144. <?php } ?>
  145. </div>
  146. <div id='quote_content' style='display:none;'>
  147. <?php foreach($quote as $item) { ?>
  148. <ul class='item_list'>
  149. <li>
  150. <div class='item'>
  151. <ul>
  152. <li><em>"<?php echo substr($item['quote'], 0, 50), "..."; ?>"</em></li>
  153. <li>--<?php echo $item['source']; ?></li>
  154. </ul>
  155. </div>
  156. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  157. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  158. </div>
  159. </li>
  160. </ul>
  161. <?php } ?>
  162. </div>
  163. <div id='link_content' style='display:none;'>
  164. <?php foreach($link as $item) { ?>
  165. <ul class='item_list'>
  166. <li>
  167. <div class='item link'>
  168. <ul>
  169. <li><a href="<?php echo $item['link']; ?>"><?php echo $item['text']; ?></a></li>
  170. </ul>
  171. </div>
  172. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  173. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  174. </div>
  175. </li>
  176. </ul>
  177. <?php } ?>
  178. </div>
  179. <div id='photo_content' style='display:none;'>
  180. <?php foreach($photo as $item) { ?>
  181. <ul class='item_list'>
  182. <li>
  183. <div class='item' style="background-image:url('<?php echo $item['photo']; ?>')"></div>
  184. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  185. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  186. </div>
  187. </li>
  188. </ul>
  189. <?php } ?>
  190. </div>
  191. <div id='regular_content' style='display:none;'>
  192. <?php foreach($regular as $item) { ?>
  193. <ul class='item_list'>
  194. <li>
  195. <div class='item'>
  196. <h4><?php echo $item['title']; ?></h4>
  197. <p><?php echo $item['body']; ?></p>
  198. </div>
  199. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  200. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  201. </div>
  202. </li>
  203. </ul>
  204. <?php } ?>
  205. </div>
  206. <div id='video_content' style='display:none;'>
  207. <?php foreach($video as $item) { ?>
  208. <ul class='item_list'>
  209. <li>
  210. <div class='item' style='text-align:center;'>
  211. <?php echo $item['embed']; //$item['caption'] ?>
  212. </div>
  213. <div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
  214. <h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
  215. </div>
  216. </li>
  217. </ul>
  218. <?php } ?>
  219. </div>
  220. </div>
  221. <br clear='both' />
  222. </div>
  223. </body>
  224. </html>