@@ -65,7 +65,7 @@ |
||
65 | 65 | } |
66 | 66 | if(isset($this->name)){ |
67 | 67 | return $this->composeTagString($attributeString); |
68 | - }else{ |
|
68 | + } else{ |
|
69 | 69 | return ""; |
70 | 70 | } |
71 | 71 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param string $name |
34 | 34 | */ |
35 | - public function __construct($name){ |
|
35 | + public function __construct($name) { |
|
36 | 36 | $this->name = $name; |
37 | 37 | } |
38 | 38 | |
39 | - public function setTab($tab){ |
|
39 | + public function setTab($tab) { |
|
40 | 40 | $this->tab = $tab; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $name |
46 | 46 | * @param string $value |
47 | 47 | */ |
48 | - public function addAttribute($name, $value){ |
|
48 | + public function addAttribute($name, $value) { |
|
49 | 49 | $this->attributes [] = new Attribute($name, $value); |
50 | 50 | } |
51 | 51 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @param string $attributeString |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - protected function composeTagString($attributeString){ |
|
58 | - return "\n" . $this->tab . "<".$this->name.$attributeString.">"; |
|
57 | + protected function composeTagString($attributeString) { |
|
58 | + return "\n" . $this->tab . "<" . $this->name . $attributeString . ">"; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * {@inheritDoc} |
64 | 64 | * @see \web\lib\admin\view\html\HtmlElementInterface::__toString() |
65 | 65 | */ |
66 | - public function __toString(){ |
|
66 | + public function __toString() { |
|
67 | 67 | $attributeString = ""; |
68 | 68 | foreach ($this->attributes as $attribute) { |
69 | 69 | $attributeString .= $attribute; |
70 | 70 | } |
71 | - if(isset($this->name)){ |
|
71 | + if (isset($this->name)) { |
|
72 | 72 | return $this->composeTagString($attributeString); |
73 | - }else{ |
|
73 | + } else { |
|
74 | 74 | return ""; |
75 | 75 | } |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * {@inheritDoc} |
81 | 81 | * @see \web\lib\admin\view\PageElementInterface::render() |
82 | 82 | */ |
83 | - public function render(){ |
|
83 | + public function render() { |
|
84 | 84 | echo $this->__toString(); |
85 | 85 | } |
86 | 86 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use web\lib\admin\view\html\Attribute; |
5 | 5 | |
6 | -class TitledFormDecorator extends PageElementDecorator{ |
|
6 | +class TitledFormDecorator extends PageElementDecorator { |
|
7 | 7 | |
8 | 8 | const BEFORE = 0; |
9 | 9 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @var array |
36 | 36 | */ |
37 | - private $elements = array( self::BEFORE => array(), self::AFTER => array()); |
|
37 | + private $elements = array(self::BEFORE => array(), self::AFTER => array()); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $class |
43 | 43 | * @param string $title |
44 | 44 | */ |
45 | - public function __construct($element, $title, $action, $class = '', $method = 'post', $charset = 'UTF-8'){ |
|
45 | + public function __construct($element, $title, $action, $class = '', $method = 'post', $charset = 'UTF-8') { |
|
46 | 46 | parent::__construct($element, $class); |
47 | 47 | $this->title = $title; |
48 | 48 | $this->action = new Attribute('action', $action); |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | $this->charset = new Attribute('accept-charset', $charset); |
51 | 51 | } |
52 | 52 | |
53 | - public function addHtmlElement($element, $position = self::AFTER){ |
|
53 | + public function addHtmlElement($element, $position = self::AFTER) { |
|
54 | 54 | $this->elements[$position][] = $element; |
55 | 55 | } |
56 | 56 | |
57 | 57 | public function render() { |
58 | 58 | ?> |
59 | - <form enctype="multipart/form-data"<?php echo $this->action.$this->method.$this->charset; ?>> |
|
59 | + <form enctype="multipart/form-data"<?php echo $this->action . $this->method . $this->charset; ?>> |
|
60 | 60 | <fieldset<?php echo $this->class; ?>> |
61 | 61 | <legend> |
62 | 62 | <strong><?php echo $this->title; ?></strong> |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | <?php |
66 | 66 | foreach ($this->elements[self::BEFORE] as $element) { |
67 | - echo "\n".$element; |
|
67 | + echo "\n" . $element; |
|
68 | 68 | } |
69 | 69 | ?> |
70 | 70 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | $this->element->render(); |
73 | 73 | ?> |
74 | 74 | |
75 | - <?php if(count($this->elements[self::AFTER]) > 0){ ?> |
|
75 | + <?php if (count($this->elements[self::AFTER]) > 0) { ?> |
|
76 | 76 | <div style="padding: 20px;"> |
77 | 77 | <?php |
78 | 78 | foreach ($this->elements[self::AFTER] as $element) { |
79 | - echo "\n".$element; |
|
79 | + echo "\n" . $element; |
|
80 | 80 | } |
81 | 81 | ?> |
82 | 82 | </div> |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $name Name of an input element |
46 | 46 | * @param string $format Defines a format template for the date value |
47 | 47 | */ |
48 | - public function __construct($name, $format='yyyy-MM-dd'){ |
|
48 | + public function __construct($name, $format = 'yyyy-MM-dd') { |
|
49 | 49 | self::$COUNT++; |
50 | - $this->id = self::INPUT_CLASS.'-'.self::$COUNT; |
|
50 | + $this->id = self::INPUT_CLASS . '-' . self::$COUNT; |
|
51 | 51 | $this->name = $name; |
52 | 52 | $this->format = $format; |
53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * {@inheritDoc} |
58 | 58 | * @see \web\lib\admin\view\PageElementInterface::render() |
59 | 59 | */ |
60 | - public function render(){ |
|
60 | + public function render() { |
|
61 | 61 | echo $this; |
62 | 62 | |
63 | 63 | /*?> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | } |
71 | 71 | |
72 | - public function __toString(){ |
|
72 | + public function __toString() { |
|
73 | 73 | $div = new CompositeTag('div'); |
74 | 74 | $div->addAttribute('class', self::BLOCK_CLASS); |
75 | 75 | $input = new UnaryTag('input'); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use web\lib\admin\view\html\Table; |
5 | 5 | use web\lib\admin\view\html\Row; |
6 | 6 | |
7 | -class InfoBlockTable implements PageElementInterface{ |
|
7 | +class InfoBlockTable implements PageElementInterface { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $decorator; |
20 | 20 | |
21 | - public function __construct($title){ |
|
21 | + public function __construct($title) { |
|
22 | 22 | $this->table = new Table(); |
23 | 23 | $this->table->addAttribute("cellpadding", 5); |
24 | - $this->decorator = new TitledBlockDecorator($this->table, $title, PageElementInterface::INFOBLOCK_CLASS); |
|
24 | + $this->decorator = new TitledBlockDecorator($this->table, $title, PageElementInterface::INFOBLOCK_CLASS); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @param array $rowArray |
29 | 29 | */ |
30 | - public function addRow($rowArray){ |
|
30 | + public function addRow($rowArray) { |
|
31 | 31 | $row = new Row($rowArray); |
32 | 32 | $row->addCellAttribute(0, 'class', Table::TITLED_CELL_CLASS); |
33 | 33 | $this->table->addRow($row); |
34 | 34 | } |
35 | 35 | |
36 | - public function render(){ |
|
36 | + public function render() { |
|
37 | 37 | $this->decorator->render(); |
38 | 38 | } |
39 | 39 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace web\lib\admin\view; |
3 | 3 | |
4 | -class TitledBlockDecorator extends PageElementDecorator{ |
|
4 | +class TitledBlockDecorator extends PageElementDecorator { |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param string $class |
16 | 16 | * @param string $title |
17 | 17 | */ |
18 | - public function __construct($element, $title, $class = ""){ |
|
18 | + public function __construct($element, $title, $class = "") { |
|
19 | 19 | parent::__construct($element, $class); |
20 | 20 | $this->title = $title; |
21 | 21 |
@@ -40,7 +40,7 @@ |
||
40 | 40 | <button type="submit" name="<?php echo $this->controls[self::YES]['name']; ?>" value="<?php echo $this->controls[self::YES]['value']; ?>"><?php echo _('Yes'); ?></button> |
41 | 41 | <?php if($this->controls[self::NO]['name'] == ''){ ?> |
42 | 42 | <button class="<?php echo $this->id . '-close'; ?>" type="reset"><?php echo _('No'); ?></button> |
43 | - <?php }else{ ?> |
|
43 | + <?php } else{ ?> |
|
44 | 44 | <button type="submit" name="<?php echo $this->controls[self::NO]['name']; ?>" value="<?php echo $this->controls[self::NO]['value']; ?>"><?php echo _('No'); ?></button> |
45 | 45 | <?php } |
46 | 46 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @author Zilvinas Vaira |
7 | 7 | * |
8 | 8 | */ |
9 | -class YesNoDialogBox extends AbstractTextDialogBox{ |
|
9 | +class YesNoDialogBox extends AbstractTextDialogBox { |
|
10 | 10 | |
11 | 11 | const NO = 0; |
12 | 12 | const YES = 1; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $action |
26 | 26 | * @param string $text |
27 | 27 | */ |
28 | - public function __construct($id, $action, $text){ |
|
28 | + public function __construct($id, $action, $text) { |
|
29 | 29 | parent::__construct($action, $text); |
30 | 30 | $this->id = $id; |
31 | 31 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param string $name |
36 | 36 | * @param string $value |
37 | 37 | */ |
38 | - public function setYesControl($name, $value){ |
|
38 | + public function setYesControl($name, $value) { |
|
39 | 39 | $this->controls[self::YES]['name'] = $name; |
40 | 40 | $this->controls[self::YES]['value'] = $value; |
41 | 41 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $name |
46 | 46 | * @param string $value |
47 | 47 | */ |
48 | - public function setNoControl($name, $value){ |
|
48 | + public function setNoControl($name, $value) { |
|
49 | 49 | $this->controls[self::NO]['name'] = $name; |
50 | 50 | $this->controls[self::NO]['value'] = $value; |
51 | 51 | } |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * {@inheritDoc} |
56 | 56 | * @see \web\lib\admin\view\AbstractDialogBox::renderControls() |
57 | 57 | */ |
58 | - protected function renderControls(){ |
|
58 | + protected function renderControls() { |
|
59 | 59 | ?> |
60 | 60 | <button type="submit" name="<?php echo $this->controls[self::YES]['name']; ?>" value="<?php echo $this->controls[self::YES]['value']; ?>"><?php echo _('Yes'); ?></button> |
61 | - <?php if($this->controls[self::NO]['name'] == ''){ ?> |
|
61 | + <?php if ($this->controls[self::NO]['name'] == '') { ?> |
|
62 | 62 | <button class="<?php echo $this->id . '-close'; ?>" type="reset"><?php echo _('No'); ?></button> |
63 | - <?php }else{ ?> |
|
63 | + <?php } else { ?> |
|
64 | 64 | <button type="submit" name="<?php echo $this->controls[self::NO]['name']; ?>" value="<?php echo $this->controls[self::NO]['value']; ?>"><?php echo _('No'); ?></button> |
65 | 65 | <?php } |
66 | 66 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use web\lib\admin\view\html\Attribute; |
5 | 5 | |
6 | -abstract class PageElementDecorator implements PageElementInterface{ |
|
6 | +abstract class PageElementDecorator implements PageElementInterface { |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | /** |
31 | 31 | * |
32 | - * @return number |
|
32 | + * @return integer |
|
33 | 33 | */ |
34 | 34 | public function size(){ |
35 | 35 | return count($this->rows); |
@@ -53,7 +53,6 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * |
56 | - * @param array $row |
|
57 | 56 | */ |
58 | 57 | public function addRowArray($cells){ |
59 | 58 | $this->addRow(new Row($cells)); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @author Zilvinas Vaira |
6 | 6 | * |
7 | 7 | */ |
8 | -class Table extends Tag{ |
|
8 | +class Table extends Tag { |
|
9 | 9 | |
10 | 10 | const TITLED_CELL_CLASS = 'sb-titled-cell'; |
11 | 11 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param array $rows |
26 | 26 | */ |
27 | - public function __construct($rows = array()){ |
|
27 | + public function __construct($rows = array()) { |
|
28 | 28 | parent::__construct('table'); |
29 | 29 | $this->setRows($rows); |
30 | 30 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return number |
35 | 35 | */ |
36 | - public function size(){ |
|
36 | + public function size() { |
|
37 | 37 | return count($this->rows); |
38 | 38 | } |
39 | 39 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @param int $row |
43 | 43 | * @param string $column |
44 | 44 | */ |
45 | - private function createRow($row, $column){ |
|
46 | - if(!in_array($column, $this->columns)){ |
|
45 | + private function createRow($row, $column) { |
|
46 | + if (!in_array($column, $this->columns)) { |
|
47 | 47 | $this->columns [] = $column; |
48 | 48 | } |
49 | - if(!isset($this->rows[$row])){ |
|
49 | + if (!isset($this->rows[$row])) { |
|
50 | 50 | $this->rows [$row] = new Row(); |
51 | 51 | } |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $column |
58 | 58 | * @param UnaryTag $element |
59 | 59 | */ |
60 | - public function addToCell($row, $column, $element){ |
|
60 | + public function addToCell($row, $column, $element) { |
|
61 | 61 | $this->createRow($row, $column); |
62 | 62 | $this->rows[$row]->addToCell($column, $element); |
63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $column |
69 | 69 | * @return \web\lib\admin\view\html\CompositeTag |
70 | 70 | */ |
71 | - public function getCell($row, $column){ |
|
71 | + public function getCell($row, $column) { |
|
72 | 72 | $this->createRow($row, $column); |
73 | 73 | return $this->rows[$row]->getCell($column); |
74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $row |
79 | 79 | */ |
80 | - public function addRowArray($cells){ |
|
80 | + public function addRowArray($cells) { |
|
81 | 81 | $this->addRow(new Row($cells)); |
82 | 82 | } |
83 | 83 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param Row $row |
87 | 87 | */ |
88 | - public function addRow($row){ |
|
89 | - if(count($row->size())>0){ |
|
88 | + public function addRow($row) { |
|
89 | + if (count($row->size()) > 0) { |
|
90 | 90 | $this->rows [] = $row; |
91 | 91 | $this->setColumns($row); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param array $rows |
98 | 98 | */ |
99 | - public function setRows($rows){ |
|
100 | - if(count($rows)>0){ |
|
99 | + public function setRows($rows) { |
|
100 | + if (count($rows) > 0) { |
|
101 | 101 | foreach ($rows as $cells) { |
102 | 102 | $this->addRowArray($cells); |
103 | 103 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param Row $row |
110 | 110 | */ |
111 | - private function setColumns($row){ |
|
111 | + private function setColumns($row) { |
|
112 | 112 | $cells = $row->getCells(); |
113 | 113 | foreach ($cells as $key => $value) { |
114 | - if(!in_array($key, $this->columns)){ |
|
114 | + if (!in_array($key, $this->columns)) { |
|
115 | 115 | $this->columns [] = $key; |
116 | 116 | } |
117 | 117 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return string |
123 | 123 | */ |
124 | - protected function composeInnerString(){ |
|
124 | + protected function composeInnerString() { |
|
125 | 125 | $innerString = ""; |
126 | 126 | foreach ($this->rows as $row) { |
127 | 127 | $row->setColumns($this->columns); |
128 | - $row->setTab("\t".$this->tab); |
|
128 | + $row->setTab("\t" . $this->tab); |
|
129 | 129 | $innerString .= $row; |
130 | 130 | } |
131 | 131 | return $innerString; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | private function valid_IdP($input, $owner){ |
17 | 17 | if ($input == 1){ |
18 | 18 | return new MockInstitution(); |
19 | - }else{ |
|
19 | + } else{ |
|
20 | 20 | throw new Exception('IdP '.$input.' not found in database!'); |
21 | 21 | } |
22 | 22 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * @param unknown $input |
16 | 16 | * @param unknown $owner |
17 | 17 | * @throws Exception |
18 | - * @return mixed |
|
18 | + * @return MockInstitution |
|
19 | 19 | */ |
20 | 20 | private function valid_IdP($input, $owner){ |
21 | 21 | if ($input == 1){ |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | use web\lib\admin\view\DefaultHtmlPage; |
4 | 4 | use web\lib\admin\view\InstitutionPageBuilder; |
5 | 5 | |
6 | -class MockValidateInstitutionPageBuilder extends InstitutionPageBuilder{ |
|
6 | +class MockValidateInstitutionPageBuilder extends InstitutionPageBuilder { |
|
7 | 7 | |
8 | - protected function validateInstitution(){ |
|
8 | + protected function validateInstitution() { |
|
9 | 9 | $this->institution = $this->valid_IdP($_GET['inst_id'], $_SESSION['user']); |
10 | 10 | } |
11 | 11 | |
@@ -16,34 +16,34 @@ discard block |
||
16 | 16 | * @throws Exception |
17 | 17 | * @return mixed |
18 | 18 | */ |
19 | - private function valid_IdP($input, $owner){ |
|
20 | - if ($input == 1){ |
|
19 | + private function valid_IdP($input, $owner) { |
|
20 | + if ($input == 1) { |
|
21 | 21 | return new MockInstitution(); |
22 | - }else{ |
|
23 | - throw new Exception('IdP '.$input.' not found in database!'); |
|
22 | + } else { |
|
23 | + throw new Exception('IdP ' . $input . ' not found in database!'); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | } |
28 | 28 | |
29 | -class MockInstitution{ |
|
29 | +class MockInstitution { |
|
30 | 30 | public $name = "Test name"; |
31 | 31 | } |
32 | 32 | |
33 | -class InstitutionPageBuilderTest extends \PHPUnit_Framework_TestCase{ |
|
33 | +class InstitutionPageBuilderTest extends \PHPUnit_Framework_TestCase { |
|
34 | 34 | |
35 | 35 | protected function setUp() { |
36 | 36 | $_SESSION['user'] = "user"; |
37 | 37 | } |
38 | 38 | |
39 | - public function testConstructorSuccess(){ |
|
40 | - $_GET['inst_id']=1; |
|
39 | + public function testConstructorSuccess() { |
|
40 | + $_GET['inst_id'] = 1; |
|
41 | 41 | $builder = new MockValidateInstitutionPageBuilder(new DefaultHtmlPage("Testing Page")); |
42 | 42 | $this->assertTrue($builder->isReady()); |
43 | 43 | } |
44 | 44 | |
45 | - public function testConstructorFailure(){ |
|
46 | - $_GET['inst_id']=-1; |
|
45 | + public function testConstructorFailure() { |
|
46 | + $_GET['inst_id'] = -1; |
|
47 | 47 | $builder = new MockValidateInstitutionPageBuilder(new DefaultHtmlPage("Testing Page")); |
48 | 48 | $this->assertFalse($builder->isReady()); |
49 | 49 |