aboutsummaryrefslogtreecommitdiff
path: root/mod/twitter
diff options
context:
space:
mode:
Diffstat (limited to 'mod/twitter')
-rw-r--r--mod/twitter/graphics/thewire_speech_bubble.gifbin0 -> 560 bytes
-rw-r--r--mod/twitter/graphics/twitter16px.pngbin0 -> 724 bytes
-rw-r--r--mod/twitter/languages/en.php17
-rw-r--r--mod/twitter/manifest.xml16
-rw-r--r--mod/twitter/start.php14
-rw-r--r--mod/twitter/views/default/twitter/css.php63
-rw-r--r--mod/twitter/views/default/widgets/twitter/content.php42
-rw-r--r--mod/twitter/views/default/widgets/twitter/edit.php24
8 files changed, 176 insertions, 0 deletions
diff --git a/mod/twitter/graphics/thewire_speech_bubble.gif b/mod/twitter/graphics/thewire_speech_bubble.gif
new file mode 100644
index 000000000..d0e8606a1
--- /dev/null
+++ b/mod/twitter/graphics/thewire_speech_bubble.gif
Binary files differ
diff --git a/mod/twitter/graphics/twitter16px.png b/mod/twitter/graphics/twitter16px.png
new file mode 100644
index 000000000..de51c6953
--- /dev/null
+++ b/mod/twitter/graphics/twitter16px.png
Binary files differ
diff --git a/mod/twitter/languages/en.php b/mod/twitter/languages/en.php
new file mode 100644
index 000000000..11e745ba1
--- /dev/null
+++ b/mod/twitter/languages/en.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Twitter widget language file
+ */
+
+$english = array(
+ 'twitter:title' => 'Twitter',
+ 'twitter:info' => 'Display your latest tweets',
+ 'twitter:username' => 'Your twitter username',
+ 'twitter:num' => 'Number of tweets to show*',
+ 'twitter:visit' => 'visit my twitter',
+ 'twitter:notset' => 'This widget needs to be configured. To display your latest tweets, click the customize icon and fill in your Twitter username.',
+ 'twitter:invalid' => 'This widget is configured with an invalid Twitter username. Click the customize icon to correct it.',
+ 'twitter:apibug' => "*Due to a bug in the Twitter 1.0 API, you may see fewer tweets than you ask for.",
+);
+
+add_translation("en", $english);
diff --git a/mod/twitter/manifest.xml b/mod/twitter/manifest.xml
new file mode 100644
index 000000000..18fa8c957
--- /dev/null
+++ b/mod/twitter/manifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>Twitter Widget</name>
+ <author>Core developers</author>
+ <version>1.7</version>
+ <category>bundled</category>
+ <category>widget</category>
+ <description>Elgg simple twitter widget</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/twitter/start.php b/mod/twitter/start.php
new file mode 100644
index 000000000..b793eadf0
--- /dev/null
+++ b/mod/twitter/start.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Elgg twitter widget
+ * This plugin allows users to pull in their twitter feed to display on their profile
+ *
+ * @package ElggTwitter
+ */
+
+elgg_register_event_handler('init', 'system', 'twitter_init');
+
+function twitter_init() {
+ elgg_extend_view('css/elgg', 'twitter/css');
+ elgg_register_widget_type('twitter', elgg_echo('twitter:title'), elgg_echo('twitter:info'));
+}
diff --git a/mod/twitter/views/default/twitter/css.php b/mod/twitter/views/default/twitter/css.php
new file mode 100644
index 000000000..eb0cda98a
--- /dev/null
+++ b/mod/twitter/views/default/twitter/css.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Elgg Twitter CSS
+ *
+ * @package ElggTwitter
+ */
+?>
+
+#twitter_widget {
+ margin:0 10px 0 10px;
+}
+#twitter_widget ul {
+ margin:0;
+ padding:0;
+}
+#twitter_widget li {
+ list-style-image:none;
+ list-style-position:outside;
+ list-style-type:none;
+ margin:0 0 5px 0;
+ padding:0;
+ overflow-x: hidden;
+ border: 2px solid #dedede;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+}
+#twitter_widget li span {
+ color:#666666;
+ background:white;
+
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+
+ padding:5px;
+ display:block;
+}
+p.visit_twitter a {
+ background:url(<?php echo elgg_get_site_url(); ?>mod/twitter/graphics/twitter16px.png) left no-repeat;
+ padding:0 0 0 20px;
+ margin:0;
+}
+p.twitter_username .input-text {
+ width:200px;
+}
+.visit_twitter {
+ background:white;
+
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+
+ padding:2px;
+ margin:0 0 5px 0;
+}
+#twitter_widget li > a {
+ display:block;
+ margin:0 0 0 4px;
+}
+#twitter_widget li span a {
+ display:inline !important;
+} \ No newline at end of file
diff --git a/mod/twitter/views/default/widgets/twitter/content.php b/mod/twitter/views/default/widgets/twitter/content.php
new file mode 100644
index 000000000..caefd369a
--- /dev/null
+++ b/mod/twitter/views/default/widgets/twitter/content.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * Elgg twitter view page
+ *
+ * @package ElggTwitter
+ */
+
+$username = $vars['entity']->twitter_username;
+
+if (empty($username)) {
+ echo "<p>" . elgg_echo("twitter:notset") . "</p>";
+ return;
+}
+
+$username_is_valid = preg_match('~^[a-zA-Z0-9_]{1,20}$~', $username);
+if (!$username_is_valid) {
+ echo "<p>" . elgg_echo("twitter:invalid") . "</p>";
+ return;
+}
+
+
+$num = $vars['entity']->twitter_num;
+if (empty($num)) {
+ $num = 5;
+}
+
+// @todo upgrade to 1.1 API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline
+$script_url = "https://api.twitter.com/1/statuses/user_timeline/" . urlencode($username) . ".json"
+ . "?callback=twitterCallback2&count=" . (int) $num;
+
+?>
+<div id="twitter_widget">
+ <ul id="twitter_update_list"></ul>
+ <p class="visit_twitter"><?php echo elgg_view('output/url', array(
+ 'text' => elgg_echo("twitter:visit"),
+ 'href' => 'http://twitter.com/' . urlencode($username),
+ 'is_trusted' => true,
+ )) ?></p>
+ <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
+ <script type="text/javascript" src="<?php echo htmlspecialchars($script_url, ENT_QUOTES, 'UTF-8') ?>"></script>
+</div>
diff --git a/mod/twitter/views/default/widgets/twitter/edit.php b/mod/twitter/views/default/widgets/twitter/edit.php
new file mode 100644
index 000000000..c3fc6f0d5
--- /dev/null
+++ b/mod/twitter/views/default/widgets/twitter/edit.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Elgg twitter edit page
+ *
+ * @package ElggTwitter
+ */
+
+?>
+<div>
+ <?php echo elgg_echo("twitter:username"); ?>
+ <?php echo elgg_view('input/text', array(
+ 'name' => 'params[twitter_username]',
+ 'value' => $vars['entity']->twitter_username,
+ )) ?>
+</div>
+<div>
+ <?php echo elgg_echo("twitter:num"); ?>
+ <?php echo elgg_view('input/text', array(
+ 'name' => 'params[twitter_num]',
+ 'value' => $vars['entity']->twitter_num,
+ )) ?>
+ <span class="elgg-text-help"><?php echo elgg_echo("twitter:apibug"); ?></span>
+</div> \ No newline at end of file