aboutsummaryrefslogtreecommitdiff
path: root/mod/twitter_api/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/twitter_api/views')
-rw-r--r--mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php62
-rw-r--r--mod/twitter_api/views/default/plugins/twitter_api/settings.php50
-rw-r--r--mod/twitter_api/views/default/plugins/twitter_api/usersettings.php37
-rw-r--r--mod/twitter_api/views/default/twitter_api/css.php13
-rw-r--r--mod/twitter_api/views/default/twitter_api/js.php16
-rw-r--r--mod/twitter_api/views/default/twitter_api/login.php17
-rw-r--r--mod/twitter_api/views/default/twitter_api/metatags.php19
7 files changed, 214 insertions, 0 deletions
diff --git a/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php
new file mode 100644
index 000000000..cad2be345
--- /dev/null
+++ b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Make the user set up some alternative ways to login.
+ */
+
+$user = elgg_get_logged_in_user_entity();
+
+if (elgg_is_sticky_form('twitter_api_interstitial')) {
+ extract(elgg_get_sticky_values('twitter_api_interstitial'));
+ elgg_clear_sticky_form('twitter_api_interstitial');
+}
+
+if (!isset($display_name)) {
+ $display_name = $user->name;
+}
+
+// username
+$title = elgg_echo('username');
+
+$body = elgg_echo('twitter_api:interstitial:username');
+$body .= elgg_view('input/text', array('value' => $user->username, 'disabled' => 'disabled'));
+
+echo elgg_view_module('info', $title, $body);
+
+// display name
+$title = elgg_echo('name');
+
+$body = elgg_echo('twitter_api:interstitial:name');
+$body .= elgg_view('input/text', array('name' => 'display_name', 'value' => $display_name));
+
+echo elgg_view_module('info', $title, $body);
+
+// email
+$title = elgg_echo('email');
+
+$body = elgg_echo('twitter_api:interstitial:email');
+$body .= elgg_view('input/email', array('name' => 'email', 'value' => $email));
+
+echo elgg_view_module('info', $title, $body);
+
+// password
+$title = elgg_echo('password');
+
+$body = elgg_echo('twitter_api:interstitial:password');
+$body .= elgg_view('input/password', array('name' => 'password_1'));
+$body .= elgg_echo('twitter_api:interstitial:password2');
+$body .= elgg_view('input/password', array('name' => 'password_2'));
+
+echo elgg_view_module('info', $title, $body);
+
+// buttons
+
+echo elgg_view('input/submit', array(
+ 'text' => elgg_echo('save')
+));
+
+echo elgg_view('output/url', array(
+ 'class' => 'float-alt',
+ 'text' => elgg_echo('twitter_api:interstitial:no_thanks'),
+ 'href' => '/',
+ 'is_trusted' => true,
+)); \ No newline at end of file
diff --git a/mod/twitter_api/views/default/plugins/twitter_api/settings.php b/mod/twitter_api/views/default/plugins/twitter_api/settings.php
new file mode 100644
index 000000000..0b9afd4cf
--- /dev/null
+++ b/mod/twitter_api/views/default/plugins/twitter_api/settings.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Twitter API plugin settings
+ */
+
+$instructions = elgg_echo('twitter_api:settings:instructions', array(elgg_get_site_url()));
+
+$consumer_key_string = elgg_echo('twitter_api:consumer_key');
+$consumer_key_view = elgg_view('input/text', array(
+ 'name' => 'params[consumer_key]',
+ 'value' => $vars['entity']->consumer_key,
+ 'class' => 'elgg-input-thin',
+));
+
+$consumer_secret_string = elgg_echo('twitter_api:consumer_secret');
+$consumer_secret_view = elgg_view('input/text', array(
+ 'name' => 'params[consumer_secret]',
+ 'value' => $vars['entity']->consumer_secret,
+ 'class' => 'elgg-input-thin',
+));
+
+$sign_on_with_twitter_string = elgg_echo('twitter_api:login');
+$sign_on_with_twitter_view = elgg_view('input/dropdown', array(
+ 'name' => 'params[sign_on]',
+ 'options_values' => array(
+ 'yes' => elgg_echo('option:yes'),
+ 'no' => elgg_echo('option:no'),
+ ),
+ 'value' => $vars['entity']->sign_on ? $vars['entity']->sign_on : 'no',
+));
+
+$new_users_with_twitter = elgg_echo('twitter_api:new_users');
+$new_users_with_twitter_view = elgg_view('input/dropdown', array(
+ 'name' => 'params[new_users]',
+ 'options_values' => array(
+ 'yes' => elgg_echo('option:yes'),
+ 'no' => elgg_echo('option:no'),
+ ),
+ 'value' => $vars['entity']->new_users ? $vars['entity']->new_users : 'no',
+));
+
+$settings = <<<__HTML
+<div class="elgg-content-thin mtm"><p>$instructions</p></div>
+<div><label>$consumer_key_string</label><br /> $consumer_key_view</div>
+<div><label>$consumer_secret_string</label><br /> $consumer_secret_view</div>
+<div>$sign_on_with_twitter_string $sign_on_with_twitter_view</div>
+<div>$new_users_with_twitter $new_users_with_twitter_view</div>
+__HTML;
+
+echo $settings;
diff --git a/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php b/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php
new file mode 100644
index 000000000..edcea2f0d
--- /dev/null
+++ b/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * User settings for Twitter API
+ */
+
+$user = elgg_get_logged_in_user_entity();
+$user_guid = $user->getGUID();
+$twitter_name = elgg_get_plugin_user_setting('twitter_name', $user_guid, 'twitter_api');
+$access_key = elgg_get_plugin_user_setting('access_key', $user_guid, 'twitter_api');
+$access_secret = elgg_get_plugin_user_setting('access_secret', $user_guid, 'twitter_api');
+
+$site_key = elgg_get_plugin_setting('consumer_key', 'twitter_api');
+$site_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api');
+
+if (!($site_key && $site_secret)) {
+ echo '<div>' . elgg_echo('twitter_api:usersettings:site_not_configured') . '</div>';
+ return true;
+}
+
+$site_name = elgg_get_site_entity()->name;
+echo '<div>' . elgg_echo('twitter_api:usersettings:description', array($site_name)) . '</div>';
+
+if (!$access_key || !$access_secret) {
+ // send user off to validate account
+ $request_link = twitter_api_get_authorize_url(null, false);
+ echo '<div>' . elgg_echo('twitter_api:usersettings:request', array($request_link, $site_name)) . '</div>';
+} else {
+ // if this user logged in through twitter and never set up an email address, don't
+ // let them disassociate their account.
+ if ($user->email) {
+ $url = elgg_get_site_url() . "twitter_api/revoke";
+ echo '<div>' . elgg_echo('twitter_api:usersettings:authorized', array($site_name, $twitter_name)) . '</div>';
+ echo '<div>' . sprintf(elgg_echo('twitter_api:usersettings:revoke'), $url) . '</div>';
+ } else {
+ echo elgg_echo('twitter_api:usersettings:cannot_revoke', array(elgg_normalize_url('twitter_api/interstitial')));
+ }
+}
diff --git a/mod/twitter_api/views/default/twitter_api/css.php b/mod/twitter_api/views/default/twitter_api/css.php
new file mode 100644
index 000000000..2d081d361
--- /dev/null
+++ b/mod/twitter_api/views/default/twitter_api/css.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Elgg Twitter API CSS
+ */
+?>
+
+.login_with_twitter {
+ padding: 10px 0 0 0;
+}
+
+.twitter-secret {
+ width: 400px;
+} \ No newline at end of file
diff --git a/mod/twitter_api/views/default/twitter_api/js.php b/mod/twitter_api/views/default/twitter_api/js.php
new file mode 100644
index 000000000..3d2905a44
--- /dev/null
+++ b/mod/twitter_api/views/default/twitter_api/js.php
@@ -0,0 +1,16 @@
+<?php if (0): ?><script><?php endif; ?>
+
+// add ?persistent to login link
+elgg.register_hook_handler('init', 'system', function() {
+ $('form.elgg-form-login').each(function () {
+ var link = $('.login_with_twitter a', this).get(0),
+ $input = $('input[name="persistent"]', this);
+ function sync() {
+ link.href = link.href.replace(/\?.*/, '') + ($input[0].checked ? '?persistent' : '');
+ }
+ if (link && $input.length) {
+ sync();
+ $input.change(sync);
+ }
+ });
+});
diff --git a/mod/twitter_api/views/default/twitter_api/login.php b/mod/twitter_api/views/default/twitter_api/login.php
new file mode 100644
index 000000000..7b4b4ecb1
--- /dev/null
+++ b/mod/twitter_api/views/default/twitter_api/login.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Extension of login form for Twitter sign in
+ */
+
+$url = elgg_get_site_url() . 'twitter_api/forward';
+$img_url = elgg_get_site_url() . 'mod/twitter_api/graphics/sign-in-with-twitter-d.png';
+
+$login = <<<__HTML
+<div class="login_with_twitter">
+ <a href="$url">
+ <img src="$img_url" alt="Twitter" />
+ </a>
+</div>
+__HTML;
+
+echo $login;
diff --git a/mod/twitter_api/views/default/twitter_api/metatags.php b/mod/twitter_api/views/default/twitter_api/metatags.php
new file mode 100644
index 000000000..67c66dc37
--- /dev/null
+++ b/mod/twitter_api/views/default/twitter_api/metatags.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Adds required HTML head tags for Twitter Services.
+ *
+ * @package TwitterAPI
+ */
+
+if ($api_key = elgg_get_plugin_setting('consumer_key', 'twitter_api')) {
+ $tags = <<<__HTML
+<script src="http://platform.twitter.com/anywhere.js?id=$api_key&v=1" type="text/javascript"></script>
+<script type="text/javascript">
+ twttr.anywhere(function (T) {
+ T(".twitter_anywhere").hovercards();
+ });
+</script>
+__HTML;
+
+ echo $tags;
+}