* 2012/4/13
* 1. Release first version
* 2012/4/14
* 1. Add Album Name Function : Get Album Name
*/
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_photowidget extends DokuWiki_Syntax_Plugin {
var $dflt = array(
'feed' => 'off',
'width' => 300,
'height' => 300
);
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Jonathan Tsai',
'email' => 'tryweb@ichiayi.com',
'date' => '2012-04-14',
'name' => 'photowidget Plugin',
'desc' => 'Add Photo Widget to your wiki
Syntax: Album Name',
'url' => 'http://www.dokuwiki.org/plugin:photowidget'
);
}
/**
* What kind of syntax are we?
*/
function getType() { return 'substition'; }
function getPType() { return 'block'; }
/**
* Where to sort in to parse?
*/
function getSort() { return 900; }
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\n]*>.*?',$mode,'plugin_photowidget');
}
function postConnect() {
$this->Lexer->addExitPattern('','plugin_photowidget');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
// break matched cdata into its components
list($str_params,$str_albumname) = explode('>',substr($match,13,-14),2);
$gmap = $this->_extract_params($str_params);
$gmap['name']=$str_albumname;
return array($gmap);
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
if ($mode == 'xhtml') {
list($param) = $data;
$w_width = str_replace("px","",$param['width']);
$w_height = str_replace("px","",$param['height']);
$str_name =(isset($param['name']) && trim($param['name'])!='')?$param['name']:'';
$w_height0=($str_name!='')?$w_height+25:$w_height;
$renderer->doc .= '