tasklist_top.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * View for task object
  4. *
  5. * @package ElggTasks
  6. *
  7. * @uses $vars['entity'] The task list object
  8. * @uses $vars['full_view'] Whether to display the full view
  9. */
  10. $full = elgg_extract('full_view', $vars, FALSE);
  11. $tasklist = elgg_extract('entity', $vars, FALSE);
  12. if (!$tasklist) {
  13. return TRUE;
  14. }
  15. $icon = elgg_view_entity_icon($tasklist, 'tiny');
  16. $owner = get_entity($tasklist->owner_guid);
  17. $owner_link = elgg_view('output/url', array(
  18. 'href' => $owner->getURL(),
  19. 'text' => $owner->name,
  20. ));
  21. $date = elgg_view_friendly_time($tasklist->time_created);
  22. $strapline = elgg_echo("tasks:lists:strapline", array($date, $owner_link));
  23. if (isset($tasklist->enddate) && $tasklist->enddate) {
  24. $deadline = elgg_view_friendly_time(strtotime($tasklist->enddate));
  25. $strapline .= elgg_echo("tasks:lists:deadline", array($deadline));
  26. }
  27. $tags = elgg_view('output/tags', array('tags' => $tasklist->tags));
  28. $comments_count = $tasklist->countComments();
  29. //only display if there are commments
  30. if ($comments_count != 0) {
  31. $text = elgg_echo("comments") . " ($comments_count)";
  32. $comments_link = elgg_view('output/url', array(
  33. 'href' => $tasklist->getURL() . '#tasklist-comments',
  34. 'text' => $text,
  35. ));
  36. } else {
  37. $comments_link = '';
  38. }
  39. $metadata = elgg_view_menu('entity', array(
  40. 'entity' => $vars['entity'],
  41. 'handler' => 'tasks',
  42. 'sort_by' => 'priority',
  43. 'class' => 'elgg-menu-hz',
  44. ));
  45. $subtitle = "$strapline $categories $comments_link";
  46. // do not show the metadata and controls in widget view
  47. if (elgg_in_context('widgets')) {
  48. $metadata = '';
  49. }
  50. if ($full) {
  51. $body = elgg_view('output/longtext', array('value' => $tasklist->description));
  52. $content = elgg_view('tasks/tasklist_graph', array(
  53. 'entity' => $tasklist,
  54. ));
  55. $params = array(
  56. 'entity' => $tasklist,
  57. 'title' => false,
  58. 'metadata' => $metadata,
  59. 'subtitle' => $subtitle,
  60. 'tags' => $tags,
  61. 'content' => $content,
  62. );
  63. $params = $params + $vars;
  64. $list_body = elgg_view('object/elements/summary', $params);
  65. $info = elgg_view_image_block($icon, $list_body);
  66. $new_task_form = elgg_view_form('tasks/inline', array(
  67. 'id' => 'tasks-inline-form',
  68. 'class' => 'hidden',
  69. 'action' => 'action/tasks/edit',
  70. ), array(
  71. 'list' => $tasklist,
  72. ));
  73. $assigned_tasks = elgg_list_entities(array(
  74. 'list_guid' => $tasklist->guid,
  75. 'status' => array('assigned', 'active'),
  76. 'full_view' => false,
  77. 'offset' => (int) get_input('assigned_offset'),
  78. 'offset_key' => 'assigned_offset',
  79. ), 'tasks_get_entities');
  80. $info_vars = array(
  81. 'id' => 'tasks-status-assigned',
  82. 'class' => !$assigned_tasks ? 'hidden' : false,
  83. );
  84. $assigned_tasks = elgg_view_module('info', elgg_echo('tasks:assigned'), $assigned_tasks, $info_vars);
  85. $unassigned_tasks = elgg_list_entities(array(
  86. 'list_guid' => $tasklist->guid,
  87. 'status' => array('new', 'unassigned', 'reopened'),
  88. 'full_view' => false,
  89. 'offset' => (int) get_input('unassigned_offset'),
  90. 'offset_key' => 'unassigned_offset',
  91. ), 'tasks_get_entities');
  92. $info_vars = array(
  93. 'id' => 'tasks-status-unassigned',
  94. 'class' => !$unassigned_tasks ? 'hidden' : false,
  95. );
  96. $unassigned_tasks = elgg_view_module('info', elgg_echo('tasks:unassigned'), $unassigned_tasks, $info_vars);
  97. $closed_tasks = elgg_list_entities(array(
  98. 'list_guid' => $tasklist->guid,
  99. 'status' => array('done', 'closed'),
  100. 'full_view' => false,
  101. 'offset' => (int) get_input('closed_offset'),
  102. 'offset_key' => 'closed_offset',
  103. ), 'tasks_get_entities');
  104. $info_vars = array(
  105. 'id' => 'tasks-status-closed',
  106. 'class' => !$closed_tasks ? 'hidden' : false,
  107. );
  108. $closed_tasks = elgg_view_module('info', elgg_echo('tasks:closed'), $closed_tasks, $info_vars);
  109. echo <<<HTML
  110. <div class="elgg-item">
  111. $info
  112. </div>
  113. $body
  114. $new_task_form
  115. <div class="mtl">
  116. $assigned_tasks
  117. $unassigned_tasks
  118. $closed_tasks
  119. </div>
  120. HTML;
  121. } else {
  122. // brief view
  123. $content = elgg_view('tasks/tasklist_graph', array(
  124. 'entity' => $tasklist,
  125. ));
  126. $params = array(
  127. 'entity' => $tasklist,
  128. 'metadata' => $metadata,
  129. 'subtitle' => $subtitle,
  130. 'tags' => false,
  131. 'content' => $content,
  132. );
  133. $params = $params + $vars;
  134. $list_body = elgg_view('object/elements/summary', $params);
  135. echo elgg_view_image_block($icon, $list_body);
  136. }