Skip to content

Commit

Permalink
Merge pull request #5 from LarsGit223/master
Browse files Browse the repository at this point in the history
Added var 'ALIAS' for outputing email aliases.
  • Loading branch information
LarsGit223 committed Jun 8, 2017
2 parents 41aa56a + be472a9 commit 3a3d00a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
require_once(DOKU_INC.'inc/infoutils.php');

class syntax_plugin_var extends DokuWiki_Syntax_Plugin {
protected $aliasSeps = '._-';

/// Added in 2015-06 release to implement
static $wikiVERSION;

function getType() { return 'substition'; }
function getSort() { return 99; }
function connectTo($mode) { $this->Lexer->addSpecialPattern('@\w{2,6}@', $mode, 'plugin_var'); }
function connectTo($mode) { $this->Lexer->addSpecialPattern('@\w{2,6}['.$this->aliasSeps.']?@', $mode, 'plugin_var'); }

function handle($match, $state, $pos, Doku_Handler $handler) {
$match = substr($match, 1, -1); // strip markup
Expand All @@ -32,7 +33,14 @@ function render($mode, Doku_Renderer $renderer, $data) {
global $INFO;
global $conf;

$meta = $data[0];
$meta = $data[0];
$length = strlen($meta);
$aliasSep = '.';
$part = substr($meta, 0, -1);
if ($part == 'ALIAS' && strpos ($this->aliasSeps, $meta[$length-1]) !== false) {
$aliasSep = $meta[$length-1];
$meta = $part;
}
$nocache = false;
switch ($meta) {
case 'ID':
Expand All @@ -51,6 +59,10 @@ function render($mode, Doku_Renderer $renderer, $data) {
$xhtml = $_SERVER['REMOTE_USER'];
$nocache = true;
break;
case 'ALIAS':
$xhtml = ($_SERVER['REMOTE_USER'] ? str_replace(' ', $aliasSep, $INFO['userinfo']['name']) : $_SERVER['REMOTE_USER']);
$nocache = true;
break;
case 'NAME':
$xhtml = ($_SERVER['REMOTE_USER'] ? $INFO['userinfo']['name'] : clientIP());
$nocache = true;
Expand Down

0 comments on commit 3a3d00a

Please sign in to comment.