aboutsummaryrefslogtreecommitdiff
path: root/mod/tasks/views/default/object/tasklist_top.php
blob: 9ce5ca1c63ccb43827ac5a5263c636b2afc1dfe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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);
}