1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/extlib/');
- class LRDDPlugin extends Plugin
- {
- const PLUGIN_VERSION = '2.0.0';
- public function onAutoload($cls)
- {
- switch ($cls) {
- case 'XML_XRD':
- require_once __DIR__ . '/extlib/XML/XRD.php';
- return false;
- }
- return parent::onAutoload($cls);
- }
- public function onStartDiscoveryMethodRegistration(Discovery $disco) {
- $disco->registerMethod('LRDDMethod_WebFinger');
- }
- public function onEndDiscoveryMethodRegistration(Discovery $disco) {
- $disco->registerMethod('LRDDMethod_HostMeta');
- $disco->registerMethod('LRDDMethod_LinkHeader');
- $disco->registerMethod('LRDDMethod_LinkHTML');
- }
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = array('name' => 'LRDD',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Mikael Nordfeldth',
- 'homepage' => GNUSOCIAL_ENGINE_URL,
-
- 'rawdescription' => _m('Implements LRDD support for GNU Social.'));
- return true;
- }
-
- public static function grab_profile_aliases(string $uri): ?array
- {
- $disco = new Discovery();
- $xrd = $disco->lookup($uri);
- $all_ids = array_merge([$xrd->subject], $xrd->aliases);
- if (!in_array($uri, $all_ids)) {
- $this->log(LOG_INFO, 'The original URI was not listed itself when doing discovery on it!');
- return null;
- }
- return $all_ids;
- }
- }
|