A tumblelog CMS built on AJAX, PHP and MySQL.

archive.php 12KB

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