*
* Plugin touchtile: display URL in tiles
*/
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_tile extends DokuWiki_Syntax_Plugin {
// ============================================================
function getType () { return 'substition'; }
function getPType () { return 'block';}
function getSort () { return 299; }
function connectTo ($mode) {
$this->Lexer->addEntryPattern (']*>', $mode, 'plugin_tile');
}
function postConnect() {
$this->Lexer->addExitPattern ('', 'plugin_tile');
}
// ============================================================
function handle ($match, $state, $pos, Doku_Handler $handler){
switch ($state) {
case DOKU_LEXER_ENTER:
return array ($state, trim (substr ($match, 5, -1))); // "
5 ">" => 1
case DOKU_LEXER_UNMATCHED:
return array ($state, $match);
case DOKU_LEXER_EXIT:
return array ($state);
}
return false;
}
var $iconSize;
var $imgAttr;
// ============================================================
function render ($mode, Doku_Renderer $renderer, $indata) {
if ($mode != 'xhtml')
return false;
if (empty ($indata))
return false;
list ($instr, $data) = $indata;
switch ($instr) {
case DOKU_LEXER_ENTER :
if (preg_match_all ("#(\"[^\"]*\")*help(\"[^\"]*\")*#", $data, $dumy) > 0)
$this->help ($renderer);
$this->iconSize = $this->getConf ('iconSize');
if (preg_match_all ("#(\"[^\"]*\")*width=\"(?[^\"]*)\"(\"[^\"]*\")*#", $data, $dumy) > 0)
$this->iconSize = $dumy ['width'][0];
$this->imgAttr = ' width="'.$this->iconSize.'"';
$renderer->doc .= ' ';
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= '
';
break;
case DOKU_LEXER_UNMATCHED :
$data = trim ($data);
if (empty ($data))
return false;
global $_REQUEST;
foreach (explode ("\n", $data) as $line) {
$line = trim ($line);
if (!$line)
continue;
$line = preg_replace ("#\s+\|#", "|", $line);
$line = preg_replace ("#\|\s+#", "|", $line);
$line = trim ($line,'|');
list ($id, $title, $img, $email, $name) = explode ("|", $line);
if (!$id)
continue;
$email = obfuscate ($email);
$mailto = $email ? ''.($name ? $name : $email).'' : "";
$renderer->doc .= '
';
}
break;
}
return true;
}
// ============================================================
function help (Doku_Renderer $renderer) {
$url = "http://admin.parlenet.org/plugins/tile/";
$renderer->doc .=
' Tile Help
'.NL.
' '.NL.
' - Syntax : <tile [help] [width=pp]>
'.
' | :dokuwiki:namespace:page | Short Description | :dokuwiki:namespace:icon.png | member.mel@some.where.org | nickname |
'.
' | http... | Short Description | :dokuwiki:namespace:icon.png | member.mel@some.where.org | nickname |
'.
' ...
'.
' </tile> '.NL.
' - Info : '.$url.'
'.NL.
'
'.NL;
}
// ============================================================
} // syntax_plugin_tile
?>