zapierInstructionsHTML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
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
        echo $this->zapierInstructionsHTML();
36
    }
37
38
    /**
39
     * Get the instructions for IFTTT
40
     *
41
     * @return string
42
     */
43
    protected function iftttInstructionsHTML()
44
    {
45
        $secret = $this->getConf('hook_secret');
46
47
        $html = $this->locale_xhtml('ifttt_instructions');
48
49
        $html = str_replace('DOKU_URL', DOKU_URL, $html);
50
        $html = str_replace('$secret', hsc($secret), $html);
51
52
        return $html;
53
    }
54
55
    /**
56
     * Get the instructions for Zapier
57
     *
58
     * @return string
59
     */
60
    protected function zapierInstructionsHTML()
61
    {
62
        $html = $this->locale_xhtml('zapier_instructions');
63
        $html = str_replace('DOKU_URL', DOKU_URL, $html);
64
        return $html;
65
    }
66
}
67