aboutsummaryrefslogtreecommitdiff
path: root/views/default/object
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-17 12:00:58 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-17 12:00:58 -0300
commit228d3697bcd0218605be2e28131574cc85293a2e (patch)
tree6a59c627f6226bd2b3056b959acc9cc871eb1f8f /views/default/object
downloadelgg-228d3697bcd0218605be2e28131574cc85293a2e.tar.gz
elgg-228d3697bcd0218605be2e28131574cc85293a2e.tar.bz2
Squashed 'mod/tasks/' content from commit c9b1097
git-subtree-dir: mod/tasks git-subtree-split: c9b1097ce081d6893f9c939146208559c089dc15
Diffstat (limited to 'views/default/object')
-rw-r--r--views/default/object/task.php133
-rw-r--r--views/default/object/tasklist_top.php166
2 files changed, 299 insertions, 0 deletions
diff --git a/views/default/object/task.php b/views/default/object/task.php
new file mode 100644
index 000000000..d8ed01233
--- /dev/null
+++ b/views/default/object/task.php
@@ -0,0 +1,133 @@
+<?php
+/**
+ * View for task object
+ *
+ * @package ElggTasks
+ *
+ * @uses $vars['entity'] The task object
+ * @uses $vars['full_view'] Whether to display the full view
+ */
+
+elgg_load_library('elgg:tasks');
+
+$full = elgg_extract('full_view', $vars, FALSE);
+$task = elgg_extract('entity', $vars, FALSE);
+
+if (!$task) {
+ return TRUE;
+}
+
+$options = array('metadata_name' => 'list_guid', 'metadata_value' => $task->guid, 'type' => 'object', 'subtype' => 'task');
+$has_children = elgg_get_entities_from_metadata($options);
+if ($has_children) {
+ echo elgg_view('object/tasklist_top', $vars);
+ return;
+}
+
+
+$icon = elgg_view_entity_icon($task, 'tiny');
+
+$status = $task->status;
+
+if(!in_array($status, array('new', 'assigned', 'unassigned', 'active', 'done', 'closed', 'reopened'))){
+ $status = 'new';
+}
+
+$annotation = $task->getAnnotations('task_state_changed', 2, 0, 'desc');
+$more_than_one = count($annotation) > 1;
+
+if ($annotation) {
+ $annotation = $annotation[0];
+} else {
+ $annotation = new stdClass();
+ $annotation->owner_guid = $task->owner_guid;
+ $annotation->time_created = $task->time_created;
+}
+
+if (in_array($status, array('assigned', 'active', 'done')) && $more_than_one) {
+ $owner_link = elgg_view('tasks/participant_count', array('entity' => $task));
+} else {
+ $owner = get_entity($annotation->owner_guid);
+ $owner_link = elgg_view('output/url', array(
+ 'href' => $owner->getURL(),
+ 'text' => $owner->name,
+ ));
+}
+$date = elgg_view_friendly_time($annotation->time_created);
+$strapline = elgg_echo("tasks:strapline:$status", array($date, $owner_link));
+$tags = elgg_view('output/tags', array('tags' => $task->tags));
+
+$comments_count = $task->countComments();
+//only display if there are commments
+if ($comments_count != 0) {
+ $text = elgg_echo("comments") . " ($comments_count)";
+ $comments_link = elgg_view('output/url', array(
+ 'href' => $task->getURL() . '#task-comments',
+ 'text' => $text,
+ ));
+} else {
+ $comments_link = '';
+}
+
+
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $task,
+ 'handler' => 'tasks',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
+
+$subtitle = "$strapline $categories $comments_link";
+
+// do not show the metadata and controls in widget view
+if (elgg_in_context('widgets')) {
+ $metadata = '';
+}
+
+if ($full) {
+ $body = elgg_view('output/longtext', array('value' => $task->description));
+ $new_task_form = elgg_view_form('tasks/inline', array(
+ 'id' => 'tasks-inline-form',
+ 'class' => 'hidden',
+ 'action' => 'action/tasks/edit',
+ ), array(
+ 'list' => $task,
+ ));
+
+ $body .= elgg_view('tasks/info/extend', $vars);
+
+ $body .= $new_task_form;
+
+ $params = array(
+ 'entity' => $page,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => $tags,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ $info = elgg_view_image_block($icon, $list_body);
+
+ echo <<<HTML
+$info
+$body
+HTML;
+
+} else {
+ // brief view
+
+ $excerpt = elgg_get_excerpt($task->description);
+
+ $params = array(
+ 'entity' => $task,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => false,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($icon, $list_body);
+}
diff --git a/views/default/object/tasklist_top.php b/views/default/object/tasklist_top.php
new file mode 100644
index 000000000..9ce5ca1c6
--- /dev/null
+++ b/views/default/object/tasklist_top.php
@@ -0,0 +1,166 @@
+<?php
+/**
+ * View for task object
+ *
+ * @package ElggTasks
+ *
+ * @uses $vars['entity'] The task list object
+ * @uses $vars['full_view'] Whether to display the full view
+ */
+
+
+$full = elgg_extract('full_view', $vars, FALSE);
+$tasklist = elgg_extract('entity', $vars, FALSE);
+
+if (!$tasklist) {
+ return TRUE;
+}
+
+$icon = elgg_view_entity_icon($tasklist, 'tiny');
+
+$owner = get_entity($tasklist->owner_guid);
+$owner_link = elgg_view('output/url', array(
+ 'href' => $owner->getURL(),
+ 'text' => $owner->name,
+));
+
+$date = elgg_view_friendly_time($tasklist->time_created);
+$strapline = elgg_echo("tasks:lists:strapline", array($date, $owner_link));
+
+if (isset($tasklist->enddate) && $tasklist->enddate) {
+ $deadline = elgg_view_friendly_time(strtotime($tasklist->enddate));
+ $strapline .= elgg_echo("tasks:lists:deadline", array($deadline));
+}
+
+$tags = elgg_view('output/tags', array('tags' => $tasklist->tags));
+
+$comments_count = $tasklist->countComments();
+//only display if there are commments
+if ($comments_count != 0) {
+ $text = elgg_echo("comments") . " ($comments_count)";
+ $comments_link = elgg_view('output/url', array(
+ 'href' => $tasklist->getURL() . '#tasklist-comments',
+ 'text' => $text,
+ ));
+} else {
+ $comments_link = '';
+}
+
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
+ 'handler' => 'tasks',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
+
+$subtitle = "$strapline $categories $comments_link";
+
+// do not show the metadata and controls in widget view
+if (elgg_in_context('widgets')) {
+ $metadata = '';
+}
+
+if ($full) {
+ $body = elgg_view('output/longtext', array('value' => $tasklist->description));
+
+ $content = elgg_view('tasks/tasklist_graph', array(
+ 'entity' => $tasklist,
+ ));
+
+ $params = array(
+ 'entity' => $tasklist,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => $tags,
+ 'content' => $content,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ $info = elgg_view_image_block($icon, $list_body);
+
+ $new_task_form = elgg_view_form('tasks/inline', array(
+ 'id' => 'tasks-inline-form',
+ 'class' => 'hidden',
+ 'action' => 'action/tasks/edit',
+ ), array(
+ 'list' => $tasklist,
+ ));
+
+ $assigned_tasks = elgg_list_entities(array(
+ 'list_guid' => $tasklist->guid,
+ 'status' => array('assigned', 'active'),
+ 'full_view' => false,
+ 'offset' => (int) get_input('assigned_offset'),
+ 'offset_key' => 'assigned_offset',
+ ), 'tasks_get_entities');
+
+ $info_vars = array(
+ 'id' => 'tasks-status-assigned',
+ 'class' => !$assigned_tasks ? 'hidden' : false,
+ );
+ $assigned_tasks = elgg_view_module('info', elgg_echo('tasks:assigned'), $assigned_tasks, $info_vars);
+
+ $unassigned_tasks = elgg_list_entities(array(
+ 'list_guid' => $tasklist->guid,
+ 'status' => array('new', 'unassigned', 'reopened'),
+ 'full_view' => false,
+ 'offset' => (int) get_input('unassigned_offset'),
+ 'offset_key' => 'unassigned_offset',
+ ), 'tasks_get_entities');
+
+ $info_vars = array(
+ 'id' => 'tasks-status-unassigned',
+ 'class' => !$unassigned_tasks ? 'hidden' : false,
+ );
+ $unassigned_tasks = elgg_view_module('info', elgg_echo('tasks:unassigned'), $unassigned_tasks, $info_vars);
+
+ $closed_tasks = elgg_list_entities(array(
+ 'list_guid' => $tasklist->guid,
+ 'status' => array('done', 'closed'),
+ 'full_view' => false,
+ 'offset' => (int) get_input('closed_offset'),
+ 'offset_key' => 'closed_offset',
+ ), 'tasks_get_entities');
+
+ $info_vars = array(
+ 'id' => 'tasks-status-closed',
+ 'class' => !$closed_tasks ? 'hidden' : false,
+ );
+ $closed_tasks = elgg_view_module('info', elgg_echo('tasks:closed'), $closed_tasks, $info_vars);
+
+
+
+ echo <<<HTML
+<div class="elgg-item">
+$info
+</div>
+$body
+$new_task_form
+<div class="mtl">
+$assigned_tasks
+$unassigned_tasks
+$closed_tasks
+</div>
+HTML;
+
+} else {
+ // brief view
+
+ $content = elgg_view('tasks/tasklist_graph', array(
+ 'entity' => $tasklist,
+ ));
+
+ $params = array(
+ 'entity' => $tasklist,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => false,
+ 'content' => $content,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($icon, $list_body);
+}