1<?php 2/** 3 * Imageflow Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author i-net software <tools@inetsoftware.de> 7 * @author Gerry Weissbach <gweissbach@inetsoftware.de> 8 */ 9 10if(!defined('DOKU_INC')) die(); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12 13require_once(DOKU_PLUGIN.'syntax.php'); 14 15class syntax_plugin_phosphor_phblock extends DokuWiki_Syntax_Plugin { 16 17 /** 18 * return some info 19 */ 20 function getInfo(){ 21 return array_merge(confToHash(dirname(__FILE__).'/info.txt'), array( 22 'name' => 'PhosPhor - movie embedding as a block', 23 )); 24 } 25 26 function getType(){ return 'container';} 27 function getAllowedTypes() { return array('phitem'); } 28 function getPType(){ return 'block';} 29 30 /** 31 * Where to sort in? 32 */ 33 function getSort(){ return 301; } 34 35 /** 36 * Connect pattern to lexer 37 */ 38 function connectTo($mode) { 39 $this->Lexer->addEntryPattern('<phosphor>(?=.*?</phosphor>)',$mode,'plugin_phosphor_phblock'); 40 $this->Lexer->addEntryPattern('<phosphor .+?>(?=.*?</phosphor>)',$mode,'plugin_phosphor_phblock'); 41 } 42 43 function postConnect() { 44 $this->Lexer->addExitPattern('</phosphor.*?>', 'plugin_phosphor_phblock'); 45 } 46 47 /** 48 * Handle the match 49 */ 50 function handle($match, $state, $pos, Doku_Handler $handler){ 51 52 switch ($state) { 53 case DOKU_LEXER_ENTER: 54 55 $option = array( 'class' => 'phosphor' ); 56 foreach ( explode(' ', substr($match, 10, -1)) as $item ) { 57 list($v,$n) = explode('=', $item, 2); 58 list($w1, $w2) = explode('x', $item, 2); 59 60 if ( empty($n) ) { 61 if ( !empty($w2) ) { 62 // Width+Height 63 $option['phwrapper_width'] = $w1; 64 $v = 'phitemlist_width'; 65 $n = $w2; 66 } else { 67 $option['class'] .= ' ' . trim($v); 68 continue; 69 } 70 } 71 72 $option[$v] = trim($n); 73 } 74 75 return array('phosphor__start', $option, $pos); 76 break; 77 78 case DOKU_LEXER_EXIT: 79 80 return array('phosphor__end', null, $pos + strlen($match)); 81 break; 82 } 83 return false; 84 } 85 86 /** 87 * Create output 88 */ 89 function render($mode, Doku_Renderer $renderer, $input) { 90 global $conf; 91 if($mode == 'xhtml'){ 92 93 $renderer->nocache(); 94 95 list($instr, $data, $pos) = $input; 96 97 switch ( $instr ) { 98 99 case 'phosphor__start' : 100 101 $renderer->doc .= '<div class="phblock' . (method_exists($renderer, "finishSectionEdit") ? ' ' . $renderer->startSectionEdit($pos, array( 'target' => 'section', 'name' => 'layeranimation')) : "") . '">' . "\n"; 102 $renderer->doc .= '<div class="phwrapper"' . (!empty($data['phitemlist_width'])?' style="width:' . hsc($data['phwrapper_width']) . '"':'') . '>'; 103 104 $functions =& plugin_load('syntax', 'phosphor_phosphor' ); 105 $renderer->doc .= $functions->backgroundContainer($renderer, $data); 106 107 $renderer->doc .= '</div>'; 108 $renderer->doc .= '<div class="phitemlist"' . (!empty($data['phitemlist_width'])?' style="width:' . hsc($data['phitemlist_width']) . '"':'') . '>'; 109 110 break; 111 case 'phosphor__end' : 112 113 $renderer->doc .= '</div></div>' . "\n"; 114 if ( method_exists($renderer, "finishSectionEdit") ) { $renderer->finishSectionEdit($pos); } 115 116 break; 117 default : 118 return false; 119 } 120 return true; 121 } 122 return false; 123 } 124} 125 126//Setup VIM: ex: et ts=4 enc=utf-8 : 127