* @version 2018-05-12
*
* pgn4web.js changes: "=" -> "||" ; "+" -> "\u2192"
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
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');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_pgn4web extends DokuWiki_Syntax_Plugin {
/**
* function constructor
*/
function syntax_plugin_pgn4web(){
// enable direct access to language strings
$this->setupLocale();
}
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Michael Arlt',
'email' => 'michael.arlt@sk-schwanstetten.de',
'date' => '2016-07-24',
'name' => 'pgn4web Plugin',
'desc' => $this->getLang('desc') ,
'license'=> 'GPL v3 (http://www.gnu.org/licenses/gpl.html)',
'url' => 'http://wiki.splitbrain.org/plugin:pgn4web'
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* Where to sort in?
*/
function getSort(){
return 38;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('.+?',$mode,'plugin_pgn4web');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler) {
$match=substr($match,6,-7);
return $match;
}
/**
* Create output
*/
function render($mode, Doku_Renderer $renderer,$data)
{
if($mode == 'xhtml')
{
$shadow_size=20;
// defaults
$set = $this->getConf('set');
$setsizeportrait = $this->getConf('setsizeportrait');
$setsizelandscape = $this->getConf('setsizelandscape');
$pluginwidthportrait = $this->getConf('pluginwidthportrait');
$pluginwidthlandscape = $this->getConf('pluginwidthlandscape');
$font = $this->getConf('font');
$infowidth = $this->getConf('infowidth');
$textheight = $this->getConf('textheight');
$layout = $this->getConf('layout');
//error_log("set:$set setsizeportrait:$setsizeportrait font:$font");
$squaresizeportrait=intval($setsizeportrait/2);
$squaresizelandscape=intval($setsizelandscape/2);
$boardsizeportrait=8*($squaresizeportrait+12)+16;
$boardsizelandscape=8*($squaresizelandscape+12)+16;
if ($layout == "portrait") {
$boardsizelandscape = $boardsizeportrait;
$setsizelandscape = $setsizeportrait;
$pluginwidthlandscape = $pluginwidthportrait;
}
if ($layout == "landscape") {
$boardsizeportrait = $boardsizelandscape;
$setsizeportrait = $setsizelandscape;
$pluginwidthportrait = $pluginwidthlandscape;
}
$renderer->doc .= '
';
$renderer->doc .= '
';
// check set folder
// TODO!
if (! is_dir( DOKU_PLUGIN . "pgn4web/pgn4web/images/$relative_pieces_path")) {
$problem = true;
if (preg_match("/svg/",$set)) {
$renderer->doc .= pgn4web_error(sprintf($this->getLang('err_font_dir'),$pieces_fs_path));
} else {
if ($set >=0 && $set <= 6) { # set is valid -> err_size if folder not found
$renderer->doc .= pgn4web_error(sprintf($this->getLang('err_size'),$setsizeportrait,$set+1));
}
}
}
// check single pgn4web instance
if (defined('PGN4WEB')) {
$problem = true;
$renderer->doc .= pgn4web_info($this->getConf('err_instance'));
if (auth_quickaclcheck($ID) >= AUTH_EDIT) {
$renderer->doc .= pgn4web_info($this->getConf('err_instance_author'));
}
} else {
define('PGN4WEB',true);
}
if ($problem) {
return true;
}
// ausgabe
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '
';
return true;
}
return false;
}
}
function pgn4web_info($text) {
return "$text
";
}
function pgn4web_error($text) {
$problem = true;
return "$text
";
}
//Setup VIM: ex: et ts=4 :