Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
This commit is contained in:
@@ -179,28 +179,22 @@ class FacebookBridgePlugin extends Plugin
|
||||
// Always add the admin panel route
|
||||
$m->connect('admin/facebook', array('action' => 'facebookadminpanel'));
|
||||
|
||||
// Only add these routes if an application has been setup on
|
||||
// Facebook for the plugin to use.
|
||||
if ($this->hasApplication()) {
|
||||
|
||||
$m->connect(
|
||||
'main/facebooklogin',
|
||||
array('action' => 'facebooklogin')
|
||||
);
|
||||
$m->connect(
|
||||
'main/facebookfinishlogin',
|
||||
array('action' => 'facebookfinishlogin')
|
||||
);
|
||||
$m->connect(
|
||||
'settings/facebook',
|
||||
array('action' => 'facebooksettings')
|
||||
);
|
||||
$m->connect(
|
||||
'facebook/deauthorize',
|
||||
array('action' => 'facebookdeauthorize')
|
||||
);
|
||||
|
||||
}
|
||||
$m->connect(
|
||||
'main/facebooklogin',
|
||||
array('action' => 'facebooklogin')
|
||||
);
|
||||
$m->connect(
|
||||
'main/facebookfinishlogin',
|
||||
array('action' => 'facebookfinishlogin')
|
||||
);
|
||||
$m->connect(
|
||||
'settings/facebook',
|
||||
array('action' => 'facebooksettings')
|
||||
);
|
||||
$m->connect(
|
||||
'facebook/deauthorize',
|
||||
array('action' => 'facebookdeauthorize')
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -51,7 +51,14 @@ class Facebookclient
|
||||
function __construct($notice)
|
||||
{
|
||||
$this->facebook = self::getFacebook();
|
||||
$this->notice = $notice;
|
||||
|
||||
if (empty($this->facebook)) {
|
||||
throw new FacebookApiException(
|
||||
"Could not create Facebook client! Bad application ID or secret?"
|
||||
);
|
||||
}
|
||||
|
||||
$this->notice = $notice;
|
||||
|
||||
$this->flink = Foreign_link::getByUserID(
|
||||
$notice->profile_id,
|
||||
@@ -89,6 +96,22 @@ class Facebookclient
|
||||
$secret = common_config('facebook', 'global_secret');
|
||||
}
|
||||
|
||||
if (empty($appId)) {
|
||||
common_log(
|
||||
LOG_WARNING,
|
||||
"Couldn't find Facebook application ID!",
|
||||
__FILE__
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($secret)) {
|
||||
common_log(
|
||||
LOG_WARNING,
|
||||
"Couldn't find Facebook application ID!",
|
||||
__FILE__
|
||||
);
|
||||
}
|
||||
|
||||
return new Facebook(
|
||||
array(
|
||||
'appId' => $appId,
|
||||
@@ -174,6 +197,9 @@ class Facebookclient
|
||||
return $this->sendGraph();
|
||||
}
|
||||
}
|
||||
|
||||
// dequeue
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -68,6 +68,9 @@ class MobileProfilePlugin extends WAP20Plugin
|
||||
$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) {
|
||||
|
||||
$this->serveMobile = true;
|
||||
} else if (isset($_COOKIE['MobileOverride'])) {
|
||||
// Cookie override is controlled by link at bottom.
|
||||
$this->serveMobile = (bool)$_COOKIE['MobileOverride'];
|
||||
} else {
|
||||
// If they like the WAP 2.0 mimetype, serve them MP
|
||||
// @fixme $type is undefined, making this if case useless and spewing errors.
|
||||
@@ -381,9 +384,40 @@ class MobileProfilePlugin extends WAP20Plugin
|
||||
}
|
||||
}
|
||||
|
||||
function onStartShowScripts($action)
|
||||
function onEndShowScripts($action)
|
||||
{
|
||||
$action->inlineScript('
|
||||
$(function() {
|
||||
$("#mobile-toggle-disable").click(function() {
|
||||
$.cookie("MobileOverride", "0", {path: "/"});
|
||||
window.location.reload();
|
||||
return false;
|
||||
});
|
||||
$("#mobile-toggle-enable").click(function() {
|
||||
$.cookie("MobileOverride", "1", {path: "/"});
|
||||
window.location.reload();
|
||||
return false;
|
||||
});
|
||||
});'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function onEndShowInsideFooter($action)
|
||||
{
|
||||
if ($this->serveMobile) {
|
||||
// TRANS: Link to switch site layout from mobile to desktop mode. Appears at very bottom of page.
|
||||
$linkText = _m('Switch to desktop site layout.');
|
||||
$key = 'mobile-toggle-disable';
|
||||
} else {
|
||||
// TRANS: Link to switch site layout from desktop to mobile mode. Appears at very bottom of page.
|
||||
$linkText = _m('Switch to mobile site layout.');
|
||||
$key = 'mobile-toggle-enable';
|
||||
}
|
||||
$action->elementStart('p');
|
||||
$action->element('a', array('href' => '#', 'id' => $key), $linkText);
|
||||
$action->elementEnd('p');
|
||||
return true;
|
||||
}
|
||||
|
||||
function _common_path($relative, $ssl=false)
|
||||
|
@@ -554,8 +554,8 @@ class TwitterImport
|
||||
}
|
||||
|
||||
// Move all the entities into order so we can
|
||||
// replace them in reverse order and thus
|
||||
// not mess up their indices
|
||||
// replace them and escape surrounding plaintext
|
||||
// in order
|
||||
|
||||
$toReplace = array();
|
||||
|
||||
@@ -577,56 +577,85 @@ class TwitterImport
|
||||
}
|
||||
}
|
||||
|
||||
// sort in reverse order by key
|
||||
// sort in forward order by key
|
||||
|
||||
krsort($toReplace);
|
||||
ksort($toReplace);
|
||||
|
||||
$result = '';
|
||||
$cursor = 0;
|
||||
|
||||
foreach ($toReplace as $part) {
|
||||
list($type, $object) = $part;
|
||||
$start = $object->indices[0];
|
||||
$end = $object->indices[1];
|
||||
if ($cursor < $start) {
|
||||
// Copy in the preceding plaintext
|
||||
$result .= $this->twitEscape(mb_substr($text, $cursor, $start - $cursor));
|
||||
$cursor = $start;
|
||||
}
|
||||
$orig = $this->twitEscape(mb_substr($text, $start, $end - $start));
|
||||
switch($type) {
|
||||
case self::URL:
|
||||
$linkText = $this->makeUrlLink($object);
|
||||
$linkText = $this->makeUrlLink($object, $orig);
|
||||
break;
|
||||
case self::HASHTAG:
|
||||
$linkText = $this->makeHashtagLink($object);
|
||||
$linkText = $this->makeHashtagLink($object, $orig);
|
||||
break;
|
||||
case self::MENTION:
|
||||
$linkText = $this->makeMentionLink($object);
|
||||
$linkText = $this->makeMentionLink($object, $orig);
|
||||
break;
|
||||
default:
|
||||
$linkText = $orig;
|
||||
continue;
|
||||
}
|
||||
$text = mb_substr($text, 0, $object->indices[0]) . $linkText . mb_substr($text, $object->indices[1]);
|
||||
$result .= $linkText;
|
||||
$cursor = $end;
|
||||
}
|
||||
return $text;
|
||||
$last = $this->twitEscape(mb_substr($text, $cursor));
|
||||
$result .= $last;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function makeUrlLink($object)
|
||||
function twitEscape($str)
|
||||
{
|
||||
return "<a href='{$object->url}' class='extlink'>{$object->url}</a>";
|
||||
// Twitter seems to preemptive turn < and > into < and >
|
||||
// but doesn't for &, so while you may have some magic protection
|
||||
// against XSS by not bothing to escape manually, you still get
|
||||
// invalid XHTML. Thanks!
|
||||
//
|
||||
// Looks like their web interface pretty much sends anything
|
||||
// through intact, so.... to do equivalent, decode all entities
|
||||
// and then re-encode the special ones.
|
||||
return htmlspecialchars(html_entity_decode($str, ENT_COMPAT, 'UTF-8'));
|
||||
}
|
||||
|
||||
function makeHashtagLink($object)
|
||||
function makeUrlLink($object, $orig)
|
||||
{
|
||||
return "#" . self::tagLink($object->text);
|
||||
return "<a href='{$object->url}' class='extlink'>{$orig}</a>";
|
||||
}
|
||||
|
||||
function makeMentionLink($object)
|
||||
function makeHashtagLink($object, $orig)
|
||||
{
|
||||
return "@".self::atLink($object->screen_name, $object->name);
|
||||
return "#" . self::tagLink($object->text, substr($orig, 1));
|
||||
}
|
||||
|
||||
static function tagLink($tag)
|
||||
function makeMentionLink($object, $orig)
|
||||
{
|
||||
return "<a href='https://search.twitter.com/search?q=%23{$tag}' class='hashtag'>{$tag}</a>";
|
||||
return "@".self::atLink($object->screen_name, $object->name, substr($orig, 1));
|
||||
}
|
||||
|
||||
static function atLink($screenName, $fullName=null)
|
||||
static function tagLink($tag, $orig)
|
||||
{
|
||||
return "<a href='https://search.twitter.com/search?q=%23{$tag}' class='hashtag'>{$orig}</a>";
|
||||
}
|
||||
|
||||
static function atLink($screenName, $fullName, $orig)
|
||||
{
|
||||
if (!empty($fullName)) {
|
||||
return "<a href='http://twitter.com/#!/{$screenName}' title='{$fullName}'>{$screenName}</a>";
|
||||
return "<a href='http://twitter.com/#!/{$screenName}' title='{$fullName}'>{$orig}</a>";
|
||||
} else {
|
||||
return "<a href='http://twitter.com/#!/{$screenName}'>{$screenName}</a>";
|
||||
return "<a href='http://twitter.com/#!/{$screenName}'>{$orig}</a>";
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user