Completed
Branch master (d3bd06)
by Mark
02:04
created
syntax.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,46 +91,46 @@  discard block
 block discarded – undo
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');
98 98
             $backlinks = ft_backlinks($data[0]);
99 99
 
100
-            $renderer->doc .= '<div id="plugin__backlinks">' . DW_LF;
100
+            $renderer->doc .= '<div id="plugin__backlinks">'.DW_LF;
101 101
 
102 102
             $filterNS = $data[1];
103
-            if(!empty($backlinks) && !empty($filterNS)) {
103
+            if (!empty($backlinks) && !empty($filterNS)) {
104 104
                 if (stripos($filterNS, "!", 0) === 0) {
105 105
                     $filterNS = substr($filterNS, 1);
106
-                    $backlinks= array_filter($backlinks, function($ns) use($filterNS) {
106
+                    $backlinks = array_filter($backlinks, function($ns) use($filterNS) {
107 107
                         return stripos($ns, $filterNS, 0) !== 0;
108 108
                     });
109 109
                 } else {
110
-                    $backlinks= array_filter($backlinks, function($ns) use($filterNS) {
110
+                    $backlinks = array_filter($backlinks, function($ns) use($filterNS) {
111 111
                         return stripos($ns, $filterNS, 0) === 0;
112 112
                     });
113 113
                 }
114 114
             }
115 115
 
116
-            if(!empty($backlinks)) {
116
+            if (!empty($backlinks)) {
117 117
 
118 118
                 $renderer->doc .= '<ul class="idx">';
119 119
 
120
-                foreach($backlinks as $backlink){
121
-                    $name = p_get_metadata($backlink,'title');
122
-                    if(empty($name)) $name = $backlink;
120
+                foreach ($backlinks as $backlink) {
121
+                    $name = p_get_metadata($backlink, 'title');
122
+                    if (empty($name)) $name = $backlink;
123 123
                     $renderer->doc .= '<li><div class="li">';
124
-                    $renderer->doc .= html_wikilink(':'.$backlink,$name,'');
124
+                    $renderer->doc .= html_wikilink(':'.$backlink, $name, '');
125 125
                     $renderer->doc .= '</div></li>';
126 126
                 }
127 127
 
128 128
                 $renderer->doc .= '</ul>';
129 129
             } else {
130
-                $renderer->doc .= "<strong>Plugin Backlinks: " . $lang['nothingfound'] . "</strong>";
130
+                $renderer->doc .= "<strong>Plugin Backlinks: ".$lang['nothingfound']."</strong>";
131 131
             }
132 132
 
133
-            $renderer->doc .= '</div>' . DW_LF;
133
+            $renderer->doc .= '</div>'.DW_LF;
134 134
 
135 135
             return true;
136 136
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,10 +13,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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>';
Please login to merge, or discard this patch.