X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Fpubsubhubbub%2Fpubsubhubbub.php;h=a7bd34c1926d6f012751b33a47ec4ed6514874ae;hb=a932f486f20f3daf8ad657d8d39a6d6c316e66eb;hp=03b6757bd3687f9f46c2402c72beb6f8641392bb;hpb=fc11ab2f290a3712b766d78fdbcd354625a35d0a;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php index 03b6757b..a7bd34c1 100644 --- a/plugins/pubsubhubbub/pubsubhubbub.php +++ b/plugins/pubsubhubbub/pubsubhubbub.php @@ -6,10 +6,13 @@ * PubSub is a protocol which fasten up RSS fetching: * - Every time a new link is posted, Shaarli notify the hub. * - The hub notify all feed subscribers that a new link has been posted. - * - Subscribers retrieve the new link. + * - Subscribers retrieve the new link. */ use pubsubhubbub\publisher\Publisher; +use Shaarli\Config\ConfigManager; +use Shaarli\Feed\FeedBuilder; +use Shaarli\Router; /** * Plugin init function - set the hub to the default appspot one. @@ -65,7 +68,7 @@ function hook_pubsubhubbub_save_link($data, $conf) $p = new Publisher($conf->get('plugins.PUBSUBHUB_URL')); $p->publish_update($feeds, $httpPost); } catch (Exception $e) { - error_log('Could not publish to PubSubHubbub: ' . $e->getMessage()); + error_log(sprintf(t('Could not publish to PubSubHubbub: %s'), $e->getMessage())); } return $data; @@ -81,7 +84,8 @@ function hook_pubsubhubbub_save_link($data, $conf) * * @throws Exception An error occurred. */ -function nocurl_http_post($url, $postString) { +function nocurl_http_post($url, $postString) +{ $params = array('http' => array( 'method' => 'POST', 'content' => $postString, @@ -91,11 +95,20 @@ function nocurl_http_post($url, $postString) { $context = stream_context_create($params); $fp = @fopen($url, 'rb', false, $context); if (!$fp) { - throw new Exception('Could not post to '. $url); + throw new Exception(sprintf(t('Could not post to %s'), $url)); } $response = @stream_get_contents($fp); if ($response === false) { - throw new Exception('Bad response from the hub '. $url); + throw new Exception(sprintf(t('Bad response from the hub %s'), $url)); } return $response; } + +/** + * This function is never called, but contains translation calls for GNU gettext extraction. + */ +function pubsubhubbub_dummy_translation() +{ + // meta + t('Enable PubSubHubbub feed publishing.'); +}