<commit_before><?php
/*
 *
 * @license    MIT
 * @author     <NAME> <<EMAIL>>
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');


class syntax_plugin_profiles extends DokuWiki_Syntax_Plugin {
 
    var $links = array ("facebook" => "https://www.facebook.com/", "github" => "https://github.com/", "googleplus" => "https://plus.google.com/", "linkedin" => "http://www.linkedin.com/", "twitter" => "https://twitter.com/");
  
    function getInfo(){
        return confToHash(dirname(__FILE__).'/info.txt');
    }
 
 
    function getType(){ return 'substition'; }
    function getPType(){ return 'normal'; }
    function getAllowedTypes() { 
        return array('substition');
    }
    function getSort(){ 
      return 305; 
    }

    function connectTo($mode) {
        $this->Lexer->addSpecialPattern('{{(?:facebook|github|googleplus|linkedin|twitter)(?:|\..*?):.*?}}',$mode,'plugin_profiles');
    }
 
    function handle($match, $state, $pos, &$handler){

        switch ($state) {

          case DOKU_LEXER_SPECIAL : 
            preg_match ('/{{(?P<service>facebook|github|googleplus|linkedin|twitter)(?P<type>|\..*?):(?P<parameter>.*?)}}/', $match, $data);
            $params = array ();
            $params["service"] = $data["service"];
            $params["type"] = $data["type"];
            $params["parameter"] = $data["parameter"];

            return $params;
        
          default:
            return "";
        }
    }
 
    function render($mode, &$renderer, $indata) {

        if($mode == 'xhtml'){

              $service = $indata["service"];
              $type = $indata["type"];
              if (strlen ($type)>0) $type = substr ($type, 1);
              $p = explode ("|", $indata["parameter"]);
              $parameter = htmlspecialchars($p[0]);
              if (strlen ($p[1])==0) $name = htmlspecialchars($p[0]);
              else $name = htmlspecialchars($p[1]);
              $ahref = $this->links[$service];
              if ($type == "link") $ahref = $parameter;
              if ($service=="facebook")
              {
                if ($type == "profile" || $type == "page" || $type == "") $ahref = $ahref.$parameter;
              }
              else
              if ($service=="github")
              {
                $ahref = $ahref.$parameter;
              }
              else
              if ($service=="googleplus")
              {
                $ahref = $ahref.$parameter;
              }
              else
              if ($service=="linkedin")
              {
                if ($type == "profile" || $type == "") $ahref = $ahref."in/".$parameter;
                else if ($type == "page") $ahref = $ahref.$parameter;
              }
              else
              if ($service=="twitter")
              {
                if ($type != "link") $ahref = $ahref.$parameter;
              }
              $renderer->doc .= '<a href='.$ahref.' target="_blank"><img src="/lib/plugins/profiles/images/'.$service.'_icon.png" alt="'.$service.'" border="0"> '.$name.'</a>';
              
              return true;
        }
        
        return false;
    } 
}<commit_msg>Fixes an issue where images doesn't load when wiki installation is different from root folder<commit_after><?php
/*
 *
 * @license    MIT
 * @author     <NAME> <<EMAIL>>
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');


class syntax_plugin_profiles extends DokuWiki_Syntax_Plugin {
 
    var $links = array ("facebook" => "https://www.facebook.com/", "github" => "https://github.com/", "googleplus" => "https://plus.google.com/", "linkedin" => "http://www.linkedin.com/", "twitter" => "https://twitter.com/");
  
    function getInfo(){
        return confToHash(dirname(__FILE__).'/info.txt');
    }
 
 
    function getType(){ return 'substition'; }
    function getPType(){ return 'normal'; }
    function getAllowedTypes() { 
        return array('substition');
    }
    function getSort(){ 
      return 305; 
    }

    function connectTo($mode) {
        $this->Lexer->addSpecialPattern('{{(?:facebook|github|googleplus|linkedin|twitter)(?:|\..*?):.*?}}',$mode,'plugin_profiles');
    }
 
    function handle($match, $state, $pos, &$handler){

        switch ($state) {

          case DOKU_LEXER_SPECIAL : 
            preg_match ('/{{(?P<service>facebook|github|googleplus|linkedin|twitter)(?P<type>|\..*?):(?P<parameter>.*?)}}/', $match, $data);
            $params = array ();
            $params["service"] = $data["service"];
            $params["type"] = $data["type"];
            $params["parameter"] = $data["parameter"];

            return $params;
        
          default:
            return "";
        }
    }
 
    function render($mode, &$renderer, $indata) {

        if($mode == 'xhtml'){

              $service = $indata["service"];
              $type = $indata["type"];
              if (strlen ($type)>0) $type = substr ($type, 1);
              $p = explode ("|", $indata["parameter"]);
              $parameter = htmlspecialchars($p[0]);
              if (strlen ($p[1])==0) $name = htmlspecialchars($p[0]);
              else $name = htmlspecialchars($p[1]);
              $ahref = $this->links[$service];
              if ($type == "link") $ahref = $parameter;
              if ($service=="facebook")
              {
                if ($type == "profile" || $type == "page" || $type == "") $ahref = $ahref.$parameter;
              }
              else
              if ($service=="github")
              {
                $ahref = $ahref.$parameter;
              }
              else
              if ($service=="googleplus")
              {
                $ahref = $ahref.$parameter;
              }
              else
              if ($service=="linkedin")
              {
                if ($type == "profile" || $type == "") $ahref = $ahref."in/".$parameter;
                else if ($type == "page") $ahref = $ahref.$parameter;
              }
              else
              if ($service=="twitter")
              {
                if ($type != "link") $ahref = $ahref.$parameter;
              }
              $renderer->doc .= '<a href='.$ahref.' target="_blank"><img src="' . DOKU_BASE . '/lib/plugins/profiles/images/'.$service.'_icon.png" alt="'.$service.'" border="0"> '.$name.'</a>';
              
              return true;
        }
        
        return false;
    } 
}
{'fraction_non_alphanumeric': 0.19414138394858765, 'fraction_numerical': 0.0032879988043640713, 'mean_word_length': 1.895716140199048, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 41, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6454141', 'n_tokens_mistral': 2042, 'n_tokens_neox': 1963, 'n_words': 352}