mirror of
https://github.com/e107inc/e107.git
synced 2025-08-16 19:44:09 +02:00
Social plugin now provides social share links in admin after creating/updating a news item.
This commit is contained in:
@@ -17,6 +17,7 @@ class social_shortcodes extends e_shortcode
|
||||
public $var;
|
||||
|
||||
|
||||
|
||||
public function getProviders()
|
||||
{
|
||||
|
||||
@@ -215,6 +216,55 @@ class social_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type provider key. eg. facebook, twitter etc.
|
||||
* @param string $urlScheme The URL scheme. @see getProviders 'url'
|
||||
* @param array $data
|
||||
* @param string $data['title'] Title for the URL
|
||||
* @param string $data['description'] Description for the URL
|
||||
* @param string $data['media']
|
||||
* @param array $options Currently 'twitterAccount' and 'hashtags' are supported.
|
||||
* @return string
|
||||
*/
|
||||
public function getShareUrl($type, $urlScheme, $data=array(), $options=array())
|
||||
{
|
||||
$data = array('u'=> rawurlencode($data['url']), 't'=> rawurlencode($data['title']), 'd' => rawurlencode($data['description']), 'm' => rawurlencode($data['media']));
|
||||
|
||||
return $this->parseShareUrlScheme($type, $urlScheme, $data, $options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $providerUrlScheme
|
||||
* @param array $data Array containing keys: 'u' (URL), 't' (Title), 'd' (Description)', 'm' (Media)
|
||||
* @param array $options (optional) 'hashtags' and 'twitterAccount'
|
||||
* @return string
|
||||
*/
|
||||
private function parseShareUrlScheme($type, $providerUrlScheme, $data=array(), $options=array())
|
||||
{
|
||||
$pUrl = str_replace("&","&",$providerUrlScheme);
|
||||
|
||||
$shareUrl = e107::getParser()->lanVars($pUrl,$data);
|
||||
|
||||
if($type === 'twitter')
|
||||
{
|
||||
if(!empty($options['hashtags']))
|
||||
{
|
||||
$shareUrl .= "&hashtags=".rawurlencode($options['hashtags']);
|
||||
}
|
||||
|
||||
if(!empty($options['twitterAccount']))
|
||||
{
|
||||
$shareUrl .= "&via=".$options['twitterAccount'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $shareUrl;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {SOCIALSHARE: url=x&title=y}
|
||||
* @example {SOCIALSHARE: type=basic} - Show only Email, Facebook, Twitter and Google.
|
||||
@@ -315,25 +365,7 @@ class social_shortcodes extends e_shortcode
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pUrl = str_replace("&","&",$val['url']);
|
||||
|
||||
$shareUrl = $tp->lanVars($pUrl,$data);
|
||||
|
||||
if($k == 'twitter')
|
||||
{
|
||||
if(!empty($hashtags))
|
||||
{
|
||||
$shareUrl .= "&hashtags=".rawurlencode($hashtags);
|
||||
}
|
||||
|
||||
if(!empty($twitterAccount))
|
||||
{
|
||||
$shareUrl .= "&via=".$twitterAccount;
|
||||
}
|
||||
|
||||
}
|
||||
$shareUrl = $this->parseShareUrlScheme($k, $val['url'], $data, array('twitterAccount'=>$twitterAccount, 'hashtags'=>$hashtags));
|
||||
|
||||
if(!empty($val['mobile']))
|
||||
{
|
||||
|
Reference in New Issue
Block a user