aboutsummaryrefslogtreecommitdiff
path: root/views/default/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/widgets')
-rw-r--r--views/default/widgets/admin_welcome/content.php19
-rw-r--r--views/default/widgets/content_stats/content.php28
-rw-r--r--views/default/widgets/content_stats/edit.php23
-rw-r--r--views/default/widgets/control_panel/content.php38
-rw-r--r--views/default/widgets/feed_reader/content.php81
-rw-r--r--views/default/widgets/feed_reader/edit.php62
-rw-r--r--views/default/widgets/friends/content.php25
-rw-r--r--views/default/widgets/friends/edit.php52
-rw-r--r--views/default/widgets/new_users/content.php11
-rw-r--r--views/default/widgets/new_users/edit.php23
-rw-r--r--views/default/widgets/online_users/content.php15
-rw-r--r--views/default/widgets/online_users/edit.php22
-rw-r--r--views/default/widgets/river_widget/content.php27
-rw-r--r--views/default/widgets/river_widget/edit.php58
14 files changed, 341 insertions, 143 deletions
diff --git a/views/default/widgets/admin_welcome/content.php b/views/default/widgets/admin_welcome/content.php
new file mode 100644
index 000000000..f4b92ea66
--- /dev/null
+++ b/views/default/widgets/admin_welcome/content.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Welcome widget for admins
+ */
+
+// section => string replacements.
+$sections = array(
+ 'intro' => array(),
+ 'admin_overview' => array(),
+ 'outro' => array()
+);
+
+// don't use longtext because it filters output.
+// that's annoying.
+echo '<div class="elgg-output">';
+foreach ($sections as $section => $strings) {
+ echo '<p>' . elgg_echo("admin:widget:admin_welcome:$section", $strings) . '</p>';
+}
+echo '</div>'; \ No newline at end of file
diff --git a/views/default/widgets/content_stats/content.php b/views/default/widgets/content_stats/content.php
new file mode 100644
index 000000000..56772047d
--- /dev/null
+++ b/views/default/widgets/content_stats/content.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Content stats widget
+ */
+
+$max = $vars['entity']->num_display;
+
+$entity_stats = get_entity_statistics();
+$object_stats = $entity_stats['object'];
+arsort($object_stats);
+$object_stats = array_slice($object_stats, 0, $max);
+
+echo '<table class="elgg-table-alt">';
+echo '<tr><th>' . elgg_echo('widget:content_stats:type') . '</th>';
+echo '<th>' . elgg_echo('widget:content_stats:number') . '</th></tr>';
+foreach ($object_stats as $subtype => $num) {
+ $name = elgg_echo("item:object:$subtype");
+ echo "<tr><td>$name</td><td>$num</td></tr>";
+}
+echo '</table>';
+
+echo '<div class="mtm">';
+echo elgg_view('output/url', array(
+ 'href' => 'admin/statistics/overview',
+ 'text' => elgg_echo('more'),
+ 'is_trusted' => true,
+));
+echo '</div>';
diff --git a/views/default/widgets/content_stats/edit.php b/views/default/widgets/content_stats/edit.php
new file mode 100644
index 000000000..f1a050df8
--- /dev/null
+++ b/views/default/widgets/content_stats/edit.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Content statistics widget edit view
+ */
+
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 8;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(5, 8, 10, 12, 15, 20),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<p>
+ <?php echo elgg_echo('widget:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</p>
diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php
new file mode 100644
index 000000000..a348d612f
--- /dev/null
+++ b/views/default/widgets/control_panel/content.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Admin control panel widget
+ */
+
+elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'flush',
+ 'text' => elgg_echo('admin:cache:flush'),
+ 'href' => 'action/admin/site/flush_cache',
+ 'is_action' => true,
+ 'link_class' => 'elgg-button elgg-button-action',
+));
+
+// @todo Move in this in ElggUpgradeManager::isLocked() when #4682 fixed
+$is_locked = _elgg_upgrade_is_locked();
+
+if (!$is_locked) {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'upgrade',
+ 'text' => elgg_echo('upgrade'),
+ 'href' => 'upgrade.php',
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+} else {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'unlock_upgrade',
+ 'text' => elgg_echo('upgrade:unlock'),
+ 'href' => 'action/admin/site/unlock_upgrade',
+ 'is_action' => true,
+ 'link_class' => 'elgg-button elgg-button-action',
+ 'confirm' => elgg_echo('upgrade:unlock:confirm'),
+ ));
+}
+
+echo elgg_view_menu('admin_control_panel', array(
+ 'class' => 'elgg-menu-hz',
+ 'item_class' => 'mrm',
+));
diff --git a/views/default/widgets/feed_reader/content.php b/views/default/widgets/feed_reader/content.php
deleted file mode 100644
index f13b00fe7..000000000
--- a/views/default/widgets/feed_reader/content.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * View a feed in a widget
- */
-
-elgg_load_library('simplepie');
-
-$allowed_tags = '<a><p><br><b><i><em><del><pre><strong><ul><ol><li><img>';
-$feed_url = $vars['entity']->feed_url;
-if ($feed_url) {
-
- // get widget settings
- $excerpt = $vars['entity']->excerpt;
- $num_items = $vars['entity']->num_items;
- $post_date = $vars['entity']->post_date;
-
- $cache_location = elgg_get_data_path() . '/simplepie_cache/';
- if (!file_exists($cache_location)) {
- mkdir($cache_location, 0777);
- }
-
- $feed = new SimplePie($feed_url, $cache_location);
-
- // doubles timeout if going through a proxy
- //$feed->set_timeout(20);
-
- // only display errors to profile owner
- $num_posts_in_feed = $feed->get_item_quantity();
- if (!$num_posts_in_feed) {
- if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
- echo '<p>' . elgg_echo('simplepie:notfind') . '</p>';
- }
- }
-
- // don't display more feed items than user requested
- if ($num_items > $num_posts_in_feed) {
- $num_items = $num_posts_in_feed;
- }
-
- $feed_link = elgg_view('output/url', array(
- 'href' => $feed->get_permalink(),
- 'text' => $feed->get_title(),
- ));
-
- // need to center
- echo "<h2 class=\"simplepie-heading\">$feed_link</h2>";
- echo '<ul class="simplepie-list">';
- foreach ($feed->get_items(0, $num_items) as $item) {
- $item_link = elgg_view('output/url', array(
- 'href' => $item->get_permalink(),
- 'text' => $item->get_title(),
- ));
-
- if ($excerpt) {
- $text = strip_tags($item->get_description(true), $allowed_tags);
- $excerpt = $text;
- }
-
- if ($post_date) {
- $item_date_label = elgg_echo('simplepie:postedon');
- $item_date = $item->get_date('j F Y | g:i a');
- $post_date = "$item_date_label $item_date";
- }
-
- echo <<<HTML
-<li class="mbm">
- <h4 class="mbs">$item_link</h4>
- <div class="mbs clearfix">$excerpt</div>
- <p class="elgg-subtext">$post_date</p>
-</li>
-HTML;
-
- }
- echo "</ul>";
-
-} else {
- // display message only to owner
- if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
- echo '<p>' . elgg_echo('simplepie:notset') . '</p>';
- }
-}
diff --git a/views/default/widgets/feed_reader/edit.php b/views/default/widgets/feed_reader/edit.php
deleted file mode 100644
index 83218dcbb..000000000
--- a/views/default/widgets/feed_reader/edit.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/**
- * Simplepie feed reader widget settings
- */
-
-// set default value
-if (!isset($vars['entity']->num_items)) {
- $vars['entity']->num_items = 10;
-}
-
-if (!isset($vars['entity']->excerpt)) {
- $vars['entity']->excerpt = false;
-}
-
-if (!isset($vars['entity']->post_date)) {
- $vars['entity']->post_date = false;
-}
-
-$url_label = elgg_echo("simplepie:feed_url");
-$url_textbox = elgg_view('input/text', array(
- 'name' => 'params[feed_url]',
- 'value' => $vars['entity']->feed_url,
- 'onclick' => 'this.select();',
-));
-
-$num_items_label = elgg_echo('simplepie:num_items');
-$num_items_select = elgg_view('input/dropdown', array(
- 'name' => 'params[num_items]',
- 'value' => $vars['entity']->num_items,
- 'options' => array(3, 5, 8, 10, 12, 15, 20),
-));
-
-$excerpt_label = elgg_echo('simplepie:excerpt');
-$excerpt_checkbox = elgg_view('input/checkbox', array(
- 'name' => 'params[excerpt]',
- 'value' => true,
- 'checked' => $vars['entity']->excerpt ? 'checked' : '',
-));
-
-$post_date_label = elgg_echo('simplepie:post_date');
-$post_date_checkbox = elgg_view('input/checkbox', array(
- 'name' => 'params[post_date]',
- 'value' => true,
- 'checked' => $vars['entity']->post_date ? 'checked' : '',
-));
-
-echo <<<HTML
-<div>
- $url_label
- $url_textbox
-</div>
-<div>
- $num_items_label
- $num_items_select
-</div>
-<div>
- $excerpt_checkbox $excerpt_label
-</div>
-<div>
- $post_date_checkbox $post_date_label
-</div>
-HTML;
diff --git a/views/default/widgets/friends/content.php b/views/default/widgets/friends/content.php
new file mode 100644
index 000000000..98814c244
--- /dev/null
+++ b/views/default/widgets/friends/content.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Friend widget display view
+ *
+ */
+
+// owner of the widget
+$owner = $vars['entity']->getOwnerEntity();
+
+// the number of friends to display
+$num = (int) $vars['entity']->num_display;
+
+// get the correct size
+$size = $vars['entity']->icon_size;
+
+if (elgg_instanceof($owner, 'user')) {
+ $html = $owner->listFriends('', $num, array(
+ 'size' => $size,
+ 'list_type' => 'gallery',
+ 'pagination' => false
+ ));
+ if ($html) {
+ echo $html;
+ }
+}
diff --git a/views/default/widgets/friends/edit.php b/views/default/widgets/friends/edit.php
new file mode 100644
index 000000000..c7e6b06ff
--- /dev/null
+++ b/views/default/widgets/friends/edit.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Friend widget options
+ *
+ */
+
+// set default value for display number
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 12;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 50, 100),
+);
+$display_dropdown = elgg_view('input/dropdown', $params);
+
+
+// handle upgrade to 1.7.2 from previous versions
+if ($vars['entity']->icon_size == 1) {
+ $vars['entity']->icon_size = 'small';
+} elseif ($vars['entity']->icon_size == 2) {
+ $vars['entity']->icon_size = 'tiny';
+}
+
+// set default value for icon size
+if (!isset($vars['entity']->icon_size)) {
+ $vars['entity']->icon_size = 'small';
+}
+
+$params = array(
+ 'name' => 'params[icon_size]',
+ 'value' => $vars['entity']->icon_size,
+ 'options_values' => array(
+ 'small' => elgg_echo('friends:small'),
+ 'tiny' => elgg_echo('friends:tiny'),
+ ),
+);
+$size_dropdown = elgg_view('input/dropdown', $params);
+
+
+?>
+<p>
+ <?php echo elgg_echo('friends:num_display'); ?>:
+ <?php echo $display_dropdown; ?>
+</p>
+
+<p>
+ <?php echo elgg_echo('friends:icon_size'); ?>:
+ <?php echo $size_dropdown; ?>
+</p>
diff --git a/views/default/widgets/new_users/content.php b/views/default/widgets/new_users/content.php
new file mode 100644
index 000000000..ba85e7421
--- /dev/null
+++ b/views/default/widgets/new_users/content.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * New users admin widget
+ */
+
+echo elgg_list_entities(array(
+ 'type' => 'user',
+ 'subtype'=> null,
+ 'full_view' => false,
+ 'pagination' => false,
+)); \ No newline at end of file
diff --git a/views/default/widgets/new_users/edit.php b/views/default/widgets/new_users/edit.php
new file mode 100644
index 000000000..ed07213cb
--- /dev/null
+++ b/views/default/widgets/new_users/edit.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * New users widget edit view
+ */
+
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 5;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(5, 8, 10, 12, 15, 20),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<p>
+ <?php echo elgg_echo('widget:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</p>
diff --git a/views/default/widgets/online_users/content.php b/views/default/widgets/online_users/content.php
new file mode 100644
index 000000000..6e0cc7abb
--- /dev/null
+++ b/views/default/widgets/online_users/content.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Online users widget
+ */
+
+$count = find_active_users(600, 10, 0, true);
+$objects = find_active_users(600, 10);
+
+if ($objects) {
+ echo elgg_view_entity_list($objects, array(
+ 'count' => $count,
+ 'limit' => 10,
+ 'pagination' => false,
+ ));
+}
diff --git a/views/default/widgets/online_users/edit.php b/views/default/widgets/online_users/edit.php
new file mode 100644
index 000000000..66f03a745
--- /dev/null
+++ b/views/default/widgets/online_users/edit.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Online users widget edit view
+ */
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 8;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(5, 8, 10, 12, 15, 20),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<p>
+ <?php echo elgg_echo('widget:numbertodisplay'); ?>:
+ <?php echo $dropdown; ?>
+</p>
diff --git a/views/default/widgets/river_widget/content.php b/views/default/widgets/river_widget/content.php
new file mode 100644
index 000000000..867fc9db6
--- /dev/null
+++ b/views/default/widgets/river_widget/content.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Activity widget content view
+ */
+
+$num = (int) $vars['entity']->num_display;
+
+$options = array(
+ 'limit' => $num,
+ 'pagination' => false,
+);
+
+if (elgg_in_context('dashboard')) {
+ if ($vars['entity']->content_type == 'friends') {
+ $options['relationship_guid'] = elgg_get_page_owner_guid();
+ $options['relationship'] = 'friend';
+ }
+} else {
+ $options['subject_guid'] = elgg_get_page_owner_guid();
+}
+
+$content = elgg_list_river($options);
+if (!$content) {
+ $content = elgg_echo('river:none');
+}
+
+echo $content;
diff --git a/views/default/widgets/river_widget/edit.php b/views/default/widgets/river_widget/edit.php
new file mode 100644
index 000000000..228212e47
--- /dev/null
+++ b/views/default/widgets/river_widget/edit.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Edit settings for river widget
+ */
+
+// dashboard widget has type parameter
+if (elgg_in_context('dashboard')) {
+ if (!isset($vars['entity']->content_type)) {
+ $vars['entity']->content_type = 'friends';
+ }
+ $params = array(
+ 'name' => 'params[content_type]',
+ 'value' => $vars['entity']->content_type,
+ 'options_values' => array(
+ 'friends' => elgg_echo('river:widgets:friends'),
+ 'all' => elgg_echo('river:widgets:all'),
+ ),
+ );
+ $type_dropdown = elgg_view('input/dropdown', $params);
+ ?>
+ <div>
+ <?php echo elgg_echo('river:widget:type'); ?>:
+ <?php echo $type_dropdown; ?>
+ </div>
+ <?php
+}
+
+
+// set default value for number to display
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 8;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(5, 8, 10, 12, 15, 20),
+);
+$num_dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<div>
+ <?php echo elgg_echo('widget:numbertodisplay'); ?>:
+ <?php echo $num_dropdown; ?>
+</div>
+
+<?php
+// pass the context so we have the correct output upon save.
+if (elgg_in_context('dashboard')) {
+ $context = 'dashboard';
+} else {
+ $context = 'profile';
+}
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'context',
+ 'value' => $context
+)); \ No newline at end of file