Skip to content

Commit aae7aec

Browse files
committed
coding style
1 parent 3f61cb4 commit aae7aec

File tree

5 files changed

+53
-52
lines changed

5 files changed

+53
-52
lines changed

action/editor.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*
1515
* like displaying the editor and adding custom edit buttons
1616
*/
17-
class action_plugin_edittable_editor extends DokuWiki_Action_Plugin {
18-
17+
class action_plugin_edittable_editor extends DokuWiki_Action_Plugin
18+
{
1919
/**
2020
* Register its handlers with the DokuWiki's event controller
2121
*/
@@ -40,10 +40,10 @@ public function register(Doku_Event_Handler $controller)
4040
*
4141
* @param Doku_Event $event
4242
*/
43-
function secedit_button(Doku_Event $event) {
44-
if($event->data['target'] !== 'table') {
45-
return;
46-
}
43+
public function secedit_button(Doku_Event $event)
44+
{
45+
if ($event->data['target'] !== 'table') return;
46+
4747
$event->data['name'] = $this->getLang('secedit_name');
4848
}
4949

@@ -151,12 +151,12 @@ public function build_table($data, $meta) {
151151
$colmax = $cols ? array_fill(0, $cols, 0) : array();
152152

153153
// find maximum column widths
154-
for($row = 0; $row < $rows; $row++) {
155-
for($col = 0; $col < $cols; $col++) {
154+
for ($row = 0; $row < $rows; $row++) {
155+
for ($col = 0; $col < $cols; $col++) {
156156
$len = dokuwiki\Utf8\PhpString::strlen($data[$row][$col]);
157157

158158
// alignment adds padding
159-
if($meta[$row][$col]['align'] == 'center') {
159+
if ($meta[$row][$col]['align'] == 'center') {
160160
$len += 4;
161161
} else {
162162
$len += 3;
@@ -165,19 +165,19 @@ public function build_table($data, $meta) {
165165
// remember lenght
166166
$meta[$row][$col]['length'] = $len;
167167

168-
if($len > $colmax[$col]) $colmax[$col] = $len;
168+
if ($len > $colmax[$col]) $colmax[$col] = $len;
169169
}
170170
}
171171

172172
$last = '|'; // used to close the last cell
173-
for($row = 0; $row < $rows; $row++) {
174-
for($col = 0; $col < $cols; $col++) {
173+
for ($row = 0; $row < $rows; $row++) {
174+
for ($col = 0; $col < $cols; $col++) {
175175

176176
// minimum padding according to alignment
177-
if($meta[$row][$col]['align'] == 'center') {
177+
if ($meta[$row][$col]['align'] == 'center') {
178178
$lpad = 2;
179179
$rpad = 2;
180-
} elseif($meta[$row][$col]['align'] == 'right') {
180+
} elseif ($meta[$row][$col]['align'] == 'right') {
181181
$lpad = 2;
182182
$rpad = 1;
183183
} else {
@@ -189,13 +189,13 @@ public function build_table($data, $meta) {
189189
$target = $colmax[$col];
190190

191191
// colspanned columns span all the cells
192-
for($i = 1; $i < $meta[$row][$col]['colspan']; $i++) {
192+
for ($i = 1; $i < $meta[$row][$col]['colspan']; $i++) {
193193
$target += $colmax[$col + $i];
194194
}
195195

196196
// copy colspans to rowspans below if any
197-
if($meta[$row][$col]['colspan'] > 1){
198-
for($i = 1; $i < $meta[$row][$col]['rowspan']; $i++) {
197+
if ($meta[$row][$col]['colspan'] > 1){
198+
for ($i = 1; $i < $meta[$row][$col]['rowspan']; $i++) {
199199
$meta[$row + $i][$col]['colspan'] = $meta[$row][$col]['colspan'];
200200
}
201201
}
@@ -205,15 +205,15 @@ public function build_table($data, $meta) {
205205
$addpad = $target - $length;
206206

207207
// decide which side needs padding
208-
if($meta[$row][$col]['align'] == 'right') {
208+
if ($meta[$row][$col]['align'] == 'right') {
209209
$lpad += $addpad;
210210
} else {
211211
$rpad += $addpad;
212212
}
213213

214214
// add the padding
215215
$cdata = $data[$row][$col];
216-
if(!$meta[$row][$col]['hide'] || $cdata) {
216+
if (!$meta[$row][$col]['hide'] || $cdata) {
217217
$cdata = str_pad('', $lpad).$cdata.str_pad('', $rpad);
218218
}
219219

action/jsinfo.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?php
22

3-
if(!defined('DOKU_INC')) die();
4-
53
/**
64
* handles the data that has to be written into jsinfo
75
*
86
* like displaying the editor and adding custom edit buttons
97
*/
10-
class action_plugin_edittable_jsinfo extends DokuWiki_Action_Plugin {
11-
8+
class action_plugin_edittable_jsinfo extends DokuWiki_Action_Plugin
9+
{
1210
/**
1311
* Register its handlers with the DokuWiki's event controller
1412
*/
15-
function register(Doku_Event_Handler $controller) {
13+
public function register(Doku_Event_Handler $controller)
14+
{
1615
// register custom edit buttons
1716
$controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'fill_jsinfo');
1817
}
1918

20-
function fill_jsinfo() {
19+
public function fill_jsinfo()
20+
{
2121
global $JSINFO;
2222
$JSINFO['plugins']['edittable']['default columnwidth'] = $this->getConf('default colwidth');
2323
}

action/newtable.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
* @author Adrian Lang <[email protected]>
66
*/
77

8-
if(!defined('DOKU_INC')) die();
9-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
10-
118
/**
129
* Handles the inserting of a new table in a running edit session
1310
*/
14-
class action_plugin_edittable_newtable extends DokuWiki_Action_Plugin {
15-
11+
class action_plugin_edittable_newtable extends DokuWiki_Action_Plugin
12+
{
1613
/**
1714
* Register its handlers with the DokuWiki's event controller
1815
*/
19-
function register(Doku_Event_Handler $controller) {
16+
function register(Doku_Event_Handler $controller)
17+
{
2018
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'toolbar');
2119

2220
//$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_newtable');
@@ -28,7 +26,8 @@ function register(Doku_Event_Handler $controller) {
2826
*
2927
* @param Doku_Event $event
3028
*/
31-
function toolbar($event) {
29+
public function toolbar(Doku_Event $event)
30+
{
3231
$event->data[] = array(
3332
'title' => $this->getLang('add_table'),
3433
'type' => 'NewTable',
@@ -42,11 +41,12 @@ function toolbar($event) {
4241
*
4342
* @param Doku_Event $event
4443
*/
45-
function handle_newtable($event) {
44+
public function handle_newtable(Doku_Event $event)
45+
{
4646
global $INPUT;
4747
global $TEXT;
4848

49-
if(!$INPUT->post->has('edittable__new')) return;
49+
if (!$INPUT->post->has('edittable__new')) return;
5050

5151
/*
5252
* $fields['pre'] has all data before the selection when the "Insert table" button was clicked
@@ -64,7 +64,7 @@ function handle_newtable($event) {
6464

6565

6666
$event->data = act_clean($event->data);
67-
switch($event->data){
67+
switch ($event->data) {
6868
case 'preview':
6969
// preview view of a table edit
7070
$INPUT->post->set('target', 'table');
@@ -73,7 +73,7 @@ function handle_newtable($event) {
7373
// edit view of a table (first edit)
7474
$INPUT->post->set('target', 'table');
7575
$TEXT = "^ ^ ^\n";
76-
foreach(explode("\n", $fields['text']) as $line) {
76+
foreach (explode("\n", $fields['text']) as $line) {
7777
$TEXT .= "| $line | |\n";
7878
}
7979
break;

action/preprocess.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@
55
* @author Andreas Gohr <[email protected]>
66
*/
77

8-
if(!defined('DOKU_INC')) die();
9-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
10-
118
/**
129
* just intercepts ACTION_ACT_PREPROCESS and emits two new events
1310
*
1411
* We have two action components handling above event but need them to execute in a specific order.
1512
* That's currently not possible to guarantee, so we catch the event only once and emit two of our own
1613
* in the right order. Once DokuWiki supports a sort we can skip this.
1714
*/
18-
class action_plugin_edittable_preprocess extends DokuWiki_Action_Plugin {
19-
15+
class action_plugin_edittable_preprocess extends DokuWiki_Action_Plugin
16+
{
2017
/**
2118
* Register its handlers with the DokuWiki's event controller
2219
*/
23-
function register(Doku_Event_Handler $controller) {
20+
public function register(Doku_Event_Handler $controller)
21+
{
2422
// register preprocessing for accepting editor data
2523
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_preprocess');
2624
}
@@ -30,7 +28,8 @@ function register(Doku_Event_Handler $controller) {
3028
*
3129
* @param Doku_Event $event
3230
*/
33-
public function handle_preprocess(Doku_Event $event){
31+
public function handle_preprocess(Doku_Event $event)
32+
{
3433
trigger_event('PLUGIN_EDITTABLE_PREPROCESS_EDITOR', $event->data);
3534
trigger_event('PLUGIN_EDITTABLE_PREPROCESS_NEWTABLE', $event->data);
3635
}

action/sectionjump.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
* @author Adrian Lang <[email protected]>
66
*/
77

8-
if(!defined('DOKU_INC')) die();
9-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
10-
11-
class action_plugin_edittable_sectionjump extends DokuWiki_Action_Plugin {
12-
8+
/**
9+
* redirect to the section containg the table
10+
*/
11+
class action_plugin_edittable_sectionjump extends DokuWiki_Action_Plugin
12+
{
1313
/**
1414
* Register its handlers with the DokuWiki's event controller
1515
*/
16-
function register(Doku_Event_Handler $controller) {
16+
function register(Doku_Event_Handler $controller)
17+
{
1718
$controller->register_hook('ACTION_SHOW_REDIRECT', 'BEFORE', $this, 'jump_to_section');
1819
}
1920

@@ -22,12 +23,13 @@ function register(Doku_Event_Handler $controller) {
2223
*
2324
* @param Doku_Event $event
2425
*/
25-
function jump_to_section($event) {
26+
function jump_to_section($event)
27+
{
2628
global $INPUT;
27-
if(!$INPUT->has('edittable_data')) return;
29+
if (!$INPUT->has('edittable_data')) return;
2830

2931
global $PRE;
30-
if(preg_match_all('/^\s*={2,}([^=\n]+)/m', $PRE, $match, PREG_SET_ORDER)) {
32+
if (preg_match_all('/^\s*={2,}([^=\n]+)/m', $PRE, $match, PREG_SET_ORDER)) {
3133
$check = false; //Byref
3234
$match = array_pop($match);
3335
$event->data['fragment'] = sectionID($match[1], $check);

0 commit comments

Comments
 (0)