Skip to content

Commit

Permalink
Manual code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Jan 31, 2024
1 parent b7b9d8d commit 820f7b6
Show file tree
Hide file tree
Showing 17 changed files with 484 additions and 392 deletions.
4 changes: 2 additions & 2 deletions _test/action_edit_button.test.php
Expand Up @@ -16,7 +16,7 @@ function testSetName()
'target' => 'plugin_data'
);
$event = new Doku_Event('', $data);
$action->_editbutton($event, null);
$action->editButton($event, null);

$this->assertTrue(isset($data['name']));
}
Expand All @@ -28,7 +28,7 @@ function testWrongTarget()
'target' => 'default target'
);
$event = new Doku_Event('', $data);
$action->_editbutton($event, null);
$action->editButton($event, null);

$this->assertFalse(isset($data['name']));
}
Expand Down
11 changes: 5 additions & 6 deletions _test/action_handle.test.php
Expand Up @@ -8,7 +8,6 @@
*/
class action_handle_test extends DokuWikiTest
{

protected $pluginsEnabled = array('data', 'sqlite');

protected $action;
Expand All @@ -30,15 +29,15 @@ public function setUp(): void

$this->action = new action_plugin_data();
$this->helper = plugin_load('helper', 'data');
$this->db = $this->helper->_getDB();
$this->db = $this->helper->getDB();

$this->db->exec(
'INSERT INTO pages ( pid, page, title , class , lastmod) VALUES (?, ?, ?, ?, ?)',
[1, 'test', 'title', 'class', time()]
);
}

function testHandleStillPresent()
public function testHandleStillPresent()
{

$data = array(
Expand All @@ -49,13 +48,13 @@ function testHandleStillPresent()
2 => 'test'
);
$event = new Doku_Event('', $data);
$this->action->_handle($event, null);
$this->action->handle($event, null);

$pid = $this->getTestPageId();
$this->assertFalse(!$pid);
}

function testHandleDelete()
public function testHandleDelete()
{
$data = array(
0 => array(
Expand All @@ -66,7 +65,7 @@ function testHandleDelete()
);

$event = new Doku_Event('', $data);
$this->action->_handle($event, null);
$this->action->handle($event, null);

$pid = $this->db->queryValue('SELECT pid FROM pages WHERE page = ?', 'test');
$this->assertTrue(!$pid);
Expand Down
198 changes: 99 additions & 99 deletions _test/helper.test.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _test/helperAliases.test.php
Expand Up @@ -12,7 +12,7 @@ class helper_plugin_data_test_aliases extends DokuWikiTest
public function testAliases()
{
$helper = new helper_plugin_data();
$db = $helper->_getDB();
$db = $helper->getDB();
$this->assertTrue($db !== false);
$db->exec(
'INSERT INTO aliases (name, type, prefix, postfix, enum) VALUES (?,?,?,?,?)',
Expand All @@ -26,7 +26,7 @@ public function testAliases()
'postfix' => ']]'
)
);
$this->assertEquals($expect, $helper->_aliases());
$this->assertEquals($expect, $helper->aliases());

}
}
2 changes: 1 addition & 1 deletion _test/syntax_plugin_data_entry.test.php
Expand Up @@ -341,7 +341,7 @@ function testShowData()

$result = $plugin->handle($this->exampleEntry, 0, 10, $handler);

$plugin->_showData($result, $xhtml);
$plugin->showData($result, $xhtml);
$doc = (new DOMWrap\Document())->html($xhtml->doc);

$this->assertEquals(1, $doc->find('div.inline.dataplugin_entry.projects')->count());
Expand Down
26 changes: 13 additions & 13 deletions action.php
Expand Up @@ -34,12 +34,12 @@ public function __construct()
*/
public function register(EventHandler $controller)
{
$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, '_handle');
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, '_editbutton');
$controller->register_hook('HTML_EDIT_FORMSELECTION', 'BEFORE', $this, '_editform'); // deprecated
$controller->register_hook('EDIT_FORM_ADDTEXTAREA', 'BEFORE', $this, '_editform'); // replacement
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, '_handle_edit_post');
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, '_handle_ajax');
$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'handle');
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, 'editButton');
$controller->register_hook('HTML_EDIT_FORMSELECTION', 'BEFORE', $this, 'editForm'); // deprecated
$controller->register_hook('EDIT_FORM_ADDTEXTAREA', 'BEFORE', $this, 'editForm'); // replacement
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handleEditPost');
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handleAjax');
}

/**
Expand All @@ -49,12 +49,12 @@ public function register(EventHandler $controller)
* @param Event $event
* @param null $param
*/
public function _handle(Event $event, $param)
public function handle(Event $event, $param)
{
$data = $event->data;
if (strpos($data[0][1], 'dataentry') !== false) return; // plugin seems still to be there

$sqlite = $this->dthlp->_getDB();
$sqlite = $this->dthlp->getDB();
if (!$sqlite) return;
$id = ltrim($data[1] . ':' . $data[2], ':');

Expand All @@ -70,7 +70,7 @@ public function _handle(Event $event, $param)
* @param Event $event
* @param null $param
*/
public function _editbutton($event, $param)
public function editButton($event, $param)
{
if ($event->data['target'] !== 'plugin_data') {
return;
Expand All @@ -83,7 +83,7 @@ public function _editbutton($event, $param)
* @param Event $event
* @param null $param
*/
public function _editform(Event $event, $param)
public function editForm(Event $event, $param)
{
global $TEXT;
if ($event->data['target'] !== 'plugin_data') {
Expand Down Expand Up @@ -113,7 +113,7 @@ public function _editform(Event $event, $param)
/**
* @param Event $event
*/
public function _handle_edit_post(Event $event)
public function handleEditPost(Event $event)
{
if (!isset($_POST['data_edit'])) {
return;
Expand All @@ -127,7 +127,7 @@ public function _handle_edit_post(Event $event)
/**
* @param Event $event
*/
public function _handle_ajax(Event $event)
public function handleAjax(Event $event)
{
if ($event->data !== 'data_page') {
return;
Expand All @@ -137,7 +137,7 @@ public function _handle_ajax(Event $event)
$event->preventDefault();

$type = substr($_REQUEST['aliastype'], 10);
$aliases = $this->dthlp->_aliases();
$aliases = $this->dthlp->aliases();

if (!isset($aliases[$type])) {
echo 'Unknown type';
Expand Down
7 changes: 4 additions & 3 deletions admin/aliases.php
Expand Up @@ -70,7 +70,7 @@ public function handle()
global $INPUT;
if (!$INPUT->has('d') || !checkSecurityToken()) return;

$sqlite = $this->dthlp->_getDB();
$sqlite = $this->dthlp->getDB();
if (!$sqlite) return;

$sqlite->getPdo()->beginTransaction();
Expand Down Expand Up @@ -103,7 +103,7 @@ public function handle()
*/
public function html()
{
$sqlite = $this->dthlp->_getDB();
$sqlite = $this->dthlp->getDB();
if (!$sqlite) return;

echo $this->locale_xhtml('admin_intro');
Expand Down Expand Up @@ -138,7 +138,8 @@ public function html()
$form->addElement('<td>');
$form->addElement(form_makeMenuField(
'd[' . $cur . '][type]',
['', 'page', 'title', 'mail', 'url', 'dt', 'wiki', 'tag', 'hidden', 'img'], //'nspage' don't support post/prefixes
//'nspage' don't support post/prefixes
['', 'page', 'title', 'mail', 'url', 'dt', 'wiki', 'tag', 'hidden', 'img'],
$row['type'],
''
));
Expand Down
2 changes: 1 addition & 1 deletion admin/clean.php
Expand Up @@ -66,7 +66,7 @@ public function handle()
{
if (!isset($_REQUEST['data_go']) || !checkSecurityToken()) return;

$sqlite = $this->dthlp->_getDB();
$sqlite = $this->dthlp->getDB();
if (!$sqlite) return;

$rows = $sqlite->queryAll('SELECT pid, page FROM pages');
Expand Down

0 comments on commit 820f7b6

Please sign in to comment.