├── .gitignore ├── Gruntfile.js ├── Main.php ├── Pages ├── Account.php ├── Admin.php ├── Auth.php ├── Callback.php └── Deauth.php ├── README.md ├── composer.json ├── composer.lock ├── languages ├── fr_FR │ └── LC_MESSAGES │ │ └── twitter.po └── twitter.pot ├── package.json ├── plugin.ini └── templates └── default ├── account ├── twitter.tpl.php └── twitter │ └── menu.tpl.php ├── admin ├── twitter.tpl.php └── twitter │ └── menu.tpl.php ├── content └── syndication │ └── icon │ └── twitter.tpl.php └── onboarding └── connect └── twitter.tpl.php /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | 4 | Twitter/.idea/.name 5 | 6 | Twitter/.idea/Twitter.iml 7 | 8 | Twitter/.idea/codeStyleSettings.xml 9 | 10 | *.xml 11 | 12 | .idea/.name 13 | 14 | *.iml 15 | 16 | .AppleDouble 17 | 18 | /nbproject/ 19 | /vendor/ 20 | 21 | node_modules 22 | package-lock.json 23 | !package.json 24 | composer.lock 25 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample language Gruntfile. 3 | * 4 | * Copy this to your Known plugin root, rename to Gruntfile.js, and create a package.json 5 | * with an appropriate "name" variable (usually your package namespace). 6 | */ 7 | 8 | module.exports = function (grunt) { 9 | 10 | // Project configuration. 11 | grunt.initConfig({ 12 | pkg: grunt.file.readJSON('package.json'), 13 | }); 14 | 15 | // Build your language file 16 | grunt.registerTask('build-lang', '', function(){ 17 | 18 | const { execSync } = require('child_process'); 19 | 20 | var pot = grunt.config.get('pkg.name').toLowerCase() + '.pot'; 21 | 22 | console.log("Building language file as ./languages/" + pot); 23 | 24 | execSync('touch ./languages/' + pot); // Make sure it exists, if we're going to remove (for broken builds) 25 | execSync('rm ./languages/' + pot); // Remove existing 26 | 27 | execSync('find . -type f -regex ".*\.php" | php vendor/mapkyca/known-language-tools/buildpot.php >> ./languages/' + pot); 28 | 29 | }); 30 | 31 | }; -------------------------------------------------------------------------------- /Main.php: -------------------------------------------------------------------------------- 1 | brevity = new Brevity(); 17 | $this->brevity->setTargetLength(280); 18 | } 19 | 20 | function registerTranslations() { 21 | 22 | \Idno\Core\Idno::site()->language()->register( 23 | new \Idno\Core\GetTextTranslation( 24 | 'twitter', dirname(__FILE__) . '/languages/' 25 | ) 26 | ); 27 | } 28 | 29 | function registerPages() 30 | { 31 | // Auth URL 32 | \Idno\Core\Idno::site()->routes()->addRoute('twitter/auth', '\IdnoPlugins\Twitter\Pages\Auth'); 33 | // Deauth URL 34 | \Idno\Core\Idno::site()->routes()->addRoute('twitter/deauth', '\IdnoPlugins\Twitter\Pages\Deauth'); 35 | // Register the callback URL 36 | \Idno\Core\Idno::site()->routes()->addRoute('twitter/callback', '\IdnoPlugins\Twitter\Pages\Callback'); 37 | // Register admin settings 38 | \Idno\Core\Idno::site()->routes()->addRoute('admin/twitter', '\IdnoPlugins\Twitter\Pages\Admin'); 39 | // Register settings page 40 | \Idno\Core\Idno::site()->routes()->addRoute('account/twitter', '\IdnoPlugins\Twitter\Pages\Account'); 41 | 42 | /** Template extensions */ 43 | // Add menu items to account & administration screens 44 | \Idno\Core\Idno::site()->template()->extendTemplate('admin/menu/items', 'admin/twitter/menu'); 45 | \Idno\Core\Idno::site()->template()->extendTemplate('account/menu/items', 'account/twitter/menu'); 46 | \Idno\Core\Idno::site()->template()->extendTemplate('onboarding/connect/networks', 'onboarding/connect/twitter'); 47 | } 48 | 49 | function registerEventHooks() 50 | { 51 | 52 | \Idno\Core\Idno::site()->syndication()->registerService('twitter', function () { 53 | return $this->hasTwitter(); 54 | }, array('note', 'article', 'image', 'media', 'rsvp', 'bookmark', 'like', 'share')); 55 | 56 | \Idno\Core\Idno::site()->events()->addListener('user/auth/success', function (\Idno\Core\Event $event) { 57 | if ($this->hasTwitter()) { 58 | $twitter = \Idno\Core\Idno::site()->session()->currentUser()->twitter; 59 | if (is_array($twitter)) { 60 | foreach($twitter as $username => $details) { 61 | if (!in_array($username, ['user_token','user_secret','screen_name'])) { 62 | \Idno\Core\Idno::site()->syndication()->registerServiceAccount('twitter', $username, $username); 63 | } 64 | } 65 | if (array_key_exists('user_token', $twitter)) { 66 | \Idno\Core\Idno::site()->syndication()->registerServiceAccount('twitter', $twitter['screen_name'], $twitter['screen_name']); 67 | } 68 | } 69 | } 70 | }); 71 | 72 | // Activate syndication automatically, if replying to twitter 73 | \Idno\Core\Idno::site()->events()->addListener('syndication/selected/twitter', function (\Idno\Core\Event $event) { 74 | $eventdata = $event->data(); 75 | 76 | if (!empty($eventdata['reply-to'])) { 77 | $replyto = (array) $eventdata['reply-to']; 78 | foreach ($replyto as $url) { 79 | if (strpos(parse_url($url)['host'], 'twitter.com')!==false) 80 | $event->setResponse(true); 81 | } 82 | } 83 | }); 84 | 85 | // Push "notes" to Twitter 86 | \Idno\Core\Idno::site()->events()->addListener('post/note/twitter', function (\Idno\Core\Event $event) { 87 | $eventdata = $event->data(); 88 | if ($this->hasTwitter()) { 89 | $object = $eventdata['object']; 90 | if (!empty($eventdata['syndication_account'])) { 91 | $twitterAPI = $this->connect($eventdata['syndication_account']); 92 | $screenName = $eventdata['syndication_account']; 93 | } else { 94 | $twitterAPI = $this->connect(); 95 | $screenName = isset(\Idno\Core\Idno::site()->session()->currentUser()->twitter['screen_name']) 96 | ? \Idno\Core\Idno::site()->session()->currentUser()->twitter['screen_name'] 97 | : false; 98 | } 99 | 100 | $params = []; 101 | 102 | $status_full = trim($object->getDescription()); 103 | $status = preg_replace('/<[^\>]*>/', '', $status_full); //strip_tags($status_full); 104 | $status = str_replace("\r", '', $status); 105 | $status = html_entity_decode($status); 106 | 107 | // Find any Twitter status IDs in case we need to mark this as a reply to them 108 | $inreplytourls = array_merge((array) $object->inreplyto, (array) $object->syndicatedto); 109 | if ($inreplyto = self::findTwitterStatus($inreplytourls)) { 110 | $params['in_reply_to_status_id'] = $inreplyto['status_id']; 111 | 112 | // if inreplytoname is not in the status, and is not this user's name, then prepend it to the status 113 | $replyName = $inreplyto['screen_name']; 114 | if ($replyName 115 | && mb_strtolower($screenName) !== mb_strtolower($replyName) 116 | && mb_stristr($status, '@'.$replyName) === false) { 117 | $status = '@' . $replyName . ' ' . $status; 118 | } 119 | } 120 | 121 | // Permalink will be included if the status message is truncated 122 | $permalink = $object->getSyndicationURL(); 123 | // Add link to original post, if IndieWeb references have been requested 124 | $permashortlink = \Idno\Core\Idno::site()->config()->indieweb_reference ? $object->getShortURL() : false; 125 | $status = $this->brevity->shorten($status, $permalink, $permashortlink); 126 | 127 | //\Idno\Core\Idno::site()->logging()->debug("status after shortening: $status"); 128 | 129 | $params['status'] = trim($status); 130 | 131 | $response = $twitterAPI->request('POST', $twitterAPI->url('1.1/statuses/update'), $params); 132 | if (!empty($twitterAPI->response['response'])) { 133 | if ($json = json_decode($twitterAPI->response['response'])) { 134 | if (!empty($json->id_str)) { 135 | $object->setPosseLink('twitter', 'https://twitter.com/' . $json->user->screen_name . '/status/' . $json->id_str, '@' . $json->user->screen_name, $json->id_str, $json->user->screen_name); 136 | $object->save(); 137 | } else { 138 | \Idno\Core\Idno::site()->logging()->debug("Nothing was posted to Twitter: " . var_export($json,true)); 139 | //\Idno\Core\Idno::site()->logging()->log("Twitter tokens: " . var_export(\Idno\Core\Idno::site()->session()->currentUser()->twitter,true)); 140 | } 141 | } else { 142 | \Idno\Core\Idno::site()->logging()->error("Bad JSON from Twitter: " . var_export($json,true)); 143 | } 144 | } 145 | } 146 | }); 147 | 148 | // Function for articles, RSVPs etc 149 | $article_handler = function (\Idno\Core\Event $event) { 150 | if ($this->hasTwitter()) { 151 | $eventdata = $event->data(); 152 | $object = $eventdata['object']; 153 | if (!empty($eventdata['syndication_account'])) { 154 | $twitterAPI = $this->connect($eventdata['syndication_account']); 155 | } else { 156 | $twitterAPI = $this->connect(); 157 | } 158 | 159 | $status = html_entity_decode($status); 160 | $status = $this->brevity->shorten($object->getTitle(), $object->getSyndicationURL(), false, false, Brevity::FORMAT_ARTICLE); 161 | 162 | $params = array( 163 | 'status' => $status 164 | ); 165 | 166 | // Find any Twitter status IDs in case we need to mark this as a reply to them 167 | $inreplytourls = array_merge((array) $object->inreplyto, (array) $object->syndicatedto); 168 | if ($inreplyto = self::findTwitterStatus($inreplytourls)) { 169 | $params['in_reply_to_status_id'] = $inreplyto['status_id']; 170 | 171 | // if inreplytoname is not in the status, and is not this user's name, then prepend it to the status 172 | $replyName = $inreplyto['screen_name']; 173 | if ($replyName 174 | && mb_strtolower($screenName) !== mb_strtolower($replyName) 175 | && mb_stristr($status, '@'.$replyName) === false) { 176 | $status = '@' . $replyName . ' ' . $status; 177 | } 178 | } 179 | 180 | $response = $twitterAPI->request('POST', $twitterAPI->url('1.1/statuses/update'), $params); 181 | 182 | if (!empty($twitterAPI->response['response'])) { 183 | if ($json = json_decode($twitterAPI->response['response'])) { 184 | if (!empty($json->id_str)) { 185 | $object->setPosseLink('twitter', 'https://twitter.com/' . $json->user->screen_name . '/status/' . $json->id_str, '@' . $json->user->screen_name, $json->id_str, $json->user->screen_name); 186 | $object->save(); 187 | } else { 188 | \Idno\Core\Idno::site()->logging()->error("Nothing was posted to Twitter: " . var_export($json,true)); 189 | } 190 | } else { 191 | \Idno\Core\Idno::site()->logging()->error("Bad JSON from Twitter: " . var_export($json,true)); 192 | } 193 | } 194 | 195 | } 196 | }; 197 | 198 | // Push "articles" and "rsvps" to Twitter 199 | \Idno\Core\Idno::site()->events()->addListener('post/article/twitter', $article_handler); 200 | \Idno\Core\Idno::site()->events()->addListener('post/rsvp/twitter', $article_handler); 201 | \Idno\Core\Idno::site()->events()->addListener('post/bookmark/twitter', $article_handler); 202 | 203 | // Push "media" to Twitter 204 | \Idno\Core\Idno::site()->events()->addListener('post/media/twitter', function (\Idno\Core\Event $event) { 205 | if ($this->hasTwitter()) { 206 | $eventdata = $event->data(); 207 | $object = $eventdata['object']; 208 | if (!empty($eventdata['syndication_account'])) { 209 | $twitterAPI = $this->connect($eventdata['syndication_account']); 210 | } else { 211 | $twitterAPI = $this->connect(); 212 | } 213 | 214 | // format as an "article" because we're just tweeting the title, with more content at the original url 215 | $status = html_entity_decode($status); 216 | $status = $this->brevity->shorten($object->getTitle(), $object->getSyndicationURL(), false, false, Brevity::FORMAT_ARTICLE); 217 | 218 | $params = array( 219 | 'status' => $status 220 | ); 221 | 222 | $response = $twitterAPI->request('POST', $twitterAPI->url('1.1/statuses/update'), $params); 223 | 224 | if (!empty($twitterAPI->response['response'])) { 225 | if ($json = json_decode($twitterAPI->response['response'])) { 226 | if (!empty($json->id_str)) { 227 | $object->setPosseLink('twitter', 'https://twitter.com/' . $json->user->screen_name . '/status/' . $json->id_str, '@' . $json->user->screen_name, $json->id_str, $json->user->screen_name); 228 | $object->save(); 229 | } else { 230 | \Idno\Core\Idno::site()->logging()->error("Nothing was posted to Twitter: " . var_export($json,true)); 231 | } 232 | } else { 233 | \Idno\Core\Idno::site()->logging()->error("Bad JSON from Twitter: " . var_export($json,true)); 234 | } 235 | } 236 | 237 | } 238 | }); 239 | 240 | // Push "images" to Twitter 241 | \Idno\Core\Idno::site()->events()->addListener('post/image/twitter', function (\Idno\Core\Event $event) { 242 | if ($this->hasTwitter()) { 243 | $eventdata = $event->data(); 244 | $object = $eventdata['object']; 245 | if (!empty($eventdata['syndication_account'])) { 246 | $twitterAPI = $this->connect($eventdata['syndication_account']); 247 | } else { 248 | $twitterAPI = $this->connect(); 249 | } 250 | $status = $object->getTitle(); 251 | if ($status == 'Untitled') { 252 | $status = ''; 253 | } 254 | 255 | $status = html_entity_decode($status); 256 | $status = $this->brevity->shorten($status, $object->getSyndicationURL(), false, false, Brevity::FORMAT_NOTE_WITH_MEDIA); 257 | 258 | // Let's first try getting the thumbnail 259 | if (!empty($object->thumbnail_id)) { 260 | if ($thumb = (array)\Idno\Entities\File::getByID($object->thumbnail_id)) { 261 | $attachments = array($thumb['file']); 262 | } 263 | } 264 | 265 | // No? Then we'll use the main event 266 | if (empty($attachments)) { 267 | $attachments = $object->getAttachments(); 268 | } 269 | 270 | if (!empty($attachments)) { 271 | foreach ($attachments as $attachment) { 272 | if ($bytes = \Idno\Entities\File::getFileDataFromAttachment($attachment)) { 273 | $media = array(); 274 | $filename = tempnam(sys_get_temp_dir(), 'idnotwitter'); 275 | file_put_contents($filename, $bytes); 276 | $media['media_data'] = base64_encode(file_get_contents($filename)); 277 | $params = $media; 278 | $response = $twitterAPI->request('POST', ('https://upload.twitter.com/1.1/media/upload.json'), $params, true, true); 279 | \Idno\Core\Idno::site()->logging()->debug($response); 280 | $json = json_decode($twitterAPI->response['response']); 281 | if (isset($json->media_id_string)) { 282 | $media_id[] = $json->media_id_string; 283 | \Idno\Core\Idno::site()->logging()->error("Twitter media_id : " . $json->media_id); 284 | } else { 285 | /*{"errors":[{"message":"Sorry, that page does not exist","code":34}]}*/ 286 | if (isset($json->errors)){ 287 | $message[] = $json->errors; 288 | $twitter_error = $message['message']." (code ".$message['code'].")"; 289 | } 290 | \Idno\Core\Idno::site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_("We couldn't upload your photo to Twitter. Twitter's response: %s.", [$twitter_error])); 291 | } 292 | } 293 | } 294 | } 295 | 296 | if (!empty($media_id)) { 297 | $id = implode(',', $media_id); 298 | $params = array('status' => $status, 299 | 'media_ids' => "{$id}"); 300 | 301 | // Find any Twitter status IDs in case we need to mark this as a reply to them 302 | $inreplytourls = array_merge((array) $object->inreplyto, (array) $object->syndicatedto); 303 | if ($inreplyto = self::findTwitterStatus($inreplytourls)) { 304 | $params['in_reply_to_status_id'] = $inreplyto['status_id']; 305 | 306 | // if inreplytoname is not in the status, and is not this user's name, then prepend it to the status 307 | $replyName = $inreplyto['screen_name']; 308 | if ($replyName 309 | && mb_strtolower($screenName) !== mb_strtolower($replyName) 310 | && mb_stristr($status, '@'.$replyName) === false) { 311 | $status = '@' . $replyName . ' ' . $status; 312 | } 313 | } 314 | 315 | try { 316 | $response = $twitterAPI->request('POST', ('https://api.twitter.com/1.1/statuses/update.json'), $params, true, false); 317 | \Idno\Core\Idno::site()->logging()->debug("JSON from Twitter: " . var_export($twitterAPI->response['response'], true)); 318 | } catch (\Exception $e) { 319 | \Idno\Core\Idno::site()->logging()->error($e->getMessage()); 320 | } 321 | } 322 | /*$code = $twitterAPI->request( 'POST','https://upload.twitter.com/1.1/statuses/update_with_media', 323 | $params, 324 | true, // use auth 325 | true // multipart 326 | );*/ 327 | 328 | @unlink($filename); 329 | 330 | if (!empty($twitterAPI->response['response'])) { 331 | if ($json = json_decode($twitterAPI->response['response'])) { 332 | if (!empty($json->id_str)) { 333 | $object->setPosseLink('twitter', 'https://twitter.com/' . $json->user->screen_name . '/status/' . $json->id_str, '@' . $json->user->screen_name, $json->id_str, $json->user->screen_name); 334 | $object->save(); 335 | } else { 336 | \Idno\Core\Idno::site()->logging()->error("Nothing was posted to Twitter: " . var_export($json,true)); 337 | } 338 | } else { 339 | \Idno\Core\Idno::site()->logging()->error("Bad JSON from Twitter: " . var_export($json,true)); 340 | } 341 | } 342 | 343 | } 344 | }); 345 | 346 | // Push "likes" to Twitter 347 | \Idno\Core\Idno::site()->events()->addListener('post/like/twitter', function (\Idno\Core\Event $event) { 348 | $eventdata = $event->data(); 349 | if ($this->hasTwitter()) { 350 | $object = $eventdata['object']; 351 | if (!empty($eventdata['syndication_account'])) { 352 | $twitterAPI = $this->connect($eventdata['syndication_account']); 353 | } else { 354 | $twitterAPI = $this->connect(); 355 | } 356 | 357 | $params = array(); 358 | // Find the status ID of the tweet that was liked 359 | $likeofurls = array_merge((array) $object->likeof, (array) $object->syndicatedto); 360 | if ($likeof = self::findTwitterStatus($likeofurls)) { 361 | $params['id'] = $likeof['status_id']; 362 | } 363 | else { 364 | \Idno\Core\Idno::site()->logging()->error("Could not find a status to like"); 365 | return; 366 | } 367 | 368 | $response = $twitterAPI->request('POST', $twitterAPI->url('1.1/favorites/create'), $params); 369 | if (!empty($twitterAPI->response['response'])) { 370 | if ($json = json_decode($twitterAPI->response['response'])) { 371 | // not much to be done with the result but log it 372 | \Idno\Core\Idno::site()->logging()->log("Successfully posted like to Twitter: " . var_export($json, true)); 373 | } else { 374 | \Idno\Core\Idno::site()->logging()->error("Bad JSON response when posting a like to Twitter: " . $twitterAPI->response['response']); 375 | } 376 | } 377 | } 378 | }); 379 | 380 | // Push "shares" (reposts) to Twitter 381 | \Idno\Core\Idno::site()->events()->addListener('post/share/twitter', function (\Idno\Core\Event $event) { 382 | $eventdata = $event->data(); 383 | if ($this->hasTwitter()) { 384 | $object = $eventdata['object']; 385 | if (!empty($eventdata['syndication_account'])) { 386 | $twitterAPI = $this->connect($eventdata['syndication_account']); 387 | } else { 388 | $twitterAPI = $this->connect(); 389 | } 390 | 391 | $params = array(); 392 | // Find the status ID of the tweet that was reposted 393 | $repostofurls = array_merge((array) $object->repostof, (array) $object->syndicatedto); 394 | if ($repostof = self::findTwitterStatus($repostofurls)) { 395 | $params['id'] = $repostof['status_id']; 396 | } else { 397 | \Idno\Core\Idno::site()->logging()->error("Could not find a status to retweet"); 398 | return; 399 | } 400 | 401 | \Idno\Core\Idno::site()->logging()->log('Retweeting with: ' . var_export($params, true)); 402 | $response = $twitterAPI->request('POST', $twitterAPI->url('1.1/statuses/retweet'), $params); 403 | if (!empty($twitterAPI->response['response'])) { 404 | if ($json = json_decode($twitterAPI->response['response'])) { 405 | if (!empty($json->id_str) && !empty($json->user)) { 406 | $object->setPosseLink('twitter', 'https://twitter.com/' . $json->user->screen_name . '/status/' . $json->id_str, '@' . $json->user->screen_name, $json->id_str, $json->user->screen_name); 407 | $object->save(); 408 | \Idno\Core\Idno::site()->logging()->log("Successful retweet: " . var_export($json, true)); 409 | } else { 410 | \Idno\Core\Idno::site()->logging()->error("Bad reponse to retweet: " . var_export($json, true)); 411 | } 412 | } else { 413 | \Idno\Core\Idno::site()->logging()->error("Bad JSON response to retweet: " . $twitterAPI->response['response']); 414 | } 415 | } 416 | } 417 | }); 418 | } 419 | 420 | /** 421 | * Search a list of URLs for one that looks like a Tweet 422 | * permalink and return an array with the Tweet's 423 | * 'status_id' and 'screen_name'. 424 | * @param array urls 425 | * @return array or false 426 | */ 427 | private static function findTwitterStatus($urls) 428 | { 429 | foreach ($urls as $url) { 430 | if (preg_match('/(www\.|m\.)?twitter.com/i', parse_url($url, PHP_URL_HOST))) { 431 | $path = explode('/', parse_url($url, PHP_URL_PATH)); 432 | if (count($path) >= 4) { 433 | return [ 434 | 'screen_name' => $path[1], 435 | 'status_id' => $path[3], 436 | ]; 437 | } 438 | } 439 | } 440 | return false; 441 | } 442 | 443 | /** 444 | * Retrieve the OAuth authentication URL for the API 445 | * @return string 446 | */ 447 | function getAuthURL() 448 | { 449 | $twitter = $this; 450 | $twitterAPI = $twitter->connect(); 451 | if (!$twitterAPI) { 452 | return ''; 453 | } 454 | $code = $twitterAPI->request('POST', $twitterAPI->url('oauth/request_token', ''), array('oauth_callback' => \Idno\Core\Idno::site()->config()->getDisplayURL() . 'twitter/callback', 'x_auth_access_type' => 'write')); 455 | if ($code == 200) { 456 | $oauth = $twitterAPI->extract_params($twitterAPI->response['response']); 457 | \Idno\Core\Idno::site()->session()->set('oauth', $oauth); // Save OAuth to the session 458 | $oauth_url = $twitterAPI->url("oauth/authorize", '') . "?oauth_token={$oauth['oauth_token']}"; 459 | } else { 460 | $oauth_url = ''; 461 | } 462 | 463 | return $oauth_url; 464 | } 465 | 466 | /** 467 | * Returns a new Twitter OAuth connection object, if credentials have been added through administration 468 | * and it's possible to connect 469 | * 470 | * @param $username If supplied, attempts to connect with this username 471 | * @return bool|\tmhOAuth 472 | */ 473 | function connect($username = false) 474 | { 475 | if (!empty(\Idno\Core\Idno::site()->config()->twitter)) { 476 | $params = array( 477 | 'consumer_key' => \Idno\Core\Idno::site()->config()->twitter['consumer_key'], 478 | 'consumer_secret' => \Idno\Core\Idno::site()->config()->twitter['consumer_secret'], 479 | ); 480 | if (!empty($username) && !empty(\Idno\Core\Idno::site()->session()->currentUser()->twitter[$username])) { 481 | $params = array_merge($params, \Idno\Core\Idno::site()->session()->currentUser()->twitter[$username]); 482 | } else if (!empty(\Idno\Core\Idno::site()->session()->currentUser()->twitter['user_token']) && ($username == \Idno\Core\Idno::site()->session()->currentUser()->twitter['screen_name'] || empty($username))) { 483 | $params['user_token'] = \Idno\Core\Idno::site()->session()->currentUser()->twitter['user_token']; 484 | $params['user_secret'] = \Idno\Core\Idno::site()->session()->currentUser()->twitter['user_secret']; 485 | $params['screen_name'] = \Idno\Core\Idno::site()->session()->currentUser()->twitter['screen_name']; 486 | } 487 | 488 | return new \tmhOAuth($params); 489 | } 490 | 491 | return false; 492 | } 493 | 494 | /** 495 | * Can the current user use Twitter? 496 | * @return bool 497 | */ 498 | function hasTwitter() 499 | { 500 | if (!\Idno\Core\Idno::site()->session()->currentUser()) { 501 | return false; 502 | } 503 | if (!empty(\Idno\Core\Idno::site()->session()->currentUser()->twitter)) { 504 | if (is_array(\Idno\Core\Idno::site()->session()->currentUser()->twitter)) { 505 | $accounts = 0; 506 | foreach(\Idno\Core\Idno::site()->session()->currentUser()->twitter as $username => $value) { 507 | if ($username != 'user_token') { 508 | $accounts++; 509 | } 510 | } 511 | if ($accounts > 0) { 512 | return true; 513 | } 514 | } 515 | return true; 516 | } 517 | 518 | return false; 519 | } 520 | 521 | } 522 | 523 | } 524 | -------------------------------------------------------------------------------- /Pages/Account.php: -------------------------------------------------------------------------------- 1 | gatekeeper(); // Logged-in users only 18 | /*if ($twitter = \Idno\Core\site()->plugins()->get('Twitter')) { 19 | $oauth_url = $twitter->getAuthURL(); 20 | }*/ 21 | $oauth_url = \Idno\Core\site()->config()->getDisplayURL() . 'twitter/auth'; 22 | $t = \Idno\Core\site()->template(); 23 | $body = $t->__(array('oauth_url' => $oauth_url))->draw('account/twitter'); 24 | $t->__(array('title' => 'Twitter', 'body' => $body))->drawPage(); 25 | } 26 | 27 | function postContent() { 28 | $this->gatekeeper(); // Logged-in users only 29 | if (($this->getInput('remove'))) { 30 | $rm = $this->getInput('remove'); 31 | $user = \Idno\Core\site()->session()->currentUser(); 32 | if($rm === '1') { 33 | $user->twitter = array(); // wipes all credentials 34 | } else { 35 | unset($user->twitter[$rm]); // wipes specific credentials 36 | } 37 | $user->save(); 38 | \Idno\Core\site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_('Your Twitter settings have been removed from your account.')); 39 | } 40 | $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/twitter/'); 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Pages/Admin.php: -------------------------------------------------------------------------------- 1 | adminGatekeeper(); // Admins only 18 | $t = \Idno\Core\site()->template(); 19 | $body = $t->draw('admin/twitter'); 20 | $t->__(array('title' => 'Twitter', 'body' => $body))->drawPage(); 21 | } 22 | 23 | function postContent() { 24 | $this->adminGatekeeper(); // Admins only 25 | $consumer_key = trim($this->getInput('consumer_key')); 26 | $consumer_secret = trim($this->getInput('consumer_secret')); 27 | \Idno\Core\site()->config()->config['twitter'] = array( 28 | 'consumer_key' => $consumer_key, 29 | 'consumer_secret' => $consumer_secret 30 | ); 31 | \Idno\Core\site()->config()->save(); 32 | \Idno\Core\site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_('Your Twitter application details were saved.')); 33 | $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'admin/twitter/'); 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Pages/Auth.php: -------------------------------------------------------------------------------- 1 | gatekeeper(); // Logged-in users only 18 | if ($twitter = \Idno\Core\site()->plugins()->get('Twitter')) { 19 | $login_url = $twitter->getAuthURL(); 20 | if (!empty($login_url)) { 21 | $this->forward($login_url); exit; 22 | } 23 | } 24 | $this->forward($_SERVER['HTTP_REFERER']); 25 | } 26 | 27 | function postContent() { 28 | $this->getContent(); 29 | } 30 | 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Pages/Callback.php: -------------------------------------------------------------------------------- 1 | gatekeeper(); // Logged-in users only 18 | if ($token = $this->getInput('oauth_token')) { 19 | if ($twitter = \Idno\Core\site()->plugins()->get('Twitter')) { 20 | $twitterAPI = $twitter->connect(); 21 | $twitterAPI->config['user_token'] = \idno\Core\site()->session()->get('oauth')['oauth_token']; 22 | $twitterAPI->config['user_secret'] = \idno\Core\site()->session()->get('oauth')['oauth_token_secret']; 23 | 24 | $decoded = urldecode($this->getInput('oauth_verifier')); 25 | 26 | if (!mb_check_encoding($decoded, 'UTF-8')) { 27 | $decoded = utf8_encode($decoded); 28 | } 29 | 30 | $code = $twitterAPI->request('POST', $twitterAPI->url('oauth/access_token', ''), array( 31 | 'oauth_verifier' => urldecode($decoded) 32 | )); 33 | if ($code == 200) { 34 | $access_token = $twitterAPI->extract_params($twitterAPI->response['response']); 35 | \Idno\Core\site()->session()->remove('oauth'); 36 | $user = \Idno\Core\site()->session()->currentUser(); 37 | \Idno\Core\site()->syndication()->registerServiceAccount('twitter', $access_token['screen_name'], '@' . $access_token['screen_name']); 38 | $user->twitter[$access_token['screen_name']] = array('user_token' => $access_token['oauth_token'], 'user_secret' => $access_token['oauth_token_secret'], 'screen_name' => $access_token['screen_name']); 39 | $user->save(); 40 | \Idno\Core\site()->session()->addMessage(\Idno\Core\Idno::site()->language()->_('Your Twitter credentials were saved.')); 41 | } 42 | else { 43 | \Idno\Core\site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_('Your Twitter credentials could not be saved.')); 44 | } 45 | 46 | if (!empty($_SESSION['onboarding_passthrough'])) { 47 | unset($_SESSION['onboarding_passthrough']); 48 | $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'begin/connect-forwarder'); 49 | } 50 | $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/twitter'); 51 | } 52 | } 53 | } 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Pages/Deauth.php: -------------------------------------------------------------------------------- 1 | gatekeeper(); // Logged-in users only 18 | if ($twitter = \Idno\Core\site()->plugins()->get('Twitter')) { 19 | if ($user = \Idno\Core\site()->session()->currentUser()) { 20 | if ($remove = $this->getInput('remove')) { 21 | if (is_array($user->twitter)) { 22 | if (array_key_exists($remove, $user->twitter)) { 23 | unset($user->twitter[$remove]); 24 | } 25 | } else { 26 | $user->twitter = false; 27 | } 28 | } else { 29 | $user->twitter = false; 30 | } 31 | $user->save(); 32 | \Idno\Core\site()->session()->refreshSessionUser($user); 33 | if (!empty($user->link_callback)) { 34 | error_log($user->link_callback); 35 | $this->forward($user->link_callback); exit; 36 | } 37 | } 38 | } 39 | $this->forward($_SERVER['HTTP_REFERER']); 40 | } 41 | 42 | function postContent() { 43 | $this->getContent(); 44 | } 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Twitter for Known 2 | ================= 3 | 4 | This plugin provides POSSE support for Known. 5 | 6 | Installation 7 | ------------ 8 | 9 | * Drop the Twitter folder into the IdnoPlugins folder of your Known installation. 10 | * You need to run ``composer install`` or ``composer update`` if you're updating in the Twitter folder so PHP Composer will download and install the dependencies. (see "Vendor" folder) 11 | * Log into Known and click **Site Configuration**. 12 | * On the **Site Features** tab, click **Enable** next to Twitter. A **Twitter** 13 | entry is added to the site configuration menu. 14 | * Click **Twitter** in the site configuration menu. Set up your custom Twitter 15 | application, which will post tweets for your Known instance, and save the API 16 | key and API secret. 17 | 18 | Once you have installed and configured the Twitter plugin, each user of your 19 | Known instance will be able to set up Twitter syndication support using the 20 | **Twitter** entry in the user settings menu. 21 | 22 | License 23 | ------- 24 | 25 | Released under the Apache 2.0 license: http://www.apache.org/licenses/LICENSE-2.0.html 26 | 27 | Contains 28 | -------- 29 | 30 | Also contains tmhOAuth, which is released under the Apache 2.0 license. Source: http://www.apache.org/licenses/LICENSE-2.0.html 31 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "idno/twitter", 3 | "type": "known-plugin", 4 | "description": "Cross-post site content to Twitter. Contains Matt Harris's Twitter library, released under the Apache 2.0 license.", 5 | "version": "1.0.0", 6 | "prefer-stable": true, 7 | "minimum-stability": "dev", 8 | "require": { 9 | "kylewm/brevity": "^0.2.10", 10 | "themattharris/tmhoauth": "^0.8.4", 11 | "composer/installers": "~1.0" 12 | }, 13 | "require-dev": { 14 | "mapkyca/known-language-tools": "^1.0", 15 | "mapkyca/known-dev-scripts": "^1.0" 16 | }, 17 | "extra": { 18 | "installer-name": "Twitter" 19 | } 20 | } -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "43d8e288f0245d310950a0bd03da6571", 8 | "packages": [ 9 | { 10 | "name": "kylewm/brevity", 11 | "version": "0.2.10", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/kylewm/brevity-php.git", 15 | "reference": "9700a3ca666ff9486bd8bed322d7096ef78b6580" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/kylewm/brevity-php/zipball/9700a3ca666ff9486bd8bed322d7096ef78b6580", 20 | "reference": "9700a3ca666ff9486bd8bed322d7096ef78b6580", 21 | "shasum": "" 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit": "^4.8" 25 | }, 26 | "type": "library", 27 | "autoload": { 28 | "psr-0": { 29 | "Kylewm\\Brevity": "src/" 30 | } 31 | }, 32 | "notification-url": "https://packagist.org/downloads/", 33 | "license": [ 34 | "CC0" 35 | ], 36 | "authors": [ 37 | { 38 | "name": "Kyle Mahan", 39 | "email": "kyle+brevityphp@kylewm.com" 40 | } 41 | ], 42 | "description": "A small utility to count characters and shorten posts to tweet-length.", 43 | "time": "2017-11-25T19:51:26+00:00" 44 | }, 45 | { 46 | "name": "themattharris/tmhoauth", 47 | "version": "0.8.4", 48 | "source": { 49 | "type": "git", 50 | "url": "https://github.com/themattharris/tmhOAuth.git", 51 | "reference": "455552d6c57549632644b6c9ac9204766be2b5ee" 52 | }, 53 | "dist": { 54 | "type": "zip", 55 | "url": "https://api.github.com/repos/themattharris/tmhOAuth/zipball/455552d6c57549632644b6c9ac9204766be2b5ee", 56 | "reference": "455552d6c57549632644b6c9ac9204766be2b5ee", 57 | "shasum": "" 58 | }, 59 | "require": { 60 | "ext-curl": "*", 61 | "php": ">=5.3.0" 62 | }, 63 | "type": "library", 64 | "autoload": { 65 | "psr-0": { 66 | "tmhOAuth": "" 67 | } 68 | }, 69 | "notification-url": "https://packagist.org/downloads/", 70 | "license": [ 71 | "Apache-2.0" 72 | ], 73 | "authors": [ 74 | { 75 | "name": "themattharris", 76 | "email": "matt@themattharris.com", 77 | "role": "Developer" 78 | } 79 | ], 80 | "description": "An OAuth library written in PHP by @themattharris", 81 | "keywords": [ 82 | "oauth", 83 | "twitter" 84 | ], 85 | "time": "2014-08-06T22:29:35+00:00" 86 | } 87 | ], 88 | "packages-dev": [], 89 | "aliases": [], 90 | "minimum-stability": "dev", 91 | "stability-flags": [], 92 | "prefer-stable": true, 93 | "prefer-lowest": false, 94 | "platform": [], 95 | "platform-dev": [] 96 | } 97 | -------------------------------------------------------------------------------- /languages/fr_FR/LC_MESSAGES/twitter.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "POT-Creation-Date: \n" 5 | "PO-Revision-Date: \n" 6 | "Language-Team: \n" 7 | "MIME-Version: 1.0\n" 8 | "Content-Type: text/plain; charset=UTF-8\n" 9 | "Content-Transfer-Encoding: 8bit\n" 10 | "X-Generator: Poedit 2.2.4\n" 11 | "Last-Translator: \n" 12 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 13 | "Language: fr_FR\n" 14 | 15 | #: ./Main.php:276 16 | msgid "We couldn't upload your photo to Twitter. Twitter's response: %s." 17 | msgstr "Nous n’avons pas pu télécharger votre photo sur Twitter. Réponse de Twitter: %s." 18 | 19 | #: ./Pages/Account.php:33 20 | msgid "Your Twitter settings have been removed from your account." 21 | msgstr "Votre paramètres Twitter ont été supprimés de votre compte." 22 | 23 | #: ./Pages/Admin.php:32 24 | msgid "Your Twitter application details were saved." 25 | msgstr "Les détails de votre application Twitter ont été sauvegardés." 26 | 27 | #: ./Pages/Callback.php:40 28 | msgid "Your Twitter credentials were saved." 29 | msgstr "Vos informations d'identification Twitter ont été enregistrées." 30 | 31 | #: ./Pages/Callback.php:43 32 | msgid "Your Twitter credentials could not be saved." 33 | msgstr "Vos informations d'identification Twitter n'ont pas pu être sauvegardées." 34 | 35 | #: ./templates/default/account/twitter.tpl.php:28 36 | msgid "Easily share updates, posts, and pictures to Twitter." 37 | msgstr "Partagez facilement des mises à jour, des publications et des photos sur Twitter." 38 | 39 | #: ./templates/default/account/twitter.tpl.php:30 40 | msgid "With Twitter connected, you can cross-post content that you publish publicly on your site." 41 | msgstr "Avec Twitter connecté, vous pouvez publier du contenu que vous publiez publiquement sur votre site." 42 | 43 | #: ./templates/default/account/twitter.tpl.php:37 44 | msgid "Connect Twitter" 45 | msgstr "Connectez Twitter" 46 | 47 | #: ./templates/default/account/twitter.tpl.php:57 48 | msgid "Your account is currently connected to Twitter. Public content that you publish here can be cross-posted to your Twitter account." 49 | msgstr "Votre compte est actuellement connecté au Twitter. Les mises à jour publiques, les photos et les publications que vous publiez ici peuvent être cross-posted (renvoit multiples)." 50 | 51 | #: ./templates/default/account/twitter.tpl.php:65 52 | msgid "Disconnect Twitter" 53 | msgstr "Déconnecter Twitter" 54 | 55 | #: ./templates/default/account/twitter.tpl.php:85 56 | msgid "You have connected the below accounts to Twitter. Public content that you publish here can be cross-posted to your Twitter account." 57 | msgstr "Vous avez connecté les comptes ci-dessous à Twitter. Les mises à jour publiques, les photos et les publications que vous publiez ici peuvent être cross-posted (renvoit multiples)." 58 | 59 | #: ./templates/default/account/twitter.tpl.php:101 60 | msgid "Disconnect" 61 | msgstr "Débrancher" 62 | 63 | #: ./templates/default/account/twitter.tpl.php:113 64 | msgid "Add another Twitter account" 65 | msgstr "Ajouter un autre compte Twitter" 66 | 67 | #: ./templates/default/account/twitter.tpl.php:141 68 | msgid "Before you can begin connecting to Twitter, you need to set it up." 69 | msgstr "Avant de commencer à vous connecter à Twitter, vous devez le configurer." 70 | 71 | #: ./templates/default/account/twitter.tpl.php:144 72 | msgid "Click here to begin Twitter configuration." 73 | msgstr "Cliquez ici pour commencer la configuration Twitter." 74 | 75 | #: ./templates/default/account/twitter.tpl.php:152 76 | msgid "The administrator has not finished setting up Twitter on this site. Please come back later." 77 | msgstr "L’administrateur n’a pas fini de configurer Twitter sur ce site. S’ll vous plaît, revenez plus tard." 78 | 79 | #: ./templates/default/admin/twitter.tpl.php:5 80 | msgid "Twitter configuration" 81 | msgstr "Configuration Twitter" 82 | 83 | #: ./templates/default/admin/twitter.tpl.php:16 84 | msgid "To begin using Twitter, create a new application in the Twitter developer portal" 85 | msgstr "Pour commencer à utiliser Twitter, créez une nouvelle application dans le portail des développeurs Twitter" 86 | 87 | #: ./templates/default/admin/twitter.tpl.php:18 88 | msgid "The callback URL should be set to:" 89 | msgstr "L’URL de rappel doit être réglé sur :" 90 | 91 | #: ./templates/default/admin/twitter.tpl.php:30 92 | msgid "Once you've finished, fill in the details below:" 93 | msgstr "Une fois que vous avez terminé, remplissez les détails ci-dessous :" 94 | 95 | #: ./templates/default/admin/twitter.tpl.php:32 96 | msgid "API key" 97 | msgstr "Clé API" 98 | 99 | #: ./templates/default/admin/twitter.tpl.php:38 100 | msgid "API secret" 101 | msgstr "Secret API" 102 | 103 | #: ./templates/default/admin/twitter.tpl.php:46 104 | msgid "After the Twitter application is configured, site users must authenticate their Twitter account under Settings." 105 | msgstr "Une fois l’application Twitter configurée, les utilisateurs du site doivent authentifier leur compte Twitter sous Paramètres." 106 | 107 | #: ./templates/default/admin/twitter.tpl.php:53 108 | msgid "Save settings" 109 | msgstr "Enregistre paramètres" 110 | 111 | # Known localisation covers above 112 | 113 | -------------------------------------------------------------------------------- /languages/twitter.pot: -------------------------------------------------------------------------------- 1 | #: ./Pages/Account.php:33 2 | msgid "Your Twitter settings have been removed from your account." 3 | msgstr "" 4 | 5 | #: ./Pages/Callback.php:40 6 | msgid "Your Twitter credentials were saved." 7 | msgstr "" 8 | 9 | #: ./Pages/Callback.php:43 10 | msgid "Your Twitter credentials could not be saved." 11 | msgstr "" 12 | 13 | #: ./Pages/Admin.php:32 14 | msgid "Your Twitter application details were saved." 15 | msgstr "" 16 | 17 | #: ./templates/default/admin/twitter.tpl.php:5 18 | msgid "Twitter configuration" 19 | msgstr "" 20 | 21 | #: ./templates/default/admin/twitter.tpl.php:16 22 | msgid "To begin using Twitter, create a new application in the Twitter developer portal" 23 | msgstr "" 24 | 25 | #: ./templates/default/admin/twitter.tpl.php:18 26 | msgid "The callback URL should be set to:" 27 | msgstr "" 28 | 29 | #: ./templates/default/admin/twitter.tpl.php:30 30 | msgid "Once you\'ve finished, fill in the details below:" 31 | msgstr "" 32 | 33 | #: ./templates/default/admin/twitter.tpl.php:32 34 | msgid "API key" 35 | msgstr "" 36 | 37 | #: ./templates/default/admin/twitter.tpl.php:38 38 | msgid "API secret" 39 | msgstr "" 40 | 41 | #: ./templates/default/admin/twitter.tpl.php:46 42 | msgid "After the Twitter application is configured, site users must authenticate their Twitter account under Settings." 43 | msgstr "" 44 | 45 | #: ./templates/default/admin/twitter.tpl.php:53 46 | msgid "Save settings" 47 | msgstr "" 48 | 49 | #: ./templates/default/account/twitter.tpl.php:28 50 | msgid "Easily share updates, posts, and pictures to Twitter." 51 | msgstr "" 52 | 53 | #: ./templates/default/account/twitter.tpl.php:30 54 | msgid "With Twitter connected, you can cross-post content that you publish publicly on your site." 55 | msgstr "" 56 | 57 | #: ./templates/default/account/twitter.tpl.php:37 58 | msgid "Connect Twitter" 59 | msgstr "" 60 | 61 | #: ./templates/default/account/twitter.tpl.php:57 62 | msgid "Your account is currently connected to Twitter. Public content that you publish here can be cross-posted to your Twitter account." 63 | msgstr "" 64 | 65 | #: ./templates/default/account/twitter.tpl.php:65 66 | msgid "Disconnect Twitter" 67 | msgstr "" 68 | 69 | #: ./templates/default/account/twitter.tpl.php:85 70 | msgid "You have connected the below accounts to Twitter. Public content that you publish here can be cross-posted to your Twitter account." 71 | msgstr "" 72 | 73 | #: ./templates/default/account/twitter.tpl.php:101 74 | msgid "Disconnect" 75 | msgstr "" 76 | 77 | #: ./templates/default/account/twitter.tpl.php:113 78 | msgid "Add another Twitter account" 79 | msgstr "" 80 | 81 | #: ./templates/default/account/twitter.tpl.php:141 82 | msgid "Before you can begin connecting to Twitter, you need to set it up." 83 | msgstr "" 84 | 85 | #: ./templates/default/account/twitter.tpl.php:144 86 | msgid "Click here to begin Twitter configuration." 87 | msgstr "" 88 | 89 | #: ./templates/default/account/twitter.tpl.php:152 90 | msgid "The administrator has not finished setting up Twitter on this site. Please come back later." 91 | msgstr "" 92 | 93 | #: ./Main.php:276 94 | msgid "We couldn't upload your photo to Twitter. Twitter's response: %s." 95 | msgstr "" 96 | 97 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Twitter", 3 | "version": "1.0.0", 4 | "devDependencies": { 5 | "grunt": "^1.0.3" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /plugin.ini: -------------------------------------------------------------------------------- 1 | [Plugin description] 2 | name = 'Twitter' 3 | version = '1.0.0' 4 | author = 'Known' 5 | author_email = 'hello@withknown.com' 6 | author_url = 'https://withknown.com' 7 | description = 'Cross-post site content to Twitter. Contains Matt Harris’s Twitter library, released under the Apache 2.0 license.' 8 | -------------------------------------------------------------------------------- /templates/default/account/twitter.tpl.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | draw('account/menu')?> 5 |

Twitter

6 | 7 |
8 | 9 |
10 |
11 |
12 | config()->twitter['consumer_key']) && !empty(\Idno\Core\site()->config()->twitter['consumer_secret'])) { 15 | 16 | ?> 17 |
18 | session()->currentUser()->twitter)) { 20 | ?> 21 | 22 |
23 |
24 | 25 |
26 |
27 |

28 | language()->_('Easily share updates, posts, and pictures to Twitter.'); ?>

29 |

30 | language()->_('With Twitter connected, you can cross-post content that you publish publicly on your site.'); ?> 31 |

32 | 33 | 34 | 40 | 41 | 42 |
43 |
44 |
45 |
46 | 47 | config()->multipleSyndicationAccounts()) { 50 | 51 | ?> 52 |
53 |
54 |
55 |
56 |

57 | language()->_('Your account is currently connected to Twitter. Public content that you publish here can be cross-posted to your Twitter account.'); ?> 58 |

59 | 60 | 61 | 68 | 69 |
70 |
71 |
72 |
73 | 74 | 75 | 80 |
81 |
82 |
83 |
84 |

85 | language()->_('You have connected the below accounts to Twitter. Public content that you publish here can be cross-posted to your Twitter account.'); ?> 86 |

87 | 88 | syndication()->getServiceAccounts('twitter')) { 91 | 92 | foreach ($accounts as $account) { 93 | 94 | ?> 95 | 96 | 104 | 111 | 112 |

113 | language()->_('Add another Twitter account'); ?> 114 |

115 |
116 |
117 |
118 |
119 | 120 | 125 | 126 | actions()->signForm('/account/twitter/')?> 127 | 128 |
129 | session()->currentUser()->isAdmin()) { 134 | 135 | ?> 136 |
137 |
138 |
139 |
140 |

141 | language()->_('Before you can begin connecting to Twitter, you need to set it up.'); ?> 142 |

143 |

144 | language()->_('Click here to begin Twitter configuration.'); ?> 145 |

146 | 151 |

152 | language()->_('The administrator has not finished setting up Twitter on this site. Please come back later.'); ?> 153 |

154 |
155 |
156 |
157 |
158 | 159 | 166 |
167 |
168 | -------------------------------------------------------------------------------- /templates/default/account/twitter/menu.tpl.php: -------------------------------------------------------------------------------- 1 |
  • >Twitter
  • -------------------------------------------------------------------------------- /templates/default/admin/twitter.tpl.php: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 | draw('admin/menu')?> 5 |

    language()->_('Twitter configuration'); ?>

    6 | 7 |
    8 | 9 |
    10 |
    11 |
    12 |
    13 |
    14 |
    15 |

    16 | language()->_('To begin using Twitter, create a new application in the Twitter developer portal'); ?>.

    17 |

    18 | language()->_('The callback URL should be set to:'); ?> 19 |

    20 |

    21 | 22 |

    23 | 24 |
    25 |
    26 | 27 | 28 |
    29 |

    30 | language()->_('Once you\'ve finished, fill in the details below:'); ?> 31 |

    32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
    43 | 44 |
    45 |

    46 | language()->_('After the Twitter application is configured, site users must authenticate their Twitter account under Settings.'); ?> 47 |

    48 | 49 |
    50 | 51 |
    52 |
    53 | 54 |
    55 |
    56 | actions()->signForm('/admin/twitter/')?> 57 |
    58 |
    59 |
    60 | -------------------------------------------------------------------------------- /templates/default/admin/twitter/menu.tpl.php: -------------------------------------------------------------------------------- 1 |
  • >Twitter
  • 2 | -------------------------------------------------------------------------------- /templates/default/content/syndication/icon/twitter.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /templates/default/onboarding/connect/twitter.tpl.php: -------------------------------------------------------------------------------- 1 | session()->currentUser()->twitter)) { 4 | $login_url = \Idno\Core\site()->config()->getDisplayURL() . 'twitter/auth'; 5 | } else { 6 | $login_url = \Idno\Core\site()->config()->getDisplayURL() . 'twitter/deauth'; 7 | } 8 | 9 | ?> 10 |
    11 | Twittersession()->currentUser()->twitter)) { 20 | echo ' - connected!'; 21 | } 22 | 23 | ?> 24 | 25 |
    26 | --------------------------------------------------------------------------------