From ffe20bdf00070812250bce7eb73aaac5f93a9ebb Mon Sep 17 00:00:00 2001 From: Gabe Date: Mon, 31 Oct 2016 18:40:08 -0500 Subject: [PATCH 1/2] Add Polr to URL shortener preferences --- core/src/plugins/shorten.multi/manifest.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/plugins/shorten.multi/manifest.xml b/core/src/plugins/shorten.multi/manifest.xml index 6438d280b3..73c8ef3674 100755 --- a/core/src/plugins/shorten.multi/manifest.xml +++ b/core/src/plugins/shorten.multi/manifest.xml @@ -27,6 +27,10 @@ + + + + From 71921407f1ab83359b3625485b50a1c98952b988 Mon Sep 17 00:00:00 2001 From: Gabe Date: Mon, 31 Oct 2016 18:41:23 -0500 Subject: [PATCH 2/2] Add Polr URL shortener to MultiShortener.php --- .../plugins/shorten.multi/MultiShortener.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/core/src/plugins/shorten.multi/MultiShortener.php b/core/src/plugins/shorten.multi/MultiShortener.php index f1d4cb33b5..e68420317b 100644 --- a/core/src/plugins/shorten.multi/MultiShortener.php +++ b/core/src/plugins/shorten.multi/MultiShortener.php @@ -170,6 +170,31 @@ protected function generateLink(ContextInterface $ctx, $url){ return $shorturl; } break; + case 5: + if (!isSet($type["POLR_DOMAIN"])) { + $this->logError("Config", "polr Shortener : you must set the domain name"); + return null; + } + if (!isSet($type["POLR_APIKEY"])) { + $this->logError("Config", "polr Shortener : you must set the api key"); + return null; + } + $polr_domain = $type["POLR_DOMAIN"]; + $polr_api = $type["POLR_APIKEY"]; + $polr = 'http://'.$polr_domain.'/api/v2/action/shorten?key='.$polr_api.'&url='.$url; + $response = FileHelper::getRemoteContent($polr); + if (isSet($response)) { + $shorturl = $response; + if ($useidn) { + // WARNING: idn_to_utf8 requires php-idn module. + // WARNING: http_build_url requires php-pecl-http module. + $purl = parse_url($shorturl); + $purl['host'] = idn_to_utf8($purl['host']); + $shorturl = http_build_url($purl); + } + return $shorturl; + } + break; default: break;