aboutsummaryrefslogtreecommitdiff
path: root/mod/custom_index
diff options
context:
space:
mode:
Diffstat (limited to 'mod/custom_index')
-rw-r--r--mod/custom_index/index.php68
-rw-r--r--mod/custom_index/languages/en.php14
-rw-r--r--mod/custom_index/manifest.xml15
-rw-r--r--mod/custom_index/start.php30
-rw-r--r--mod/custom_index/views/default/custom_index/css.php23
-rw-r--r--mod/custom_index/views/default/page/layouts/custom_index.php68
6 files changed, 218 insertions, 0 deletions
diff --git a/mod/custom_index/index.php b/mod/custom_index/index.php
new file mode 100644
index 000000000..53990a006
--- /dev/null
+++ b/mod/custom_index/index.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Elgg custom index page
+ *
+ */
+
+elgg_push_context('front');
+
+elgg_push_context('widgets');
+
+$list_params = array(
+ 'type' => 'object',
+ 'limit' => 4,
+ 'full_view' => false,
+ 'view_type_toggle' => false,
+ 'pagination' => false,
+);
+
+//grab the latest 4 blog posts
+$list_params['subtype'] = 'blog';
+$blogs = elgg_list_entities($list_params);
+
+//grab the latest bookmarks
+$list_params['subtype'] = 'bookmarks';
+$bookmarks = elgg_list_entities($list_params);
+
+//grab the latest files
+$list_params['subtype'] = 'file';
+$files = elgg_list_entities($list_params);
+
+//get the newest members who have an avatar
+$newest_members = elgg_list_entities_from_metadata(array(
+ 'metadata_names' => 'icontime',
+ 'types' => 'user',
+ 'limit' => 10,
+ 'full_view' => false,
+ 'pagination' => false,
+ 'list_type' => 'gallery',
+ 'gallery_class' => 'elgg-gallery-users',
+ 'size' => 'small',
+));
+
+//newest groups
+$list_params['type'] = 'group';
+unset($list_params['subtype']);
+$groups = elgg_list_entities($list_params);
+
+//grab the login form
+$login = elgg_view("core/account/login_box");
+
+elgg_pop_context();
+
+// lay out the content
+$params = array(
+ 'blogs' => $blogs,
+ 'bookmarks' => $bookmarks,
+ 'files' => $files,
+ 'groups' => $groups,
+ 'login' => $login,
+ 'members' => $newest_members,
+);
+$body = elgg_view_layout('custom_index', $params);
+
+// no RSS feed with a "widget" front page
+global $autofeed;
+$autofeed = FALSE;
+
+echo elgg_view_page('', $body);
diff --git a/mod/custom_index/languages/en.php b/mod/custom_index/languages/en.php
new file mode 100644
index 000000000..071ff81e5
--- /dev/null
+++ b/mod/custom_index/languages/en.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Custom Index English language file
+ */
+
+$english = array(
+ 'custom:bookmarks' => "Latest bookmarks",
+ 'custom:groups' => "Latest groups",
+ 'custom:files' => "Latest files",
+ 'custom:blogs' => "Latest blog posts",
+ 'custom:members' => "Newest members",
+);
+
+add_translation("en", $english);
diff --git a/mod/custom_index/manifest.xml b/mod/custom_index/manifest.xml
new file mode 100644
index 000000000..80187efbc
--- /dev/null
+++ b/mod/custom_index/manifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>Custom Index</name>
+ <author>Core developers</author>
+ <version>1.8</version>
+ <category>bundled</category>
+ <description>A demonstration of how to create a front page plugin.</description>
+ <website>http://www.elgg.org/</website>
+ <copyright>See COPYRIGHT.txt</copyright>
+ <license>GNU General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+</plugin_manifest>
diff --git a/mod/custom_index/start.php b/mod/custom_index/start.php
new file mode 100644
index 000000000..48d03f27b
--- /dev/null
+++ b/mod/custom_index/start.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Elgg demo custom index page plugin
+ *
+ */
+
+elgg_register_event_handler('init', 'system', 'custom_index_init');
+
+function custom_index_init() {
+
+ // Extend system CSS with our own styles
+ elgg_extend_view('css/elgg', 'custom_index/css');
+
+ // Replace the default index page
+ elgg_register_plugin_hook_handler('index', 'system', 'custom_index');
+}
+
+function custom_index($hook, $type, $return, $params) {
+ if ($return == true) {
+ // another hook has already replaced the front page
+ return $return;
+ }
+
+ if (!include_once(dirname(__FILE__) . "/index.php")) {
+ return false;
+ }
+
+ // return true to signify that we have handled the front page
+ return true;
+}
diff --git a/mod/custom_index/views/default/custom_index/css.php b/mod/custom_index/views/default/custom_index/css.php
new file mode 100644
index 000000000..4c780a905
--- /dev/null
+++ b/mod/custom_index/views/default/custom_index/css.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Custom Index CSS
+ *
+ */
+?>
+
+/*******************************
+ Custom Index
+********************************/
+.custom-index {
+ padding: 10px 0;
+}
+.elgg-module-highlight {
+ -webkit-box-shadow: 1px 1px 5px #CCC;
+ -moz-box-shadow: 1px 1px 5px #CCC;
+ box-shadow: 1px 1px 5px #CCC;
+}
+.elgg-module-highlight:hover {
+ -webkit-box-shadow: 1px 1px 6px #AAA;
+ -moz-box-shadow: 1px 1px 6px #AAA;
+ box-shadow: 1px 1px 6px #AAA;
+}
diff --git a/mod/custom_index/views/default/page/layouts/custom_index.php b/mod/custom_index/views/default/page/layouts/custom_index.php
new file mode 100644
index 000000000..1267e19b2
--- /dev/null
+++ b/mod/custom_index/views/default/page/layouts/custom_index.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Elgg custom index layout
+ *
+ * You can edit the layout of this page with your own layout and style.
+ * Whatever you put in this view will appear on the front page of your site.
+ *
+ */
+
+$mod_params = array('class' => 'elgg-module-highlight');
+
+?>
+
+<div class="custom-index elgg-main elgg-grid clearfix">
+ <div class="elgg-col elgg-col-1of2">
+ <div class="elgg-inner pvm prl">
+<?php
+// left column
+
+// Top box for login or welcome message
+if (elgg_is_logged_in()) {
+ $top_box = "<h2>" . elgg_echo("welcome") . " ";
+ $top_box .= elgg_get_logged_in_user_entity()->name;
+ $top_box .= "</h2>";
+} else {
+ $top_box = $vars['login'];
+}
+echo elgg_view_module('featured', '', $top_box, $mod_params);
+
+// a view for plugins to extend
+echo elgg_view("index/lefthandside");
+
+// files
+if (elgg_is_active_plugin('file')) {
+ echo elgg_view_module('featured', elgg_echo("custom:files"), $vars['files'], $mod_params);
+}
+
+// groups
+if (elgg_is_active_plugin('groups')) {
+ echo elgg_view_module('featured', elgg_echo("custom:groups"), $vars['groups'], $mod_params);
+}
+?>
+ </div>
+ </div>
+ <div class="elgg-col elgg-col-1of2">
+ <div class="elgg-inner pvm">
+<?php
+// right column
+
+// a view for plugins to extend
+echo elgg_view("index/righthandside");
+
+// files
+echo elgg_view_module('featured', elgg_echo("custom:members"), $vars['members'], $mod_params);
+
+// groups
+if (elgg_is_active_plugin('blog')) {
+ echo elgg_view_module('featured', elgg_echo("custom:blogs"), $vars['blogs'], $mod_params);
+}
+
+// files
+if (elgg_is_active_plugin('bookmarks')) {
+ echo elgg_view_module('featured', elgg_echo("custom:bookmarks"), $vars['bookmarks'], $mod_params);
+}
+?>
+ </div>
+ </div>
+</div>