messages.phtml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * this partial will require either a:
  4. *
  5. * @var \Ppb\Db\Table\Row\Message $message
  6. * => in this case it will display all messages from the topic in desc order
  7. * @var \Ppb\Db\Table\Row\Listing $listing
  8. * => in this case it will display all questions and answers for the listing in desc order
  9. */
  10. /**
  11. * @version 7.5
  12. */
  13. $message = (isset($message)) ? $message : null;
  14. $listing = (isset($listing)) ? $listing : null;
  15. $publicQuestions = false;
  16. $messages = array();
  17. if ($message instanceof \Ppb\Db\Table\Row\Message) {
  18. $messages = $message->findDependentRowset('\Ppb\Db\Table\Messaging');
  19. }
  20. else if ($listing instanceof \Ppb\Db\Table\Row\Listing) {
  21. $publicQuestions = true;
  22. $messages = $listing->findDependentRowset('\Ppb\Db\Table\Messaging');
  23. }
  24. ?>
  25. <?php if (count($messages) <= 0) { ?>
  26. <div class="no-results">
  27. <?php echo $this->_('There are no messages posted.'); ?>
  28. </div>
  29. <?php } ?>
  30. <?php foreach ($messages as $message) {
  31. $sender = $message->findParentRow('\Ppb\Db\Table\Users', 'Sender'); ?>
  32. <dl class="dl-horizontal">
  33. <dt>
  34. <?php if ($publicQuestions) { ?>
  35. <i class="fa fa-2x fa-question"></i>
  36. <?php
  37. }
  38. else {
  39. echo $sender->username;
  40. } ?>
  41. </dt>
  42. <dd>
  43. <div>
  44. <?php if ($publicQuestions) { ?>
  45. <div><?php echo $this->userDetails($sender)->display(); ?></div>
  46. <?php } ?>
  47. <?php if (!empty($message['title'])) { ?>
  48. <strong><?php echo $this->renderText($message['title']); ?></strong>
  49. <?php } ?>
  50. <div class="pull-right">
  51. <?php echo $this->date($message['created_at']); ?>
  52. </div>
  53. </div>
  54. <div>
  55. <?php echo $this->renderText($message['content'], true); ?>
  56. </div>
  57. </dd>
  58. <?php if ($publicQuestions) {
  59. $answers = $message->findDependentRowset('\Ppb\Db\Table\Messaging', null,
  60. $message->getTable()->select()->where('listing_id IS NULL')->order('created_at ASC'));
  61. foreach ($answers as $answer) {
  62. ?>
  63. <!-- display all answers for the above question -->
  64. <dt>
  65. <i class="fa fa-reply"></i>
  66. </dt>
  67. <dd>
  68. <div>
  69. <?php if (!empty($answer['title'])) { ?>
  70. <strong><?php echo $this->renderText($answer['title']); ?></strong>
  71. <?php } ?>
  72. <div class="pull-right">
  73. <?php echo $this->date($answer['created_at']); ?>
  74. </div>
  75. </div>
  76. <div>
  77. <?php echo $this->renderText($answer['content'], true); ?>
  78. </div>
  79. </dd>
  80. <?php } ?>
  81. <?php } ?>
  82. </dl>
  83. <?php } ?>