Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_grid_Cell_SubgridAdapter | |
0.00% |
0 / 23 |
|
0.00% |
0 / 3 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |||
| getValue | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| getSubgridRows | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| initSubgridClass | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getGridContainer | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * Short description of class tao_helpers_grid_Cell_SubgridAdapter |
| 27 | * |
| 28 | * @abstract |
| 29 | * @access public |
| 30 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 31 | * @package tao |
| 32 | |
| 33 | */ |
| 34 | abstract class tao_helpers_grid_Cell_SubgridAdapter extends tao_helpers_grid_Cell_Adapter |
| 35 | { |
| 36 | // --- ASSOCIATIONS --- |
| 37 | |
| 38 | |
| 39 | // --- ATTRIBUTES --- |
| 40 | |
| 41 | /** |
| 42 | * Short description of attribute subgridClass |
| 43 | * |
| 44 | * @access public |
| 45 | * @var string |
| 46 | */ |
| 47 | public $subgridClass = ''; |
| 48 | |
| 49 | /** |
| 50 | * Instance of gridContainer used to format the cell content. |
| 51 | * This instance is a prototype and will be cloned for each cells. |
| 52 | * |
| 53 | * @access public |
| 54 | * @var GridContainer |
| 55 | */ |
| 56 | public $subGridContainer = null; |
| 57 | |
| 58 | // --- OPERATIONS --- |
| 59 | |
| 60 | /** |
| 61 | * Short description of method __construct |
| 62 | * |
| 63 | * @access public |
| 64 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 65 | * @param array options |
| 66 | * @param string subgridClass |
| 67 | * @return mixed |
| 68 | */ |
| 69 | public function __construct($options = [], $subgridClass = '') |
| 70 | { |
| 71 | |
| 72 | parent::__construct($options); |
| 73 | |
| 74 | $this->initSubgridClass($subgridClass); |
| 75 | //the class exists |
| 76 | if (!class_exists($this->subgridClass)) { |
| 77 | throw new Exception('the subgrid class does not exist : ' . $this->subgridClass); |
| 78 | } |
| 79 | $this->subGridContainer = new $this->subgridClass([]); |
| 80 | //the instance is an instance of the good class |
| 81 | if ( |
| 82 | is_a($this->subGridContainer, $this->subgridClass) |
| 83 | && is_a($this->subGridContainer, 'tao_helpers_grid_GridContainer') |
| 84 | ) { |
| 85 | $returnValue = $this->subGridContainer->getGrid()->getColumnsModel(); |
| 86 | } else { |
| 87 | throw new common_Exception('invalid subgrid class : ' . $this->subgridClass); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Short description of method getValue |
| 93 | * |
| 94 | * @access public |
| 95 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 96 | * @param string rowId |
| 97 | * @param string columnId |
| 98 | * @param string data |
| 99 | * @return mixed |
| 100 | */ |
| 101 | public function getValue($rowId, $columnId, $data = null) |
| 102 | { |
| 103 | $returnValue = null; |
| 104 | |
| 105 | |
| 106 | if ( |
| 107 | isset($this->data[$rowId]) |
| 108 | && is_a($this->data[$rowId], 'wfEngine_helpers_Monitoring_ActivityMonitoringGrid') |
| 109 | ) { |
| 110 | $returnValue = $this->data[$rowId]; |
| 111 | } else { |
| 112 | $subgridData = $this->getSubgridRows($rowId); |
| 113 | $cloneSubGridCtn = clone $this->subGridContainer; |
| 114 | $cloneSubGridCtn->getGrid()->setData($subgridData); |
| 115 | $returnValue = $cloneSubGridCtn; |
| 116 | $this->data[$rowId] = $cloneSubGridCtn; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | return $returnValue; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Short description of method getSubgridRows |
| 125 | * |
| 126 | * @abstract |
| 127 | * @access protected |
| 128 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 129 | * @param string rowId |
| 130 | * @return array |
| 131 | */ |
| 132 | abstract protected function getSubgridRows($rowId); |
| 133 | |
| 134 | /** |
| 135 | * Short description of method initSubgridClass |
| 136 | * |
| 137 | * @abstract |
| 138 | * @access protected |
| 139 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 140 | * @param subgridClass |
| 141 | * @return mixed |
| 142 | */ |
| 143 | abstract protected function initSubgridClass($subgridClass = ''); |
| 144 | |
| 145 | /** |
| 146 | * Short description of method getGridContainer |
| 147 | * |
| 148 | * @access public |
| 149 | * @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> |
| 150 | * @return tao_helpers_grid_GridContainer |
| 151 | */ |
| 152 | public function getGridContainer() |
| 153 | { |
| 154 | $returnValue = null; |
| 155 | |
| 156 | |
| 157 | $returnValue = $this->subGridContainer; |
| 158 | |
| 159 | |
| 160 | return $returnValue; |
| 161 | } |
| 162 | } |