This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * TbEditableColumn class file. |
||
4 | * |
||
5 | * @author Vitaliy Potapov <[email protected]> |
||
6 | * @link https://github.com/vitalets/x-editable-yii |
||
7 | * @copyright Copyright © Vitaliy Potapov 2012 |
||
8 | * @version 1.3.1 |
||
9 | */ |
||
10 | |||
11 | Yii::import('booster.widgets.TbEditable'); |
||
12 | Yii::import('booster.widgets.TbEditableField'); |
||
13 | Yii::import('zii.widgets.grid.CDataColumn'); |
||
14 | |||
15 | /** |
||
16 | * TbEditableColumn widget makes editable one column in CGridView. |
||
17 | * |
||
18 | * @package widgets |
||
19 | */ |
||
20 | class TbEditableColumn extends TbDataColumn |
||
21 | { |
||
22 | /** |
||
23 | * @var array editable config options. |
||
24 | * @see TbEditableField config |
||
25 | */ |
||
26 | public $editable = array(); |
||
27 | |||
28 | protected function fetchKeys($dataProvider) { |
||
29 | $keys = array(); |
||
30 | $data = $dataProvider->getData(); |
||
31 | if(isset($data) && !empty($data)) |
||
32 | foreach($data[0] as $i=>$data) |
||
33 | $keys[]=$i; |
||
34 | return $keys; |
||
35 | } |
||
36 | |||
37 | public function init() |
||
38 | { |
||
39 | if (!$this->name) { |
||
40 | throw new CException('You should provide name for TbEditableColumn'); |
||
41 | } |
||
42 | |||
43 | parent::init(); |
||
44 | |||
45 | /** |
||
46 | * add a dummy object to the data provider and call render function to allow register |
||
47 | * required scripts if grid was initially empty... |
||
48 | */ |
||
49 | if(empty($this->grid->dataProvider->data)) { |
||
50 | if ($this->grid->dataProvider instanceof CActiveDataProvider) |
||
0 ignored issues
–
show
|
|||
51 | $dummy = new $this->grid->dataProvider->modelClass(); |
||
52 | else if ($this->grid->dataProvider instanceof CArrayDataProvider) { |
||
0 ignored issues
–
show
The class
CArrayDataProvider does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
53 | $keys = $this->fetchKeys($this->grid->dataProvider); |
||
54 | $dummy = array(); |
||
55 | foreach ($keys as $key) { |
||
56 | $dummy[$key] = $key; // anyvalue; |
||
57 | } |
||
58 | } else { |
||
59 | $dummy = null; |
||
60 | } |
||
61 | $this->grid->dataProvider->data = array($dummy); |
||
62 | $this->editable['htmlOptions'] = array('style' => 'display: none;'); |
||
63 | $this->renderDataCellContent(0, $dummy); // this is the target line |
||
64 | $this->grid->dataProvider->data = array(); |
||
65 | } |
||
66 | //need to attach ajaxUpdate handler to refresh editables on pagination and sort |
||
67 | TbEditable::attachAjaxUpdateEvent($this->grid); |
||
68 | } |
||
69 | |||
70 | //protected was removed due to https://github.com/vitalets/x-editable-yii/issues/63 |
||
71 | public function renderDataCellContent($row, $data) |
||
72 | { |
||
73 | $isModel = $data instanceOf CModel; |
||
0 ignored issues
–
show
The class
CModel does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
74 | |||
75 | if($isModel) { |
||
76 | $widgetClass = 'TbEditableField'; |
||
77 | $options = array( |
||
78 | 'model' => $data, |
||
79 | 'attribute' => empty($this->editable['attribute']) ? $this->name : $this->editable['attribute'], |
||
80 | ); |
||
81 | |||
82 | //if value defined in column config --> we should evaluate it |
||
83 | //and pass to widget via `text` option: set flag `passText` = true |
||
84 | $passText = !empty($this->value); |
||
85 | } else { |
||
86 | $widgetClass = 'TbEditable'; |
||
87 | $options = array( |
||
88 | 'pk' => $data[$this->grid->dataProvider->keyField], |
||
89 | 'name' => empty($this->editable['name']) ? $this->name : $this->editable['name'], |
||
90 | ); |
||
91 | |||
92 | $passText = true; |
||
93 | //if autotext will be applied, do not pass `text` option (pass `value` instead) |
||
94 | if(empty($this->value) && TbEditable::isAutotext($this->editable, isset($this->editable['type']) ? $this->editable['type'] : '')) { |
||
95 | $options['value'] = $data[$this->name]; |
||
96 | $passText = false; |
||
97 | } |
||
98 | } |
||
99 | |||
100 | //for live update |
||
101 | $options['liveTarget'] = $this->grid->id; |
||
102 | |||
103 | $options = CMap::mergeArray($this->editable, $options); |
||
104 | |||
105 | //if value defined for column --> use it as element text |
||
106 | if($passText) { |
||
107 | ob_start(); |
||
108 | parent::renderDataCellContent($row, $data); |
||
109 | $text = ob_get_clean(); |
||
110 | $options['text'] = $text; |
||
111 | $options['encode'] = false; |
||
112 | } |
||
113 | |||
114 | //apply may be a string expression, see https://github.com/vitalets/x-editable-yii/issues/33 |
||
115 | if (isset($options['apply']) && is_string($options['apply'])) { |
||
116 | $options['apply'] = $this->evaluateExpression($options['apply'], array('data'=>$data, 'row'=>$row)); |
||
117 | } |
||
118 | |||
119 | //evaluate htmlOptions inside editable config as they can depend on $data |
||
120 | //see https://github.com/vitalets/x-editable-yii/issues/40 |
||
121 | if (isset($options['htmlOptions']) && is_array($options['htmlOptions'])) { |
||
122 | foreach($options['htmlOptions'] as $k => $v) { |
||
123 | if(is_string($v) && (strpos($v, '$data') !== false || strpos($v, '$row') !== false)) { |
||
124 | $options['htmlOptions'][$k] = $this->evaluateExpression($v, array('data'=>$data, 'row'=>$row)); |
||
125 | } |
||
126 | } |
||
127 | } |
||
128 | |||
129 | $this->grid->controller->widget($widgetClass, $options); |
||
130 | } |
||
131 | |||
132 | /* |
||
133 | Require this overwrite to show bootstrap sort icons |
||
134 | */ |
||
135 | protected function renderHeaderCellContent() |
||
136 | { |
||
137 | /* TODO |
||
138 | if(yii::app()->editable->form != 'bootstrap') { |
||
139 | parent::renderHeaderCellContent(); |
||
140 | return; |
||
141 | } */ |
||
142 | |||
143 | if ($this->grid->enableSorting && $this->sortable && $this->name !== null) |
||
144 | { |
||
145 | $sort = $this->grid->dataProvider->getSort(); |
||
146 | $label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name); |
||
147 | |||
148 | if ($sort->resolveAttribute($this->name) !== false) |
||
149 | $label .= '<span class="caret"></span>'; |
||
150 | |||
151 | echo $sort->link($this->name, $label, array('class'=>'sort-link')); |
||
152 | } |
||
153 | else |
||
154 | { |
||
155 | if ($this->name !== null && $this->header === null) |
||
156 | { |
||
157 | if ($this->grid->dataProvider instanceof CActiveDataProvider) |
||
0 ignored issues
–
show
The class
CActiveDataProvider does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
158 | echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); |
||
159 | else |
||
160 | echo CHtml::encode($this->name); |
||
161 | } |
||
162 | else |
||
163 | parent::renderHeaderCellContent(); |
||
164 | } |
||
165 | } |
||
166 | |||
167 | /* |
||
168 | Require this overwrite to show bootstrap filter field |
||
169 | */ |
||
170 | public function renderFilterCell() |
||
171 | { |
||
172 | /* TODO |
||
173 | if(yii::app()->editable->form != 'bootstrap') { |
||
174 | parent::renderFilterCell(); |
||
175 | return; |
||
176 | } */ |
||
177 | |||
178 | parent::renderFilterCell(); |
||
179 | } |
||
180 | } |
||
181 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.