From 5f6dc365a8445a48156b45912827eac39fd64fc5 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 16 Mar 2014 21:01:42 -0300 Subject: Squashed 'mod/subgroups/' content from commit 835015b git-subtree-dir: mod/subgroups git-subtree-split: 835015b66b9de6dc6de91ab39f95e1f09b2dbf84 --- views/default/forms/groups/edit.php | 142 +++++++++++++++++++++++ views/default/forms/subgroups/add.php | 37 ++++++ views/default/group/default.php | 39 +++++++ views/default/group/elements/summary.php | 67 +++++++++++ views/default/groups/css/elements/components.php | 6 + views/default/groups/group_sort_menu.php | 46 ++++++++ views/default/groups/profile/fields.php | 41 +++++++ views/default/groups/sidebar/subgroups.php | 44 +++++++ views/default/icon/default.php | 58 +++++++++ views/default/input/autocomplete.php | 57 +++++++++ views/default/navigation/breadcrumbs.php | 83 +++++++++++++ views/default/subgroups/group_module.php | 51 ++++++++ views/default/subgroups/groups_i_can_edit.php | 71 ++++++++++++ views/default/subgroups/subgroups_icons.php | 11 ++ 14 files changed, 753 insertions(+) create mode 100644 views/default/forms/groups/edit.php create mode 100644 views/default/forms/subgroups/add.php create mode 100644 views/default/group/default.php create mode 100644 views/default/group/elements/summary.php create mode 100644 views/default/groups/css/elements/components.php create mode 100644 views/default/groups/group_sort_menu.php create mode 100644 views/default/groups/profile/fields.php create mode 100644 views/default/groups/sidebar/subgroups.php create mode 100644 views/default/icon/default.php create mode 100644 views/default/input/autocomplete.php create mode 100644 views/default/navigation/breadcrumbs.php create mode 100644 views/default/subgroups/group_module.php create mode 100644 views/default/subgroups/groups_i_can_edit.php create mode 100644 views/default/subgroups/subgroups_icons.php (limited to 'views/default') diff --git a/views/default/forms/groups/edit.php b/views/default/forms/groups/edit.php new file mode 100644 index 000000000..e2f9fb394 --- /dev/null +++ b/views/default/forms/groups/edit.php @@ -0,0 +1,142 @@ + +
+
+ 'icon')); ?> +
+
+
+ 'name', + 'value' => $name + )); + ?> +
+ 0) { + foreach ($group_profile_fields as $shortname => $valtype) { + $line_break = '
'; + if ($valtype == 'longtext') { + $line_break = ''; + } + echo '
$line_break"; + echo elgg_view("input/{$valtype}", array( + 'name' => $shortname, + 'value' => elgg_extract($shortname, $vars) + )); + echo '
'; + } +} +?> + +
+ +
+ + elgg_echo('groups:access:group'), + ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"), + ACCESS_PUBLIC => elgg_echo("PUBLIC") + ); +?> + +
+ +
+ +label,$b->label);')); + foreach ($tools as $group_option) { + $group_option_toggle_name = $group_option->name . "_enable"; + $value = elgg_extract($group_option_toggle_name, $vars); +?> +
+ + $group_option_toggle_name, + "value" => $value, + 'options' => array( + elgg_echo('groups:yes') => 'yes', + elgg_echo('groups:no') => 'no', + ), + )); + ?> +
+ +
+ 'group_guid', + 'value' => $entity->getGUID(), + )); +} + +echo elgg_view('input/hidden', array( + 'name' => 'container_guid', + 'value' => isset($vars['entity']) ? + $entity->getContainerGUID() : + get_input('container_guid'), +)); + +echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + +if (isset($entity)) { + $delete_url = 'action/groups/delete?guid=' . $entity->getGUID(); + echo elgg_view('output/confirmlink', array( + 'text' => elgg_echo('groups:delete'), + 'href' => $delete_url, + 'confirm' => elgg_echo('groups:deletewarning'), + 'class' => 'elgg-button elgg-button-delete float-alt', + )); +} +?> +
diff --git a/views/default/forms/subgroups/add.php b/views/default/forms/subgroups/add.php new file mode 100644 index 000000000..f0349a728 --- /dev/null +++ b/views/default/forms/subgroups/add.php @@ -0,0 +1,37 @@ + + + 'group', + 'value' => $vars['group']->guid)); + echo elgg_view('input/submit', array( + 'value' => elgg_echo('subgroups:add:button'))); +?> + + + diff --git a/views/default/group/default.php b/views/default/group/default.php new file mode 100644 index 000000000..9c0356550 --- /dev/null +++ b/views/default/group/default.php @@ -0,0 +1,39 @@ + $group, + 'handler' => 'groups', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); + +if (elgg_in_context('owner_block') || elgg_in_context('widgets')) { + $metadata = ''; +} + +if (elgg_get_context() == 'gallery') { + echo $icon; +} elseif ($vars['full_view']) { + echo elgg_view("groups/profile/profile_block", $vars); +} else { + // brief view + + $params = array( + 'entity' => $group, + 'metadata' => $metadata, + 'subtitle' => $group->briefdescription, + ); + $params = $params + $vars; + $list_body = elgg_view('group/elements/summary', $params); + + echo elgg_view_image_block($icon, $list_body, $vars); +} diff --git a/views/default/group/elements/summary.php b/views/default/group/elements/summary.php new file mode 100644 index 000000000..a95d1e296 --- /dev/null +++ b/views/default/group/elements/summary.php @@ -0,0 +1,67 @@ +title)) { + $text = $entity->title; + } else { + $text = $entity->name; + } + $params = array( + 'text' => $text, + 'href' => $entity->getURL(), + 'is_trusted' => true, + ); + $title_link = elgg_view('output/url', $params); +} + +$metadata = elgg_extract('metadata', $vars, ''); +$subtitle = elgg_extract('subtitle', $vars, ''); +$content = elgg_extract('content', $vars, ''); + +$container = get_entity($entity->container_guid); + +$tags = elgg_extract('tags', $vars, ''); +if ($tags !== false) { + $tags = elgg_view('output/tags', array('tags' => $entity->tags)); +} + +if ($metadata) { + echo $metadata; +} +if ($title_link) { + echo "

$title_link

"; +} +if(elgg_instanceof($container, 'group')) { + $container_link = elgg_view('output/url', array( + 'text' => $container->name, + 'href' => $container->getURL(), + 'is_trusted' => true, + )); + $container_link = elgg_echo('subgroups:owner:single', array($container_link)); + echo "
$container_link
"; +} +echo "
$subtitle
"; + +$subgroups = elgg_view('subgroups/subgroups_icons', array('entity' => $entity)); +echo "
$subgroups
"; + +echo $tags; + +echo elgg_view('object/summary/extend', $vars); + +if ($content) { + echo "
$content
"; +} diff --git a/views/default/groups/css/elements/components.php b/views/default/groups/css/elements/components.php new file mode 100644 index 000000000..0198fa309 --- /dev/null +++ b/views/default/groups/css/elements/components.php @@ -0,0 +1,6 @@ +/* *************************************** + Gallery +*************************************** */ +.elgg-gallery-groups > li { + margin: 0 2px; +} diff --git a/views/default/groups/group_sort_menu.php b/views/default/groups/group_sort_menu.php new file mode 100644 index 000000000..7e4d1bca6 --- /dev/null +++ b/views/default/groups/group_sort_menu.php @@ -0,0 +1,46 @@ + array( + 'text' => elgg_echo('groups:newest'), + 'href' => 'groups/all?filter=newest', + 'priority' => 200, + ), + + 'popular' => array( + 'text' => elgg_echo('groups:popular'), + 'href' => 'groups/all?filter=popular', + 'priority' => 400, + ), + + 'discussion' => array( + 'text' => elgg_echo('groups:latestdiscussion'), + 'href' => 'groups/all?filter=discussion', + 'priority' => 500, + ), +); + +if ($user = elgg_get_logged_in_user_entity()) { + $tabs['member'] = array( + 'text' => elgg_echo('groups:yours'), + 'href' => "groups/member/$user->username", + 'priority' => 300, + ); +} + +foreach ($tabs as $name => $tab) { + $tab['name'] = $name; + + if ($vars['selected'] == $name) { + $tab['selected'] = true; + } + + elgg_register_menu_item('filter', $tab); +} + +echo elgg_view_menu('filter', array('sort_by' => 'priority', 'class' => 'elgg-menu-hz')); diff --git a/views/default/groups/profile/fields.php b/views/default/groups/profile/fields.php new file mode 100644 index 000000000..41b0de9a0 --- /dev/null +++ b/views/default/groups/profile/fields.php @@ -0,0 +1,41 @@ + 0) { + + $even_odd = 'odd'; + foreach ($profile_fields as $key => $valtype) { + // do not show the name or hidden values + if ($key == 'name' || $valtype == 'hidden') { + continue; + } + + $value = $group->$key; + if (empty($value)) { + continue; + } + + $options = array('value' => $group->$key); + if ($valtype == 'tags') { + $options['tag_names'] = $key; + } + + if ($output = elgg_view("output/$valtype", $options)) { + + echo "
"; + echo ""; + echo elgg_echo("groups:$key"); + echo ": "; + echo $output; + echo "
"; + + $even_odd = ($even_odd == 'even') ? 'odd' : 'even'; + } + } +} diff --git a/views/default/groups/sidebar/subgroups.php b/views/default/groups/sidebar/subgroups.php new file mode 100644 index 000000000..35ffbaef9 --- /dev/null +++ b/views/default/groups/sidebar/subgroups.php @@ -0,0 +1,44 @@ + 'subgroups/owner/' . $owner->guid, + 'text' => elgg_echo('subgroups:more'), + 'is_trusted' => true, +)); + +$params = array( + 'type' => 'group', + 'container_guid' => $owner->guid, + 'limit' => $limit, + 'types' => 'group', + 'list_type' => 'gallery', + 'gallery_class' => 'elgg-gallery-groups', + 'full_view' => false +); + +$params['count'] = true; +if(elgg_get_entities($params) == 0) { + return true; +} +$params['count'] = false; + +$body = elgg_list_entities($params); +$body .= "
$all_link
"; + +echo elgg_view_module('aside', elgg_echo('subgroups'), $body); diff --git a/views/default/icon/default.php b/views/default/icon/default.php new file mode 100644 index 000000000..3ef1a05a1 --- /dev/null +++ b/views/default/icon/default.php @@ -0,0 +1,58 @@ +name)) { + $title = $entity->name; +} else { + $title = $entity->title; +} +$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false); + +$url = $entity->getURL(); +if (isset($vars['href'])) { + $url = $vars['href']; +} + +$img = elgg_view('output/img', array( + 'src' => $entity->getIconURL($vars['size']), + 'alt' => $title, + 'class' => $class, +)); + +if ($url) { + $params = array( + 'href' => $url, + 'text' => $img, + 'title' => $title, + 'is_trusted' => true, + ); + $class = elgg_extract('link_class', $vars, ''); + if ($class) { + $params['class'] = $class; + } + + echo elgg_view('output/url', $params); +} else { + echo $img; +} diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php new file mode 100644 index 000000000..4eedac22a --- /dev/null +++ b/views/default/input/autocomplete.php @@ -0,0 +1,57 @@ + '', + 'disabled' => false, +); + +$vars = array_merge($defaults, $vars); + +$params = array(); +if (isset($vars['match_on'])) { + $params['match_on'] = $vars['match_on']; + unset($vars['match_on']); +} +if (isset($vars['match_owner'])) { + $params['match_owner'] = $vars['match_owner']; + unset($vars['match_owner']); +} +$ac_url_params = http_build_query($params); + +elgg_load_js('elgg.autocomplete'); +elgg_load_js('jquery.ui.autocomplete.html'); + +?> + + + /> diff --git a/views/default/navigation/breadcrumbs.php b/views/default/navigation/breadcrumbs.php new file mode 100644 index 000000000..6ceb5eacc --- /dev/null +++ b/views/default/navigation/breadcrumbs.php @@ -0,0 +1,83 @@ +guid; + $alias = $page_owner->alias; + + $title = $breadcrumbs[1]['title']; + $name = $page_owner->name; + + if(strpos($link, $guid) || $alias && strpos($link, $alias) || !$link && $title == $name) { + $first_crumb = array_shift($breadcrumbs); + $container = get_entity($page_owner->container_guid); + while(elgg_instanceof($container, 'group')) { + + // TODO: I should find a better solution for this. + if(strpos($first_crumb['link'], 'groups') !== false) { + $container_link = str_replace('all', "profile/$container->guid", $first_crumb['link']); + } elseif(strpos($first_crumb['link'], 'discussion') !== false) { + $container_link = str_replace('all', "owner/$container->guid", $first_crumb['link']); + } else { + $container_link = str_replace('all', "group/$container->guid", $first_crumb['link']); + } + + $container_link = elgg_trigger_plugin_hook('container_crumb_link', 'breadcrumbs', array('container' => $container, 'first_crumb' => $first_crumb), $container_link); + + array_unshift($breadcrumbs, array( + 'title' => $container->name, + 'link' => $container_link, + )); + $container = get_entity($container->container_guid); + } + array_unshift($breadcrumbs, $first_crumb); + } +} + + +$class = 'elgg-menu elgg-breadcrumbs'; +$additional_class = elgg_extract('class', $vars, ''); +if ($additional_class) { + $class = "$class $additional_class"; +} + +if (is_array($breadcrumbs) && count($breadcrumbs) > 0) { + echo "'; +} diff --git a/views/default/subgroups/group_module.php b/views/default/subgroups/group_module.php new file mode 100644 index 000000000..083e50b16 --- /dev/null +++ b/views/default/subgroups/group_module.php @@ -0,0 +1,51 @@ +subgroups_enable != "yes") { + return true; +} + +$all_link = elgg_view('output/url', array( + 'href' => "subgroups/owner/$group->guid/all", + 'text' => elgg_echo('link:view:all'), + 'is_trusted' => true, +)); + +$options = array( + 'type' => 'group', + 'container_guid' => $group->guid, + 'type' => 'group', + 'limit' => 6, + 'full_view' => false, + 'pagination' => false, +); + +elgg_push_context('widgets'); +$content = elgg_list_entities($options); +elgg_pop_context(); + +if (!$content) { + $content = '

' . elgg_echo('subgroups:none') . '

'; +} +if($group->canEdit()) { + $new_link = elgg_view('output/url', array( + 'href' => "subgroups/add/$group->guid", + 'text' => elgg_echo('subgroups:add'), + 'is_trusted' => true, + )); +} else { + $new_link = false; +} + +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('subgroups:group'), + 'content' => $content, + 'all_link' => $all_link, + 'add_link' => $new_link, +)); diff --git a/views/default/subgroups/groups_i_can_edit.php b/views/default/subgroups/groups_i_can_edit.php new file mode 100644 index 000000000..45b0c9e6e --- /dev/null +++ b/views/default/subgroups/groups_i_can_edit.php @@ -0,0 +1,71 @@ + 'group', + 'owner_guid' => $user_guid, + 'limit' => 0, +)); +$entities = array_merge( + $entities, + elgg_get_entities_from_relationship(array( + 'type' => 'group', + 'relationship' => 'operator', + 'relationship_guid' => $user_guid, + 'limit' => 0, + )) +); + +$all_entities = array(); +while (!empty($entities)) { + $entity = array_pop($entities); + $childs = elgg_get_entities(array( + 'type' => 'group', + 'container_guid' => $entity->guid, + )); + foreach ($childs as $child) { + array_push($entities, $child); + } + $all_entities[] = $entity; +} + +$results = array(); +foreach ($all_entities as $entity) { + + if (!preg_match("/^{$q}/i", $entity->name)) { + continue; + } + + $output = elgg_view_list_item($entity, array( + 'use_hover' => false, + 'class' => 'elgg-autocomplete-item', + )); + + $icon = elgg_view_entity_icon($entity, 'tiny', array( + 'use_hover' => false, + )); + $results[$entity->name . $entity->guid] = array( + 'type' => 'group', + 'name' => $entity->name, + 'desc' => strip_tags($entity->description), + 'guid' => $entity->guid, + 'label' => $output, + 'value' => $entity->guid, + 'icon' => $icon, + 'url' => $entity->getURL(), + ); +} + +ksort($results); +header("Content-Type: application/json"); +echo json_encode(array_values($results)); +exit; diff --git a/views/default/subgroups/subgroups_icons.php b/views/default/subgroups/subgroups_icons.php new file mode 100644 index 000000000..dfd5b29fa --- /dev/null +++ b/views/default/subgroups/subgroups_icons.php @@ -0,0 +1,11 @@ + $subgroup, + 'size' => 'tiny' + )); + echo " "; +} -- cgit v1.2.3