Skip to content

Commit a8aa294

Browse files
committed
remove requires, if defined DOKU_INC, add phpdocs,
remove some by ref of objects, some formatting
1 parent 7267916 commit a8aa294

File tree

7 files changed

+53
-59
lines changed

7 files changed

+53
-59
lines changed

action.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
* @author Esther Brunner <[email protected]>
55
*/
66

7-
// must be run within Dokuwiki
8-
if(!defined('DOKU_INC')) die();
9-
10-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11-
require_once(DOKU_PLUGIN.'action.php');
12-
137
class action_plugin_blog extends DokuWiki_Action_Plugin {
148

159
/**
1610
* register the eventhandlers
11+
* @param Doku_Event_Handler $contr
1712
*/
1813
function register(Doku_Event_Handler $contr) {
1914
$contr->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_act_preprocess', array());
@@ -24,6 +19,8 @@ function register(Doku_Event_Handler $contr) {
2419
/**
2520
* Checks if 'newentry' was given as action, if so we
2621
* do handle the event our self and no further checking takes place
22+
* @param Doku_Event $event
23+
* @param $param
2724
*/
2825
function handle_act_preprocess(Doku_Event $event, $param) {
2926
if ($event->data != 'newentry') return; // nothing to do for us
@@ -34,9 +31,12 @@ function handle_act_preprocess(Doku_Event $event, $param) {
3431
/**
3532
* Removes draft entries from feeds
3633
*
34+
* @param Doku_Event $event
35+
* @param $param
36+
*
3737
* @author Michael Klier <[email protected]>
3838
*/
39-
function handle_feed_item(&$event, $param) {
39+
function handle_feed_item(Doku_Event $event, $param) {
4040
global $conf;
4141

4242
$url = parse_url($event->data['item']->link);
@@ -80,6 +80,9 @@ function handle_feed_item(&$event, $param) {
8080

8181
/**
8282
* Creates a new entry page
83+
*
84+
* @param Doku_Event $event
85+
* @return string
8386
*/
8487
function _handle_newEntry(Doku_Event $event) {
8588
global $ID, $INFO;
@@ -123,6 +126,10 @@ function _handle_newEntry(Doku_Event $event) {
123126

124127
/**
125128
* Adapted version of pageTemplate() function
129+
*
130+
* @param $text
131+
* @param $data
132+
* @return string|string[]
126133
*/
127134
function _pageTemplate($text, $data) {
128135
global $conf, $INFO;
@@ -175,8 +182,12 @@ function _pageTemplate($text, $data) {
175182
/**
176183
* Returns the ID of a new entry based on its namespace, title and the date prefix
177184
*
178-
* @author Esther Brunner <[email protected]>
185+
* @param $ns
186+
* @param $title
187+
* @return mixed|string|string[]|null
188+
*
179189
* @author Michael Arlt <[email protected]>
190+
* @author Esther Brunner <[email protected]>
180191
*/
181192
function _newEntryID($ns, $title) {
182193
$dateprefix = $this->getConf('dateprefix');
@@ -205,6 +216,9 @@ function _newEntryID($ns, $title) {
205216
/**
206217
* Expire the renderer cache of archive pages whenever a page is updated or a comment or linkback is added
207218
*
219+
* @param Doku_Event $event
220+
* @param $params
221+
*
208222
* @author Michael Hamann <[email protected]>
209223
*/
210224
function handle_cache(Doku_Event $event, $params) {
@@ -243,4 +257,3 @@ function handle_cache(Doku_Event $event, $params) {
243257
}
244258
}
245259
}
246-
// vim:ts=4:sw=4:et:enc=utf-8:

helper.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
* @author Esther Brunner <[email protected]>
55
*/
66

7-
// must be run within Dokuwiki
8-
if (!defined('DOKU_INC')) die();
9-
107
class helper_plugin_blog extends DokuWiki_Plugin {
118

129
var $sort = ''; // sort key
@@ -15,8 +12,6 @@ class helper_plugin_blog extends DokuWiki_Plugin {
1512
* Constructor
1613
*/
1714
function helper_plugin_blog() {
18-
global $conf;
19-
2015
// load sort key from settings
2116
$this->sort = $this->getConf('sortkey');
2217
}
@@ -42,16 +37,17 @@ function getMethods() {
4237

4338
/**
4439
* Get blog entries from a given namespace
40+
*
41+
* @param $ns
42+
* @param null $num
43+
* @param null $author
44+
* @return array
4545
*/
4646
function getBlog($ns, $num = NULL, $author = NULL) {
47-
global $conf;
48-
4947
// add pages in given namespace
5048
$result = array();
5149
global $conf;
5250

53-
require_once (DOKU_INC.'inc/search.php');
54-
5551
$pages = array();
5652
$unique_keys_memoize = array();
5753

@@ -172,6 +168,10 @@ function getFlags($setflags) {
172168
/**
173169
* Function to create sortable, unique array keys
174170
*
171+
* @param $key
172+
* @param $unique_keys_memoize
173+
* @return string
174+
*
175175
* @author Esther Brunner <[email protected]>
176176
* @author Ilya S. Lebedev <[email protected]>
177177
* @author Balazs Attila-Mihaly <[email protected]>
@@ -187,4 +187,3 @@ function _uniqueKey($key, &$unique_keys_memoize){
187187
}
188188

189189
}
190-
// vim:ts=4:sw=4:et:enc=utf-8:

plugin.info.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
base blog
33
author Michael Hamann, Michael Klier, Gina Haeussge
44
5-
date 2018-09-03
5+
date 2020-09-18
66
name Blog
77
desc Use DokuWiki as blogging tool. (previous authors: Esther Brunner)
8-
url http://www.dokuwiki.org/plugin:blog
8+
url https://www.dokuwiki.org/plugin:blog

syntax/archive.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
* @author Esther Brunner <[email protected]>
77
*/
88

9-
// must be run within Dokuwiki
10-
if(!defined('DOKU_INC')) die();
11-
12-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13-
require_once(DOKU_PLUGIN.'syntax.php');
14-
159
/**
1610
* All DokuWiki plugins to extend the parser/rendering mechanism
1711
* need to inherit from this class
@@ -100,7 +94,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
10094

10195
// get the blog entries for our namespace
10296
/** @var helper_plugin_blog $my */
103-
if ($my =& plugin_load('helper', 'blog')) $entries = $my->getBlog($ns, NULL, $author);
97+
if ($my = plugin_load('helper', 'blog')) $entries = $my->getBlog($ns, NULL, $author);
10498
else return false;
10599

106100
// use tag refinements?
@@ -127,7 +121,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
127121
} else {
128122
// let Pagelist Plugin do the work for us
129123
if (plugin_isdisabled('pagelist')
130-
|| (!$pagelist =& plugin_load('helper', 'pagelist'))) {
124+
|| (!$pagelist = plugin_load('helper', 'pagelist'))) {
131125
msg($this->getLang('missing_pagelistplugin'), -1);
132126
return false;
133127
}

syntax/autoarchive.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?php
22
/**
3-
* Dynamic Archive Plugin: dynamically displays
3+
* Dynamic Archive Plugin: dynamically displays
44
*
55
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
66
* @author Esther Brunner <[email protected]>
77
*/
88

9-
// must be run within Dokuwiki
10-
if(!defined('DOKU_INC')) die();
11-
12-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13-
require_once(DOKU_PLUGIN.'syntax.php');
14-
159
/**
1610
* All DokuWiki plugins to extend the parser/rendering mechanism
1711
* need to inherit from this class
@@ -50,7 +44,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
5044
$renderer->info['cache'] = false;
5145

5246
// get the blog entries for our namespace
53-
if ($my =& plugin_load('helper', 'blog')) $entries = $my->getBlog($ns);
47+
if ($my = plugin_load('helper', 'blog')) $entries = $my->getBlog($ns);
5448

5549
// use tag refinements?
5650
if ($refine) {
@@ -79,7 +73,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
7973

8074
// let Pagelist Plugin do the work for us
8175
if (plugin_isdisabled('pagelist')
82-
|| (!$pagelist =& plugin_load('helper', 'pagelist'))) {
76+
|| (!$pagelist = plugin_load('helper', 'pagelist'))) {
8377
msg($this->getLang('missing_pagelistplugin'), -1);
8478
return false;
8579
}

syntax/blog.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
* @author Robert Rackl <[email protected]>
88
*/
99

10-
// must be run within Dokuwiki
11-
if (!defined('DOKU_INC')) die();
12-
13-
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
14-
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
15-
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
16-
17-
require_once(DOKU_PLUGIN.'syntax.php');
18-
1910
class syntax_plugin_blog_blog extends DokuWiki_Syntax_Plugin {
2011
private $included_pages = array();
2112

@@ -62,13 +53,13 @@ function render($mode, Doku_Renderer $renderer, $data) {
6253

6354
// get the blog entries for our namespace
6455
/** @var helper_plugin_blog $my */
65-
if ($my =& plugin_load('helper', 'blog')) $entries = $my->getBlog($ns);
56+
if ($my = plugin_load('helper', 'blog')) $entries = $my->getBlog($ns);
6657
else return false;
6758

6859
// use tag refinements?
6960
if ($refine) {
7061
/** @var helper_plugin_tag $tag */
71-
if (plugin_isdisabled('tag') || (!$tag =& plugin_load('helper', 'tag'))) {
62+
if (plugin_isdisabled('tag') || (!$tag = plugin_load('helper', 'tag'))) {
7263
msg($this->getLang('missing_tagplugin'), -1);
7364
} else {
7465
$entries = $tag->tagRefine($entries, $refine);
@@ -94,12 +85,12 @@ function render($mode, Doku_Renderer $renderer, $data) {
9485
}
9586

9687
// slice the needed chunk of pages
97-
$more = ((count($entries) > ($first + $num)) ? true : false);
88+
$isMore = count($entries) > ($first + $num);
9889
$entries = array_slice($entries, $first, $num);
9990

10091
// load the include helper plugin
10192
/** @var helper_plugin_include $include */
102-
if (plugin_isdisabled('include') || (!$include =& plugin_load('helper', 'include'))) {
93+
if (plugin_isdisabled('include') || (!$include = plugin_load('helper', 'include'))) {
10394
msg($this->getLang('missing_includeplugin'), -1);
10495
return false;
10596
}
@@ -150,7 +141,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
150141
if ($clevel && !$include_flags['inline']) $renderer->doc .= '<div class="level'.$clevel.'">'.DOKU_LF;
151142

152143
// show older / newer entries links
153-
if ($pagingcontrols) $renderer->doc .= $this->_browseEntriesLinks($more, $first, $num);
144+
if ($pagingcontrols) $renderer->doc .= $this->_browseEntriesLinks($isMore, $first, $num);
154145

155146
// show new entry form
156147
if ($perm_create && $formpos == 'bottom') {
@@ -165,6 +156,11 @@ function render($mode, Doku_Renderer $renderer, $data) {
165156

166157
/**
167158
* Displays links to older newer entries of the blog namespace
159+
*
160+
* @param $more
161+
* @param $first
162+
* @param $num
163+
* @return string
168164
*/
169165
function _browseEntriesLinks($more, $first, $num) {
170166
global $ID;
@@ -191,6 +187,10 @@ function _browseEntriesLinks($more, $first, $num) {
191187
/**
192188
* Displays a form to enter the title of a new entry in the blog namespace
193189
* and then open that page in the edit mode
190+
*
191+
* @param $ns
192+
* @param $newentrytitle
193+
* @return string
194194
*/
195195
function _newEntryForm($ns, $newentrytitle) {
196196
global $lang;

syntax/draft.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?php
22
/**
33
* Blog Plugin, draft component: marks the current page as draft
4-
*
4+
*
55
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
66
* @author Esther Brunner <[email protected]>
77
*/
88

9-
// must be run within Dokuwiki
10-
if (!defined('DOKU_INC')) die();
11-
12-
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13-
require_once(DOKU_PLUGIN.'syntax.php');
14-
159
class syntax_plugin_blog_draft extends DokuWiki_Syntax_Plugin {
1610

1711
function getType() { return 'substition'; }

0 commit comments

Comments
 (0)