Your IP : 216.73.217.80


Current Path : /home/jlgagfroyt/www/AAOLD/modules/mod_socialsharebuttons/
Upload File :
Current File : /home/jlgagfroyt/www/AAOLD/modules/mod_socialsharebuttons/helper.php

<?php
/**
 * @package		Module Social Share Buttons
 * @version		1.2.3
 * @author		E-max
 * @copyright	Copyright (C) 2008 - 2017 - E-max. All rights reserved.
 * @license		http://www.gnu.org/copyleft/gpl.html GNU/GPL
 **/

// no direct access
defined('_JEXEC') or die('Restricted access');

class SocialShareButtonsHelper {
    public static function getTwitter($params, $url, $title) {
        $html = "";
        if($params->get("twitterButton")) {
            $html = '
            <div class="social-share-button-mod-tw">
            <a href="//twitter.com/share" class="twitter-share-button" data-url="' . $url . '" data-text="' . $title . '" data-count="' . $params->get("twitterCounter") . '" data-via="' . $params->get("twitterName") . '" data-lang="' . $params->get("twitterLanguage") . '">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
            </div>
            ';
        }
        return $html;
    }

    public static 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 = '
            <div class="social-share-button-mod-gone">
            <!-- Place this tag in your head or just before your close body tag -->
            <script type="text/javascript" src="//apis.google.com/js/plusone.js">' . $language . '</script>
            <!-- Place this tag where you want the +1 button to render -->
            <g:plusone ' . $type . ' href="' . $url . '"></g:plusone>
            </div>
            ';
        }
        
        return $html;
    }
    
    public static function getFacebookLike($params, $url, $title) {
        
        if($params->get("fbDynamicLocale", 0)) {
            $fbLocale = JFactory::getLanguage();
            $fbLocale = $fbLocale->getTag();
            $fbLocale = str_replace("-","_",$fbLocale);
        } else {
            $fbLocale = $params->get("fbLocale", "en_US");
        }

        if($params->get("facebookLikeAppId")){
            $appId = 'appId=' . $params->get("facebookLikeAppId");
        }

        $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";
            }
            $html = '<div class="social-share-button-mod-fbl">';

            $html .= '<div id="fb-root"></div>
            <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/' . $fbLocale . '/sdk.js#xfbml=1&version=v2.8&'. $appId.'";
            fjs.parentNode.insertBefore(js, fjs);
            }(document, \'script\', \'facebook-jssdk\'));</script>';
            $html .= '
                <div class="fb-like" 
                data-href="' . $url . '" 
                data-layout="' . $layout . '" 
                data-show-faces="' . $faces . '" 
                data-width="' . $params->get("facebookLikeWidth","450") . '" 
                data-colorscheme="' . $params->get("facebookLikeColor","light") . '" ';

            if($params->get("facebookShareMeButton")){
                $html .= 'data-share="true" ';
            }
            $html .= 'data-action="' . $params->get("facebookLikeAction",'like') . '" ';

            $html .= '></div></div>';
        }
        
        return $html;
    }
    
    public static function getStumbpleUpon($params, $url, $title) {
        
        $html = "";
        if($params->get("stumbleButton")) {
            
            $html = '
            <div class="social-share-button-mod-su">
            <script src="//www.stumbleupon.com/hostedbadge.php?s=' . $params->get("stumbleType",1). '&r=' . rawurlencode($url) . '"></script>
            </div>
            ';
        }
        
        return $html;
    }

    public static function getTumblr($params, $url, $title) {
        
        $html = "";
        if($params->get("tumblrButton")) {
            
			if ($params->get("tumblrType") == '1') { $tumblr_style= 'width:81px; background:url(\'//platform.tumblr.com/v1/share_1.png\')'; }
			else if ($params->get("tumblrType") == '2') { $tumblr_style= 'width:81px; background:url(\'//platform.tumblr.com/v1/share_1T.png\')'; }
			else if ($params->get("tumblrType") == '3') { $tumblr_style= 'width:61px; background:url(\'//platform.tumblr.com/v1/share_2.png\')'; }
			else if ($params->get("tumblrType") == '4') { $tumblr_style= 'width:61px; background:url(\'//platform.tumblr.com/v1/share_2T.png\')'; }
			else if ($params->get("tumblrType") == '5') { $tumblr_style= 'width:129px; background:url(\'//platform.tumblr.com/v1/share_3.png\')'; }
			else if ($params->get("tumblrType") == '6') { $tumblr_style= 'width:129px; background:url(\'//platform.tumblr.com/v1/share_3T.png\')'; }
			else if ($params->get("tumblrType") == '7') { $tumblr_style= 'width:20px; background:url(\'//platform.tumblr.com/v1/share_4.png\')'; }
			else if ($params->get("tumblrType") == '8') { $tumblr_style= 'width:20px; background:url(\'//platform.tumblr.com/v1/share_4T.png\')'; }
			
            $html = '
            <div class="social-share-button-mod-tum">
			<a href="//www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; height:20px; ' . $tumblr_style . ' top left no-repeat transparent;">Share on Tumblr</a>
            </div>
            ';
        }
        
        return $html;
    }
    
    public static function getReddit($params, $url, $title) {
        
        $html = "";
        if($params->get("redditButton")) {
            
			if ($params->get("redditType") == '1') { $reddit_style= '<a href="//www.reddit.com/submit" onclick="window.location = \'//www.reddit.com/submit?url=\' + encodeURIComponent(window.location); return false"> <img src="//www.reddit.com/static/spreddit1.gif" alt="submit to reddit" border="0" /> </a>'; }
			else if ($params->get("redditType") == '2') { $reddit_style= '<a href="//www.reddit.com/submit" onclick="window.location = \'//www.reddit.com/submit?url=\' + encodeURIComponent(window.location); return false"> <img src="//www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>'; }
			else if ($params->get("redditType") == '3') { $reddit_style= '<script type="text/javascript" src="//www.reddit.com/static/button/button1.js"></script>'; }
			else if ($params->get("redditType") == '4') { $reddit_style= '<script type="text/javascript" src="//www.reddit.com/static/button/button2.js"></script>'; }
			
            $html = '
            <div class="social-share-button-mod-red">' . $reddit_style . '</div>
            ';
        }
        
        return $html;
    }

    public static function getPinterest($params, $url, $title) {
        
        $html = "";
		
		$article_title = JTable::getInstance("content");
        $article_title->load(JFactory::getApplication()->input->get("id"));

        $image_pin = "";
		$pinterestDesc = "";
		
		if ($params->get("pinterestStaticImage")) {
			$image_pin = $params->get("pinterestImage");
		}
		else {
			$first_image = "";
			$text = $article_title->get("introtext");
			$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $text, $matches);
			if ($output) {
				$image_pin = JURI::base().$matches[1][0];				
			}
			else {
				$image_pin = $params->get("pinterestImage");
			}
		}
		
		if ($params->get("pinterestStaticDesc")) {
			$pinterestDesc = $params->get("pinterestDesc");
		}
		else {
			$pinterestDesc = $article_title->get("metadesc");
			if ($pinterestDesc == "") {
				$pinterestDesc = $params->get("pinterestDesc");
			}
		}
		
        if($params->get("pinterestButton")) {
            
            $html = '
            <div class="social-share-button-mod-pin"><a href="//pinterest.com/pin/create/button/?url=' . $url . '&media=' . $image_pin. '&description='. $pinterestDesc .'" class="pin-it-button" count-layout="' . $params->get("pinterestType","horizontal"). '"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script></div>
            ';
        }
        
        return $html;
    }

    public static function getBufferApp($params, $url, $title) {
        
        $html = "";
        if($params->get("bufferappButton")) {
            
            $html = '
            <div class="social-share-button-mod-buf"><a href="//bufferapp.com/add" class="buffer-add-button" data-count="' . $params->get("bufferappType","vertical"). '">Buffer</a><script type="text/javascript" src="//static.bufferapp.com/js/button.js"></script></div>
            ';
        }
        
        return $html;
    }

    public static function getLinkedIn($params, $url, $title) {
        
        $html = "";
        if($params->get("linkedInButton")) {
            
            $html = '
            <div class="social-share-button-mod-lin">
            <script type="text/javascript" src="//platform.linkedin.com/in.js"></script><script type="in/share" data-url="' . $url . '" data-counter="' . $params->get("linkedInType",'right'). '"></script>
            </div>
            ';
        }
        
        return $html;
    }
     
    public static function getFacebookShareMe($params, $url, $title) {

        if($params->get("fbDynamicLocale", 0)) {
            $fbLocale = JFactory::getLanguage();
            $fbLocale = $fbLocale->getTag();
            $fbLocale = str_replace("-","_",$fbLocale);
        } else {
            $fbLocale = $params->get("fbLocale", "en_US");
        }

        if($params->get("facebookLikeAppId")){
            $appId = 'appId=' . $params->get("facebookLikeAppId");
        }

        $layout = $params->get("facebookLikeType","button_count");
        if ($layout == 'standard') $layout='button_count';
        
        $html = "";
        if($params->get("facebookShareMeButton") && !$params->get("facebookLikeButton")) {
            $html = '
            <div class="social-share-button-mod-fbsh">
            <div id="fb-root"></div>
            <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/' . $fbLocale . '/sdk.js#xfbml=1&version=v2.8&'. $appId.'";
            fjs.parentNode.insertBefore(js, fjs);
            }(document, \'script\', \'facebook-jssdk\'));</script>
            <div class="fb-share-button" 
            data-href="' . $url . '" 
            data-layout="' . $layout . '" 
            data-size="' . $params->get("facebookShareMeType","large"). '">
            </div></div>';
        }

        return $html;
    }
}