2014-01-14 11:20:10 -08:00
< ? php
/*
* Copyright ( c ) e107 Inc e107 . org , Licensed under GNU GPL ( http :// www . gnu . org / licenses / gpl . txt )
* $Id : e_shortcode . php 12438 2011 - 12 - 05 15 : 12 : 56 Z secretr $
*
* Featurebox shortcode batch class - shortcodes available site - wide . ie . equivalent to multiple . sc files .
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
class social_shortcodes extends e_shortcode
{
2014-01-23 09:18:40 -08:00
/**
* { XURL_ICONS : size = 2 x }
*/
2014-01-14 11:20:10 -08:00
function sc_xurl_icons ( $parm = '' )
{
$social = array (
'rss' => array ( 'href' => ( e107 :: isInstalled ( 'rss_menu' ) ? e_PLUGIN_ABS . " rss_menu/rss.php?news.2 " : '' ), 'title' => 'Feed' ),
'facebook' => array ( 'href' => deftrue ( 'XURL_FACEBOOK' ), 'title' => 'Facebook' ),
'twitter' => array ( 'href' => deftrue ( 'XURL_TWITTER' ), 'title' => 'Twitter' ),
'googleplus' => array ( 'href' => deftrue ( 'XURL_GOOGLE' ), 'title' => 'Google Plus' ),
'linkedin' => array ( 'href' => deftrue ( 'XURL_LINKEDIN' ), 'title' => 'LinkedIn' ),
'pinterest' => array ( 'href' => deftrue ( 'XURL_PINTEREST' ), 'title' => 'Pinterest' ),
'instagram' => array ( 'href' => deftrue ( 'XURL_INSTAGRAM' ), 'title' => 'Instagram' ),
'youtube' => array ( 'href' => deftrue ( 'XURL_YOUTUBE' ), 'title' => 'YouTube' ),
'vimeo' => array ( 'href' => deftrue ( 'XURL_VIMEO' ), 'title' => 'Vimeo' )
);
2014-01-15 11:04:44 -08:00
2014-01-14 11:20:10 -08:00
2014-01-15 11:04:44 -08:00
$class = ( vartrue ( $parm [ 'size' ])) ? 'fa-' . $parm [ 'size' ] : '' ;
2014-01-14 11:20:10 -08:00
$text = '' ;
foreach ( $social as $id => $data )
{
if ( $data [ 'href' ] != '' )
{
2014-01-23 09:18:40 -08:00
$text .= '<a rel="external" href="' . $data [ 'href' ] . '" class="e-tip social-icon social-' . $id . ' " >
2014-01-15 11:04:44 -08:00
< span class = " fa fa-'. $id .' '. $class .' " ></ span >
2014-01-14 11:20:10 -08:00
</ a > ' ;
$text .= " \n " ;
}
}
if ( $text != '' )
{
return '<p class="xurl-social-icons">' . $text . '</p>' ;
}
}
2014-01-23 09:18:40 -08:00
/**
* { SOCIALSHARE : url = x & title = y }
*/
function sc_socialshare ( $parm = '' ) // Designed so that no additional JS required.
{
$tp = e107 :: getParser ();
$url = varset ( $parm [ 'url' ], e_REQUEST_URL );
2014-01-23 15:56:53 -08:00
$title = varset ( $parm [ 'title' ], deftrue ( 'e_PAGETITLE' ) . " | " . SITENAME ) ;
2014-01-23 09:18:40 -08:00
$description = varset ( $parm [ 'title' ], e107 :: getUrl () -> response () -> getMetaDescription ());
$media = " " ;
2014-01-25 05:32:40 -08:00
$label = varset ( $parm [ 'label' ], $tp -> toGlyph ( 'e-social-spread' ));
2014-01-23 09:18:40 -08:00
$size = varset ( $parm [ 'size' ], 'md' );
2014-01-25 05:40:23 -08:00
//TODO LANS ie. "Share on [x]" in English_global.php
2014-01-23 09:18:40 -08:00
$providers = array (
2014-01-25 05:40:23 -08:00
'email' => array ( 'icon' => 'e-social-mail' , 'title' => " Email to someone " , 'url' => " mailto:EMAIL_RECIPIENT?subject=[t]&body=Check out this link: [u] " ),
2014-01-25 05:18:31 -08:00
'facebook-like' => array ( 'icon' => 'e-social-thumbs-up' , 'title' => " Like on Facebook " , 'url' => " http://www.facebook.com/plugins/like.php?href=[u] " ),
'facebook-share' => array ( 'icon' => 'e-social-facebook' , 'title' => " Share on Facebook " , 'url' => " http://www.facebook.com/sharer.php?u=[u]&t=[t] " ),
'twitter' => array ( 'icon' => 'e-social-twitter' , 'title' => " Share on Twitter " , 'url' => " http://twitter.com/share?url=[u]&text=[t] " ),
'google-plus1' => array ( 'icon' => 'e-social-gplus' , 'title' => " +1 on Google " , 'url' => " https://apis.google.com/_/+1/fastbutton?usegapi=1&size=large&hl=en&url=[u] " ),
// 'google-plus' => array('icon' => 'fa-google-plus', 'title'=>"On Google Plus", 'url' => "https://plusone.google.com/_/+1/confirm?hl=en&url=[u]"),
'linkedin' => array ( 'icon' => 'e-social-linkedin' , 'title' => " Share on LinkedIn " , 'url' => " http://www.linkedin.com/shareArticle?mini=true&url=[u] " ),
'pinterest' => array ( 'icon' => 'e-social-pinterest' , 'title' => " Share on Pinterest " , 'url' => " http://www.pinterest.com/pin/create/button/?url=[u]&description=[t]&media=[m] " ),
// 'thumblr' => array('icon' => 'fa-tumblr', 'title'=>"On Tumblr", 'url' => "http://www.tumblr.com/share/link?url=[u]&name=[t]&description=[d]"),
2014-01-25 05:40:23 -08:00
'stumbleupon' => array ( 'icon' => 'e-social-stumbleupon' , 'title' => " Share on StumbleUpon " , 'url' => " http://www.stumbleupon.com/submit?url=[u]&title=[t] " ),
'reddit' => array ( 'icon' => 'e-social-reddit' , 'title' => " Share on Reddit " , 'url' => " http://reddit.com/submit?url=[u]&title=[t] " ),
'digg' => array ( 'icon' => 'e-social-digg' , 'title' => " Share on Digg " , 'url' => " http://www.digg.com/submit?url=[u] " ),
2014-01-25 05:18:31 -08:00
2014-01-23 09:18:40 -08:00
//http://reddit.com/submit?url=http%3A%2F%2Fwebsite.com&title=Website%20Title // no fa icon available
//http://www.digg.com/submit?url=http%3A%2F%2Fwebsite.com // no fa icon available
);
$data = array ( 'u' => rawurlencode ( $url ), 't' => rawurlencode ( $title ), 'd' => rawurlencode ( $description ), 'm' => rawurlencode ( $media ));
if ( ! vartrue ( $parm [ 'dropdown' ]))
{
$butSize = ( $size == 'lg' || $size == 'sm' || $size == 'xs' ) ? 'btn-' . $size : '' ;
}
else
{
2014-01-25 05:18:31 -08:00
$butSize = 'btn-social' ;
2014-01-23 09:18:40 -08:00
}
$opt = array ();
foreach ( $providers as $val )
{
2014-01-23 17:24:02 -08:00
$pUrl = str_replace ( " & " , " & " , $val [ 'url' ]);
$shareUrl = $tp -> lanVars ( $pUrl , $data );
2014-01-23 09:18:40 -08:00
$opt [] = " <a class='e-tip btn " . $butSize . " btn-default social-share' target='_blank' title=' " . $val [ " title " ] . " ' href=' " . $shareUrl . " '> " . $tp -> toIcon ( $val [ " icon " ]) . " </a> " ;
}
if ( vartrue ( $parm [ 'dropdown' ]))
{
$dir = ( $parm [ 'dropdown' ] == 'right' ) ? 'pull-right' : '' ;
$text = '<div class="btn-group ' . $dir . ' " >
2014-01-25 05:32:40 -08:00
< a class = " e-tip btn btn-dropdown btn-default btn-'. $size .' dropdown-toggle " data - toggle = " dropdown " href = " # " title = " Share " > '.$label.' </ a >
2014-01-23 09:18:40 -08:00
2014-01-25 05:40:23 -08:00
< ul class = " dropdown-menu " role = " menu " aria - labelledby = " dLabel " style = " min-width:435px " >
2014-01-23 09:18:40 -08:00
< li >< div class = " btn-group " style = " padding-left: 7px; " > '.implode("\n",$opt).' </ div ></ li >
</ ul >
</ div > ' ;
return $text ;
}
else
{
return '<div class="btn-group text-center"><button class="btn btn-sm btn-default disabled">' . $label . '</button>' . implode ( " \n " , $opt ) . " </div> " ;
}
}
2014-01-14 11:20:10 -08:00
}
2014-01-23 09:18:40 -08:00
?>