* @author Gerry Weissbach */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); require_once(DOKU_INC.'inc/search.php'); require_once(DOKU_INC.'inc/JpegMeta.php'); class syntax_plugin_imageflow_imageflow extends DokuWiki_Syntax_Plugin { private $glideToImage = 0; private $saveimages = ''; private $imagedoc = ''; private $namespace = null; private $reflection_conf = false; private $sectionID = array(); private $header = array(); function getType(){ return 'protected';} function getAllowedTypes() { return array('container','substition','protected','disabled','formatting','paragraphs'); } function getPType(){ return 'block';} /** * Where to sort in? */ function getSort(){ return 301; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern('(?=.*?)',$mode,'plugin_imageflow_imageflow'); $this->Lexer->addEntryPattern(']+>(?=)',$mode,'plugin_imageflow_imageflow'); } function postConnect() { $this->Lexer->addPattern('.*?','plugin_imageflow_imageflow'); $this->Lexer->addPattern('[\r|\n]','plugin_imageflow_imageflow'); $this->Lexer->addExitPattern('', 'plugin_imageflow_imageflow'); } /** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler){ switch ($state) { case DOKU_LEXER_ENTER: if ( $match == '' ) { return array('imageflow__start', null); } if( preg_match('%]+)>%', $match, $matches) ) { return array('imageflow__start', $matches[1]); } break; case DOKU_LEXER_MATCHED: if ( !(strstr($match, '')) ) { return false; } list($orig, $desc) = explode('>', substr($match, 6, -8), 2); list($src, $title) = explode('|', $orig, 2); list($src, $params) = explode('?', $src, 2); $paramsFull = explode('&', str_replace('&', '&', $params)); $params = array(); foreach( $paramsFull as $item ) { list($key, $value) = explode('=', $item, 2); if ( $key == 'width' ) $key = 'w'; if ( $key == 'height' ) $key = 'h'; $params[$key] = $value; } $data = array('src' => trim($src), 'params' => $params, 'desc' => trim($desc), 'w' => 200, 'title' => trim($title)); if ( empty( $params['linkto'] ) ) { $data['isImage'] = true; } else { $data['linkto'] = cleanID($params['linkto']); unset($params['linkto']); } return array('image', $data); break; case DOKU_LEXER_UNMATCHED: break; case DOKU_LEXER_EXIT: if ( $match == '' ) { return array('imageflow__end', null); } break; } return false; } /** * Create output */ function render($mode, Doku_Renderer $renderer, $input) { global $conf; list($instr, $data) = $input; if( $mode == 'xhtml' || $mode == 'metadata' ) { if ( !is_array($this->header[$mode]) ) { $this->header[$mode] = array(); } switch ( $instr ) { case 'imageflow__start' : $this->sectionID[] = sectionID("imageflow_container_", $this->header[$mode]); $scID = $this->sectionID[sizeof($this->sectionID)-1]; if ($mode == 'xhtml') $renderer->doc .= <<