|
@@ -1,150 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
- * DokuWiki Plugin lsb (Syntax Component)
|
|
|
- *
|
|
|
- * @license GPL 2 http:
|
|
|
- * @author Fernando Ribeiro <pinguim.ribeiro@gmail.com>
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-if (!defined('DOKU_INC')) die();
|
|
|
-
|
|
|
-class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
|
|
|
-
|
|
|
- * @return string Syntax mode type
|
|
|
- */
|
|
|
- public function getType() {
|
|
|
- return 'substition';
|
|
|
- }
|
|
|
-
|
|
|
- * @return string Paragraph type
|
|
|
- */
|
|
|
- public function getPType() {
|
|
|
- return 'normal';
|
|
|
- }
|
|
|
-
|
|
|
- * @return int Sort order - Low numbers go before high numbers
|
|
|
- */
|
|
|
- public function getSort() {
|
|
|
- return 999;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * Connect lookup pattern to lexer.
|
|
|
- *
|
|
|
- * @param string $mode Parser mode
|
|
|
- */
|
|
|
- public function connectTo($mode) {
|
|
|
- $this->Lexer->addSpecialPattern('~~LSB\b.*?~~',$mode,'plugin_lsb_button');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- * Handle matches of the lsb syntax
|
|
|
- *
|
|
|
- * @param string $match The match of the syntax
|
|
|
- * @param int $state The state of the handler
|
|
|
- * @param int $pos The position in the document
|
|
|
- * @param Doku_Handler $handler The handler
|
|
|
- * @return array Data for the renderer
|
|
|
- */
|
|
|
- public function handle($match, $state, $pos, Doku_Handler &$handler){
|
|
|
- $match = strtolower(trim(substr($match, 5, -2)));
|
|
|
-
|
|
|
- if (empty($match)) {
|
|
|
- $match = strtolower(trim($this->getConf('networks')));
|
|
|
- }
|
|
|
-
|
|
|
- return explode(' ', $match);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * Render xhtml output or metadata
|
|
|
- *
|
|
|
- * @param string $mode Renderer mode (supported modes: xhtml)
|
|
|
- * @param Doku_Renderer $renderer The renderer
|
|
|
- * @param array $data The data from the handler() function
|
|
|
- * @return bool If rendering was successful.
|
|
|
- */
|
|
|
- public function render($mode, Doku_Renderer &$renderer, $data) {
|
|
|
-
|
|
|
- if($mode != 'xhtml') return false;
|
|
|
-
|
|
|
- $renderer->doc .= '<ul class="lsb">';
|
|
|
-
|
|
|
-
|
|
|
- $protected = array('twitter', 'facebook', 'google+', 'linkedin', 'pinterest', 'tumblr', 'reddit');
|
|
|
-
|
|
|
-
|
|
|
- foreach ($data as $network) {
|
|
|
- if (in_array($network, $protected)) {
|
|
|
- $renderer->doc .= $this->lsb_button($network);
|
|
|
- }
|
|
|
- }
|
|
|
- $renderer->doc .= '</ul>';
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * Render xhtml output for facebook share button
|
|
|
- *
|
|
|
- * @param string $network The social network to render the button to
|
|
|
- * @return string Xhtml code for button.
|
|
|
- */
|
|
|
- protected function lsb_button ($network) {
|
|
|
- global $ID;
|
|
|
- global $INFO;
|
|
|
-
|
|
|
- $url = rawurlencode(wl($ID,'',true));
|
|
|
- $title = hsc(($INFO['meta']['title']) ? $INFO['meta']['title'] : $meta);
|
|
|
- $abstract = hsc($INFO['meta']['description']['abstract']);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $xhtml = '<li class="lsb-item">';
|
|
|
-
|
|
|
- switch ($network) {
|
|
|
- case 'twitter':
|
|
|
- $xhtml .= '<a class="lsb-link ico-twitter" href="https://twitter.com/intent/tweet?url=' . $url . '&text='. $title .'&via=TWITTER-HANDLE">' . $this->getLang('twitter_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'facebook':
|
|
|
- $xhtml .= '<a class="lsb-link ico-facebook" href="http://www.facebook.com/sharer.php?u='. $url .'">' . $this->getLang('facebook_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'google+':
|
|
|
- $xhtml .= '<a class="lsb-link ico-google" href="https://plus.google.com/share?url='. $url .'">' . $this->getLang('google+_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'linkedin':
|
|
|
- $xhtml .= '<a class="lsb-link ico-linkedin" href="https://www.linkedin.com/shareArticle?url='. $url .'&title=' . $title . '&summary=' . $abstract . '&mini=true&source=YOUR-URL">' . $this->getLang('linkedin_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'pinterest':
|
|
|
- $xhtml .= '<a class="lsb-link ico-pinterest" href="https://pinterest.com/pin/create/button/?url='. $url .'&description=' . $abstract . '&media=YOUR-IMAGE-SRC">' . $this->getLang('pinterest_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'tumblr':
|
|
|
- $xhtml .= '<a class="lsb-link ico-tumblr" href="http://www.tumblr.com/share/link?url='. $url .'&description=' . $abstract . '">' . $this->getLang('tumblr_name') . '</a>';
|
|
|
- break;
|
|
|
- case 'reddit':
|
|
|
- $xhtml .= '<a class="lsb-link ico-reddit" href="http://www.reddit.com/submit?url='. $url .'&title=' . $title . '">' . $this->getLang('reddit_name') . '</a>';
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- $xhtml .= '</li>';
|
|
|
-
|
|
|
- return $xhtml;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|