Passed
Push — develop ( aead11...22319a )
by Michael
01:44
created

admin_plugin_swarmwebhook::iftttInstructionsHTML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
class admin_plugin_swarmwebhook extends DokuWiki_Admin_Plugin
4
{
5
6
    public function forAdminOnly()
7
    {
8
        return true;
9
    }
10
11
    public function handle()
12
    {
13
    }
14
15
16
    public function html()
17
    {
18
        echo '<h1>Instructions to create the swarm webhook with IFTTT</h1>';
19
        $secret = $this->getConf('hook_secret');
20
        if (empty($secret)) {
21
            $exampleSecret = md5(time());
22
            $settingsID = 'plugin____swarmwebhook____plugin_settings_name';
23
            $configHRef = DOKU_REL . DOKU_SCRIPT . '?do=admin&page=config#' . $settingsID;
24
            $configLink = '<a href="' . $configHRef . '">' . $this->getLang('configuration') . '</a>';
25
            $secretNeededMsg = sprintf(
26
                $this->getLang('secret needed'),
27
                $configLink,
28
                '<code>' . $exampleSecret . '</code>'
29
            );
30
            echo '<p>' . $secretNeededMsg . '</p>';
31
            return;
32
        }
33
34
        echo $this->iftttInstructionsHTML();
35
    }
36
37
    /**
38
     * Get the instructions for IFTTT
39
     *
40
     * @return string
41
     */
42
    protected function iftttInstructionsHTML()
43
    {
44
        $secret = $this->getConf('hook_secret');
45
46
        $html = $this->locale_xhtml('ifttt_instructions');
47
48
        $html = str_replace('DOKU_URL', DOKU_URL, $html);
49
        $html = str_replace('$secret', hsc($secret), $html);
50
51
        return $html;
52
    }
53
}
54