A tumblelog CMS built on AJAX, PHP and MySQL.

archive.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. $dates = array();
  21. $rs = $tumble->getPosts($tumble->getPostsNumber());
  22. if ($db->contarRegistros()>0) {
  23. while($register = mysql_fetch_assoc($rs)) {
  24. $date = strtotime($register['date']);
  25. $year = date('Y',$date);
  26. $month = date('M',$date);
  27. $day = date('d',$date);
  28. $dates[$year][$month][$day] = true;
  29. $output = handleNode($register);
  30. $theType = util::type2Text($register["type"]);
  31. switch($theType) {
  32. case 'quote':
  33. $quote[] = $output;
  34. continue;
  35. case 'conversation':
  36. $conversation[] = $output;
  37. continue;
  38. case 'url':
  39. $link[] = $output;
  40. continue;
  41. case 'photo':
  42. $photo[] = $output;
  43. continue;
  44. case 'post':
  45. $regular[] = $output;
  46. continue;
  47. case 'video':
  48. $video[] = $output;
  49. continue;
  50. }
  51. }
  52. }
  53. function handleNode($node) {
  54. global $user, $tumble, $conf;
  55. $dateTmp = null;
  56. $formatedDate = gmdate("M d", strtotime($node["date"]) + util::transform_offset($conf->offsetTime));
  57. $output = array();
  58. $output['url'] = $tumble->getPermalink($node["id_post"]);
  59. $output['date'] = $formatedDate;
  60. $date = strtotime($node['date']);
  61. $year = date('Y',$date);
  62. $month = date('M',$date);
  63. $day = date('d',$date);
  64. $output['full_date'] = $day.' '.$month.' '.$year;
  65. $theType = util::type2Text($node["type"]);
  66. switch($theType) {
  67. case 'quote':
  68. $output['quote'] = $node["description"];
  69. $output['source'] = $node["title"];
  70. break;
  71. case 'conversation':
  72. $output['lines'] = $tumble->formatConversation($node["description"]);
  73. break;
  74. case 'url':
  75. $node["title"] = (empty($node["title"]))? $node["url"] : $node["title"];
  76. $output['text'] = $node["title"];
  77. $output['link'] = $node["url"];
  78. break;
  79. case 'photo':
  80. $fileName = "uploads/".util::getFileName($node["url"]);
  81. $x = @getimagesize($fileName);
  82. if ($x[0] > 500) {
  83. $photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$node["url"];
  84. } else {
  85. $photoPath = str_replace("../", $conf->urlGelato."/", $node["url"]);
  86. }
  87. $output['caption'] = $node["description"];
  88. $output['photo'] = $photoPath;
  89. break;
  90. case 'post':
  91. $output['title'] = $node["title"];
  92. $output['body'] = $node["description"];
  93. break;
  94. case 'video':
  95. $output['caption'] = $node["description"];
  96. $temp = $tumble->getVideoPlayer($node["url"]);
  97. $patterns[0] = "/width='[0-9]+'/";
  98. $patterns[1] = "/height='[0-9]+'/";
  99. $replace[0] = "width='100'";
  100. $replace[1] = "height='75'";
  101. $embed = preg_replace($patterns, $replace, $temp);
  102. $output['embed'] = $embed;
  103. }
  104. return $output;
  105. }
  106. ?>
  107. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  108. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  109. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  110. <head>
  111. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  112. <meta name="generator" content="gelato <?php echo util::codeName()." (".util::version().")"; ?>" />
  113. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  114. <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $conf->urlGelato.($conf->urlFriendly ? "/rss/" : "/rss.php"); ?>"/>
  115. <title><?php echo $conf->title." &raquo; ".__(" archive"); ?></title>
  116. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
  117. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.scrollTo-min.js"></script>
  118. <link href="<?php echo $conf->urlGelato;?>/admin/css/archive.css" type="text/css" rel="stylesheet">
  119. <script type='text/javascript'>
  120. function select(object) {
  121. var sel_id = object.id;
  122. $("a.option").removeClass('selected');
  123. $(object).addClass('selected');
  124. $("#conversation_content, #quote_content, #link_content, #regular_content, #photo_content, #video_content").slideUp("fast");
  125. $(".en, .es, .wn, .ws").remove();
  126. $("li.selected").removeClass('selected');
  127. $("#"+sel_id+"_content").show();
  128. $('#user_hover').hide();
  129. };
  130. $(function(){
  131. $("#timeline li").hover(function(){
  132. $(this).css('cursor','pointer');
  133. $("#bubble").hide();
  134. $(this).queue('fx',[]);
  135. $(this).animate({width:80},300, function(){
  136. $("#bubble").text($(this).find('span').text()).fadeIn('fast').css({top:this.offsetTop - 2});
  137. });
  138. },function(){
  139. $(this).css('cursor','auto');
  140. $(this).animate({width:$(this).attr("rel")},300,'linear');
  141. }).click(function(){
  142. $(".en, .es, .wn, .ws").remove();
  143. var date = $(this).text();
  144. $("#content > div:visible ul").find('li').removeClass('selected');
  145. $("#content > div:visible ul").find('li div[rel$='+date+']').parent().addClass('selected');
  146. wrap();
  147. if($('li.selected').length > 0){
  148. var elem = $("li.selected").get();
  149. $(window).scrollTo($("li.selected").eq(0).offset().top-50,900);
  150. }else{
  151. $("#bubble").text('Not found');
  152. }
  153. });
  154. $('#user_hover').hover(function(){},function(){ $(this).hide(); });
  155. $('.item').hover(function(e){
  156. var item = $(this);
  157. $('#user_hover').css({top:$(this).offset().top,left:$(this).offset().left}).show().unbind('click').click(function(){
  158. $(item).click();
  159. });
  160. $('#user_hover h3').text($(this).attr('rel'));
  161. },function(e){});
  162. });
  163. function wrap () {
  164. var elems = $("li.selected");
  165. var list = $("#content > div:visible ul.item_list > li");
  166. var cols = 4;
  167. var l = $(elems).length;
  168. $(elems).each(function(){
  169. index = $(list).index(this);
  170. if( (index+1) % cols == 0){
  171. $(this).append("<div class='crnr en'>&nbsp;</div>").append("<div class='crnr es'>&nbsp;</div>");
  172. }else if( (index) % cols == 0){
  173. $(this).append("<div class='crnr wn'>&nbsp;</div>").append("<div class='crnr ws'>&nbsp;</div>");
  174. }
  175. });
  176. $(elems).eq(0).append("<div class='crnr wn'>&nbsp;</div>").append("<div class='crnr ws'>&nbsp;</div>");
  177. $(elems).eq(l-1).append("<div class='crnr en'>&nbsp;</div>").append("<div class='crnr es'>&nbsp;</div>");
  178. }
  179. </script>
  180. </head>
  181. <body>
  182. <div id='dash'>
  183. <div id='options'>
  184. <ul id='option-list'>
  185. <li><a href='#' id='conversation' class='option selected' onclick="select(this);">Conversations</a></li>
  186. <li><a href='#' id='photo' class='option' onclick="select(this);">Photos</a></li>
  187. <li><a href='#' id='link' class='option' onclick="select(this);">Links</a></li>
  188. <li><a href='#' id='regular' class='option' onclick="select(this);">Posts</a></li>
  189. <li><a href='#' id='quote' class='option' onclick="select(this);">Quotes</a></li>
  190. <li><a href='#' id='video' class='option' onclick="select(this);">Videos</a></li>
  191. </ul>
  192. </div>
  193. <div id="timeline">
  194. <div id="timewrap">
  195. <div id="bubble"></div>
  196. <h4>TIMELINE</h4>
  197. <ul>
  198. <?php
  199. foreach ($dates as $year => $monthday) {
  200. echo '<li class="year" rel="60"><span>'.$year.'</span></li>';
  201. if(is_array($monthday) && count($monthday) > 0){
  202. foreach ($monthday as $month => $days) {
  203. echo '<li class="month" rel="40"><span>'.$month.' '.$year.'</span></li>';
  204. if(is_array($days) && count($days) > 0){
  205. foreach ($days as $day => $val) {
  206. echo '<li class="day" rel="20"><span>'.$day.' '.$month.' '.$year.'</span></li>';
  207. }
  208. }
  209. }
  210. }
  211. }
  212. ?>
  213. </ul>
  214. </div>
  215. </div>
  216. <div id='content'>
  217. <div id='msg' style="display:none;">&nbsp;</div>
  218. <div id='conversation_content'>
  219. <ul class='item_list'>
  220. <?php foreach($conversation as $item) { ?>
  221. <li>
  222. <div class='item' rel='<?php echo $item['full_date'] ?>' title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  223. <ul>
  224. <li><?php echo $item['lines']; ?></li>
  225. </ul>
  226. </div>
  227. </li>
  228. <?php } ?>
  229. </ul>
  230. </div>
  231. <div id='quote_content' style='display:none;'>
  232. <ul class='item_list'>
  233. <?php foreach($quote as $item) { ?>
  234. <li>
  235. <div class='item' rel='<?php echo $item['full_date'] ?>' title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  236. <ul>
  237. <li><em>"<?php echo substr($item['quote'], 0, 50), "..."; ?>"</em></li>
  238. <li>--<?php echo $item['source']; ?></li>
  239. </ul>
  240. </div>
  241. </li>
  242. <?php } ?>
  243. </ul>
  244. </div>
  245. <div id='link_content' style='display:none;'>
  246. <ul class='item_list'>
  247. <?php foreach($link as $item) { ?>
  248. <li>
  249. <div class='item link' rel='<?php echo $item['full_date'] ?>' title='<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>' onclick="location.href='<?php echo $item['url'] ?>';">
  250. <ul>
  251. <li><a href="<?php echo $item['link']; ?>" ><?php echo str_replace('.','.<br/>',$item['text']); ?></a></li>
  252. </ul>
  253. </div>
  254. </li>
  255. <?php } ?>
  256. </ul>
  257. </div>
  258. <div id='photo_content' style='display:none;'>
  259. <ul class='item_list'>
  260. <?php foreach($photo as $item) { ?>
  261. <?php
  262. /*
  263. echo "<pre>";
  264. print_r($item);
  265. echo "</pre>";
  266. */
  267. ?>
  268. <li>
  269. <div class='item' style="background-image:url('<?php echo $item['photo']; ?>')" rel='<?php echo $item['full_date'] ?>' title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';"></div>
  270. </li>
  271. <?php } ?>
  272. </ul>
  273. </div>
  274. <div id='regular_content' style='display:none;'>
  275. <ul class='item_list' rel='<?php echo $item['full_date'] ?>'>
  276. <?php foreach($regular as $item) { ?>
  277. <li>
  278. <div class="item" title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  279. <h4><?php echo $item['title']; ?></h4>
  280. <p><?php echo $item['body']; ?></p>
  281. </div>
  282. </li>
  283. <?php } ?>
  284. </ul>
  285. </div>
  286. <div id='video_content' style='display:none;'>
  287. <ul class='item_list' rel='<?php echo $item['full_date'] ?>'>
  288. <?php foreach($video as $item) { ?>
  289. <li>
  290. <div class='item' style='text-align:center;' title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  291. <?php echo $item['embed']; //$item['caption'] ?>
  292. </div>
  293. </li>
  294. <?php } ?>
  295. </ul>
  296. </div>
  297. <p style="clear:both">&nbsp;</p>
  298. </div>
  299. <br clear='both' />
  300. <div id='user_hover'><h3>&nbsp;</h3></div>
  301. </div>
  302. </body>
  303. </html>