From 4d7ce7ea4f3300ade60f859a4b947d8ba4476ac5 Mon Sep 17 00:00:00 2001 From: Nick Liu <deltik@gmx.com> Date: Wed, 26 Feb 2020 22:12:11 +0100 Subject: [PATCH] Dynamically generated API documentation links for social_ui --- e107_plugins/social/admin_config.php | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/e107_plugins/social/admin_config.php b/e107_plugins/social/admin_config.php index 35d657f0f..547ad9881 100644 --- a/e107_plugins/social/admin_config.php +++ b/e107_plugins/social/admin_config.php @@ -146,20 +146,6 @@ class social_ui extends e_admin_ui { $this->prefs['sharing_providers']['writeParms']['optArray'][$k] = $k; } - - $this->social_external = array( - "Facebook" => "https://developers.facebook.com/apps", - "Twitter" => "https://dev.twitter.com/apps/new", - "Google" => "https://code.google.com/apis/console/", - "Live" => "https://manage.dev.live.com/ApplicationOverview.aspx", - "LinkedIn" => "https://www.linkedin.com/secure/developer", - "Foursquare" => "https://www.foursquare.com/oauth/", - "GitHub" => "https://github.com/settings/applications/new", - "Steam" => "http://steamcommunity.com/dev/apikey", - "Instagram" => "http://instagram.com/developer" - ); - - } @@ -410,7 +396,7 @@ class social_ui extends e_admin_ui $frm = e107::getForm(); $textKeys = ''; $textScope = ''; - $label = varset($this->social_external[$provider_name]) ? "<a class='e-tip' rel='external' title=' " . LAN_SOCIAL_ADMIN_10 . "' href='" . $this->social_external[$provider_name] . "'>" . $pretty_provider_name . "</a>" : $pretty_provider_name; + $label = varset(self::getApiDocumentationUrlFor($provider_name)) ? "<a class='e-tip' rel='external' title=' " . LAN_SOCIAL_ADMIN_10 . "' href='" . self::getApiDocumentationUrlFor($provider_name) . "'>" . $pretty_provider_name . "</a>" : $pretty_provider_name; $radio_label = strtolower($provider_name); $text = " <tr> @@ -505,6 +491,21 @@ class social_ui extends e_admin_ui } } + private static function getApiDocumentationUrlFor($providerName) + { + try + { + $class = "\Hybridauth\Provider\\$providerName"; + $reflection = new ReflectionClass($class); + $properties = $reflection->getDefaultProperties(); + return isset($properties['apiDocumentation']) ? $properties['apiDocumentation'] : null; + } + catch (ReflectionException $e) + { + return null; + } + } + private function generateAdminFormJs() { return <<<EOD