[Mapbender-commits] r7178 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Dec 2 07:53:15 EST 2010
Author: christoph
Date: 2010-12-02 04:53:15 -0800 (Thu, 02 Dec 2010)
New Revision: 7178
Removed:
trunk/mapbender/http/plugins/mb_twitter.php
trunk/mapbender/http/plugins/mb_twitter_signin.js
trunk/mapbender/http/plugins/mb_twitter_update.js
Log:
obsolete
Deleted: trunk/mapbender/http/plugins/mb_twitter.php
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter.php 2010-12-01 09:44:48 UTC (rev 7177)
+++ trunk/mapbender/http/plugins/mb_twitter.php 2010-12-02 12:53:15 UTC (rev 7178)
@@ -1,130 +0,0 @@
-<?php
-# License:
-# Copyright (c) 2009, Open Source Geospatial Foundation
-# This program is dual licensed under the GNU General Public License
-# and Simplified BSD license.
-# http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
-
-require_once dirname(__FILE__) . "/../../core/globalSettings.php";
-require_once '../extensions/epicode/EpiCurl.php';
-require_once '../extensions/epicode/EpiOAuth.php';
-require_once '../extensions/epicode/EpiTwitter.php';
-
-$gui_id = Mapbender::session()->get("mb_user_gui");
-$e_id = "twitter_signin";
-
-require_once '../include/dyn_php.php';
-
-$ajaxResponse = new AjaxResponse($_POST);
-
-if (!isset($consumerKey) || !isset($consumerSecret)) {
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Element vars consumerKey and consumerSecret are not set. If you don't have them, get them from Twitter."));
- $ajaxResponse->send();
-}
-
-function isSignedIn ($token = null) {
- global $Twitter;
-
- if (!is_null($token)) {
- try {
- $Twitter->setToken($token);
- $accessToken = $Twitter->getAccessToken();
- Mapbender::session()->set("twitter_token", $accessToken->oauth_token);
- Mapbender::session()->set("twitter_token_secret", $accessToken->oauth_token_secret);
- }
- catch (Exception $e) {
- Mapbender::session()->delete("twitter_token");
- Mapbender::session()->delete("twitter_token_secret");
- return false;
- }
- }
-
- if (Mapbender::session()->exists("twitter_token") && Mapbender::session()->exists("twitter_token_secret")) {
- $Twitter->setToken(
- Mapbender::session()->get("twitter_token"),
- Mapbender::session()->get("twitter_token_secret")
- );
- new mb_exception("token: " . Mapbender::session()->get("twitter_token"));
- new mb_exception("token_secret: " . Mapbender::session()->get("twitter_token_secret"));
- return true;
-
- }
- return false;
-}
-
-$Twitter = new EpiTwitter($consumerKey, $consumerSecret);
-
-switch ($ajaxResponse->getMethod()) {
- case "isSignedIn" :
- $token = $ajaxResponse->getParameter("token");
-
- if (isSignedIn($token)) {
- $ajaxResponse->setResult(array("signedIn" => true));
- $ajaxResponse->setMessage(_mb("Signed in."));
- $ajaxResponse->send();
- }
-
- $ajaxResponse->setResult(array("signedIn" => false));
- $ajaxResponse->setMessage(_mb("Not signed in."));
- $ajaxResponse->setSuccess(true);
- break;
-
- case "signin" :
- try {
- $url = $Twitter->getAuthenticateUrl();
- }
- catch (Exception $e) {
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Could not connect to Twitter."));
- $ajaxResponse->send();
- }
-
- $ajaxResponse->setResult(array("url" => $url));
- $ajaxResponse->setSuccess(true);
- break;
-
- case "signout" :
- Mapbender::session()->delete("twitter_token");
- Mapbender::session()->delete("twitter_token_secret");
-
- $ajaxResponse->setResult(array("signedOut" => true));
- $ajaxResponse->setMessage(_mb("Signed out."));
- $ajaxResponse->setSuccess(true);
- break;
-
- case "update":
- if (!isSignedIn()) {
- $ajaxResponse->setResult(array("signedIn" => false));
- $ajaxResponse->setMessage(_mb("Not signed in."));
- $ajaxResponse->setSuccess(true);
- $ajaxResponse->send();
- }
- $Twitter = new EpiTwitter($consumerKey, $consumerSecret);
- $status = $ajaxResponse->getParameter("status");
- $lat = $ajaxResponse->getParameter("lat");
- $lon = $ajaxResponse->getParameter("lon");
- try {
- $newStatus = $Twitter->post_statusesUpdate(array(
- 'status' => $text,
- 'lat' => $lat,
- 'long' => $long
- ));
- }
- catch (Exception $e) {
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Could not connect to Twitter."));
- $ajaxResponse->send();
- }
- $ajaxResponse->setResult(array(
- "res" => serialize($newStatus)
- ));
- $ajaxResponse->setSuccess(true);
- break;
- default:
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("An unknown error occured."));
- break;
-}
-$ajaxResponse->send();
-?>
Deleted: trunk/mapbender/http/plugins/mb_twitter_signin.js
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter_signin.js 2010-12-01 09:44:48 UTC (rev 7177)
+++ trunk/mapbender/http/plugins/mb_twitter_signin.js 2010-12-02 12:53:15 UTC (rev 7178)
@@ -1,171 +0,0 @@
-/**
- * Package: twitter_signin
- *
- * Description:
- * Authenticate with Twitter
- *
- * Files:
- * - http/plugins/mb_twitter_signin.js
- *
- * SQL:
- * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment,
- * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width,
- * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
- * > e_mb_mod, e_target, e_requires, e_url) VALUES('<appId>','twitter_signin',
- * > 1,1,'Authenticate with Twitter','Authenticate with Twitter','img',
- * > '../img/twitter_signin.png','',900,10,NULL ,NULL ,NULL ,'','','',
- * > '../plugins/mb_twitter_signin.js','','','','');
- * >
- * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name,
- * > var_value, context, var_type) VALUES('<appId>', 'twitter_signin',
- * > 'consumerKey', '<your key>', '' ,'php_var');
- * >
- * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name,
- * > var_value, context, var_type) VALUES('<appId>', 'twitter_signin',
- * > 'consumerSecret', '<your secret>',
- * > '' ,'php_var');
- *
- * Help:
- * http://www.mapbender.org/Twitter_signin
- *
- * Maintainer:
- * http://www.mapbender.org/User:Christoph_Baudson
- *
- * Parameters:
- * consumerKey - your consumer key from Twitter (PHP var)
- * consumerSecret - your consumer secret from Twitter (PHP var)
- *
- * License:
- * Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License
- * and Simplified BSD license.
- * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
- */
-
-var $this = $(this);
-
-var originalI18nObject = {
- "logIn" : "Log in at Twitter",
- "logOut" : "Log out at Twitter"
-};
-
-var translatedI18nObject = Mapbender.cloneObject(originalI18nObject);
-
-
-var TwitterSignin = function (options) {
- var that = this;
- this.isSignedIn = function () {
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_twitter.php",
- method: "isSignedIn",
- parameters: {
- token: getOauthToken()
- },
- callback: function (obj, result, message) {
- if (!result) {
- alert(message);
- $this.text(translatedI18nObject.logIn);
- return;
- }
- if (obj.signedIn) {
- alert(message);
- $this.text(translatedI18nObject.logOut);
- $this.mapbender(function () {
- this.signedIn = true;
- this.events.signedIn.trigger();
- });
- }
- else {
- $this.text(translatedI18nObject.logIn);
- $this.mapbender(function () {
- this.signedIn = false;
- this.events.signedOut.trigger();
- });
- }
- }
- });
- req.send();
-
- };
-
- this.signedIn = false;
-
- this.events = {
- signedIn: new Mapbender.Event(),
- signedOut: new Mapbender.Event()
- };
- var getOauthToken = function () {
- var getString = document.location.search.substr(1,document.location.search.length);
- if (getString === '') {
- return null;
- }
-
- var gArr = getString.split('&');
- for (i = 0; i < gArr.length; ++i) {
- var v = '';
- vArr = gArr[i].split('=');
- if (vArr.length > 1) {
- v = vArr[1];
- }
- var key = unescape(vArr[0]);
- if (key === "oauth_token") {
- return unescape(v);
- }
- }
- return null;
- };
-
- $this.click(function () {
-
- var method = that.signedIn ? "signout" : "signin";
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_twitter.php",
- method: method,
- parameters: {
- },
- callback: function (obj, result, message) {
- if (!result) {
- alert(message);
- return;
- }
-
- if (method === "signin" && obj.url && typeof obj.url === "string") {
- window.location.href = obj.url;
- }
- else if (method === "signout") {
- var newUrl = window.location.href.replace(/oauth_token\=[0-9a-zA-Z]+/g, "");
- window.location.href = newUrl;
-
- }
- }
- });
- req.send();
- });
-
-};
-
-$this.mapbender(new TwitterSignin());
-
-Mapbender.events.init.register(function () {
- // check if signed in
- $this.mapbender(function () {
- this.isSignedIn();
- });
-
- Mapbender.events.localize.register(function () {
- Mapbender.modules.i18n.queue(options.id, originalI18nObj, function (translatedObj) {
- if (typeof translatedObj !== "object") {
- return;
- }
- translatedI18nObj = translatedObj;
- try {
- $this.mapbender(function () {
- this.isSignedIn();
- });
- }
- catch (exc) {
- new Mb_warning("Error when translating: " . exc.message);
- }
- });
- });
-});
Deleted: trunk/mapbender/http/plugins/mb_twitter_update.js
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter_update.js 2010-12-01 09:44:48 UTC (rev 7177)
+++ trunk/mapbender/http/plugins/mb_twitter_update.js 2010-12-02 12:53:15 UTC (rev 7178)
@@ -1,116 +0,0 @@
-$twitterUpdate = $(this);
-var that = this;
-
-Mapbender.events.beforeInit.register(function () {
- var signIn = Mapbender.modules.twitter_signin;
- if (signIn !== undefined) {
- signIn.events.signedIn.register(function () {
- $twitterUpdate.fadeIn();
- });
- signIn.events.signedOut.register(function () {
- $twitterUpdate.fadeOut();
- });
- }
-});
-Mapbender.events.init.register(function () {
-
- var updateStatus = function (status, lat, lon, callback) {
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_twitter.php",
- method: "update",
- parameters: {
- status: status,
- lat: lat,
- lon: lon
- },
- callback: function (obj, result, message) {
- if (!result) {
- alert(message);
- return;
- }
-
- if (typeof callback === "function") {
- callback();
- }
- alert("Updated");
- new Mapbender.Notice($.toJSON(obj));
- }
- });
- req.send();
- };
-
- var button = new Mapbender.Button({
- domElement: that,
- over: options.src.replace(/_off/, "_over"),
- on: options.src.replace(/_off/, "_on"),
- off: options.src,
- name: options.id,
- go: function () {
- options.$target.each(function () {
- var $twitterStatus, m;
- var cancel = function () {
-
- $twitterStatus.fadeOut("slow", function () {
- m.remove();
- $(this).remove();
- });
- };
- $(this).mapbender(function () {
- this.events.afterMapRequest.register(cancel);
- });
- $(this).css("cursor", "pointer")
- .mousedown(function (e) {
- mb_disableThisButton(options.id);
- var map = $(this).mapbender();
- var height = map.getHeight();
- var width = map.getWidth();
- var offset = 10;
-
- var pix = map.getMousePosition(e);
- var p = map.convertPixelToReal(pix);
- m = new Mapbender.Marker(p, map);
-
- $twitterStatus = $("<div style='z-index:999;position:absolute;top:" +
- (pix.y + parseInt(this.style.top, 10)) + "px;" +
- "left:" + (offset + parseInt(this.style.left, 10)) + "px;width:"+(width-2*offset)+"px;display:none'>" +
- "<div style='width:100%;height:10px;background-position:" + (pix.x-offset-10) + "px 0px;background-image:url(http://s.twimg.com/a/1266605807/images/arr2.gif);background-repeat:no-repeat;'/>" +
- "<div style='background-color:#fff;height:110px;padding:8px;'>" +
- "<div>What's happening?<span class='chars-left' style='float:right'>140</span></div>" +
- "<textarea rows='2' cols='70'></textarea>" +
- "<br><span style='float:right;margin:10px;'>" +
- "<span id='twitter_update_send' style='cursor:pointer;margin:5px;padding:5px;' " +
- "class='ui-state-default ui-corner-all'>update</span>" +
- "<a id='twitter_cancel' href='#'>cancel</a></span>" +
- "</div></div>").appendTo("body").fadeIn("slow");
- var $charsLeft = $("span.chars-left", $twitterStatus);
- var $textarea = $("textarea", $twitterStatus);
- $textarea.focus().keypress(function () {
- var chars = $textarea.val().length;
- var avail = 140 - chars;
- $charsLeft.text(avail);
- });
- var $button = $("#twitter_update_send");
- $button.click(function () {
- $twitterStatus.fadeOut("slow", function () {
- m.remove();
- });
- // show sandclock
- updateStatus($textarea.val(), p.y, p.x, function () {
- // hide sandclock
- });
- });
- var $cancel = $("#twitter_cancel");
- $cancel.click(function () {
- return cancel();
- });
- return false;
- });
- });
- },
- stop: function () {
- options.$target.each(function () {
- $(this).css("cursor", "default").unbind("mousedown");
- });
- }
- });
-});
More information about the Mapbender_commits
mailing list