Skip to content

Commit 5ab3f10

Browse files
committed
auto code cleanup
1 parent 73a57c5 commit 5ab3f10

File tree

2 files changed

+63
-56
lines changed

2 files changed

+63
-56
lines changed

lang/en/lang.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
$lang['unknown'] = 'unknown cross reference';
4-
$lang['view'] = 'view cross reference for %s';
4+
$lang['view'] = 'view cross reference for %s';
55

syntax.php

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,98 @@
44
* @author Andreas Gohr <[email protected]>
55
*/
66
// must be run within Dokuwiki
7-
if(!defined('DOKU_INC')) die();
7+
if (!defined('DOKU_INC')) die();
88

9-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10-
require_once(DOKU_PLUGIN.'syntax.php');
9+
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
10+
require_once(DOKU_PLUGIN . 'syntax.php');
1111

12-
class syntax_plugin_xref extends DokuWiki_Syntax_Plugin {
12+
class syntax_plugin_xref extends DokuWiki_Syntax_Plugin
13+
{
1314

1415
var $dir = '';
1516
var $web = '';
1617

17-
function syntax_plugin_xref(){
18-
$this->dir = rtrim($this->getConf('dir'),'/');
19-
$this->web = rtrim($this->getConf('web'),'/');
18+
function syntax_plugin_xref()
19+
{
20+
$this->dir = rtrim($this->getConf('dir'), '/');
21+
$this->web = rtrim($this->getConf('web'), '/');
2022
}
2123

2224
/**
2325
* What kind of syntax are we?
2426
*/
25-
function getType(){
27+
function getType()
28+
{
2629
return 'substition';
2730
}
2831

2932
/**
3033
* What about paragraphs?
3134
*/
32-
function getPType(){
35+
function getPType()
36+
{
3337
return 'normal';
3438
}
3539

3640
/**
3741
* Where to sort in?
3842
*/
39-
function getSort(){
43+
function getSort()
44+
{
4045
return 150;
4146
}
4247

43-
4448
/**
4549
* Connect pattern to lexer
4650
*/
47-
function connectTo($mode) {
48-
$this->Lexer->addSpecialPattern('\[\[xref>.+?\]\]',$mode,'plugin_xref');
51+
function connectTo($mode)
52+
{
53+
$this->Lexer->addSpecialPattern('\[\[xref>.+?\]\]', $mode, 'plugin_xref');
4954
}
5055

51-
5256
/**
5357
* Handle the match
5458
*/
55-
function handle($match, $state, $pos, Doku_Handler $handler){
56-
$match = trim(substr($match,7,-2));
59+
function handle($match, $state, $pos, Doku_Handler $handler)
60+
{
61+
$match = trim(substr($match, 7, -2));
5762

58-
list($link,$name) = explode('|',$match,2);
59-
list($link,$anchor) = explode('#',$link,2);
60-
if(!$name) $name = $link;
61-
if($anchor) $anchor = "#".$anchor;
63+
list($link, $name) = explode('|', $match, 2);
64+
list($link, $anchor) = explode('#', $link, 2);
65+
if (!$name) $name = $link;
66+
if ($anchor) $anchor = "#" . $anchor;
6267

6368
$first = 0;
64-
if($link[0] == '$') $first = 4;
65-
$found = $this->_find($link,$first);
69+
if ($link[0] == '$') $first = 4;
70+
$found = $this->_find($link, $first);
6671

67-
return array($link,$found,$name,$anchor);
72+
return array($link, $found, $name, $anchor);
6873
}
6974

7075
/**
7176
* Create output
7277
*/
73-
function render($format, Doku_Renderer $R, $data) {
78+
function render($format, Doku_Renderer $R, $data)
79+
{
7480
global $conf;
75-
if($format != 'xhtml') return false;
81+
if ($format != 'xhtml') return false;
7682

7783
//prepare for formating
7884
$link['target'] = $conf['target']['extern'];
79-
$link['style'] = '';
80-
$link['pre'] = '';
81-
$link['suf'] = '';
82-
$link['more'] = '';
83-
$link['class'] = 'xref_plugin';
84-
$link['name'] = hsc($data[2]);
85-
86-
if(!$data[1]){
87-
$link['url'] = $this->web;
85+
$link['style'] = '';
86+
$link['pre'] = '';
87+
$link['suf'] = '';
88+
$link['more'] = '';
89+
$link['class'] = 'xref_plugin';
90+
$link['name'] = hsc($data[2]);
91+
92+
if (!$data[1]) {
93+
$link['url'] = $this->web;
8894
$link['title'] = $this->getLang('unknown');
8995
$link['class'] .= ' xref_plugin_err';
90-
}else{
91-
$link['url'] = $this->web.'/'.$data[1].hsc($data[3]);
92-
$link['title'] = sprintf($this->getLang('view'),hsc($data[0]));
96+
} else {
97+
$link['url'] = $this->web . '/' . $data[1] . hsc($data[3]);
98+
$link['title'] = sprintf($this->getLang('view'), hsc($data[0]));
9399
}
94100

95101
$R->doc .= $R->_formatLink($link);
@@ -101,32 +107,33 @@ function render($format, Doku_Renderer $R, $data) {
101107
*
102108
* @param int $first - defines which type should be searched first for the name
103109
*/
104-
function _find($name,$first=0){
110+
function _find($name, $first = 0)
111+
{
105112
$paths = array(
106-
0 => '_functions',
107-
1 => '_classes',
108-
2 => '_constants',
109-
3 => '_tables',
110-
4 => '_variables'
111-
);
112-
113-
$clean = preg_replace('/[^\w\-_]+/','',$name);
113+
0 => '_functions',
114+
1 => '_classes',
115+
2 => '_constants',
116+
3 => '_tables',
117+
4 => '_variables',
118+
);
119+
120+
$clean = preg_replace('/[^\w\-_]+/', '', $name);
114121
$small = strtolower($clean);
115122

116123
$path = $paths[$first];
117124
unset($paths[$first]);
118-
do{
119-
$check = $path.'/'.$clean.'.html';
120-
if(@file_exists($this->dir.'/'.$check)) return $check;
121-
$check = $path.'/'.$small.'.html';
122-
if(@file_exists($this->dir.'/'.$check)) return $check;
125+
do {
126+
$check = $path . '/' . $clean . '.html';
127+
if (@file_exists($this->dir . '/' . $check)) return $check;
128+
$check = $path . '/' . $small . '.html';
129+
if (@file_exists($this->dir . '/' . $check)) return $check;
123130
$path = array_shift($paths);
124-
}while($path);
131+
} while ($path);
125132

126133
// still here? might be a file reference
127-
$clean = preg_replace('/\.\.+/','.',$name);
128-
if(@file_exists($this->dir.'/'.$clean.'.html')){
129-
return $clean.'.html';
134+
$clean = preg_replace('/\.\.+/', '.', $name);
135+
if (@file_exists($this->dir . '/' . $clean . '.html')) {
136+
return $clean . '.html';
130137
}
131138

132139
return '';

0 commit comments

Comments
 (0)