exit(1);
}
-require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+require_once __DIR__ . '/twitter.php';
/**
* Plugin for sending and importing Twitter statuses
*
* This class allows users to link their Twitter accounts
*
+ * Depends on Favorite plugin.
+ *
* @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
*/
class TwitterBridgePlugin extends Plugin
{
- const VERSION = STATUSNET_VERSION;
+ const VERSION = GNUSOCIAL_VERSION;
public $adminImportControl = false; // Should the 'import' checkbox be exposed in the admin panel?
/**
*
* Hook for RouterInitialized event.
*
- * @param Net_URL_Mapper $m path-to-action mapper
+ * @param URLMapper $m path-to-action mapper
*
* @return boolean hook return
*/
- function onRouterInitialized($m)
+ public function onRouterInitialized(URLMapper $m)
{
$m->connect('panel/twitter', array('action' => 'twitteradminpanel'));
*
* @return boolean hook return
*/
- function onStartEnqueueNotice($notice, &$transports)
+ function onStartEnqueueNotice(Notice $notice, array &$transports)
{
if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) {
// Avoid a possible loop
*
* @return boolean hook return
*/
- function onGetValidDaemons(&$daemons)
+ function onGetValidDaemons(array &$daemons)
{
if (self::hasKeys()) {
array_push(
*
* @return boolean hook return
*/
- function onEndInitializeQueueManager($manager)
+ function onEndInitializeQueueManager(QueueManager $manager)
{
if (self::hasKeys()) {
// Outgoing notices -> twitter
* @return boolean hook value
*/
- function onEndAdminPanelNav($nav)
+ function onEndAdminPanelNav(Menu $nav)
{
if (AdminPanelAction::canAdmin('twitter')) {
*
* @return boolean hook value
*/
- function onPluginVersion(&$versions)
+ function onPluginVersion(array &$versions)
{
$versions[] = array(
'name' => 'TwitterBridge',
// For saving the last-synched status of various timelines
// home_timeline, messages (in), messages (out), ...
- $schema->ensureTable('twitter_synch_status', Twitter_sync_status::schemaDef());
+ $schema->ensureTable('twitter_synch_status', Twitter_synch_status::schemaDef());
// For storing user-submitted flags on profiles
$schema->ensureTable('notice_to_status', Notice_to_status::schemaDef());
return true;
}
+
+ public function onEndShowHeadElements(Action $action)
+ {
+ if (!($action instanceof AttachmentAction)) {
+ return true;
+ }
+
+ /* Twitter card support. See https://dev.twitter.com/docs/cards */
+ /* @fixme: should we display twitter cards only for attachments posted
+ * by local users ? Seems mandatory to display twitter:creator
+ *
+ * Author: jbfavre
+ */
+ switch ($action->attachment->mimetype) {
+ case 'image/pjpeg':
+ case 'image/jpeg':
+ case 'image/jpg':
+ case 'image/png':
+ case 'image/gif':
+ $action->element('meta', array('name' => 'twitter:card',
+ 'content' => 'photo'),
+ null);
+ $action->element('meta', array('name' => 'twitter:url',
+ 'content' => common_local_url('attachment',
+ array('attachment' => $action->attachment->id))),
+ null );
+ $action->element('meta', array('name' => 'twitter:image',
+ 'content' => $action->attachment->url));
+ $action->element('meta', array('name' => 'twitter:title',
+ 'content' => $action->attachment->title));
+
+ $ns = new AttachmentNoticeSection($action);
+ $notices = $ns->getNotices();
+ $noticeArray = $notices->fetchAll();
+
+ // Should not have more than 1 notice for this attachment.
+ if( count($noticeArray) != 1 ) { break; }
+ $post = $noticeArray[0];
+
+ $flink = Foreign_link::getByUserID($post->profile_id, TWITTER_SERVICE);
+ if( $flink ) { // Our local user has registered Twitter Gateway
+ $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
+ if( $fuser ) { // Got nickname for local user's Twitter account
+ $action->element('meta', array('name' => 'twitter:creator',
+ 'content' => '@'.$fuser->nickname));
+ }
+ }
+ break;
+ default: break;
+ }
+
+ return true;
+ }
}