@@ -13,10 +13,16 @@ discard block |
||
13 | 13 | * @author Michael Klier <[email protected]> |
14 | 14 | * @author Mark C. Prins <[email protected]> |
15 | 15 | */ |
16 | -if(!defined('DOKU_INC')) die(); |
|
16 | +if(!defined('DOKU_INC')) { |
|
17 | + die(); |
|
18 | +} |
|
17 | 19 | |
18 | -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
19 | -if(!defined('DW_LF')) define('DW_LF',"\n"); |
|
20 | +if(!defined('DOKU_PLUGIN')) { |
|
21 | + define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
22 | +} |
|
23 | +if(!defined('DW_LF')) { |
|
24 | + define('DW_LF',"\n"); |
|
25 | +} |
|
20 | 26 | |
21 | 27 | require_once(DOKU_PLUGIN.'syntax.php'); |
22 | 28 | require_once(DOKU_INC.'inc/parserutils.php'); |
@@ -119,7 +125,9 @@ discard block |
||
119 | 125 | |
120 | 126 | foreach($backlinks as $backlink){ |
121 | 127 | $name = p_get_metadata($backlink,'title'); |
122 | - if(empty($name)) $name = $backlink; |
|
128 | + if(empty($name)) { |
|
129 | + $name = $backlink; |
|
130 | + } |
|
123 | 131 | $renderer->doc .= '<li><div class="li">'; |
124 | 132 | $renderer->doc .= html_wikilink(':'.$backlink,$name,''); |
125 | 133 | $renderer->doc .= '</div></li>'; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @author Michael Klier <[email protected]> |
14 | 14 | * @author Mark C. Prins <[email protected]> |
15 | 15 | */ |
16 | -if(!defined('DOKU_INC')) die(); |
|
16 | +if (!defined('DOKU_INC')) die(); |
|
17 | 17 | |
18 | -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
|
19 | -if(!defined('DW_LF')) define('DW_LF',"\n"); |
|
18 | +if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); |
|
19 | +if (!defined('DW_LF')) define('DW_LF', "\n"); |
|
20 | 20 | |
21 | 21 | require_once(DOKU_PLUGIN.'syntax.php'); |
22 | 22 | require_once(DOKU_INC.'inc/parserutils.php'); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * Needs to return one of the mode types defined in $PARSER_MODES in parser.php |
33 | 33 | * @see DokuWiki_Syntax_Plugin::getType() |
34 | 34 | */ |
35 | - function getType() { return 'substition'; } |
|
35 | + function getType() { return 'substition'; } |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @see DokuWiki_Syntax_Plugin::getPType() |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @see Doku_Parser_Mode::getSort() |
44 | 44 | */ |
45 | - function getSort() { return 304; } |
|
45 | + function getSort() { return 304; } |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Connect pattern to lexer. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Handler to prepare matched data for the rendering process. |
57 | 57 | * @see DokuWiki_Syntax_Plugin::handle() |
58 | 58 | */ |
59 | - function handle($match, $state, $pos, Doku_Handler $handler){ |
|
59 | + function handle($match, $state, $pos, Doku_Handler $handler) { |
|
60 | 60 | |
61 | 61 | // Take the id of the source |
62 | 62 | // It can be a rendering of a sidebar |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | $id = $INFO['id']; |
69 | 69 | } |
70 | 70 | |
71 | - $match = substr($match,12,-2); //strip {{backlinks> from start and }} from end |
|
71 | + $match = substr($match, 12, -2); //strip {{backlinks> from start and }} from end |
|
72 | 72 | |
73 | - if(strstr($match, "#")){ |
|
73 | + if (strstr($match, "#")) { |
|
74 | 74 | $includeNS = substr(strstr($match, "#", FALSE), 1); |
75 | - $match= strstr($match, "#", TRUE); |
|
75 | + $match = strstr($match, "#", TRUE); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $match = ($match == '.') ? $id : $match; |
79 | 79 | |
80 | - if(strstr($match,".:")) { |
|
81 | - resolve_pageid(getNS($id),$match,$exists); |
|
80 | + if (strstr($match, ".:")) { |
|
81 | + resolve_pageid(getNS($id), $match, $exists); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return (array($match, $includeNS)); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | function render($mode, Doku_Renderer $renderer, $data) { |
92 | 92 | global $lang; |
93 | 93 | |
94 | - if($mode == 'xhtml'){ |
|
94 | + if ($mode == 'xhtml') { |
|
95 | 95 | $renderer->info['cache'] = false; |
96 | 96 | |
97 | 97 | @require_once(DOKU_INC.'inc/fulltext.php'); |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | |
100 | 100 | dbglog($backlinks, "backlinks: all backlinks to: $data[0]"); |
101 | 101 | |
102 | - $renderer->doc .= '<div id="plugin__backlinks">' . DW_LF; |
|
102 | + $renderer->doc .= '<div id="plugin__backlinks">'.DW_LF; |
|
103 | 103 | |
104 | 104 | $filterNS = $data[1]; |
105 | - if(!empty($backlinks) && !empty($filterNS)) { |
|
105 | + if (!empty($backlinks) && !empty($filterNS)) { |
|
106 | 106 | if (stripos($filterNS, "!", 0) === 0) { |
107 | 107 | $filterNS = substr($filterNS, 1); |
108 | 108 | dbglog($filterNS, "backlinks: exluding all of namespace: $filterNS"); |
109 | - $backlinks= array_filter($backlinks, function($ns) use($filterNS) { |
|
109 | + $backlinks = array_filter($backlinks, function($ns) use($filterNS) { |
|
110 | 110 | return stripos($ns, $filterNS, 0) !== 0; |
111 | 111 | }); |
112 | 112 | } else { |
113 | 113 | dbglog($filterNS, "backlinks: including namespace: $filterNS only"); |
114 | - $backlinks= array_filter($backlinks, function($ns) use($filterNS) { |
|
114 | + $backlinks = array_filter($backlinks, function($ns) use($filterNS) { |
|
115 | 115 | return stripos($ns, $filterNS, 0) === 0; |
116 | 116 | }); |
117 | 117 | } |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | |
120 | 120 | dbglog($backlinks, "backlinks: all backlinks to be rendered"); |
121 | 121 | |
122 | - if(!empty($backlinks)) { |
|
122 | + if (!empty($backlinks)) { |
|
123 | 123 | |
124 | 124 | $renderer->doc .= '<ul class="idx">'; |
125 | 125 | |
126 | - foreach($backlinks as $backlink){ |
|
126 | + foreach ($backlinks as $backlink) { |
|
127 | 127 | $name = p_get_metadata($backlink, 'title'); |
128 | - if(empty($name)) $name = $backlink; |
|
128 | + if (empty($name)) $name = $backlink; |
|
129 | 129 | $renderer->doc .= '<li><div class="li">'; |
130 | 130 | $renderer->doc .= html_wikilink(':'.$backlink, $name); |
131 | 131 | $renderer->doc .= '</div></li>'; |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | |
134 | 134 | $renderer->doc .= '</ul>'; |
135 | 135 | } else { |
136 | - $renderer->doc .= "<strong>Plugin Backlinks: " . $lang['nothingfound'] . "</strong>"; |
|
136 | + $renderer->doc .= "<strong>Plugin Backlinks: ".$lang['nothingfound']."</strong>"; |
|
137 | 137 | } |
138 | 138 | |
139 | - $renderer->doc .= '</div>' . DW_LF; |
|
139 | + $renderer->doc .= '</div>'.DW_LF; |
|
140 | 140 | |
141 | 141 | return true; |
142 | 142 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * Simple test to make sure the plugin.info.txt is in correct format |
28 | 28 | */ |
29 | 29 | public function test_plugininfo() { |
30 | - $file = __DIR__ . '/../plugin.info.txt'; |
|
30 | + $file = __DIR__.'/../plugin.info.txt'; |
|
31 | 31 | $this->assertFileExists($file); |
32 | 32 | |
33 | 33 | $info = confToHash($file); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | //print_r(scandir(DOKU_TMP_DATA.'pages/')); |
51 | 51 | } |
52 | 52 | |
53 | - function setUp() { |
|
53 | + function setUp() { |
|
54 | 54 | parent::setUp(); |
55 | 55 | |
56 | 56 | global $conf; |
@@ -87,6 +87,6 @@ discard block |
||
87 | 87 | $wikilink = pq('.idx .li .wikilink1', $doc); |
88 | 88 | $this->assertEquals(1, $wikilink->length, 'There should be 1 backlink'); |
89 | 89 | $this->assertEquals($wikilink->contents()[0],'An included link to Bob Ross', |
90 | - 'There should be a link to "An included link to Bob Ross"'); |
|
90 | + 'There should be a link to "An included link to Bob Ross"'); |
|
91 | 91 | } |
92 | 92 | } |
@@ -54,7 +54,9 @@ |
||
54 | 54 | parent::tearDownAfterClass(); |
55 | 55 | |
56 | 56 | $log = file_get_contents(TMP_DIR . '/cache/debug.log'); |
57 | - if(!$log) print_r($log); |
|
57 | + if(!$log) { |
|
58 | + print_r($log); |
|
59 | + } |
|
58 | 60 | } |
59 | 61 | |
60 | 62 | public function setUp() { |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * copy data and add pages to the index. |
30 | 30 | */ |
31 | - public static function setUpBeforeClass(){ |
|
31 | + public static function setUpBeforeClass() { |
|
32 | 32 | parent::setUpBeforeClass(); |
33 | 33 | global $conf; |
34 | 34 | |
35 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
35 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
36 | 36 | |
37 | 37 | $data = array(); |
38 | 38 | search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
39 | 39 | |
40 | 40 | $verbose = false; |
41 | 41 | $force = true; |
42 | - foreach($data as $val) { |
|
42 | + foreach ($data as $val) { |
|
43 | 43 | idx_addPage($val['id'], $verbose, $force); |
44 | 44 | } |
45 | 45 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | global $conf; |
63 | 63 | $log = file_get_contents($conf['cachedir'].'/debug.log'); |
64 | - if(!$log) print_r($log); |
|
64 | + if (!$log) print_r($log); |
|
65 | 65 | TestUtils::rdelete($conf['cachedir']); |
66 | 66 | } |
67 | 67 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $wikilink = pq('.idx .li .wikilink1', $doc); |
87 | 87 | $this->assertEquals(1, $wikilink->length, 'There should be 1 backlink'); |
88 | - $this->assertEquals($wikilink->contents()[0],'An included link to Bob Ross', |
|
88 | + $this->assertEquals($wikilink->contents()[0], 'An included link to Bob Ross', |
|
89 | 89 | 'There should be a link to "An included link to Bob Ross"'); |
90 | 90 | } |
91 | 91 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | //print_r(scandir(DOKU_TMP_DATA.'pages/')); |
51 | 51 | } |
52 | 52 | |
53 | - function setUp() { |
|
53 | + function setUp() { |
|
54 | 54 | parent::setUp(); |
55 | 55 | |
56 | 56 | global $conf; |
@@ -54,7 +54,9 @@ |
||
54 | 54 | parent::tearDownAfterClass(); |
55 | 55 | |
56 | 56 | $log = file_get_contents(TMP_DIR . '/cache/debug.log'); |
57 | - if(!$log) print_r($log); |
|
57 | + if(!$log) { |
|
58 | + print_r($log); |
|
59 | + } |
|
58 | 60 | } |
59 | 61 | |
60 | 62 | public function setUp() { |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * copy data and add pages to the index. |
30 | 30 | */ |
31 | - public static function setUpBeforeClass(){ |
|
31 | + public static function setUpBeforeClass() { |
|
32 | 32 | parent::setUpBeforeClass(); |
33 | 33 | global $conf; |
34 | 34 | |
35 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
35 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
36 | 36 | |
37 | 37 | $data = array(); |
38 | 38 | search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
39 | 39 | |
40 | 40 | $verbose = false; |
41 | 41 | $force = true; |
42 | - foreach($data as $val) { |
|
42 | + foreach ($data as $val) { |
|
43 | 43 | idx_addPage($val['id'], $verbose, $force); |
44 | 44 | } |
45 | 45 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | global $conf; |
63 | 63 | $log = file_get_contents($conf['cachedir'].'/debug.log'); |
64 | - if(!$log) print_r($log); |
|
65 | - TestUtils::rdelete(TMP_DIR . '/cache/'); |
|
64 | + if (!$log) print_r($log); |
|
65 | + TestUtils::rdelete(TMP_DIR.'/cache/'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function testExclude() { |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * copy data and add pages to the index. |
30 | 30 | */ |
31 | - public static function setUpBeforeClass(){ |
|
31 | + public static function setUpBeforeClass() { |
|
32 | 32 | parent::setUpBeforeClass(); |
33 | 33 | global $conf; |
34 | 34 | |
35 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
35 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
36 | 36 | |
37 | 37 | //print "Index dir (after copy):\n"; |
38 | 38 | //print_r(scandir(DOKU_TMP_DATA.'index/')); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $verbose = false; |
57 | 57 | $force = true; |
58 | - foreach($data as $val) { |
|
58 | + foreach ($data as $val) { |
|
59 | 59 | idx_addPage($val['id'], $verbose, $force); |
60 | 60 | } |
61 | 61 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // try to get the debug log |
67 | 67 | global $conf; |
68 | 68 | $log = file_get_contents($conf['cachedir'].'/debug.log'); |
69 | - if(!$log) { |
|
69 | + if (!$log) { |
|
70 | 70 | print_r($log); |
71 | 71 | unlink($conf['cachedir'].'/debug.log'); |
72 | 72 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->assertEquals(4, $wikilink->length, 'There should be 4 backlinks'); |
121 | 121 | //print "wikilink[0]:\n"; |
122 | 122 | //print_r(pq($wikilink->contents()[0], $doc)); |
123 | - $this->assertEquals($wikilink->contents()[3],'A link to Bob Ross', |
|
123 | + $this->assertEquals($wikilink->contents()[3], 'A link to Bob Ross', |
|
124 | 124 | 'The last backlink should be a link to Bob Ross'); |
125 | 125 | } |
126 | 126 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $this->assertEquals(4, $wikilink->length, 'There should be 4 backlinks'); |
143 | 143 | //print "wikilink[0]:\n"; |
144 | 144 | //print_r(pq($wikilink->contents()[0], $doc)); |
145 | - $this->assertEquals($wikilink->contents()[3],'A link to Bob Ross', |
|
145 | + $this->assertEquals($wikilink->contents()[3], 'A link to Bob Ross', |
|
146 | 146 | 'The last backlink should be a link to Bob Ross'); |
147 | 147 | } |
148 | 148 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | //print_r(scandir(DOKU_TMP_DATA.'pages/')); |
41 | 41 | } |
42 | 42 | |
43 | - function setUp() { |
|
43 | + function setUp() { |
|
44 | 44 | parent::setUp(); |
45 | 45 | |
46 | 46 | global $conf; |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | global $conf; |
69 | 69 | $log = file_get_contents($conf['cachedir'].'/debug.log'); |
70 | 70 | if(!$log) { |
71 | - print_r($log); |
|
72 | - unlink($conf['cachedir'].'/debug.log'); |
|
73 | - } |
|
71 | + print_r($log); |
|
72 | + unlink($conf['cachedir'].'/debug.log'); |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function testIndex() { |
77 | 77 | $indexer = idx_get_indexer(); |
78 | 78 | $query = array('Ross'); |
79 | 79 | $this->assertEquals( |
80 | - array('Ross' => array('link' => 1)), |
|
81 | - $indexer->lookup($query) |
|
80 | + array('Ross' => array('link' => 1)), |
|
81 | + $indexer->lookup($query) |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | print_r($indexer->lookup($query)); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | strpos($response->getContent(), 'A link to Bob Ross') !== false, |
102 | 102 | 'A link to Bob Ross was not in the output' |
103 | 103 | ); |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | public function testStoryPage() { |
107 | 107 | $request = new TestRequest(); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | //print "wikilink[0]:\n"; |
123 | 123 | //print_r(pq($wikilink->contents()[0], $doc)); |
124 | 124 | $this->assertEquals($wikilink->contents()[3],'A link to Bob Ross', |
125 | - 'The last backlink should be a link to Bob Ross'); |
|
125 | + 'The last backlink should be a link to Bob Ross'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | public function testBacklinks() { |
@@ -144,6 +144,6 @@ discard block |
||
144 | 144 | //print "wikilink[0]:\n"; |
145 | 145 | //print_r(pq($wikilink->contents()[0], $doc)); |
146 | 146 | $this->assertEquals($wikilink->contents()[3],'A link to Bob Ross', |
147 | - 'The last backlink should be a link to Bob Ross'); |
|
147 | + 'The last backlink should be a link to Bob Ross'); |
|
148 | 148 | } |
149 | 149 | } |