@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Zilvinas Vaira |
10 | 10 | * |
11 | 11 | */ |
12 | -class DefaultAjaxPage extends AbstractPage{ |
|
12 | +class DefaultAjaxPage extends AbstractPage { |
|
13 | 13 | |
14 | 14 | const SECTION_RESPONSE = 'response'; |
15 | 15 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * {@inheritDoc} |
27 | 27 | * @see \web\lib\admin\view\PageElementInterface::render() |
28 | 28 | */ |
29 | - public function render(){ |
|
29 | + public function render() { |
|
30 | 30 | $response = $this->fetch(self::SECTION_RESPONSE); |
31 | 31 | ?><response><?php $response->render(); ?></response><?php |
32 | 32 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @author Zilvinas Vaira |
11 | 11 | * |
12 | 12 | */ |
13 | -class DefaultHtmlPage extends AbstractPage{ |
|
13 | +class DefaultHtmlPage extends AbstractPage { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Manage users base page type. |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param string $url File source url (must be clean url without query parameters). |
66 | 66 | * @return string File source url with version query. |
67 | 67 | */ |
68 | - private function decorateVersion($url){ |
|
69 | - return $url.'?v='.$this->version; |
|
68 | + private function decorateVersion($url) { |
|
69 | + return $url . '?v=' . $this->version; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $type |
76 | 76 | */ |
77 | - public function setType($type){ |
|
77 | + public function setType($type) { |
|
78 | 78 | $this->type = $type; |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function getType(){ |
|
86 | + public function getType() { |
|
87 | 87 | return $this->type; |
88 | 88 | } |
89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param string $title Page title. |
94 | 94 | */ |
95 | - public function setTitle($title){ |
|
95 | + public function setTitle($title) { |
|
96 | 96 | $this->title = $title; |
97 | 97 | } |
98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - public function getTitle(){ |
|
104 | + public function getTitle() { |
|
105 | 105 | return $this->title; |
106 | 106 | } |
107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @param PageElementInterface $element Any page element. |
112 | 112 | */ |
113 | - public function appendPrelude($element){ |
|
113 | + public function appendPrelude($element) { |
|
114 | 114 | $this->append(self::SECTION_PRELUDE, $element); |
115 | 115 | } |
116 | 116 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return PageElementInterface |
121 | 121 | */ |
122 | - public function fetchPrelude(){ |
|
122 | + public function fetchPrelude() { |
|
123 | 123 | return $this->fetch(self::SECTION_PRELUDE); |
124 | 124 | } |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param PageElementInterface $element Any page element. |
130 | 130 | */ |
131 | - public function appendContent($element){ |
|
131 | + public function appendContent($element) { |
|
132 | 132 | $this->append(self::SECTION_CONTENT, $element); |
133 | 133 | } |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return PageElementInterface |
139 | 139 | */ |
140 | - public function fetchContent(){ |
|
140 | + public function fetchContent() { |
|
141 | 141 | return $this->fetch(self::SECTION_CONTENT); |
142 | 142 | } |
143 | 143 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param string $url Path to a JavaScript file. |
148 | 148 | */ |
149 | - public function appendScript($url){ |
|
149 | + public function appendScript($url) { |
|
150 | 150 | $script = new Tag('script'); |
151 | 151 | $script->addAttribute('type', 'text/javascript'); |
152 | 152 | $script->addAttribute('src', $this->decorateVersion($url)); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return PageElementInterface |
160 | 160 | */ |
161 | - public function fetchScript(){ |
|
161 | + public function fetchScript() { |
|
162 | 162 | return $this->fetch(self::SECTION_SCRIPT); |
163 | 163 | } |
164 | 164 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param string $url Path to a CSS file. |
169 | 169 | */ |
170 | - public function appendCss($url){ |
|
170 | + public function appendCss($url) { |
|
171 | 171 | $css = new UnaryTag('link'); |
172 | 172 | $css->addAttribute('rel', 'stylesheet'); |
173 | 173 | $css->addAttribute('type', 'text/css'); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return PageElementInterface |
182 | 182 | */ |
183 | - public function fetchCss(){ |
|
183 | + public function fetchCss() { |
|
184 | 184 | return $this->fetch(self::SECTION_CSS); |
185 | 185 | } |
186 | 186 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param string[] $attributes Associative list of attributes for meta element. |
191 | 191 | */ |
192 | - public function appendMeta($attributes = array()){ |
|
192 | + public function appendMeta($attributes = array()) { |
|
193 | 193 | $meta = new Tag('meta'); |
194 | 194 | foreach ($attributes as $name => $value) { |
195 | 195 | $meta->addAttribute($name, $value); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return PageElementInterface |
204 | 204 | */ |
205 | - public function fetchMeta(){ |
|
205 | + public function fetchMeta() { |
|
206 | 206 | return $this->fetch(self::SECTION_META); |
207 | 207 | } |
208 | 208 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * {@inheritDoc} |
212 | 212 | * @see \web\lib\admin\view\PageElementInterface::render() |
213 | 213 | */ |
214 | - public function render(){ |
|
214 | + public function render() { |
|
215 | 215 | $content = $this->fetch(self::SECTION_CONTENT); |
216 | 216 | $content->render(); |
217 | 217 | } |
@@ -14,11 +14,11 @@ |
||
14 | 14 | */ |
15 | 15 | class InstitutionPageBuilder { |
16 | 16 | |
17 | - /** |
|
18 | - * Particular IdP instance. If set to null means that page is entered by a mistake. |
|
19 | - * |
|
20 | - * @var \core\IdP |
|
21 | - */ |
|
17 | + /** |
|
18 | + * Particular IdP instance. If set to null means that page is entered by a mistake. |
|
19 | + * |
|
20 | + * @var \core\IdP |
|
21 | + */ |
|
22 | 22 | protected $institution = null; |
23 | 23 | |
24 | 24 | /** |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param DefaultHtmlPage $page |
54 | 54 | */ |
55 | - public function __construct($page){ |
|
55 | + public function __construct($page) { |
|
56 | 56 | $this->page = $page; |
57 | 57 | $this->decoration = new PageDecoration(); |
58 | 58 | $this->validation = new InputValidation(); |
59 | - if(isset($_GET['inst_id'])){ |
|
59 | + if (isset($_GET['inst_id'])) { |
|
60 | 60 | try { |
61 | 61 | $this->validateInstitution(); |
62 | 62 | } catch (\Exception $e) { |
63 | 63 | $this->headerTitle = $e->getMessage(); |
64 | 64 | } |
65 | 65 | |
66 | - if($this->isReady()){ |
|
66 | + if ($this->isReady()) { |
|
67 | 67 | $pageTitle = sprintf(_("%s: %s '%s'"), CONFIG['APPEARANCE']['productname'], $page->getTitle(), $this->institution->name); |
68 | 68 | $this->page->setTitle($pageTitle); |
69 | 69 | $this->headerTitle = sprintf(_("%s information for '%s'"), $page->getTitle(), $this->institution->name); |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return \web\lib\admin\view\DefaultHtmlPage |
77 | 77 | */ |
78 | - public function getPage(){ |
|
78 | + public function getPage() { |
|
79 | 79 | return $this->page; |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Validates and retrieves institution. |
84 | 84 | */ |
85 | - protected function validateInstitution(){ |
|
85 | + protected function validateInstitution() { |
|
86 | 86 | $this->institution = $this->validation->IdP($_GET['inst_id'], $_SESSION['user']); |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return boolean |
93 | 93 | */ |
94 | - public function isReady(){ |
|
94 | + public function isReady() { |
|
95 | 95 | return isset($this->institution); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return IdP |
102 | 102 | */ |
103 | - public function getInstitution(){ |
|
103 | + public function getInstitution() { |
|
104 | 104 | return $this->institution; |
105 | 105 | } |
106 | 106 | |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return \core\ProfileSilverbullet|mixed |
111 | 111 | */ |
112 | - public function getProfile(){ |
|
112 | + public function getProfile() { |
|
113 | 113 | $profile = null; |
114 | - if($this->isReady()){ |
|
114 | + if ($this->isReady()) { |
|
115 | 115 | $profiles = $this->institution->listProfiles(); |
116 | 116 | if (count($profiles) == 1) { |
117 | 117 | if ($profiles[0] instanceof \core\ProfileSilverbullet) { |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public function getRealmName(){ |
|
130 | + public function getRealmName() { |
|
131 | 131 | $realmName = 'unknown'; |
132 | 132 | $profile = $this->getProfile(); |
133 | - if(!empty($profile)){ |
|
133 | + if (!empty($profile)) { |
|
134 | 134 | $realmName = $profile->realm; |
135 | 135 | } |
136 | 136 | return $realmName; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param PageElementInterface $element |
143 | 143 | */ |
144 | - public function addContentElement($element){ |
|
144 | + public function addContentElement($element) { |
|
145 | 145 | $this->page->appendContent($element); |
146 | 146 | } |
147 | 147 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * Builds page beginning elements. |
150 | 150 | * |
151 | 151 | */ |
152 | - public function buildPagePrelude(){ |
|
152 | + public function buildPagePrelude() { |
|
153 | 153 | $pagePrelude = new PageElementAdapter(); |
154 | 154 | $pagePrelude->addText($this->decoration->defaultPagePrelude($this->page->getTitle())); |
155 | 155 | $this->page->appendPrelude($pagePrelude); |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * Builds page content header elements. |
160 | 160 | */ |
161 | - public function buildPageHeader(){ |
|
161 | + public function buildPageHeader() { |
|
162 | 162 | $productHeader = new PageElementAdapter(); |
163 | 163 | $productHeader->addText($this->decoration->productheader($this->page->getType())); |
164 | - $this->page->appendContent($productHeader) ; |
|
164 | + $this->page->appendContent($productHeader); |
|
165 | 165 | |
166 | 166 | $pageHeading = new Tag('h1'); |
167 | 167 | $pageHeading->addText($this->headerTitle); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Builds page content footer elements. |
173 | 173 | */ |
174 | - public function buildPageFooter(){ |
|
174 | + public function buildPageFooter() { |
|
175 | 175 | $pageFooter = new PageElementAdapter(); |
176 | - $pageFooter->addText( $this->decoration->footer()); |
|
176 | + $pageFooter->addText($this->decoration->footer()); |
|
177 | 177 | $this->page->appendContent($pageFooter); |
178 | 178 | } |
179 | 179 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Zilvinas Vaira |
10 | 10 | * |
11 | 11 | */ |
12 | -class PageElementAdapter implements PageElementInterface{ |
|
12 | +class PageElementAdapter implements PageElementInterface { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Wrapped HTML element. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string $text |
41 | 41 | */ |
42 | - public function addText($text){ |
|
42 | + public function addText($text) { |
|
43 | 43 | $this->text .= $text; |
44 | 44 | } |
45 | 45 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @see \web\lib\admin\view\PageElementInterface::render() |
50 | 50 | */ |
51 | 51 | public function render() { |
52 | - if($this->element != null){ |
|
52 | + if ($this->element != null) { |
|
53 | 53 | echo $this->element; |
54 | 54 | } |
55 | - if($this->text != ''){ |
|
55 | + if ($this->text != '') { |
|
56 | 56 | echo $this->text; |
57 | 57 | } |
58 | 58 | } |
@@ -8,15 +8,15 @@ discard block |
||
8 | 8 | use web\lib\admin\view\DefaultHtmlPage; |
9 | 9 | use web\lib\admin\view\InstitutionPageBuilder; |
10 | 10 | |
11 | -class MockEmptyPageBuilder extends InstitutionPageBuilder{ |
|
11 | +class MockEmptyPageBuilder extends InstitutionPageBuilder { |
|
12 | 12 | |
13 | - public function __construct($page){ |
|
13 | + public function __construct($page) { |
|
14 | 14 | $this->page = $page; |
15 | 15 | } |
16 | 16 | |
17 | 17 | } |
18 | 18 | |
19 | -class SendTokenByEmailTest extends PHPUnit_Framework_TestCase{ |
|
19 | +class SendTokenByEmailTest extends PHPUnit_Framework_TestCase { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->command = new MockSendTokenByEmail(MockSendTokenByEmail::COMMAND, $context); |
37 | 37 | } |
38 | 38 | |
39 | - public function testExecute(){ |
|
39 | + public function testExecute() { |
|
40 | 40 | |
41 | 41 | $this->command->execute(); |
42 | 42 | $mail = $this->command->getMailer(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->command->execute(); |
51 | 51 | $this->assertEmpty($mail->ErrorInfo); |
52 | 52 | $this->assertNotEquals("", $mail->Subject); |
53 | - $this->assertTrue(strpos($mail->Body, $_POST[GetTokenEmailDetails::PARAM_TOKENLINK])!==false); |
|
53 | + $this->assertTrue(strpos($mail->Body, $_POST[GetTokenEmailDetails::PARAM_TOKENLINK]) !== false); |
|
54 | 54 | $this->assertNotEmpty($mail->getAllRecipientAddresses()); |
55 | 55 | $this->assertArrayHasKey($_POST[ValidateEmailAddress::PARAM_ADDRESS], $mail->getAllRecipientAddresses()); |
56 | 56 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))) . "/core/PHPMailer/src/PHPMailer.php"); |
3 | 3 | use PHPMailer\PHPMailer\PHPMailer; |
4 | 4 | |
5 | -class MockPHPMailer extends PHPMailer{ |
|
5 | +class MockPHPMailer extends PHPMailer { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * {@inheritDoc} |
17 | 17 | * @see \PHPMailer\PHPMailer\PHPMailer::send() |
18 | 18 | */ |
19 | - public function send(){ |
|
20 | - if($this->Subject && $this->Body && count($this->to)>0){ |
|
19 | + public function send() { |
|
20 | + if ($this->Subject && $this->Body && count($this->to) > 0) { |
|
21 | 21 | return true; |
22 | - }else{ |
|
22 | + } else { |
|
23 | 23 | $this->ErrorInfo = "Missing subject, body or email address!"; |
24 | 24 | return false; |
25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | public function send(){ |
20 | 20 | if($this->Subject && $this->Body && count($this->to)>0){ |
21 | 21 | return true; |
22 | - }else{ |
|
22 | + } else{ |
|
23 | 23 | $this->ErrorInfo = "Missing subject, body or email address!"; |
24 | 24 | return false; |
25 | 25 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use web\lib\admin\view\DefaultAjaxPage; |
4 | 4 | use web\lib\admin\view\html\CompositeTag; |
5 | 5 | |
6 | -class MockDefaultAjaxPage extends DefaultAjaxPage{ |
|
6 | +class MockDefaultAjaxPage extends DefaultAjaxPage { |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * {@inheritDoc} |
24 | 24 | * @see \web\lib\admin\view\AbstractPage::appendHtmlElement() |
25 | 25 | */ |
26 | - public function appendHtmlElement($name, $element){ |
|
27 | - if($name==DefaultAjaxPage::SECTION_RESPONSE){ |
|
26 | + public function appendHtmlElement($name, $element) { |
|
27 | + if ($name == DefaultAjaxPage::SECTION_RESPONSE) { |
|
28 | 28 | $this->response->addTag($element); |
29 | 29 | } |
30 | 30 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return CompositeTag |
35 | 35 | */ |
36 | - public function getResponse(){ |
|
36 | + public function getResponse() { |
|
37 | 37 | return $this->response; |
38 | 38 | } |
39 | 39 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use web\lib\admin\http\DefaultContext; |
6 | 6 | use web\lib\admin\http\GetTokenEmailDetails; |
7 | 7 | |
8 | -class GetTokenEmailDetailsTest extends PHPUnit_Framework_TestCase{ |
|
8 | +class GetTokenEmailDetailsTest extends PHPUnit_Framework_TestCase { |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | $this->command = new GetTokenEmailDetails(GetTokenEmailDetails::COMMAND, new DefaultContext($this->page)); |
25 | 25 | } |
26 | 26 | |
27 | - public function testExecute(){ |
|
27 | + public function testExecute() { |
|
28 | 28 | |
29 | 29 | $this->command->execute(); |
30 | 30 | $response = $this->page->getResponse(); |
31 | 31 | $renderedResponse = $response->__toString(); |
32 | - $this->assertTrue(strpos($renderedResponse, '<response>')!==false); |
|
33 | - $this->assertTrue(strpos($renderedResponse, '</response>')!==false); |
|
32 | + $this->assertTrue(strpos($renderedResponse, '<response>') !== false); |
|
33 | + $this->assertTrue(strpos($renderedResponse, '</response>') !== false); |
|
34 | 34 | $this->assertFalse(strpos($renderedResponse, 'subject=')); |
35 | 35 | |
36 | 36 | $_POST[GetTokenEmailDetails::PARAM_TOKENLINK] = 'testtokenlinkstring'; |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | $renderedResponse = $response->__toString(); |
41 | 41 | |
42 | - $this->assertTrue(strpos($renderedResponse, '<response>')!==false); |
|
43 | - $this->assertTrue(strpos($renderedResponse, '</response>')!==false); |
|
44 | - $this->assertTrue(strpos($renderedResponse, 'subject=')!==false); |
|
45 | - $this->assertTrue(strpos($renderedResponse, $_POST[GetTokenEmailDetails::PARAM_TOKENLINK])!==false); |
|
42 | + $this->assertTrue(strpos($renderedResponse, '<response>') !== false); |
|
43 | + $this->assertTrue(strpos($renderedResponse, '</response>') !== false); |
|
44 | + $this->assertTrue(strpos($renderedResponse, 'subject=') !== false); |
|
45 | + $this->assertTrue(strpos($renderedResponse, $_POST[GetTokenEmailDetails::PARAM_TOKENLINK]) !== false); |
|
46 | 46 | } |
47 | 47 | } |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | use web\lib\admin\http\SilverbulletContext; |
5 | 5 | use web\lib\admin\http\GetTokenEmailDetails; |
6 | 6 | |
7 | -class MockSendTokenByEmail extends SendTokenByEmail{ |
|
7 | +class MockSendTokenByEmail extends SendTokenByEmail { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * |
11 | 11 | * @param string $commandToken |
12 | 12 | * @param SilverbulletContext $context |
13 | 13 | */ |
14 | - public function __construct($commandToken, $context){ |
|
14 | + public function __construct($commandToken, $context) { |
|
15 | 15 | $this->session = $context->getSession(); |
16 | 16 | $this->mail = new MockPHPMailer(); |
17 | 17 | $this->detailsCommand = new GetTokenEmailDetails(GetTokenEmailDetails::COMMAND, $context); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return \PHPMailer\PHPMailer\PHPMailer |
24 | 24 | */ |
25 | - public function getMailer(){ |
|
25 | + public function getMailer() { |
|
26 | 26 | return $this->mail; |
27 | 27 | } |
28 | 28 | } |