PgwJsLibrary::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PgwJsLibrary.php
5
 *
6
 * Adapter for the PgwJs ModalInterface library.
7
 *
8
 * @package jaxon-dialogs
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-dialogs
13
 */
14
15
namespace Jaxon\Dialogs\PgwJs;
16
17
use Jaxon\App\Dialog\Library\DialogLibraryTrait;
18
use Jaxon\App\Dialog\ModalInterface;
19
20
class PgwJsLibrary implements ModalInterface
21
{
22
    use DialogLibraryTrait;
23
24
    /**
25
     * @const The library name
26
     */
27
    const NAME = 'pgwjs';
28
29
    /**
30
     * @inheritDoc
31
     */
32
    public function getName(): string
33
    {
34
        return self::NAME;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function getSubdir(): string
41
    {
42
        return 'pgwjs/modal';
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function getVersion(): string
49
    {
50
        return '2.0.0';
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56
    public function getJs(): string
57
    {
58
        return $this->helper()->getJsCode('pgwmodal.min.js');
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64
    public function getCss(): string
65
    {
66
        return $this->helper()->getCssCode('pgwmodal.min.css');
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function getScript(): string
73
    {
74
        return $this->helper()->render('pgwjs/alert.js');
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    public function getReadyScript(): string
81
    {
82
        $sVarPrefix = 'jaxon.dialogs.pgwjs.options.';
83
        return $this->helper()->render('pgwjs/ready.js.php', [
84
            'options' => $this->helper()->getOptionScript($sVarPrefix, 'options.modal.'),
85
        ]);
86
    }
87
88
    /**
89
     * @inheritDoc
90
     */
91
    public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = [])
92
    {
93
        // Set the value of the max width, if there is no value defined
94
        $aOptions['title'] = $sTitle;
95
        $aOptions['content'] = $this->helper()->render('pgwjs/dialog.html',
96
            ['content' => $sContent, 'buttons' => $aButtons]);
97
        // Affectations du contenu de la fenêtre
98
        $this->addCommand(array('cmd'=>'pgw.modal'), $aOptions);
99
    }
100
101
    /**
102
     * @inheritDoc
103
     */
104
    public function hide()
105
    {
106
        $this->response()->script('$.pgwModal("close")');
107
    }
108
}
109