A tumblelog CMS built on AJAX, PHP and MySQL.

archive.php 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  110. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  111. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  112. <head>
  113. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  114. <meta name="generator" content="sorbet <?php echo $util_class->codeName()." (".$util_class->version().")"; ?>" />
  115. <link rel="shortcut icon" href="<?php echo $conf->urlSorbet;?>/images/favicon.ico" />
  116. <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $conf->urlSorbet.($conf->urlFriendly ? "/rss/" : "/rss.php"); ?>"/>
  117. <title><?php echo $conf->title." &raquo; ".__(" archive"); ?></title>
  118. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet;?>/admin/scripts/jquery.js"></script>
  119. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet;?>/admin/scripts/jquery.scrollTo-min.js"></script>
  120. <link href="<?php echo $conf->urlSorbet;?>/admin/css/archive.css" type="text/css" rel="stylesheet">
  121. <script type='text/javascript'>
  122. function select(object) {
  123. var sel_id = object.id;
  124. $("a.option").removeClass('selected');
  125. $(object).addClass('selected');
  126. $("#conversation_content, #quote_content, #link_content, #regular_content, #photo_content, #video_content").slideUp("fast");
  127. $(".en, .es, .wn, .ws").remove();
  128. $("li.selected").removeClass('selected');
  129. $("#"+sel_id+"_content").show();
  130. $('#user_hover').hide();
  131. };
  132. $(function(){
  133. $("#timeline li").hover(function(){
  134. $(this).css('cursor','pointer');
  135. $("#bubble").hide();
  136. $(this).queue('fx',[]);
  137. $(this).animate({width:80},300, function(){
  138. $("#bubble").text($(this).find('span').text()).fadeIn('fast').css({top:this.offsetTop - 2});
  139. });
  140. },function(){
  141. $(this).css('cursor','auto');
  142. $(this).animate({width:$(this).attr("rel")},300,'linear');
  143. }).click(function(){
  144. $(".en, .es, .wn, .ws").remove();
  145. var date = $(this).text();
  146. $("#content > div:visible ul").find('li').removeClass('selected');
  147. $("#content > div:visible ul").find('li div[rel$='+date+']').parent().addClass('selected');
  148. wrap();
  149. if($('li.selected').length > 0){
  150. var elem = $("li.selected").get();
  151. $(window).scrollTo($("li.selected").eq(0).offset().top-50,900);
  152. }else{
  153. $("#bubble").text('Not found');
  154. }
  155. });
  156. $('#user_hover').hover(function(){},function(){ $(this).hide(); });
  157. $('.item').hover(function(e){
  158. var item = $(this);
  159. $('#user_hover').css({top:$(this).offset().top,left:$(this).offset().left}).show().unbind('click').click(function(){
  160. $(item).click();
  161. });
  162. $('#user_hover h3').text($(this).attr('rel'));
  163. },function(e){});
  164. });
  165. function wrap () {
  166. var elems = $("li.selected");
  167. var list = $("#content > div:visible ul.item_list > li");
  168. var cols = 4;
  169. var l = $(elems).length;
  170. $(elems).each(function(){
  171. index = $(list).index(this);
  172. if( (index+1) % cols == 0){
  173. $(this).append("<div class='crnr en'>&nbsp;</div>").append("<div class='crnr es'>&nbsp;</div>");
  174. }else if( (index) % cols == 0){
  175. $(this).append("<div class='crnr wn'>&nbsp;</div>").append("<div class='crnr ws'>&nbsp;</div>");
  176. }
  177. });
  178. $(elems).eq(0).append("<div class='crnr wn'>&nbsp;</div>").append("<div class='crnr ws'>&nbsp;</div>");
  179. $(elems).eq(l-1).append("<div class='crnr en'>&nbsp;</div>").append("<div class='crnr es'>&nbsp;</div>");
  180. }
  181. </script>
  182. </head>
  183. <body>
  184. <div id='dash'>
  185. <div id='options'>
  186. <ul id='option-list'>
  187. <li><a href='#' id='conversation' class='option selected' onclick="select(this);">Conversations</a></li>
  188. <li><a href='#' id='photo' class='option' onclick="select(this);">Photos</a></li>
  189. <li><a href='#' id='link' class='option' onclick="select(this);">Links</a></li>
  190. <li><a href='#' id='regular' class='option' onclick="select(this);">Posts</a></li>
  191. <li><a href='#' id='quote' class='option' onclick="select(this);">Quotes</a></li>
  192. <li><a href='#' id='video' class='option' onclick="select(this);">Videos</a></li>
  193. </ul>
  194. </div>
  195. <div id="timeline">
  196. <div id="timewrap">
  197. <div id="bubble"></div>
  198. <h4>TIMELINE</h4>
  199. <ul>
  200. <?php
  201. foreach ($dates as $year => $monthday) {
  202. echo '<li class="year" rel="60"><span>'.$year.'</span></li>';
  203. if (is_array($monthday) && count($monthday) > 0) {
  204. foreach ($monthday as $month => $days) {
  205. echo '<li class="month" rel="40"><span>'.$month.' '.$year.'</span></li>';
  206. if (is_array($days) && count($days) > 0) {
  207. foreach ($days as $day => $val) {
  208. echo '<li class="day" rel="20"><span>'.$day.' '.$month.' '.$year.'</span></li>';
  209. }
  210. }
  211. }
  212. }
  213. }
  214. ?>
  215. </ul>
  216. </div>
  217. </div>
  218. <div id='content'>
  219. <div id='msg' style="display:none;">&nbsp;</div>
  220. <div id='conversation_content'>
  221. <ul class='item_list'>
  222. <?php foreach ($conversation as $item) {
  223. ?>
  224. <li>
  225. <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'] ?>';">
  226. <ul>
  227. <li><?php echo $item['lines']; ?></li>
  228. </ul>
  229. </div>
  230. </li>
  231. <?php
  232. } ?>
  233. </ul>
  234. </div>
  235. <div id='quote_content' style='display:none;'>
  236. <ul class='item_list'>
  237. <?php foreach ($quote as $item) {
  238. ?>
  239. <li>
  240. <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'] ?>';">
  241. <ul>
  242. <li><em>"<?php echo substr($item['quote'], 0, 50), "..."; ?>"</em></li>
  243. <li>--<?php echo $item['source']; ?></li>
  244. </ul>
  245. </div>
  246. </li>
  247. <?php
  248. } ?>
  249. </ul>
  250. </div>
  251. <div id='link_content' style='display:none;'>
  252. <ul class='item_list'>
  253. <?php foreach ($link as $item) {
  254. ?>
  255. <li>
  256. <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'] ?>';">
  257. <ul>
  258. <li><a href="<?php echo $item['link']; ?>" ><?php echo str_replace('.', '.<br/>', $item['text']); ?></a></li>
  259. </ul>
  260. </div>
  261. </li>
  262. <?php
  263. } ?>
  264. </ul>
  265. </div>
  266. <div id='photo_content' style='display:none;'>
  267. <ul class='item_list'>
  268. <?php foreach ($photo as $item) {
  269. ?>
  270. <?php
  271. /*
  272. echo "<pre>";
  273. print_r($item);
  274. echo "</pre>";
  275. */
  276. ?>
  277. <li>
  278. <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>
  279. </li>
  280. <?php
  281. } ?>
  282. </ul>
  283. </div>
  284. <div id='regular_content' style='display:none;'>
  285. <ul class='item_list' rel='<?php echo $item['full_date'] ?>'>
  286. <?php foreach ($regular as $item) {
  287. ?>
  288. <li>
  289. <div class="item" title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  290. <h4><?php echo $item['title']; ?></h4>
  291. <p><?php echo $item['body']; ?></p>
  292. </div>
  293. </li>
  294. <?php
  295. } ?>
  296. </ul>
  297. </div>
  298. <div id='video_content' style='display:none;'>
  299. <ul class='item_list' rel='<?php echo $item['full_date'] ?>'>
  300. <?php foreach ($video as $item) {
  301. ?>
  302. <li>
  303. <div class='item' style='text-align:center;' title="<?php echo strftime("%b %d, %G", strtotime($item['date'])); ?>" onclick="location.href='<?php echo $item['url'] ?>';">
  304. <?php echo $item['embed']; //$item['caption']?>
  305. </div>
  306. </li>
  307. <?php
  308. } ?>
  309. </ul>
  310. </div>
  311. <p style="clear:both">&nbsp;</p>
  312. </div>
  313. <br clear='both' />
  314. <div id='user_hover'><h3>&nbsp;</h3></div>
  315. </div>
  316. </body>
  317. </html>