config = array(
'id' => 'default',
'name' => 'Default',
'home' => '',
'url_api' => SHORTEN_SERVICE_API,
'url_base' => SHORTEN_SERVICE_BASE,
'url_min_len' => strlen(SHORTEN_SERVICE_BASE) + 2,
'url_param' => SHORTEN_SERVICE_PARAM,
'url_encode' => SHORTEN_SERVICE_ENCODE
);
}
public function settingsForm()
{
echo
'
'.
__('There is nothing to configure for this service.').
'
'.
''.__('This service is set to:').'
'.
''.
'- '.__('Service name:').'
'.
'- '.SHORTEN_SERVICE_NAME.'
'.
'- '.__('Full API URL:').'
'.
'- '.SHORTEN_SERVICE_API.'
'.
'- '.__('Query param:').'
'.
'- '.SHORTEN_SERVICE_PARAM.'
'.
'- '.__('Short URL domain:').'
'.
'- '.SHORTEN_SERVICE_BASE.'
'.
'- '.__('Encode URL:').'
'.
'- '.(SHORTEN_SERVICE_ENCODE ? __('yes') : __('no')).'
'.
'
';
}
public function testService()
{
$url = $this->url_encode ? urlencode($this->url_test) : $this->url_test;
$arg = array($this->url_param => urlencode($this->url_test));
if (!self::post($this->url_api,$arg,true,true))
{
$this->error->add(__('Service is unavailable.'));
return false;
}
return true;
}
public function createHash($url,$hash=null)
{
$enc = $this->url_encode ? urlencode($url) : $url;
$arg = array($this->url_param => $url);
if (!($response = self::post($this->url_api,$arg,true,true)))
{
$this->error->add(__('Service is unavailable.'));
return false;
}
$rs = new ArrayObject();
$rs->hash = str_replace($this->url_base,'',$response);
$rs->url = $url;
$rs->type = $this->id;
return $rs;
}
}
?>