<?php
/**
* Serendipity plugin for displaying a link to your public profile on www.linkedin
* Feel free to use and distribute this code to you needs, but please retain this notice.
*
* @author Ketil Stadskleiv <hide@address.com>
* @version 1.0
*/
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_plugin_linkedInProfile extends serendipity_plugin {
function introspect(&$propbag) {
$propbag->add('name', PLUGIN_LINKEDIN_TITLE);
$propbag->add('description', PLUGIN_LINKEDIN_INFO);
$propbag->add('configuration', array('profileUrl', 'imageUrl','newwindow'));
$propbag->add('author', 'Ketil Stadskleiv');
$propbag->add('stackable', true);
$propbag->add('version', '1.0');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'php' => '4.1.0'
));
$propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES'));
}
function introspect_config_item($name, &$propbag) {
switch($name) {
case 'profileUrl':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_LINKEDIN_URL_TITLE);
$propbag->add('description', PLUGIN_LINKEDIN_URL_TITLE_DESC);
$propbag->add('default', 'http://www.linkedin.com/in/');
break;
case 'imageUrl':
$select = array(
'http://www.linkedin.com/img/webpromo/btn_viewmy_160x33.gif' => '160x33 - 1',
'http://www.linkedin.com/img/webpromo/btn_myprofile_160x33.gif' => '160x33 - 2',
'http://www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif' => '160x25',
'http://www.linkedin.com/img/webpromo/btn_viewmy_120x33.gif' => '120x33',
'http://www.linkedin.com/img/webpromo/btn_linkedin_120x30.gif' => '120x30',
'http://www.linkedin.com/img/webpromo/btn_profile_bluetxt_80x15.gif' => '80x15 - 1',
'http://www.linkedin.com/img/webpromo/btn_profile_greytxt_80x15.gif' => '80x15 - 2',
'http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif' => '80x15 - 3',
'http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif' => '80x15 - 3'
);
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_LINKEDIN_IMAGE_URL);
$propbag->add('description', PLUGIN_LINKEDIN_IMAGE_URL_DESC);
$propbag->add('default', 'http://www.linkedin.com/img/webpromo/btn_myprofile_160x33.gif');
$propbag->add('select_values', $select);
break;
case 'newwindow':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_LINKEDIN_NEWWINDOW);
$propbag->add('description', PLUGIN_LINKEDIN_NEWWINDOW_DESC);
$propbag->add('default', false);
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
global $serendipity;
$newwindow = $this->get_config('newwindow');
$img = $this->get_config('imageUrl');
$url = $this->get_config('profileUrl');
$display = '<a href="'.$url.'"';
if ($newwindow) {
$display .= ' onclick="window.open(this.href); return false;"';
}
$display .= '><img src="'.$img.'" border="0" alt="Linkedin public profile"/></a>';
echo $display;
}
}
?>