aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/classes/ElggSite.php1
-rw-r--r--engine/lib/elgglib.php28
-rw-r--r--mod/externalpages/start.php11
-rw-r--r--mod/externalpages/views/default/expages/wrapper.php16
-rw-r--r--views/default/core/walled_garden/body.php11
-rw-r--r--views/default/core/walled_garden/login.php8
-rw-r--r--views/default/core/walled_garden/lost_password.php8
-rw-r--r--views/default/core/walled_garden/register.php8
-rw-r--r--views/default/css/walled_garden.php13
-rw-r--r--views/default/js/walled_garden.php54
-rw-r--r--views/default/page/layouts/walled_garden.php16
11 files changed, 117 insertions, 57 deletions
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index af3999321..6d07778a9 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -422,6 +422,7 @@ class ElggSite extends ElggEntity {
// default public pages
$defaults = array(
+ 'walled_garden/.*',
'action/login',
'register',
'action/register',
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 11bdc7285..b55958a6c 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -2021,8 +2021,14 @@ function elgg_walled_garden_index() {
elgg_load_css('elgg.walled_garden');
elgg_load_js('elgg.walled_garden');
- $body = elgg_view('core/walled_garden/body');
+ $content = elgg_view('core/walled_garden/login');
+ $params = array(
+ 'content' => $content,
+ 'class' => 'elgg-walledgarden-double',
+ 'id' => 'elgg-walledgarden-login',
+ );
+ $body = elgg_view_layout('walled_garden', $params);
echo elgg_view_page('', $body, 'walled_garden');
// return true to prevent other plugins from adding a front page
@@ -2030,6 +2036,24 @@ function elgg_walled_garden_index() {
}
/**
+ * Serve walled garden sections
+ *
+ * @param array $page Array of URL segments
+ * @return string
+ * @access private
+ */
+function _elgg_walled_garden_ajax_handler($page) {
+ $view = $page[0];
+ $params = array(
+ 'content' => elgg_view("core/walled_garden/$view"),
+ 'class' => 'elgg-walledgarden-single hidden',
+ 'id' => str_replace('_', '-', "elgg-walledgarden-$view"),
+ );
+ echo elgg_view_layout('walled_garden', $params);
+ return true;
+}
+
+/**
* Checks the status of the Walled Garden and forwards to a login page
* if required.
*
@@ -2049,6 +2073,8 @@ function elgg_walled_garden() {
elgg_register_css('elgg.walled_garden', '/css/walled_garden.css');
elgg_register_js('elgg.walled_garden', '/js/walled_garden.js');
+ elgg_register_page_handler('walled_garden', '_elgg_walled_garden_ajax_handler');
+
// check for external page view
if (isset($CONFIG->site) && $CONFIG->site instanceof ElggSite) {
$CONFIG->site->checkWalledGarden();
diff --git a/mod/externalpages/start.php b/mod/externalpages/start.php
index 152a8b4d9..74da7f828 100644
--- a/mod/externalpages/start.php
+++ b/mod/externalpages/start.php
@@ -77,9 +77,16 @@ function expages_page_handler($page, $handler) {
} else {
$content .= elgg_echo("expages:notset");
}
+ $content = elgg_view('expages/wrapper', array('content' => $content));
- $body = elgg_view_layout("one_sidebar", array('content' => $content));
- echo elgg_view_page($title, $body);
+ if (elgg_is_logged_in() || !elgg_get_config('walled_garden')) {
+ $body = elgg_view_layout('one_sidebar', array('content' => $content));
+ echo elgg_view_page($title, $body);
+ } else {
+ elgg_load_css('elgg.walled_garden');
+ $body = elgg_view_layout('walled_garden', array('content' => $content));
+ echo elgg_view_page($title, $body, 'walled_garden');
+ }
return true;
}
diff --git a/mod/externalpages/views/default/expages/wrapper.php b/mod/externalpages/views/default/expages/wrapper.php
new file mode 100644
index 000000000..8eb0b2f84
--- /dev/null
+++ b/mod/externalpages/views/default/expages/wrapper.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Wrapper for site pages content area
+ *
+ * @uses $vars['content']
+ */
+
+echo $vars['content'];
+
+echo '<div class="mtm">';
+echo elgg_view('output/url', array(
+ 'text' => 'Back',
+ 'href' => $_SERVER['HTTP_REFERER'],
+ 'class' => 'float-alt'
+));
+echo '</div>';
diff --git a/views/default/core/walled_garden/body.php b/views/default/core/walled_garden/body.php
deleted file mode 100644
index 67d8e0c37..000000000
--- a/views/default/core/walled_garden/body.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Walled garden body
- */
-
-echo elgg_view('core/walled_garden/login');
-echo elgg_view('core/walled_garden/lost_password');
-
-if (elgg_get_config('allow_registration')) {
- echo elgg_view('core/walled_garden/register');
-}
diff --git a/views/default/core/walled_garden/login.php b/views/default/core/walled_garden/login.php
index 0a8b4a908..42b79607d 100644
--- a/views/default/core/walled_garden/login.php
+++ b/views/default/core/walled_garden/login.php
@@ -14,7 +14,7 @@ $menu = elgg_view_menu('walled_garden', array(
$login_box = elgg_view('core/account/login_box', array('module' => 'walledgarden-login'));
-$content = <<<HTML
+echo <<<HTML
<div class="elgg-col elgg-col-1of2">
<div class="elgg-inner">
<h1 class="elgg-heading-walledgarden">
@@ -29,9 +29,3 @@ $content = <<<HTML
</div>
</div>
HTML;
-
-echo elgg_view_module('walledgarden', '', $content, array(
- 'class' => 'elgg-walledgarden-double',
- 'header' => ' ',
- 'footer' => ' ',
-));
diff --git a/views/default/core/walled_garden/lost_password.php b/views/default/core/walled_garden/lost_password.php
index ce75b558b..82f8caf50 100644
--- a/views/default/core/walled_garden/lost_password.php
+++ b/views/default/core/walled_garden/lost_password.php
@@ -5,15 +5,9 @@
$title = elgg_echo('user:password:lost');
$body = elgg_view_form('user/requestnewpassword');
-$lost = <<<HTML
+echo <<<HTML
<div class="elgg-inner">
<h3>$title</h3>
$body
</div>
HTML;
-
-echo elgg_view_module('walledgarden', '', $lost, array(
- 'class' => 'elgg-walledgarden-single elgg-walledgarden-password hidden',
- 'header' => ' ',
- 'footer' => ' ',
-));
diff --git a/views/default/core/walled_garden/register.php b/views/default/core/walled_garden/register.php
index 7f6aac99b..1ce2f8716 100644
--- a/views/default/core/walled_garden/register.php
+++ b/views/default/core/walled_garden/register.php
@@ -9,15 +9,9 @@ $body = elgg_view_form('register', array(), array(
'invitecode' => get_input('invitecode'),
));
-$content = <<<__HTML
+echo <<<__HTML
<div class="elgg-inner">
<h2>$title</h2>
$body
</div>
__HTML;
-
-echo elgg_view_module('walledgarden', '', $content, array(
- 'class' => 'elgg-walledgarden-single elgg-walledgarden-register hidden',
- 'header' => ' ',
- 'footer' => ' ',
-)); \ No newline at end of file
diff --git a/views/default/css/walled_garden.php b/views/default/css/walled_garden.php
index ea2543587..f6f7f97dc 100644
--- a/views/default/css/walled_garden.php
+++ b/views/default/css/walled_garden.php
@@ -54,8 +54,8 @@ $url = elgg_get_site_url();
padding: 0 8px;
}
-.elgg-walledgarden-single > .elgg-body > .elgg-inner {
- padding: 0 8px;
+.elgg-walledgarden-single > .elgg-body {
+ padding: 0 18px;
}
.elgg-module-walledgarden-login {
@@ -68,7 +68,14 @@ $url = elgg_get_site_url();
}
.elgg-heading-walledgarden {
- color: #666666;
margin-top: 60px;
line-height: 1.1em;
}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #666;
+}
+
+a {
+ color: #999;
+} \ No newline at end of file
diff --git a/views/default/js/walled_garden.php b/views/default/js/walled_garden.php
index 46c2934ff..13ec83c04 100644
--- a/views/default/js/walled_garden.php
+++ b/views/default/js/walled_garden.php
@@ -2,9 +2,10 @@
/**
* Walled garden JavaScript
*
- * @todo update for new JS lib
+ * @since 1.8
*/
+// note that this assumes the button view is not using single quotes
$cancel_button = elgg_view('input/button', array(
'value' => elgg_echo('cancel'),
'class' => 'elgg-button-cancel mlm',
@@ -13,28 +14,43 @@ $cancel_button = trim($cancel_button);
?>
-$(document).ready(function() {
+elgg.provide('elgg.walled_garden');
- // add cancel button to inline forms
- $(".elgg-walledgarden-password").find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>');
- $('.elgg-walledgarden-register').find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>');
+elgg.walled_garden.init = function () {
- $(".forgot_link").click(function(event) {
- event.preventDefault();
- $(".elgg-walledgarden-password").fadeToggle();
- });
+ $('.forgot_link').click(elgg.walled_garden.load('lost_password'));
+ $('.registration_link').click(elgg.walled_garden.load('register'));
- $(".registration_link").click(function(event) {
+ $('input.elgg-button-cancel').live('click', function(event) {
+ if ($('.elgg-walledgarden-single').is(':visible')) {
+ $('.elgg-walledgarden-double').fadeToggle();
+ $('.elgg-walledgarden-single').fadeToggle();
+ $('.elgg-walledgarden-single').remove();
+ }
event.preventDefault();
- $(".elgg-walledgarden-register").fadeToggle();
});
+};
- $('input.elgg-button-cancel').click(function(event) {
- if ($(".elgg-walledgarden-password").is(':visible')) {
- $(".forgot_link").click();
- } else if ($('.elgg-walledgarden-register').is(':visible')) {
- $(".registration_link").click();
- }
+/**
+ * Creates a closure for loading walled garden content through ajax
+ *
+ * @param {String} view Name of the walled garden view
+ * @return {Object}
+ */
+elgg.walled_garden.load = function(view) {
+ return function(event) {
+ var id = '#elgg-walledgarden-' + view;
+ id = id.replace('_', '-');
+ elgg.get('walled_garden/' + view, {
+ 'success' : function(data) {
+ $('.elgg-body-walledgarden').append(data);
+ $(id).find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>');
+ $('#elgg-walledgarden-login').fadeToggle();
+ $(id).fadeToggle();
+ },
+ });
event.preventDefault();
- });
-}); \ No newline at end of file
+ };
+};
+
+elgg.register_hook_handler('init', 'system', elgg.walled_garden.init); \ No newline at end of file
diff --git a/views/default/page/layouts/walled_garden.php b/views/default/page/layouts/walled_garden.php
new file mode 100644
index 000000000..6ecd941ef
--- /dev/null
+++ b/views/default/page/layouts/walled_garden.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Walled Garden layout
+ *
+ * @uses $vars['content'] Main content
+ * @uses $vars['class'] CSS classes
+ * @uses $vars['id'] CSS id
+ */
+
+$class = elgg_extract('class', $vars, 'elgg-walledgarden-single');
+echo elgg_view_module('walledgarden', '', $vars['content'], array(
+ 'class' => $class,
+ 'id' => elgg_extract('id', $vars, ''),
+ 'header' => ' ',
+ 'footer' => ' ',
+));