123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class SimpleUrlPlugin extends UrlShortenerPlugin
- {
- const PLUGIN_VERSION = '2.0.0';
- public $serviceUrl;
- function onInitializePlugin(){
- parent::onInitializePlugin();
- if(!isset($this->serviceUrl)){
-
- throw new Exception(_m('You must specify a serviceUrl.'));
- }
- }
- protected function shorten($url) {
- return $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
- }
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = array('name' => sprintf('SimpleUrl (%s)', $this->shortenerName),
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Craig Andrews',
- 'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/SimpleUrl',
- 'rawdescription' =>
-
- sprintf(_m('Uses <a href="http://%1$s/">%1$s</a> URL-shortener service.'),
- $this->shortenerName));
- return true;
- }
- }
|