|
@@ -51,11 +51,21 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
public function handle($match, $state, $pos, Doku_Handler &$handler){
|
|
|
$match = strtolower(trim(substr($match, 5, -2))); // strip markup
|
|
|
|
|
|
- if (empty($match)) {
|
|
|
- $match = strtolower(trim($this->getConf('networks')));
|
|
|
+ // checks if a display mode is passed
|
|
|
+ if (substr($match, 0, 1) === ':') {
|
|
|
+ list($display) = explode(' ', $match);
|
|
|
+ $display = substr($display, 1);
|
|
|
+ $networks = trim(substr($match, strlen($display) + 1 ));
|
|
|
}
|
|
|
|
|
|
- return explode(' ', $match);
|
|
|
+ if (empty($networks)) {
|
|
|
+ $networks = strtolower(trim($this->getConf('networks')));
|
|
|
+ }
|
|
|
+
|
|
|
+ return array(
|
|
|
+ 'display' => $display,
|
|
|
+ 'networks' => explode(' ', $networks)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -70,13 +80,21 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
|
|
|
if($mode != 'xhtml') return false;
|
|
|
|
|
|
+ // validation list of available display modes
|
|
|
+ $valid_displays = array('name', 'icon', 'color');
|
|
|
// validation list of available social networks
|
|
|
- $protected = array('twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'tumblr', 'reddit', 'taringa', 'email');
|
|
|
+ $valid_networks = array('twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'tumblr', 'reddit', 'taringa', 'email');
|
|
|
+
|
|
|
+ if (in_array($data['display'], $valid_displays)) {
|
|
|
+ $display = $data['display'];
|
|
|
+ } else {
|
|
|
+ $display = $this->getConf('display') ;
|
|
|
+ }
|
|
|
|
|
|
$renderer->doc .= '<ul class="lsb">';
|
|
|
- foreach ($data as $network) {
|
|
|
- if (in_array($network, $protected)) {
|
|
|
- $renderer->doc .= $this->lsb_button($network);
|
|
|
+ foreach ($data['networks'] as $network) {
|
|
|
+ if (in_array($network, $valid_networks)) {
|
|
|
+ $renderer->doc .= $this->lsb_button($display, $network);
|
|
|
}
|
|
|
}
|
|
|
$renderer->doc .= '</ul>';
|
|
@@ -87,22 +105,22 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
/**
|
|
|
* Render xhtml output for share buttons
|
|
|
*
|
|
|
+ * @param string $display The display mode
|
|
|
* @param string $network The social network to render the button to
|
|
|
* @return string Xhtml code for button.
|
|
|
*/
|
|
|
- protected function lsb_button ($network) {
|
|
|
+ protected function lsb_button ($display, $network) {
|
|
|
global $ID;
|
|
|
global $INFO;
|
|
|
|
|
|
$url = rawurlencode(wl($ID,'',true));
|
|
|
$title = rawurlencode(($INFO['meta']['title']) ? $INFO['meta']['title'] : $meta);
|
|
|
$abstract = rawurlencode($INFO['meta']['description']['abstract']);
|
|
|
- //$text = $this->lsb_getText($network);
|
|
|
- $class = $this->getConf('display') . '-' . $network;
|
|
|
+ $class = $display . '-' . $network;
|
|
|
|
|
|
// see: http://builtbyboon.com/blog/simple-social-sharing-buttons
|
|
|
// see: https://github.com/cferdinandi/social-sharing
|
|
|
- // <a href="https://twitter.com/intent/tweet?text=YOUR-TITLE&url=YOUR-URL&via=TWITTER-HANDLE">Tweet</a>
|
|
|
+ // <a href="https://twitter.com/intent/tweet?text=YOUR-TITLE&url=YOUR-URL&via=TWITTER-HANDLE&hashtags=YOUR,HASH,TAGS">Tweet</a>
|
|
|
// <a href="https://www.facebook.com/sharer/sharer.php?u=YOUR-URL">Share on Facebook</a>
|
|
|
// <a href="https://plus.google.com/share?url=YOUR-URL">Plus on googleplus</a>
|
|
|
// <a href="https://www.linkedin.com/shareArticle?mini=true&url=YOUR-URL&title=YOUR-TITLE&summary=YOUR-SUMMARY&source=YOUR-URL">Share on LinkedIn</a>
|
|
@@ -133,11 +151,11 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
break;
|
|
|
case 'pinterest':
|
|
|
$name = 'Pinterest';
|
|
|
- $href = 'https://pinterest.com/pin/create/button/?url='. $url .'&description=' . $abstract;
|
|
|
+ $href = 'https://pinterest.com/pin/create/button/?url='. $url .'&description=' . $title;
|
|
|
break;
|
|
|
case 'tumblr':
|
|
|
$name = 'Tumblr';
|
|
|
- $href = 'http://www.tumblr.com/share/link?url='. $url .'&description=' . $abstract;
|
|
|
+ $href = 'http://www.tumblr.com/share/link?url='. $url .'&description=' . $title;
|
|
|
break;
|
|
|
case 'reddit':
|
|
|
$name = 'Reddit';
|
|
@@ -145,7 +163,7 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
break;
|
|
|
case 'taringa':
|
|
|
$name = 'Taringa';
|
|
|
- $href = 'http://www.taringa.net/widgets/share.php?url='. $url .'&body=' . $abstract;
|
|
|
+ $href = 'http://www.taringa.net/widgets/share.php?url='. $url .'&body=' . $title;
|
|
|
break;
|
|
|
case 'email':
|
|
|
$name = 'Email';
|
|
@@ -160,22 +178,4 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
return $xhtml;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns the thext to display in share button
|
|
|
- *
|
|
|
- * @param string $network The social network to get the text to
|
|
|
- * @return string text for button or empty string to show just the icon.
|
|
|
- */
|
|
|
- // protected function lsb_getText($network) {
|
|
|
-
|
|
|
- // $display = $this->getConf('display');
|
|
|
-
|
|
|
- // if ($display == 'text') {
|
|
|
- // return $this->getLang($network . '_text');
|
|
|
- // } else {
|
|
|
- // // no text, just the icon
|
|
|
- // return '';
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
}
|