commit 2ac47ba64b24b2fcf053212bd373eb2f47deef58 Author: Andreas Gohr Date: Fri Oct 3 17:39:52 2008 +0200 initial checkin darcs-hash:20081003153952-7ad00-e6c62cb9d0bc4cb0d6274e944174b5ed1110dfad.gz diff --git a/conf/metadata.php b/conf/metadata.php new file mode 100644 index 0000000..2480181 --- /dev/null +++ b/conf/metadata.php @@ -0,0 +1,5 @@ +Top level directory]
\n"; +@@ -1782,7 +1782,7 @@ + $newheader =~ s/__STYLEFILE__/..\/$config{stylefile}/g if $config{'stylefile'}; + $newheader =~ s/__PRINTSTYLEFILE__/..\/$config{printstylefile}/g if $config{'printstylefile'}; + $newheader =~ s/__RELROOT__/..\//g; +- $newheader.=javascript_header(1, '_functions', "index.$ext", "logFunction('$funcname');"); ++ $newheader.=javascript_header(1, '_functions', $func_ids{$funcname}.".$ext", "logFunction('$funcname');"); + print $FUNCINDEX $newheader; + print $FUNCINDEX &navtoggle_html('../'); + print $FUNCINDEX "[Top level directory]
\n"; +@@ -1925,7 +1925,7 @@ + $newheader =~ s/__STYLEFILE__/..\/$config{stylefile}/g if $config{'stylefile'}; + $newheader =~ s/__PRINTSTYLEFILE__/..\/$config{printstylefile}/g if $config{'printstylefile'}; + $newheader =~ s/__RELROOT__/..\//g; +- $newheader.=javascript_header(1, '_classes', "index.$ext", "logClass('$classname');"); ++ $newheader.=javascript_header(1, '_classes', $class_ids{$classname}.".$ext", "logClass('$classname');"); + print $CLASSINDEX $newheader; + print $CLASSINDEX &navtoggle_html('../'); + print $CLASSINDEX "[Top level directory]
\n"; +@@ -2025,7 +2025,7 @@ + $newheader =~ s/__STYLEFILE__/..\/$config{stylefile}/g if $config{'stylefile'}; + $newheader =~ s/__PRINTSTYLEFILE__/..\/$config{printstylefile}/g if $config{'printstylefile'}; + $newheader =~ s/__RELROOT__/..\//g; +- $newheader.=javascript_header(1, '_constants', "index.$ext", "logConstant('$constname');"); ++ $newheader.=javascript_header(1, '_constants', $constname.".$ext", "logConstant('$constname');"); + print $CONSTINDEX $newheader; + print $CONSTINDEX &navtoggle_html('../'); + print $CONSTINDEX "[Top level directory]
\n"; +@@ -2123,7 +2123,7 @@ + $newheader =~ s/__STYLEFILE__/..\/$config{stylefile}/g if $config{'stylefile'}; + $newheader =~ s/__PRINTSTYLEFILE__/..\/$config{printstylefile}/g if $config{'printstylefile'}; + $newheader =~ s/__RELROOT__/..\//g; +- $newheader.=javascript_header(1, '_tables', "index.$ext"); ++ $newheader.=javascript_header(1, '_tables', "$tablenameid.$ext"); + print $TABLEINDEX $newheader; + print $TABLEINDEX &navtoggle_html('../'); + print $TABLEINDEX &javascript_search(1); diff --git a/style.css b/style.css new file mode 100644 index 0000000..53bcc1b --- /dev/null +++ b/style.css @@ -0,0 +1,11 @@ +a.xref_plugin { + padding-left: 18px; + background: transparent url(xref.png) left top no-repeat; +} + +a.xref_plugin_err { + color: __missing__ !important; + text-decoration: none !important; + border-bottom: dashed 1px __missing__ !important; +} + diff --git a/syntax.php b/syntax.php new file mode 100644 index 0000000..061accb --- /dev/null +++ b/syntax.php @@ -0,0 +1,149 @@ + + */ +// must be run within Dokuwiki +if(!defined('DOKU_INC')) die(); + +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'syntax.php'); + +class syntax_plugin_xref extends DokuWiki_Syntax_Plugin { + + var $dir = ''; + var $web = ''; + + function syntax_plugin_xref(){ + $this->dir = rtrim($this->getConf('dir'),'/'); + $this->web = rtrim($this->getConf('web'),'/'); + } + + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Andreas Gohr', + 'email' => 'andi@splitbrain.org', + 'date' => '2008-10-03', + 'name' => 'PHPXref Plugin', + 'desc' => 'Makes linking to a PHPXref generated API doc easy.', + 'url' => 'http://dokuwiki.org/plugin:xref', + ); + } + + /** + * What kind of syntax are we? + */ + function getType(){ + return 'substition'; + } + + /** + * What about paragraphs? + */ + function getPType(){ + return 'normal'; + } + + /** + * Where to sort in? + */ + function getSort(){ + return 150; + } + + + /** + * Connect pattern to lexer + */ + function connectTo($mode) { + $this->Lexer->addSpecialPattern('\[\[xref>.+?\]\]',$mode,'plugin_xref'); + } + + + /** + * Handle the match + */ + function handle($match, $state, $pos, &$handler){ + $match = trim(substr($match,7,-2)); + + list($link,$name) = explode('|',$match,2); + if(!$name) $name = $link; + + $first = 0; + if($link[0] == '$') $first = 4; + $found = $this->_find($link,$first); + + return array($link,$found,$name); + } + + /** + * Create output + */ + function render($format, &$R, $data) { + global $conf; + if($format != 'xhtml') return false; + + //prepare for formating + $link['target'] = $conf['target']['extern']; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = ''; + $link['class'] = 'xref_plugin'; + $link['name'] = hsc($data[2]); + + if(!$data[1]){ + $link['url'] = $this->web; + $link['title'] = $this->getLang('unknown'); + $link['class'] .= ' xref_plugin_err'; + }else{ + $link['url'] = $this->web.'/'.$data[1]; + $link['title'] = sprintf($this->getLang('view'),hsc($data[0])); + } + + $R->doc .= $R->_formatLink($link); + return true; + } + + /** + * Try to find the given name in the xref directory + * + * @param int $first - defines which type should be searched first for the name + */ + function _find($name,$first=0){ + $paths = array( + 0 => '_functions', + 1 => '_classes', + 2 => '_constants', + 3 => '_tables', + 4 => '_variables' + ); + + $clean = preg_replace('/[^\w\-_]+/','',$name); + $small = strtolower($clean); + + $path = $paths[$first]; + unset($paths[$first]); + do{ + $check = $path.'/'.$clean.'.html'; + if(@file_exists($this->dir.'/'.$check)) return $check; + $check = $path.'/'.$small.'.html'; + if(@file_exists($this->dir.'/'.$check)) return $check; + $path = array_shift($paths); + }while($path); + + // still here? might be a file reference + $clean = preg_replace('/\.\.+/','.',$name); + if(@file_exists($this->dir.'/'.$clean.'.html')){ + return $clean.'.html'; + } + + return ''; + } + +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/xref.png b/xref.png new file mode 100644 index 0000000..7a7eb53 Binary files /dev/null and b/xref.png differ