_plugin = JPluginHelper::getPlugin( 'content', 'ultimate_social_bookmarking_plugin' );
$this->_params = new JParameter( $this->_plugin->params );
}
function onPrepareContent(&$article, &$params, $page)
{
$mosConfig_absolute_path = JPATH_SITE;
// Get plugin variables
$homepageListing = $this->_params->def('homepageListing','top');
$urlMode = $this->_params->get( 'urlMode', 'standard' );
$excludeCategories = $this->_params->def( 'excludeCategories', '' );
$topPrecedingHtml = $this->_params->def( 'topPrecedingHtml', ' ' );
$topFollowingHtml = $this->_params->def( 'topFollowingHtml', ' ' );
$bottomPrecedingHtml = $this->_params->def( 'bottomPrecedingHtml', '
Add this page to your favorite Social Bookmarking websites
' );
$bottomFollowingHtml = $this->_params->def( 'bottomFollowingHtml', ' ' );
$topSeparator = $this->_params->def( 'topSeparator', '
' );
$bottomSeparator = $this->_params->def( 'bottomSeparator', ' ' );
$imageFolder = $this->_params->def( 'imageFolder', 'default' );
$lookForManualSettings = $this->_params->def( 'lookForManualSettings', 'no' );
$bgColor = $this->_params->def( 'bgColor', '#ffffff' );
$addThisPubId = $this->_params->def( 'addThisPubId', '' );
$validArticle = true;
$contentOnly = $this->_params->def( 'contentOnly' );
// Check if the full content item is currently displayed
// Thank you gcolo and keruchan for the J1.5 bugfix
$isHomepage = ((JRequest::getVar('view') == 'frontpage') || (JRequest::getVar('layout') == 'blog'));
// Invalidate if on homepage and currentUrls enabled
if (($isHomepage == true) and ($urlMode == 'currentUrl')) $validArticle = false;
// Invalidate if $contentOnly is true and this is not the content component
if (($contentOnly == '1') and (JRequest::getVar('option') != 'com_content'))
{
$validArticle = false;
}
// Get base URL
$baseUrl = JURI::base();
if ($baseUrl[strlen($baseUrl)-1] == '/')
{
$baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1);
}
// Add stylesheet to header
JFactory::getDocument()->addStyleSheet($baseUrl .'/plugins/content/ultimate_social_bookmarking_plugin.css');
// Set urlMode to currentUrl if SEF URLs are not enabled for this website
//if ($mosConfig_sef == '0') $urlMode = 'currentUrl';
// Check if this content item is in an excluded category
$excluded = explode (",", $excludeCategories);
foreach ($excluded as $ex)
{
if ($article->catid == trim($ex))
{
$validArticle = false;
}
}
// Run the plugin if not excluded and content type is valid
if ($validArticle == true)
{
// Setup image directory
$imageLocation = $baseUrl .'/plugins/content/usbp_images/'. $imageFolder;
if (($lookForManualSettings == 'yes') and (preg_match('#{socialbookmarker}(.*?){/socialbookmarker}#s', $article->text, $matches, PREG_OFFSET_CAPTURE)))
{
// Get $thisurl
if (preg_match('#sburl=#s', $matches[0][0]))
{
$pos1 = stripos($matches[0][0], 'sburl="') + 12;
$pos2 = stripos($matches[0][0], '"', $pos1);
$thisurl = substr($matches[0][0], $pos1, $pos2 - $pos1);
}
else
{
$thisurl = $this->usbp_createUrl($article, $urlMode, $baseUrl);
}
// Get $thistitle
if (preg_match('#sbtitle=#s', $matches[0][0]))
{
$pos1 = stripos($matches[0][0], 'sbtitle="') + 14;
$pos2 = stripos($matches[0][0], '"', $pos1);
$thistitle = substr($matches[0][0], $pos1, $pos2 - $pos1);
}
else
{
$thistitle = $article->title;
}
// Get $thisdesc
if (preg_match('#sbdescription=#s', $matches[0][0]))
{
$pos1 = stripos($matches[0][0], 'sbdescription="') + 20;
$pos2 = stripos($matches[0][0], '"', $pos1);
$thisdesc = substr($matches[0][0], $pos1, $pos2 - $pos1);
}
else
{
$thisdesc = $article->metadesc;
}
// Get $enabled
if (preg_match('#sbenabled=#s', $matches[0][0]))
{
$pos1 = stripos($matches[0][0], 'sbenabled="') + 16;
$pos2 = stripos($matches[0][0], '"', $pos1);
$enabled = substr($matches[0][0], $pos1, $pos2 - $pos1);
if ($enabled == 'true')
{
$enabled = true;
}
else
{
$enabled = false;
}
}
else
{
$enabled = true;
}
}
else
{
$thisurl = $this->usbp_createUrl($article, $urlMode, $baseUrl);
$thistitle = $article->title;
$thisdesc = $article->metadesc;
$enabled = true;
}
// Run plugin if this page was not manually set to disabled
if ($enabled == true)
{
// Initialize button arrays
$htmls = array();
$positions = array();
// Process buttons.xml, create arrays for html and position
$xmlFileName = $mosConfig_absolute_path .'/plugins/content/ultimate_social_bookmarking_plugin_buttons.xml';
if (file_exists($xmlFileName) == true)
{
// Parse XML
$button_xml = simplexml_load_file($xmlFileName);
// For each