'flashplayer', 'author' => 'Arno Welzel', 'email' => 'himself@arnowelzel.de', 'date' => '2012-05-11', 'name' => 'FlashPlayer Plugin', 'desc' => 'Embeds JW Flash Player 5.8.2011 in the page, based on the work of Sam Hall', 'url' => 'http://arnowelzel.de/wiki/misc/flashplayer', ); } function getType(){ return 'formatting'; } function getSort(){ return 158; } function connectTo($mode) { $this->Lexer->addEntryPattern('(?=.*?)',$mode,'plugin_flashplayer'); } function postConnect() { $this->Lexer->addExitPattern('','plugin_flashplayer'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : $attributes = strtolower(substr($match, 10, -1)); $width = $this->_getNumericalAttribute($attributes, "width", "340"); $height = $this->_getNumericalAttribute($attributes, "height", "20"); $position = $this->_getNumericalAttribute($attributes, "position", "0"); $uid = md5(uniqid(rand(), true)); return array($state, array($width, $height, $position, $uid)); case DOKU_LEXER_UNMATCHED : return array($state, $match); case DOKU_LEXER_EXIT : return array($state, ''); } return array(); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ list($state, $vars) = $data; switch ($state) { case DOKU_LEXER_ENTER : list($this->width, $this->height, $this->position, $this->uid) = $vars; switch($this->position) { case 1: $renderer->doc .= '

'; break; case 2: $renderer->doc .= '

'; break; } $renderer->doc .= 'doc .= ' type="application/x-shockwave-flash"'; $renderer->doc .= ' data="'.DOKU_BASE.'lib/plugins/flashplayer/player/player.swf"'; $renderer->doc .= ' width="'.$this->width.'"'; $renderer->doc .= ' height="'.$this->height.'"'; $renderer->doc .= '>'; $renderer->doc .= ''; $renderer->doc .= '('.$this->getLang('getflash').')'; $renderer->doc .= ''; // $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= ''; switch($this->position) { case 1: case 2: $renderer->doc .= '

'; break; } break; } return true; } return false; } function _getNumericalAttribute($attributeString, $attribute, $default){ $retVal = $default; $pos = strpos($attributeString, $attribute."="); if ($pos === false) { //Maybe they have a space... $pos = strpos($attributeString, $attribute." "); } if ($pos > 0) { $pos = $pos + strlen($attribute); $value = substr($attributeString,$pos); //replace '=' and quote signs with null and trim leading spaces $value = str_replace("=","",$value); $value = str_replace("'","",$value); $value = str_replace('"','',$value); $value = ltrim($value); //grab the text before the next space $pos = strpos($value, " "); if ($pos > 0) { $value = substr($value,0,$pos); } //validate that it's numerical if (preg_match("^[0-9]+$^", $value)) $retVal = $value; } return $retVal; } } //Setup VIM: ex: et ts=4 enc=utf-8 :