media.png?999x999|Title}} * @top,left,width,height | note title text * note text line 1 * ... * note text line 2 * ~author_name * @... * ~ * ... * {{ two.jpg?300x300 |Bla}} * @10,10,100,100|title text * ~zumi * @120, 110, 50, 50|title with a [[link]] * a centered image: \\ * {{ two.jpg?100x100 }} \\ * and a link((footnote)): \\ * [[this is a very interesting link]] * ~ * {{id_seq_num = 0; } function getInfo(){ return array( 'author' => 'Itay Donenhirsch', 'email' => 'itay@bazoo.org', 'date' => '2009-05-05', 'name' => 'Annotated Image Plugin', 'desc' => 'Use FotoNotes to display annotations on images', 'url' => 'http://itay.bazoo.org/projects/aimg', ); } function getType(){ return 'container'; } function getAllowedTypes() { return array('formatting','substition','disabled','protected','container','paragraphs'); } function getPType() { return 'block'; } function getSort(){ return 311; } function connectTo($mode) { $this->Lexer->addEntryPattern('\{\{aimg>[^\}]+\}\}',$mode,'plugin_aimg'); } function postConnect() { $this->Lexer->addPattern('^@.*?\n\~.*?\n','plugin_aimg'); $this->Lexer->addExitPattern('\{\{_imgToId( $img, $pos ); $img_args = array( $img_id, $img['type'], $img['src'], $img['title'], $img['align'], $img['width'], $img['height'], $img['cache']); return array( $state, $img_args ); case DOKU_LEXER_MATCHED: return array( $state, $match ); case DOKU_LEXER_EXIT : default: return array( $state ); } } // adapted from image_map plugin function _render_image( &$renderer, $img_args ) { list($img_id, $img_type, $img_src, $img_title, $img_align, $img_width, $img_height, $img_cache) = $img_args; if ($img_type == 'internalmedia') { resolve_mediaid(getNS($ID),$img_src, $exists); } $img_src = ml($img_src,array('w'=>$img_width,'h'=>$img_height,'cache'=>$img_cache)); $renderer->doc .= ' _xmlEntities($img_title); $renderer->doc .= ' title="'.$img_title.'"'; $renderer->doc .= ' alt="'.$img_title.'"'; } else { $renderer->doc .= ' alt=""'; } if (!is_null($img_width)) { $renderer->doc .= ' width="'.$renderer->_xmlEntities($img_width).'"'; } if (!is_null($img_height)) { $renderer->doc .= ' height="'.$renderer->_xmlEntities($img_height).'"'; } $renderer->doc .= ' />'.DOKU_LF; return $img_id; } function render($mode, &$renderer, $data) { if ( substr($mode,0,5) == 'xhtml' ) { $state = $data[0]; switch($state) { case DOKU_LEXER_ENTER : $arg = $data[1]; $this->img_id = $arg[0]; $this->img_width = $arg[5]; $this->img_height = $arg[6]; $img_align = $arg[4]; $align_style = ''; switch( $img_align ) { case 'left': $align_style = 'margin-right: auto;'; break; case 'right': $align_style = 'margin-left: auto;'; break; case 'center': case 'centre': $align_style = 'margin: 0 auto;'; break; } $style = 'width: '.$this->img_width.'px; height: '.$this->img_height.'px; '.$align_style; $renderer->doc .= '

'.DOKU_LF; $renderer->doc .= '

'.DOKU_LF; $renderer->doc .= '
'.DOKU_LF; $this->_render_image( $renderer, $arg ); break; case DOKU_LEXER_MATCHED: $this->id_seq_num++; $match = $data[1]; list($header,$body) = explode( "\n", substr($match, 1, -1), 2 ); list($coords,$title) = explode( "|", $header, 2 ); list($top,$left,$width,$height) = explode( ",", $coords ); $style = 'left: '.$left.'px; top: '.$top.'px; width: '.$width.'px; height: '.$height.'px;'; list($content,$author) = preg_split( "/\n~/", $body, 2 ); // fix for case with signature right after title if ( $content[0] == '~' ) { $author = substr( $content, 1 ); $content = ''; } $renderer->doc .= '
'.DOKU_LF; $renderer->doc .= '
'.DOKU_LF; $renderer->doc .= ' '; $renderer->doc .= p_render($mode, p_get_instructions( $title ), $dummy); $renderer->doc .= ''.DOKU_LF; $renderer->doc .= ' '; $renderer->doc .= p_render($mode, p_get_instructions( $content ), $dummy); $renderer->doc .= ''.DOKU_LF; $renderer->doc .= ' '; $renderer->doc .= p_render($mode, p_get_instructions( $author ), $dummy); $renderer->doc .= ''.DOKU_LF; $renderer->doc .= '
'.DOKU_LF; $renderer->doc .= '
'.DOKU_LF; break; case DOKU_LEXER_EXIT : $renderer->doc .= '
'.DOKU_LF.'
'.DOKU_LF; $renderer->doc .= '

'.DOKU_LF; break; } return true; } else { return false; } } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>