A tumblelog CMS built on AJAX, PHP and MySQL.

archive.php 13KB

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