/application/views/post/post.php

https://github.com/lysender/ff2fb · PHP · 144 lines · 126 code · 7 blank · 11 comment · 12 complexity · f92fe0a619098ba0586a85329a2a3392 MD5 · raw file

  1. <!-- wrapper needed -->
  2. <?php
  3. $feed_content = null;
  4. $title = null;
  5. if (is_array($feed))
  6. {
  7. $feed_content = unserialize($feed['content_serialized']);
  8. $title = Model_Feed::generate_title($feed_content['body'], $feed['id']);
  9. }
  10. else
  11. {
  12. $feed_content = unserialize($feed->content_serialized);
  13. $title = Model_Feed::generate_title($feed_content['body'], $feed->id);
  14. }
  15. $ts = strtotime($feed_content['date']);
  16. $span = Dc_Date::fuzzy_span($ts);
  17. ?>
  18. <div class="profile">
  19. <a href="http://friendfeed.com/<?php echo $feed_content['from']['id'] ?>">
  20. <img src="http://friendfeed-api.com/v2/picture/<?php echo $feed_content['from']['id'] ?>?size=medium" alt="<?php echo HTML::chars($feed_content['from']['name'] . " profile image") ?>" />
  21. </a>
  22. </div>
  23. <div class="ebody">
  24. <p class="name">
  25. <a href="<?php echo URL::site('post/index/' . $feed_content['id'], true) ?>" title="<?php echo $title ?>">
  26. <?php echo HTML::chars($feed_content['from']['name']) ?>
  27. </a>
  28. </p>
  29. <div class="title">
  30. <p class="text"><?php echo $feed_content['body'] ?></p>
  31. <p class="info"><?php
  32. echo HTML::anchor($feed_content['url'], $span, array(
  33. 'class' => 'fuzzy_span',
  34. 'id' => 'ts_' . $ts
  35. ))
  36. ,
  37. ' from ',
  38. HTML::anchor('http://friendfeed.com/', 'Friendfeed');
  39. if (isset($feed_content['via']))
  40. {
  41. echo ' via ',
  42. HTML::anchor($feed_content['via']['url'], $feed_content['via']['name']);
  43. }
  44. ?></p>
  45. </div>
  46. <?php
  47. if (!empty($feed_content['thumbnails']))
  48. {
  49. // check if first entry is a video
  50. $first_thumb = reset($feed_content['thumbnails']);
  51. if (isset($first_thumb['player']))
  52. {
  53. // thumbnail images
  54. $w = ' width="' . $first_thumb['width'] . '"';
  55. $h = ' height="' . $first_thumb['height'] . '"';
  56. // output video player link
  57. // get button position
  58. $button_position = Player::button_position($first_thumb['width'], $first_thumb['height']);
  59. $button_style = ' style="top: ' . $button_position['top'] . 'px; left: ' . $button_position['left'] . 'px;"';
  60. echo '<div class="player-thumb">',
  61. '<a href="' . HTML::chars($first_thumb['link']) . '" class="play-trigger" id="play_alt_', $feed_content['id'], '" title="Play video">',
  62. '<img src="' . $first_thumb['url'] . '"' . $w . $h . ' alt="' . $title . '" />',
  63. '</a>',
  64. '<div class="player-button"', $button_style, '>',
  65. '<a href="#" title="Play video" class="play-trigger" id="play_main_', $feed_content['id'], '">',
  66. '<img src="', URL::site('/media/img/playbutton.png'), '" alt="Play video" />',
  67. '</a>',
  68. '</div>',
  69. '</div>';
  70. // output player but invisible by default
  71. echo '<p class="player" id="player_', $feed_content['id'], '">',
  72. $first_thumb['player'],
  73. '</p>';
  74. }
  75. else
  76. {
  77. // thumnail photos
  78. $exceed_limit = false;
  79. $more_button_applied = false;
  80. $acc_width = 0;
  81. echo '<p class="thumb" id="thumbs_', $feed_content['id'], '">';
  82. foreach ($feed_content['thumbnails'] as $key => $thumb)
  83. {
  84. $w = null;
  85. $img_w = 0;
  86. if (isset($thumb['width']))
  87. {
  88. $img_w = (int)$thumb['width'];
  89. $w = ' width="' . $thumb['width'] . '"';
  90. }
  91. // calculate the accumulated width if given
  92. $acc_width += $img_w;
  93. if ($acc_width >= 550)
  94. {
  95. $exceed_limit = true;
  96. }
  97. $h = null;
  98. if (isset($thumb['height']))
  99. {
  100. $h = ' height="' . $thumb['height'] . '"';
  101. }
  102. // if no dimension is set, set the max w and h
  103. $style = null;
  104. if (!$w && !$h)
  105. {
  106. $style = ' style="max-height: 175px; max-width: 525px;"';
  107. }
  108. // only show the first row and hide the rest
  109. // if exceed 525px accumulated width
  110. $class_hide = '';
  111. if ($exceed_limit)
  112. {
  113. $class_hide = ' hidden';
  114. if (!$more_button_applied)
  115. {
  116. $more_button_applied = true;
  117. // render more button
  118. echo '<span>',
  119. '<a href="#" id="thumb_more_' . $feed_content['id'] . '" class="show-more-thumbs" title="More images">',
  120. '<img src="', URL::site('/media/img/more.png'), '" alt="More images" />',
  121. '</a>',
  122. '</span>';
  123. }
  124. }
  125. echo '<span class="img-thumb', $class_hide, '">',
  126. '<a href="' . HTML::chars($thumb['link']) . '" title="' . $title . '">',
  127. '<img src="' . $thumb['url'] . '"' . $w . $h . $style . ' alt="' . $title . '" />',
  128. '</a>',
  129. '</span>';
  130. }
  131. echo '</p>';
  132. }
  133. }
  134. ?>
  135. </div><!-- ebody -->
  136. <!-- insert clearer if needed -->
  137. <!-- wrapper ends here -->