diff options
Diffstat (limited to 'views/default/tasks')
-rw-r--r-- | views/default/tasks/css.php | 26 | ||||
-rw-r--r-- | views/default/tasks/group_module.php | 50 | ||||
-rw-r--r-- | views/default/tasks/js.php | 35 | ||||
-rw-r--r-- | views/default/tasks/page/elements/comments.php | 43 | ||||
-rw-r--r-- | views/default/tasks/participant_count.php | 42 | ||||
-rw-r--r-- | views/default/tasks/sidebar.php | 14 | ||||
-rw-r--r-- | views/default/tasks/sidebar/navigation.php | 60 | ||||
-rw-r--r-- | views/default/tasks/tasklist_graph.php | 65 |
8 files changed, 335 insertions, 0 deletions
diff --git a/views/default/tasks/css.php b/views/default/tasks/css.php new file mode 100644 index 000000000..fc1b670a7 --- /dev/null +++ b/views/default/tasks/css.php @@ -0,0 +1,26 @@ +.tasklist-graph { + height: 10px; + line-height: 10px; + border: 2px solid #CCCCCC; +} + +.tasklist-graph div { + background: #4690D6; +} + +.elgg-input-radios label { + font-weight: normal; +} + +.elgg-menu-extras .elgg-icon-checkmark { + background-position: 0 -126px; +} + +#tasks-inline-form { + padding: 10px +} + +.elgg-tasks-participants { + position: absolute; + width: 345px; +}
\ No newline at end of file diff --git a/views/default/tasks/group_module.php b/views/default/tasks/group_module.php new file mode 100644 index 000000000..8f2c424b8 --- /dev/null +++ b/views/default/tasks/group_module.php @@ -0,0 +1,50 @@ +<?php +/** + * Group tasks module + */ + +elgg_load_library('elgg:tasks'); + +$group = elgg_get_page_owner_entity(); + +if ($group->tasks_enable == "no") { + return true; +} + +$all_link = elgg_view('output/url', array( + 'href' => "tasks/group/$group->guid/all", + 'text' => elgg_echo('link:view:all'), + 'is_trusted' => true, +)); + +elgg_push_context('widgets'); +$entities = tasks_get_entities(array( + 'type' => 'object', + 'subtype' => 'task', + 'container_guid' => elgg_get_page_owner_guid(), + 'limit' => 6, + 'list_guid' => 0, +)); + +$content = elgg_view_entity_list($entities, array( + 'full_view' => false, + 'pagination' => false, +)); +elgg_pop_context(); + +if (!$content) { + $content = '<p>' . elgg_echo('tasks:none') . '</p>'; +} + +$new_link = elgg_view('output/url', array( + 'href' => "tasks/add/$group->guid", + 'text' => elgg_echo('tasks:add'), + 'is_trusted' => true, +)); + +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('tasks:group'), + 'content' => $content, + 'all_link' => $all_link, + 'add_link' => $new_link, +)); diff --git a/views/default/tasks/js.php b/views/default/tasks/js.php new file mode 100644 index 000000000..985e95e0a --- /dev/null +++ b/views/default/tasks/js.php @@ -0,0 +1,35 @@ +<?php +/* + * + */ +?> + +elgg.provide('elgg.ui.getSelection'); + +elgg.ui.getSelection = function () { + if (window.getSelection) { + return window.getSelection().toString(); + } + else if (document.getSelection) { + return document.getSelection(); + } + else if (document.selection) { + // this is specifically for IE + return document.selection.createRange().text; + } +} + +$(function() { + $('.elgg-menu-extras .elgg-menu-item-task a').click(function() { + var title = encodeURIComponent(elgg.ui.getSelection()); + if (!title) { + title = encodeURIComponent($('h2.elgg-heading-main').text()); + } + referer_guid = $('.elgg-form-comments-add input[name="entity_guid"]').val(); + var href = $(this).attr('href') + "&title=" + title; + if (referer_guid) { + href += "&referer_guid=" + referer_guid; + } + $(this).attr('href', href); + }); +});
\ No newline at end of file diff --git a/views/default/tasks/page/elements/comments.php b/views/default/tasks/page/elements/comments.php new file mode 100644 index 000000000..ef1737a63 --- /dev/null +++ b/views/default/tasks/page/elements/comments.php @@ -0,0 +1,43 @@ +<?php +/** + * List comments with optional add form + * + * @uses $vars['entity'] ElggEntity + * @uses $vars['show_add_form'] Display add form or not + * @uses $vars['id'] Optional id for the div + * @uses $vars['class'] Optional additional class for the div + */ + +$show_add_form = elgg_extract('show_add_form', $vars, true); + +$id = ''; +if (isset($vars['id'])) { + $id = "id =\"{$vars['id']}\""; +} + +$class = 'elgg-comments'; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} + +// work around for deprecation code in elgg_view() +unset($vars['internalid']); + +echo "<div $id class=\"$class\">"; + +$options = array( + 'guid' => $vars['entity']->getGUID(), + 'annotation_names' => array('generic_comment', 'task_state_changed'), +); +$html = elgg_list_annotations($options); +if ($html) { + echo '<h3>' . elgg_echo('tasks:changehistory') . '</h3>'; + echo $html; +} + +if ($show_add_form) { + $form_vars = array('name' => 'elgg_add_comment'); + echo elgg_view_form('tasks/comments/add', $form_vars, $vars); +} + +echo '</div>'; diff --git a/views/default/tasks/participant_count.php b/views/default/tasks/participant_count.php new file mode 100644 index 000000000..781588693 --- /dev/null +++ b/views/default/tasks/participant_count.php @@ -0,0 +1,42 @@ +<?php +/** + * Count of who is participating in a task + * + * @uses $vars['entity'] + */ + +$guid = $vars['entity']->getGUID(); + +$list = ''; +$num_of_participants = elgg_get_entities_from_relationship(array( + 'relationship' => 'subscribes', + 'relationship_guid' => $guid, + 'inverse_relationship' => true, + 'count' => true, +)); +//var_dump($num_of_participants); +if ($num_of_participants) { + // display the number of participants + if ($num_of_participants == 1) { + $participants_string = elgg_echo('tasks:participant', array($num_of_participants)); + } else { + $participants_string = elgg_echo('tasks:participants', array($num_of_participants)); + } + $params = array( + 'text' => $participants_string, + 'title' => elgg_echo('tasks:participants:see'), + 'rel' => 'popup', + 'href' => "#tasks-participants-$guid" + ); + $list = elgg_view('output/url', $params); + $list .= "<div class='elgg-module elgg-module-popup elgg-tasks-participants hidden clearfix' id='tasks-participants-$guid'>"; + $list .= elgg_list_entities_from_relationship(array( + 'relationship' => 'subscribes', + 'relationship_guid' => $guid, + 'inverse_relationship' => true, + 'limit' => 99, + 'list_class' => 'elgg-list-tasks-participants', + )); + $list .= "</div>"; + echo $list; +} diff --git a/views/default/tasks/sidebar.php b/views/default/tasks/sidebar.php new file mode 100644 index 000000000..141965b92 --- /dev/null +++ b/views/default/tasks/sidebar.php @@ -0,0 +1,14 @@ +<?php +/** + * File sidebar + */ + +echo elgg_view('page/elements/comments_block', array( + 'subtypes' => 'task', + 'owner_guid' => elgg_get_page_owner_guid(), +)); + +echo elgg_view('page/elements/tagcloud_block', array( + 'subtypes' => 'task', + 'owner_guid' => elgg_get_page_owner_guid(), +)); diff --git a/views/default/tasks/sidebar/navigation.php b/views/default/tasks/sidebar/navigation.php new file mode 100644 index 000000000..389f4fb8a --- /dev/null +++ b/views/default/tasks/sidebar/navigation.php @@ -0,0 +1,60 @@ +<?php +/** + * Navigation menu for a user's or a group's pages + * + * @uses $vars['page'] Page object if manually setting selected item + */ + +// add the jquery treeview files for navigation +elgg_load_js('jquery-treeview'); +elgg_load_css('jquery-treeview'); + + +$entity = elgg_extract('entity', $vars, false); +if (elgg_instanceof($entity, 'object', 'task') && ($list = get_entity($entity->list_guid))) { + $url = $list->getURL(); +} elseif ($entity) { + $url = $entity->getURL(); +} + +$title = elgg_echo('tasks:navigation'); + +tasks_register_navigation_tree(elgg_get_page_owner_entity()); + +$content = elgg_view_menu('tasks_nav', array('class' => 'tasks-nav')); +if (!$content) { + $content = '<p>' . elgg_echo('tasks:none') . '</p>'; +} + +echo elgg_view_module('aside', $title, $content); + +?><?php //@todo JS 1.8: no ?> +<script type="text/javascript"> +$(document).ready(function() { + $(".tasks-nav").treeview({ + persist: "location", + collapsed: true, + unique: true + }); + +<?php +if ($entity) { + // if on a history page, we need to manually select the correct menu item + // code taken from the jquery.treeview library +?> + var current = $(".tasks-nav a[href='<?php echo $url; ?>']"); + var items = current.addClass("selected").parents("ul, li").add( current.next() ).show(); + var CLASSES = $.treeview.classes; + items.filter("li") + .swapClass( CLASSES.collapsable, CLASSES.expandable ) + .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) + .find(">.hitarea") + .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) + .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ); +<?php +} +?> + +}); + +</script> diff --git a/views/default/tasks/tasklist_graph.php b/views/default/tasks/tasklist_graph.php new file mode 100644 index 000000000..f46066a8a --- /dev/null +++ b/views/default/tasks/tasklist_graph.php @@ -0,0 +1,65 @@ +<?php + +elgg_load_library('elgg:tasks'); + +$entity = $vars['entity']; + +$total = tasks_get_entities(array( + 'list_guid' => $vars['entity']->guid, + 'count' => true, +)); +$closed = tasks_get_entities(array( + 'list_guid' => $vars['entity']->guid, + 'status' => 'closed', + 'count' => true, +)); +$total_link = $entity->getURL()."#all"; +// Closed tasks aren't contabilized in graph. +$total -= $closed; + +$done = tasks_get_entities(array( + 'list_guid' => $vars['entity']->guid, + 'status' => 'done', + 'count' => true, +)); + +$remaining = $total - $done; +$remaining_link = $entity->getURL()."#remaining"; + +$assigned = tasks_get_entities(array( + 'list_guid' => $vars['entity']->guid, + 'status' => array('assigned', 'active'), + 'count' => true, +)); +$assigned_link = $entity->getURL()."#assigned"; + +$active = tasks_get_entities(array( + 'list_guid' => $vars['entity']->guid, + 'status' => 'active', + 'count' => true, +)); +$active_link = $entity->getURL()."#active"; + +if ($total == 0) { + $percent = 0; +} else { + $percent = $done / $total * 100; +} + +?> + +<div> +<div class="tasklist-graph"> + <div style="width:<?php echo $percent.'%'; ?>"> </div> +</div> + +<?php + +echo '<a href="'.$total_link.'">' . elgg_echo('tasks:lists:graph:total', array($total)) . '</a>, '; +echo '<a href="'.$remaining_link.'">' . elgg_echo('tasks:lists:graph:remaining', array($remaining)) . '</a>, '; +echo '<a href="'.$assigned_link.'">' . elgg_echo('tasks:lists:graph:assigned', array($assigned)) . '</a>, '; +echo '<a href="'.$active_link.'">' . elgg_echo('tasks:lists:graph:active', array($active)) . '</a>'; + +?> + +</div> |