AAAAhome/academiac/www/plugins/content/socialsharebuttons/socialsharebuttons.php 0000604 00000044364 15137302255 0023715 0 ustar 00 params->get("fbDynamicLocale", 0)) { $lang = JFactory::getLanguage(); $locale = $lang->getTag(); $this->fbLocale = str_replace("-","_",$locale); } else { $this->fbLocale = $this->params->get("fbLocale", "en_US"); } } /** * Add social buttons into the article * * Method is called by the view * * @param string The context of the content being passed to the plugin. * @param object The content object. Note $article->text is also available * @param object The content params * @param int The 'page' number * @since 1.6 */ public function onContentPrepare($context, &$article, &$params, $limitstart) { $app =& JFactory::getApplication(); /* @var $app JApplication */ if($app->isAdmin()) { return; } $doc = JFactory::getDocument(); /* @var $doc JDocumentHtml */ $docType = $doc->getType(); // Check document type if(strcmp("html", $docType) != 0){ return; } $currentOption = JRequest::getCmd("option"); if( ($currentOption != "com_content") OR !isset($this->params)) { return; } $custom = $this->params->get('custom'); if ($custom) { $ok = strstr ($article->text, '{socialsharebuttons}'); } else { $ok=0; } $this->currentView = JRequest::getCmd("view"); /** Check for selected views, which will display the buttons. **/ /** If there is a specific set and do not match, return an empty string.**/ $showInArticles = $this->params->get('showInArticles'); if(!$showInArticles AND (strcmp("article", $this->currentView) == 0)){ return ""; } // Check for category view $showInCategories = $this->params->get('showInCategories'); if(!$showInCategories AND (strcmp("category", $this->currentView) == 0)){ return; } if($showInCategories AND ($this->currentView == "category")) { $articleData = $this->getArticle($article); $article->id = $articleData['id']; $article->catid = $articleData['catid']; $article->title = $articleData['title']; $article->slug = $articleData['slug']; $article->catslug = $articleData['catslug']; } if(!isset($article) OR empty($article->id) ) { return; } $excludeArticles = $this->params->get('excludeArticles'); if(!empty($excludeArticles)){ $excludeArticles = explode(',', $excludeArticles); } settype($excludeArticles, 'array'); JArrayHelper::toInteger($excludeArticles); // Exluded categories $excludedCats = $this->params->get('excludeCats'); if(!empty($excludedCats)){ $excludedCats = explode(',', $excludedCats); } settype($excludedCats, 'array'); JArrayHelper::toInteger($excludedCats); // Included Articles $includedArticles = $this->params->get('includeArticles'); if(!empty($includedArticles)){ $includedArticles = explode(',', $includedArticles); } settype($includedArticles, 'array'); JArrayHelper::toInteger($includedArticles); if(!in_array($article->id, $includedArticles)) { // Check exluded places if(in_array($article->id, $excludeArticles) OR in_array($article->catid, $excludedCats)){ return ""; } } // Generate content $content = $this->getContent($article, $params); $position = $this->params->get('position'); switch($position){ case 0: $article->text = $content . $article->text . $content; break; case 1: $article->text = $content . $article->text; break; case 2: $article->text = $article->text . $content; break; default: break; } if ($ok) { $article->text = str_replace('{socialsharebuttons}', $content, $article->text); } return; } /** * Generate content * @param object The article object. Note $article->text is also available * @param object The article params * @return string Returns html code or empty string. */ private function getContent(&$article, &$params){ $doc = JFactory::getDocument(); /* @var $doc JDocumentHtml */ $doc->addStyleSheet(JURI::root() . "plugins/content/socialsharebuttons/style/style.css"); $url = JURI::getInstance(); $root= $url->getScheme() ."://" . $url->getHost(); $url = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug), false); $url = $root.$url; $title= htmlentities($article->title, ENT_QUOTES, "UTF-8"); $html = '
'; $credits = $this->params->get('credits'); if ($credits) { $html .= ''; } else { $html .= ''; } $html .= ''; return $html; } private function getArticle(&$article) { $db = JFactory::getDbo(); $query = " SELECT `#__content`.`id`, `#__content`.`catid`, `#__content`.`alias`, `#__content`.`title`, `#__categories`.`alias` as category_alias FROM `#__content` INNER JOIN `#__categories` ON `#__content`.`catid`=`#__categories`.`id` WHERE `#__content`.`introtext` = " . $db->Quote($article->text); $db->setQuery($query); $result = $db->loadAssoc(); if ($db->getErrorNum() != 0) { JError::raiseError(500, "System error!", $db->getErrorMsg()); } if(!empty($result)) { $result['slug'] = $result['alias'] ? ($result['id'].':'.$result['alias']) : $result['id']; $result['catslug'] = $result['category_alias'] ? ($result['catid'].':'.$result['category_alias']) : $result['catid']; } return $result; } private function getTwitter($params, $url, $title){ $html = ""; if($params->get("twitterButton")) { $html = ' '; } return $html; } private function getGooglePlusOne($params, $url, $title){ $type = ""; $language = ""; if($params->get("plusType")) { $type = 'size="' . $params->get("plusType") . '"'; } if($params->get("plusLocale")) { $language = " {lang: '" . $params->get("plusLocale") . "'}"; } $html = ""; if($params->get("plusButton")) { $html = ' '; } return $html; } private function getFacebookLike($params, $url, $title){ $html = ""; if($params->get("facebookLikeButton")) { $faces = (!$params->get("facebookLikeFaces")) ? "false" : "true"; $layout = $params->get("facebookLikeType","button_count"); if(strcmp("box_count", $layout)==0){ $height = "80"; } else { $height = "25"; } if(!$params->get("facebookLikeRenderer")){ // iframe $html = ' '; } else {//XFBML $html = ' '; } } return $html; } private function getDigg($params, $url, $title){ $title = html_entity_decode($title,ENT_QUOTES, "UTF-8"); $html = ""; if($params->get("diggButton")) { $html = ' '; } return $html; } private function getStumbpleUpon($params, $url, $title){ $html = ""; if($params->get("stumbleButton")) { $html = ' '; } return $html; } private function getLinkedIn($params, $url, $title){ $html = ""; if($params->get("linkedInButton")) { $html = ' '; } return $html; } private function getBuzz($params, $url, $title){ $html = ""; if($params->get("buzzButton")) { $html = ' '; } return $html; } private function getReTweetMeMe($params, $url, $title){ $html = ""; if($params->get("retweetmeButton")) { $html = ' '; } return $html; } private function getFacebookShareMe($params, $url, $title){ $html = ""; if($params->get("facebookShareMeButton")) { $html = ' '; } return $html; } }