initial checkin

darcs-hash:20081003153952-7ad00-e6c62cb9d0bc4cb0d6274e944174b5ed1110dfad.gz
This commit is contained in:
Andreas Gohr
2008-10-03 17:39:52 +02:00
commit 2ac47ba64b
7 changed files with 222 additions and 0 deletions

5
conf/metadata.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$meta['web'] = array('string');
$meta['dir'] = array('string');

5
lang/en/lang.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$lang['unknown'] = 'unknown cross reference';
$lang['view'] = 'view cross reference for %s';

5
lang/en/settings.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$lang['dir'] = 'Specify the directory where the PHPXref files of your project are located here.';
$lang['web'] = "Specify the root URL of your PHPXref documents here.";

View File

@ -0,0 +1,47 @@
--- phpxref.pl.orig 2008-10-03 17:19:27.000000000 +0200
+++ phpxref.pl 2008-10-03 17:39:07.000000000 +0200
@@ -1657,7 +1657,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, '_variables', "index.$ext", "logVariable('$varname');");
+ $newheader.=javascript_header(1, '_variables', $var_ids{$varname}.".$ext", "logVariable('$varname');");
print $VARINDEX $newheader;
print $VARINDEX &navtoggle_html('../');
print $VARINDEX "[<a href=\"../index.$ext\">Top level directory</a>]<br>\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 "[<a href=\"../index.$ext\">Top level directory</a>]<br>\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 "[<a href=\"../index.$ext\">Top level directory</a>]<br>\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 "[<a href=\"../index.$ext\">Top level directory</a>]<br>\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);

11
style.css Normal file
View File

@ -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;
}

149
syntax.php Normal file
View File

@ -0,0 +1,149 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
// 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 :

BIN
xref.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B