public function __invoke($identifier, $title = '', $url = '')
{
if (!is_array($this->config['widgets'])) {
return;
}
foreach ($this->config['widgets'] as $widget) {
if ($identifier == $widget['identifier']) {
$data = $widget;
break;
}
}
if (empty($data)) {
return;
}
$styles = $this->addthis->getDefaultStyles();
$document = $this->getServiceLocator()->get('CurrentDocument');
if (!empty($document)) {
if (empty($url)) {
$url = $document->getUrl(true);
}
if (empty($title)) {
$title = $document->getName();
}
}
$options = array();
$addthisIdentifier = 'addthis:url="' . $url . '" ';
$addthisIdentifier .= 'addthis:title="' . $title . '"';
if ($data['settings'] == 'custom_string') {
$buttons = preg_replace('/<\\s*div\\s*/', '<div %1$s ', $data['custom_string']);
} elseif (isset($styles[$data['settings']])) {
if (!empty($data['chosen_list'])) {
if ($data['settings'] == 'large_toolbox') {
$options['size'] = '32';
} elseif ($data['settings'] == 'small_toolbox') {
$options['size'] = '16';
}
$options['type'] = $data['settings'];
$options['services'] = $data['chosen_list'];
$buttons = $this->customToolbox($options, $addthisIdentifier);
} else {
$buttons = $styles[$data['settings']]['src'];
}
} else {
return;
}
$content = sprintf($buttons, $addthisIdentifier);
$content .= $this->getConfig();
return $content;
}