Completed
Push — develop ( 4f2388...3f4b0b )
by John
02:50
created

RendererProviderHTML::setRecord()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Alpha\View\Renderer\Html;
4
5
use Alpha\View\Renderer\RendererProviderInterface;
6
use Alpha\View\Widget\Button;
7
use Alpha\View\Widget\TextBox;
8
use Alpha\View\Widget\SmallTextBox;
9
use Alpha\View\Widget\DateBox;
10
use Alpha\View\Widget\RecordSelector;
11
use Alpha\View\View;
12
use Alpha\View\ViewState;
13
use Alpha\Controller\Front\FrontController;
14
use Alpha\Controller\Controller;
15
use Alpha\Util\Logging\Logger;
16
use Alpha\Util\Security\SecurityUtils;
17
use Alpha\Util\Config\ConfigProvider;
18
use Alpha\Util\InputFilter;
19
use Alpha\Util\Http\Session\SessionProviderFactory;
20
use Alpha\Util\Http\Request;
21
use Alpha\Model\Type\SmallText;
22
use Alpha\Model\ActiveRecord;
23
use Alpha\Exception\IllegalArguementException;
24
use Alpha\Exception\AlphaException;
25
use ReflectionClass;
26
27
/**
28
 * HTML renderer.  Will invoke widgets from the Alpha\View\Widgets package
29
 * automatically for the correct data type.  Templates from ./templates/html
30
 * will be loaded by default, but these can be overridden on a per-record level in
31
 * the application when required (consider the default ones to be scaffolding).
32
 *
33
 * @since 1.2
34
 *
35
 * @author John Collins <[email protected]>
36
 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
37
 * @copyright Copyright (c) 2017, John Collins (founder of Alpha Framework).
38
 * All rights reserved.
39
 *
40
 * <pre>
41
 * Redistribution and use in source and binary forms, with or
42
 * without modification, are permitted provided that the
43
 * following conditions are met:
44
 *
45
 * * Redistributions of source code must retain the above
46
 *   copyright notice, this list of conditions and the
47
 *   following disclaimer.
48
 * * Redistributions in binary form must reproduce the above
49
 *   copyright notice, this list of conditions and the
50
 *   following disclaimer in the documentation and/or other
51
 *   materials provided with the distribution.
52
 * * Neither the name of the Alpha Framework nor the names
53
 *   of its contributors may be used to endorse or promote
54
 *   products derived from this software without specific
55
 *   prior written permission.
56
 *
57
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
58
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
59
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
60
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
61
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
62
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
67
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
68
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
 * </pre>
71
 */
72
class RendererProviderHTML implements RendererProviderInterface
73
{
74
    /**
75
     * Trace logger.
76
     *
77
     * @var \Alpha\Util\Logging\Logger;
78
     *
79
     * @since 1.2
80
     */
81
    private static $logger = null;
82
83
    /**
84
     * The business object that we are renderering.
85
     *
86
     * @var \Alpha\Model\ActiveRecord
87
     *
88
     * @since 1.2
89
     */
90
    private $Record;
0 ignored issues
show
Unused Code introduced by
The property $Record is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
91
92
    /**
93
     * The constructor.
94
     *
95
     * @since 1.2
96
     */
97
    public function __construct()
98
    {
99
        self::$logger = new Logger('RendererProviderHTML');
100
        self::$logger->debug('>>__construct()');
101
102
        self::$logger->debug('<<__construct');
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function setRecord($Record)
109
    {
110
        $this->record = $Record;
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
111
    }
112
113
    /**
114
     * {@inheritdoc}
115
     */
116
    public function createView($fields = array())
117
    {
118
        self::$logger->debug('>>createView(fields=['.var_export($fields, true).'])');
119
120
        // the form ID
121
        $fields['formID'] = stripslashes(get_class($this->record).'_'.$this->record->getOID());
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
122
123
        // buffer form fields to $formFields
124
        $fields['formFields'] = $this->renderAllFields('create');
125
126
        // buffer HTML output for Create and Cancel buttons
127
        $button = new Button('submit', 'Create', 'createBut');
128
        $fields['createButton'] = $button->render();
129
130
        if (isset($fields['cancelButtonURL'])) {
131
            $button = new Button("document.location.replace('".$fields['cancelButtonURL']."')", 'Cancel', 'cancelBut');
132
        } else {
133
            $button = new Button("document.location.replace('".FrontController::generateSecureURL('act=Alpha\\Controller\\ListActiveRecordsController')."')", 'Cancel', 'cancelBut');
134
        }
135
        $fields['cancelButton'] = $button->render();
136
137
        // buffer security fields to $formSecurityFields variable
138
        $fields['formSecurityFields'] = self::renderSecurityFields();
139
140
        self::$logger->debug('<<createView [HTML]');
141
142
        return View::loadTemplate($this->record, 'create', $fields);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function editView($fields = array())
149
    {
150
        self::$logger->debug('>>editView(fields=['.var_export($fields, true).'])');
151
152
        $config = ConfigProvider::getInstance();
153
154
        // the form ID
155
        $fields['formID'] = stripslashes(get_class($this->record).'_'.$this->record->getOID());
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
156
157
        // buffer form fields to $formFields
158
        $fields['formFields'] = $this->renderAllFields('edit');
159
160
        // buffer HTML output for Create and Cancel buttons
161
        $button = new Button('submit', 'Save', 'saveBut');
162
        $fields['saveButton'] = $button->render();
163
164
        $js = "if(window.jQuery) {
165
                    BootstrapDialog.show({
166
                        title: 'Confirmation',
167
                        message: 'Are you sure you wish to delete this item?',
168
                        buttons: [
169
                            {
170
                                icon: 'glyphicon glyphicon-remove',
171
                                label: 'Cancel',
172
                                cssClass: 'btn btn-default btn-xs',
173
                                action: function(dialogItself){
174
                                    dialogItself.close();
175
                                }
176
                            },
177
                            {
178
                                icon: 'glyphicon glyphicon-ok',
179
                                label: 'Okay',
180
                                cssClass: 'btn btn-default btn-xs',
181
                                action: function(dialogItself) {
182
                                    $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID')."\"]').attr('value', '".$this->record->getOID()."');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
183
                                    $('#deleteForm').submit();
184
                                    dialogItself.close();
185
                                }
186
                            }
187
                        ]
188
                    });
189
                }";
190
        $button = new Button($js, 'Delete', 'deleteBut');
191
        $fields['deleteButton'] = $button->render();
192
193
        $viewState = ViewState::getInstance();
194
        $start = $viewState->get('selectedStart');
195
196
        if (isset($fields['cancelButtonURL'])) {
197
            $button = new Button("document.location = '".$fields['cancelButtonURL']."'", 'Back to List', 'cancelBut');
198
        } else {
199
            $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&start='.$start.'&limit='.$config->get('app.list.page.amount'))."'", 'Back to List', 'cancelBut');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
200
        }
201
        $fields['cancelButton'] = $button->render();
202
203
        // buffer security fields to $formSecurityFields variable
204
        $fields['formSecurityFields'] = self::renderSecurityFields();
205
206
        // OID will need to be posted for optimistic lock checking
207
        $fields['version_num'] = $this->record->getVersionNumber();
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
208
209
        self::$logger->debug('<<editView [HTML]');
210
211
        return View::loadTemplate($this->record, 'edit', $fields);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
212
    }
213
214
    /**
215
     * {@inheritdoc}
216
     */
217
    public function listView($fields = array())
218
    {
219
        self::$logger->debug('>>listView(fields=['.var_export($fields, true).'])');
220
221
        $config = ConfigProvider::getInstance();
222
        $sessionProvider = $config->get('session.provider.name');
223
        $session = SessionProviderFactory::getInstance($sessionProvider);
224
225
        // work out how many columns will be in the table
226
        $reflection = new ReflectionClass(get_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
227
        $properties = array_keys($reflection->getDefaultProperties());
228
        $fields['colCount'] = 1 + count(array_diff($properties, $this->record->getDefaultAttributes(), $this->record->getTransientAttributes()));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
229
230
        // get the class attributes
231
        $properties = $reflection->getProperties();
232
233
        $html = '';
234
235
        $html .= '<tr>';
236
        foreach ($properties as $propObj) {
237
            $propName = $propObj->name;
238
239
            // skip over password fields
240
            $property = $this->record->getPropObject($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
241
            if (!($property instanceof SmallText && $property->checkIsPassword())) {
242
                if (!in_array($propName, $this->record->getDefaultAttributes()) && !in_array($propName, $this->record->getTransientAttributes())) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
243
                    $html .= '  <th>'.$this->record->getDataLabel($propName).'</th>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
244
                }
245
                if ($propName == 'OID') {
246
                    $html .= '  <th>'.$this->record->getDataLabel($propName).'</th>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
247
                }
248
            } else {
249
                $fields['colCount'] = $fields['colCount'] - 1;
250
            }
251
        }
252
        $html .= '</tr><tr>';
253
254
        $fields['formHeadings'] = $html;
255
256
        $html = '';
257
258
        // and now the values
259
        foreach ($properties as $propObj) {
260
            $propName = $propObj->name;
261
262
            $property = $this->record->getPropObject($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
263
            if (!($property instanceof SmallText && $property->checkIsPassword())) {
264
                if (!in_array($propName, $this->record->getDefaultAttributes()) && !in_array($propName, $this->record->getTransientAttributes())) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
265
                    $propClass = get_class($this->record->getPropObject($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
266
267
                    if ($propClass == 'Text') {
268
                        $text = htmlentities($this->record->get($propName), ENT_COMPAT, 'utf-8');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
269
                        if (mb_strlen($text) > 70) {
270
                            $html .= '  <td>&nbsp;'.mb_substr($text, 0, 70).'...</td>';
271
                        } else {
272
                            $html .= '  <td>&nbsp;'.$text.'</td>';
273
                        }
274
                    } elseif ($propClass == 'DEnum') {
275
                        $html .= '  <td>&nbsp;'.$this->record->getPropObject($propName)->getDisplayValue().'</td>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
276
                    } else {
277
                        $html .= '  <td>&nbsp;'.$this->record->get($propName).'</td>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
278
                    }
279
                }
280
                if ($propName == 'OID') {
281
                    $html .= '  <td>&nbsp;'.$this->record->getOID().'</td>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
282
                }
283
            }
284
        }
285
        $html .= '</tr>';
286
287
        $fields['formFields'] = $html;
288
289
        $request = new Request(array('method' => 'GET'));
290
291
        // View button
292
        if (mb_strpos($request->getURI(), '/tk/') !== false) {
293
            if (isset($fields['viewButtonURL'])) {
294
                $button = new Button("document.location = '".$fields['viewButtonURL']."';", 'View', 'view'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
295
            } else {
296
                $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordOID='.$this->record->getOID())."';", 'View', 'view'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
297
            }
298
            $fields['viewButton'] = $button->render();
299
        } else {
300
            if ($this->record->hasAttribute('URL')) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
301
                $button = new Button("document.location = '".$this->record->get('URL')."';", 'View', 'view'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
302
            } else {
303
                $button = new Button("document.location = '".$config->get('app.url').'/record/'.urlencode(get_class($this->record)).'/'.$this->record->getOID()."';", 'View', 'view'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
304
            }
305
306
            $fields['viewButton'] = $button->render();
307
        }
308
309
        $html = '';
310
        // render edit and delete buttons for admins only
311
        if ($session->get('currentUser') && $session->get('currentUser')->inGroup('Admin')) {
312
            $html .= '&nbsp;&nbsp;';
313
            if (isset($fields['editButtonURL'])) {
314
                $button = new Button("document.location = '".$fields['editButtonURL']."'", 'Edit', 'edit'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
315
            } else {
316
                $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordOID='.$this->record->getOID().'&view=edit')."'", 'Edit', 'edit'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
317
            }
318
319
            $html .= $button->render();
320
            $html .= '&nbsp;&nbsp;';
321
322
            $js = "if(window.jQuery) {
323
                    BootstrapDialog.show({
324
                        title: 'Confirmation',
325
                        message: 'Are you sure you wish to delete this item?',
326
                        buttons: [
327
                            {
328
                                icon: 'glyphicon glyphicon-remove',
329
                                label: 'Cancel',
330
                                cssClass: 'btn btn-default btn-xs',
331
                                action: function(dialogItself){
332
                                    dialogItself.close();
333
                                }
334
                            },
335
                            {
336
                                icon: 'glyphicon glyphicon-ok',
337
                                label: 'Okay',
338
                                cssClass: 'btn btn-default btn-xs',
339
                                action: function(dialogItself) {
340
                                    $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID')."\"]').attr('value', '".$this->record->getOID()."');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
341
                                    $('#deleteForm').submit();
342
                                    dialogItself.close();
343
                                }
344
                            }
345
                        ]
346
                    });
347
                }";
348
349
            $button = new Button($js, 'Delete', 'delete'.$this->record->getOID().'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
350
            $html .= $button->render();
351
        }
352
        $fields['adminButtons'] = $html;
353
354
        // buffer security fields to $formSecurityFields variable
355
        $fields['formSecurityFields'] = self::renderSecurityFields();
356
357
        self::$logger->debug('<<listView [HTML]');
358
359
        return View::loadTemplate($this->record, 'list', $fields);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
360
    }
361
362
    /**
363
     * {@inheritdoc}
364
     */
365
    public function detailedView($fields = array())
366
    {
367
        self::$logger->debug('>>detailedView(fields=['.var_export($fields, true).'])');
368
369
        $config = ConfigProvider::getInstance();
370
371
        $sessionProvider = $config->get('session.provider.name');
372
        $session = SessionProviderFactory::getInstance($sessionProvider);
373
374
        // we may want to display the OID regardless of class
375
        $fields['OIDLabel'] = $this->record->getDataLabel('OID');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
376
        $fields['OID'] = $this->record->getOID();
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
377
378
        // buffer form fields to $formFields
379
        $fields['formFields'] = $this->renderAllFields('view');
380
381
        // Back button
382
        $button = new Button('history.back()', 'Back', 'backBut');
383
        $fields['backButton'] = $button->render();
384
385
        $html = '';
386
        // render edit and delete buttons for admins only
387
        if ($session->get('currentUser') !== false && $session->get('currentUser')->inGroup('Admin')) {
388
            if (isset($fields['editButtonURL'])) {
389
                $button = new Button("document.location = '".$fields['editButtonURL']."'", 'Edit', 'editBut');
390
            } else {
391
                $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordOID='.$this->record->getOID().'&view=edit')."'", 'Edit', 'editBut');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
392
            }
393
            $html .= $button->render();
394
395
            $js = "if(window.jQuery) {
396
                    BootstrapDialog.show({
397
                        title: 'Confirmation',
398
                        message: 'Are you sure you wish to delete this item?',
399
                        buttons: [
400
                            {
401
                                icon: 'glyphicon glyphicon-remove',
402
                                label: 'Cancel',
403
                                cssClass: 'btn btn-default btn-xs',
404
                                action: function(dialogItself){
405
                                    dialogItself.close();
406
                                }
407
                            },
408
                            {
409
                                icon: 'glyphicon glyphicon-ok',
410
                                label: 'Okay',
411
                                cssClass: 'btn btn-default btn-xs',
412
                                action: function(dialogItself) {
413
                                    $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID')."\"]').attr('value', '".$this->record->getOID()."');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
414
                                    $('#deleteForm').submit();
415
                                    dialogItself.close();
416
                                }
417
                            }
418
                        ]
419
                    });
420
                }";
421
422
            $button = new Button($js, 'Delete', 'deleteBut');
423
            $html .= $button->render();
424
        }
425
        $fields['adminButtons'] = $html;
426
427
        self::$logger->debug('<<detailedView [HTML]');
428
429
        return View::loadTemplate($this->record, 'detail', $fields);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
430
    }
431
432
    /**
433
     * {@inheritdoc}
434
     */
435
    public function adminView($fields = array())
436
    {
437
        self::$logger->debug('>>adminView(fields=['.var_export($fields, true).'])');
438
439
        $config = ConfigProvider::getInstance();
440
441
        // the class name of the record
442
        $fields['fullClassName'] = stripslashes(get_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
443
444
        // the table name in the DB for the record
445
        $fields['tableName'] = $this->record->getTableName();
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
446
447
        // record count for the Record in the DB
448
        $fields['count'] = ($this->record->checkTableExists() ? $this->record->getCount() : '<span class="warning">unavailable</span>');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
449
450
        // table exists in the DB?
451
        $fields['tableExists'] = ($this->record->checkTableExists() ? '<span class="success">Yes</span>' : '<span class="warning">No</span>');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
452
453
        if ($this->record->getMaintainHistory()) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
454
            $fields['tableExists'] = ($this->record->checkTableExists(true) ? '<span class="success">Yes</span>' : '<span class="warning">No history table</span>');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
455
        }
456
457
        // table schema needs to be updated in the DB?
458
        $fields['tableNeedsUpdate'] = ($this->record->checkTableNeedsUpdate() ? '<span class="warning">Yes</span>' : '<span class="success">No</span>');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
459
460
        // create button
461
        if ($this->record->checkTableExists()) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
462
            if (isset($fields['createButtonURL'])) {
463
                $button = new Button("document.location = '".$fields['createButtonURL']."'", 'Create New', 'create'.stripslashes(get_class($this->record)).'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
464
            } else {
465
                $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType='.get_class($this->record))."'", 'Create New', 'create'.stripslashes(get_class($this->record)).'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
466
            }
467
            $fields['createButton'] = $button->render();
468
        } else {
469
            $fields['createButton'] = '';
470
        }
471
472
        // list all button
473
        if ($this->record->checkTableExists()) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
474
            $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&start=0&limit='.$config->get('app.list.page.amount'))."'", 'List All', 'list'.stripslashes(get_class($this->record)).'But');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
475
            $fields['listButton'] = $button->render();
476
        } else {
477
            $fields['listButton'] = '';
478
        }
479
480
        // the create table button (if required)
481
        $html = '';
482
483
        if (!$this->record->checkTableExists()) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
484
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createTableBut')) : 'createTableBut');
485
            $button = new Button('submit', 'Create Table', $fieldname);
486
            $html .= $button->render();
487
            // hidden field so that we know which class to create the table for
488
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createTableClass')) : 'createTableClass');
489
            $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
490
        }
491
492
        if ($html == '' && $this->record->getMaintainHistory() && !$this->record->checkTableExists(true)) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
493
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createHistoryTableBut')) : 'createHistoryTableBut');
494
            $button = new Button('submit', 'Create History Table', $fieldname);
495
            $html .= $button->render();
496
            // hidden field so that we know which class to create the table for
497
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createTableClass')) : 'createTableClass');
498
            $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
499
        }
500
        $fields['createTableButton'] = $html;
501
502
        // recreate and update table buttons (if required)
503
        $html = '';
504
        if ($this->record->checkTableNeedsUpdate() && $this->record->checkTableExists()) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
505
            $js = "if(window.jQuery) {
506
                    BootstrapDialog.show({
507
                        title: 'Confirmation',
508
                        message: 'Are you sure you wish to recreate this class table (all data will be lost)?',
509
                        buttons: [
510
                            {
511
                                icon: 'glyphicon glyphicon-remove',
512
                                label: 'Cancel',
513
                                cssClass: 'btn btn-default btn-xs',
514
                                action: function(dialogItself){
515
                                    dialogItself.close();
516
                                }
517
                            },
518
                            {
519
                                icon: 'glyphicon glyphicon-ok',
520
                                label: 'Okay',
521
                                cssClass: 'btn btn-default btn-xs',
522
                                action: function(dialogItself) {
523
                                    $('[Id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed')."\"]').attr('value', 'recreateTableBut');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
524
                                    $('#admin_".stripslashes(get_class($this->record))."').submit();
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
525
                                    dialogItself.close();
526
                                }
527
                            }
528
                        ]
529
                    });
530
                }";
531
532
            $button = new Button($js, 'Recreate Table', 'recreateTableBut');
533
            $html .= $button->render();
534
            // hidden field so that we know which class to recreate the table for
535
            $html .= '<input type="hidden" name="recreateTableClass" value="'.get_class($this->record).'"/>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
536
            $html .= '&nbsp;&nbsp;';
537
538
            $js = "if(window.jQuery) {
539
                    BootstrapDialog.show({
540
                        title: 'Confirmation',
541
                        message: 'Are you sure you wish to attempt to modify this class table by adding new attributes?',
542
                        buttons: [
543
                            {
544
                                icon: 'glyphicon glyphicon-remove',
545
                                label: 'Cancel',
546
                                cssClass: 'btn btn-default btn-xs',
547
                                action: function(dialogItself){
548
                                    dialogItself.close();
549
                                }
550
                            },
551
                            {
552
                                icon: 'glyphicon glyphicon-ok',
553
                                label: 'Okay',
554
                                cssClass: 'btn btn-default btn-xs',
555
                                action: function(dialogItself) {
556
                                    $('[Id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed')."\"]').attr('value', 'updateTableBut');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
557
                                    $('#admin_".stripslashes(get_class($this->record))."').submit();
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
558
                                    dialogItself.close();
559
                                }
560
                            }
561
                        ]
562
                    });
563
                }";
564
565
            $button = new Button($js, 'Update Table', 'updateTableBut');
566
            $html .= $button->render();
567
            // hidden field so that we know which class to update the table for
568
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('updateTableClass')) : 'updateTableClass');
569
            $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>';
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
570
            // hidden field to tell us which button was pressed
571
            $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed');
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
572
            $html .= '<input type="hidden" id="'.$fieldname.'" name="'.$fieldname.'" value=""/>';
573
        }
574
        $fields['recreateOrUpdateButtons'] = $html;
575
576
        // buffer security fields to $formSecurityFields variable
577
        $fields['formSecurityFields'] = self::renderSecurityFields();
578
579
        self::$logger->debug('<<adminView [HTML]');
580
581
        return View::loadTemplate($this->record, 'admin', $fields);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
582
    }
583
584
    /**
585
     * {@inheritdoc}
586
     */
587
    public static function displayPageHead($controller)
588
    {
589
        if (self::$logger == null) {
590
            self::$logger = new Logger('RendererProviderHTML');
591
        }
592
593
        self::$logger->debug('>>displayPageHead(controller=['.var_export($controller, true).'])');
594
595
        $config = ConfigProvider::getInstance();
596
        $sessionProvider = $config->get('session.provider.name');
597
        $session = SessionProviderFactory::getInstance($sessionProvider);
598
599
        if (!class_exists(get_class($controller))) {
600
            throw new IllegalArguementException('The controller provided ['.get_class($controller).'] is not defined anywhere!');
601
        }
602
603
        $allowCSSOverrides = true;
604
605
        $request = new Request(array('method' => 'GET'));
606
607
        if ($session->get('currentUser') != null && ActiveRecord::isInstalled() && $session->get('currentUser')->inGroup('Admin') && mb_strpos($request->getURI(), '/tk/') !== false) {
608
            $allowCSSOverrides = false;
609
        }
610
611
        $html = View::loadTemplateFragment('html', 'head.phtml', array('title' => $controller->getTitle(), 'description' => $controller->getDescription(), 'allowCSSOverrides' => $allowCSSOverrides));
612
613
        if (method_exists($controller, 'during_displayPageHead_callback')) {
614
            $html .= $controller->{'during_displayPageHead_callback'}();
615
        }
616
617
        $html .= '</head>';
618
619
        try {
620
            if ($controller->getRecord() != null) {
621
                $html .= '<body'.($controller->getRecord()->get('bodyOnload') != '' ? ' onload="'.$controller->getRecord()->get('bodyOnload').'"' : '').'>';
622
            } else {
623
                $html .= '<body>';
624
            }
625
        } catch (AlphaException $e) {
626
            $html .= '<body>';
627
        }
628
629
        $html .= '<div class="container">';
630
631
        if (method_exists($controller, 'insert_CMSDisplayStandardHeader_callback')) {
632
            $html .= $controller->{'insert_CMSDisplayStandardHeader_callback'}();
633
        }
634
635
        self::$logger->debug('<<displayPageHead [HTML]');
636
637
        return $html;
638
    }
639
640
    /**
641
     * {@inheritdoc}
642
     */
643
    public static function displayPageFoot($controller)
644
    {
645
        if (self::$logger == null) {
646
            self::$logger = new Logger('RendererProviderHTML');
647
        }
648
649
        self::$logger->debug('>>displayPageFoot(controller=['.get_class($controller).'])');
650
651
        $html = View::loadTemplateFragment('html', 'footer.phtml', array());
652
653
        self::$logger->debug('<<displayPageFoot ['.$html.']');
654
655
        return $html;
656
    }
657
658
    /**
659
     * {@inheritdoc}
660
     */
661
    public static function displayUpdateMessage($message)
662
    {
663
        if (self::$logger == null) {
664
            self::$logger = new Logger('RendererProviderHTML');
665
        }
666
        self::$logger->debug('>>displayUpdateMessage(message=['.$message.'])');
667
668
        $html = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'.$message.'</div>';
669
670
        self::$logger->debug('<<displayUpdateMessage ['.$html.']');
671
672
        return $html;
673
    }
674
675
    /**
676
     * {@inheritdoc}
677
     */
678
    public static function displayErrorMessage($message)
679
    {
680
        if (self::$logger == null) {
681
            self::$logger = new Logger('RendererProviderHTML');
682
        }
683
        self::$logger->debug('>>displayErrorMessage(message=['.$message.'])');
684
685
        $html = '<div class="alert alert-danger">'.$message.'</div>';
686
687
        self::$logger->debug('<<displayErrorMessage ['.$html.']');
688
689
        return $html;
690
    }
691
692
    /**
693
     * {@inheritdoc}
694
     */
695
    public static function renderErrorPage($code, $message)
696
    {
697
        $config = ConfigProvider::getInstance();
698
699
        $html = View::loadTemplateFragment('html', 'head.phtml', array('title' => $code.' - '.$message, 'description' => $message, 'allowCSSOverrides' => false));
700
        $html .= '</head>';
701
        $html .= '<body>';
702
        $html .= '<div class="container">';
703
        $html .= self::displayErrorMessage('<strong>'.$code.':</strong> '.$message);
704
        $html .= '<div align="center"><a href="'.$config->get('app.url').'">Home Page</a></div>';
705
        $html .= '</div></body></html>';
706
707
        return $html;
708
    }
709
710
    /**
711
     * {@inheritdoc}
712
     */
713
    public static function renderDeleteForm($URI)
714
    {
715
        if (self::$logger == null) {
716
            self::$logger = new Logger('RendererProviderHTML');
717
        }
718
        self::$logger->debug('>>renderDeleteForm()');
719
720
        $config = ConfigProvider::getInstance();
721
722
        $html = '<form action="'.$URI.'" method="POST" id="deleteForm" accept-charset="UTF-8">';
723
        $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID');
724
        $html .= '<input type="hidden" name="'.$fieldname.'" id="'.$fieldname.'" value=""/>';
725
        $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('_METHOD')) : '_METHOD');
726
        $html .= '<input type="hidden" name="'.$fieldname.'" id="'.$fieldname.'" value="DELETE"/>';
727
        $html .= self::renderSecurityFields();
728
        $html .= '</form>';
729
730
        self::$logger->debug('<<renderDeleteForm ['.$html.']');
731
732
        return $html;
733
    }
734
735
    /**
736
     * {@inheritdoc}
737
     */
738
    public static function renderSecurityFields()
739
    {
740
        if (self::$logger == null) {
741
            self::$logger = new Logger('RendererProviderHTML');
742
        }
743
744
        self::$logger->debug('>>renderSecurityFields()');
745
746
        $config = ConfigProvider::getInstance();
747
748
        $html = '';
749
750
        $fields = Controller::generateSecurityFields();
751
752
        if ($config->get('security.encrypt.http.fieldnames')) {
753
            $fieldname = base64_encode(SecurityUtils::encrypt('var1'));
754
        } else {
755
            $fieldname = 'var1';
756
        }
757
758
        $html .= '<input type="hidden" name="'.$fieldname.'" value="'.$fields[0].'"/>';
759
760
        if ($config->get('security.encrypt.http.fieldnames')) {
761
            $fieldname = base64_encode(SecurityUtils::encrypt('var2'));
762
        } else {
763
            $fieldname = 'var2';
764
        }
765
766
        $html .= '<input type="hidden" name="'.$fieldname.'" value="'.$fields[1].'"/>';
767
768
        self::$logger->debug('<<renderSecurityFields ['.$html.']');
769
770
        return $html;
771
    }
772
773
    /**
774
     * {@inheritdoc}
775
     */
776
    public function renderIntegerField($name, $label, $mode, $value = '')
777
    {
778
        self::$logger->debug('>>renderIntegerField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
779
780
        $config = ConfigProvider::getInstance();
781
782
        if ($config->get('security.encrypt.http.fieldnames')) {
783
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
784
        } else {
785
            $fieldname = $name;
786
        }
787
788
        $html = '<div class="form-group">';
789
        $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
790
791
        $request = new Request(array('method' => 'GET'));
792
793
        if ($mode == 'create') {
794
            $html .= '<input type="text" style="width:100%;" name="'.$fieldname.'" value="'.$request->getParam($name, '').'"/>';
795
        }
796
797
        if ($mode == 'edit') {
798
            $html .= '<input type="text" style="width:100%;" name="'.$fieldname.'" value="'.$value.'"/>';
799
        }
800
801
        $html .= '</div>';
802
803
        self::$logger->debug('<<renderIntegerField ['.$html.']');
804
805
        return $html;
806
    }
807
808
    /**
809
     * {@inheritdoc}
810
     */
811
    public function renderDoubleField($name, $label, $mode, $value = '')
812
    {
813
        self::$logger->debug('>>renderDoubleField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
814
815
        $config = ConfigProvider::getInstance();
816
817
        if ($config->get('security.encrypt.http.fieldnames')) {
818
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
819
        } else {
820
            $fieldname = $name;
821
        }
822
823
        $html = '<div class="form-group">';
824
        $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
825
826
        $request = new Request(array('method' => 'GET'));
827
828
        if ($mode == 'create') {
829
            $html .= '<input type="text" size="13" name="'.$fieldname.'" value="'.$request->getParam($name, '').'"/>';
830
        }
831
832
        if ($mode == 'edit') {
833
            $html .= '<input type="text" size="13" name="'.$fieldname.'" value="'.$value.'"/>';
834
        }
835
836
        $html .= '</div>';
837
838
        self::$logger->debug('<<renderDoubleField ['.$html.']');
839
840
        return $html;
841
    }
842
843
    /**
844
     * {@inheritdoc}
845
     */
846
    public function renderBooleanField($name, $label, $mode, $value = '')
847
    {
848
        self::$logger->debug('>>renderBooleanField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
849
850
        $config = ConfigProvider::getInstance();
851
852
        if ($config->get('security.encrypt.http.fieldnames')) {
853
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
854
        } else {
855
            $fieldname = $name;
856
        }
857
858
        $html = '<div class="checkbox">';
859
        $html .= '  <label>';
860
861
        if ($mode == 'create') {
862
            $html .= '      <input type="hidden" name="'.$fieldname.'" value="0">';
863
            $html .= '      <input type="checkbox" name="'.$fieldname.'" id="'.$fieldname.'">';
864
            $html .= '          '.$label;
865
        }
866
867
        if ($mode == 'edit') {
868
            $html .= '      <input type="hidden" name="'.$fieldname.'" value="0">';
869
            $html .= '      <input type="checkbox" name="'.$fieldname.'" id="'.$fieldname.'"'.($value == '1' ? ' checked' : '').' />';
870
            $html .= '          '.$label;
871
        }
872
873
        $html .= '  </label>';
874
        $html .= '</div>';
875
876
        self::$logger->debug('<<renderBooleanField ['.$html.']');
877
878
        return $html;
879
    }
880
881
    /**
882
     * {@inheritdoc}
883
     */
884
    public function renderEnumField($name, $label, $mode, $options, $value = '')
885
    {
886
        self::$logger->debug('>>renderEnumField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
887
888
        $config = ConfigProvider::getInstance();
889
890
        if ($config->get('security.encrypt.http.fieldnames')) {
891
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
892
        } else {
893
            $fieldname = $name;
894
        }
895
896
        $html = '<div class="form-group">';
897
        $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
898
899
        if ($mode == 'create') {
900
            $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
901
            foreach ($options as $val) {
902
                $html .= '      <option value="'.$val.'">'.$val.'</option>';
903
            }
904
            $html .= '  </select>';
905
        }
906
907
        if ($mode == 'edit') {
908
            $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
909
            foreach ($options as $val) {
910
                if ($value == $val) {
911
                    $html .= '      <option value="'.$val.'" selected>'.$val.'</option>';
912
                } else {
913
                    $html .= '      <option value="'.$val.'">'.$val.'</option>';
914
                }
915
            }
916
            $html .= '  </select>';
917
        }
918
919
        $html .= '</div>';
920
921
        self::$logger->debug('<<renderEnumField ['.$html.']');
922
923
        return $html;
924
    }
925
926
    /**
927
     * {@inheritdoc}
928
     */
929
    public function renderDEnumField($name, $label, $mode, $options, $value = '')
930
    {
931
        self::$logger->debug('>>renderDEnumField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
932
933
        $config = ConfigProvider::getInstance();
934
935
        if ($config->get('security.encrypt.http.fieldnames')) {
936
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
937
        } else {
938
            $fieldname = $name;
939
        }
940
941
        $html = '<div class="form-group">';
942
        $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
943
944
        if ($mode == 'create') {
945
            $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
946
            foreach (array_keys($options) as $index) {
947
                $html .= '<option value="'.$index.'">'.$options[$index].'</option>';
948
            }
949
            $html .= '  </select>';
950
        }
951
952
        if ($mode == 'edit') {
953
            $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
954
            foreach (array_keys($options) as $index) {
955
                if ($value == $index) {
956
                    $html .= '<option value="'.$index.'" selected>'.$options[$index].'</option>';
957
                } else {
958
                    $html .= '<option value="'.$index.'">'.$options[$index].'</option>';
959
                }
960
            }
961
            $html .= '  </select>';
962
        }
963
964
        $html .= '</div>';
965
966
        self::$logger->debug('<<renderDEnumField ['.$html.']');
967
968
        return $html;
969
    }
970
971
    /**
972
     * {@inheritdoc}
973
     */
974
    public function renderDefaultField($name, $label, $mode, $value = '')
975
    {
976
        self::$logger->debug('>>renderDefaultField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
977
978
        $config = ConfigProvider::getInstance();
979
980
        if ($config->get('security.encrypt.http.fieldnames')) {
981
            $fieldname = base64_encode(SecurityUtils::encrypt($name));
982
        } else {
983
            $fieldname = $name;
984
        }
985
986
        $html = '';
987
988
        $request = new Request(array('method' => 'GET'));
989
990
        if ($mode == 'create') {
991
            $html .= '<textarea cols="100" rows="3" name="'.$fieldname.'">'.$request->getParam($name, '').'</textarea>';
992
        }
993
994
        if ($mode == 'edit') {
995
            $html .= '<textarea cols="100" rows="3" name="'.$fieldname.'">'.$value.'</textarea>';
996
        }
997
998
        if ($mode == 'view') {
999
            $html .= '<p><strong>'.$label.':</strong> '.$value.'</p>';
1000
        }
1001
1002
        self::$logger->debug('<<renderDefaultField ['.$html.']');
1003
1004
        return $html;
1005
    }
1006
1007
    /**
1008
     * {@inheritdoc}
1009
     */
1010
    public function renderTextField($name, $label, $mode, $value = '')
1011
    {
1012
        self::$logger->debug('>>renderTextField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
1013
1014
        $html = '';
1015
1016
        if ($mode == 'create') {
1017
            // give 10 rows for content fields (other 5 by default)
1018
            if ($name == 'content') {
1019
                $text = new TextBox($this->record->getPropObject($name), $label, $name, 10);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1020
            } else {
1021
                $text = new TextBox($this->record->getPropObject($name), $label, $name);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1022
            }
1023
            $html .= $text->render();
1024
        }
1025
1026
        if ($mode == 'edit') {
1027
            // give 10 rows for content fields (other 5 by default)
1028
            if ($name == 'content') {
1029
                $viewState = ViewState::getInstance();
1030
1031
                if ($viewState->get('markdownTextBoxRows') == '') {
1032
                    $text = new TextBox($this->record->getPropObject($name), $label, $name, 10);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1033
                } else {
1034
                    $text = new TextBox($this->record->getPropObject($name), $label, $name, (integer) $viewState->get('markdownTextBoxRows'));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1035
                }
1036
1037
                $html .= $text->render();
1038
            } else {
1039
                $text = new TextBox($this->record->getPropObject($name), $label, $name);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1040
                $html .= $text->render();
1041
            }
1042
        }
1043
1044
        if ($mode == 'view') {
1045
            $html .= '<p><strong>';
1046
1047
            $html .= $label;
1048
1049
            $html .= ':</strong>';
1050
1051
            // filter ouput to prevent malicious injection
1052
            $value = InputFilter::encode($value);
1053
1054
            // ensures that line returns are rendered
1055
            $value = str_replace("\n", '<br>', $value);
1056
1057
            $html .= '&nbsp;';
1058
1059
            $html .= $value;
1060
1061
            $html .= '</p>';
1062
        }
1063
1064
        self::$logger->debug('<<renderTextField ['.$html.']');
1065
1066
        return $html;
1067
    }
1068
1069
    /**
1070
     * {@inheritdoc}
1071
     */
1072
    public function renderStringField($name, $label, $mode, $value = '')
1073
    {
1074
        self::$logger->debug('>>renderStringField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
1075
1076
        $html = '';
1077
1078
        if ($mode == 'create' || $mode == 'edit') {
1079
            $string = new SmallTextBox($this->record->getPropObject($name), $label, $name);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1080
            $html .= $string->render();
1081
        }
1082
1083
        if ($mode == 'view') {
1084
            $html .= '<p><strong>'.$label.':</strong> '.$value.'</p>';
1085
        }
1086
1087
        self::$logger->debug('<<renderStringField ['.$html.']');
1088
1089
        return $html;
1090
    }
1091
1092
    /**
1093
     * {@inheritdoc}
1094
     */
1095
    public function renderRelationField($name, $label, $mode, $value = '', $expanded = false, $buttons = true)
1096
    {
1097
        self::$logger->debug('>>renderRelationField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'], expanded=['.$expanded.'], buttons=['.$buttons.'])');
1098
1099
        $html = '';
1100
1101
        $rel = $this->record->getPropObject($name);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1102
1103
        if ($mode == 'create' || $mode == 'edit') {
1104
            if ($rel->getRelationType() == 'MANY-TO-MANY') {
1105
                try {
1106
                    // check to see if the rel is on this class
1107
                    $rel->getSide(get_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1108
                    $widget = new RecordSelector($rel, $label, $name, get_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1109
                    $html .= $widget->render($expanded, $buttons);
1110
                } catch (IllegalArguementException $iae) {
1111
                    // the rel may be on a parent class
1112
                    $widget = new RecordSelector($rel, $label, $name, get_parent_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1113
                    $html .= $widget->render($expanded, $buttons);
1114
                }
1115
            } else {
1116
                $rel = new RecordSelector($rel, $label, $name);
1117
                $html .= $rel->render($expanded, $buttons);
1118
            }
1119
        }
1120
1121
        if ($mode == 'view') {
1122
            if ($rel->getRelationType() == 'MANY-TO-ONE') {
1123
                $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue());
1124
            } elseif ($rel->getRelationType() == 'MANY-TO-MANY') {
1125
                try {
1126
                    // check to see if the rel is on this class
1127
                    $rel->getSide(get_class($this->record));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1128
                    $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue(get_class($this->record)));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1129
                } catch (IllegalArguementException $iae) {
1130
                    // the rel may be on a parent class
1131
                    $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue(get_parent_class($this->record)));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1132
                }
1133
            } else {
1134
                $rel = new RecordSelector($rel, $label, $name);
1135
                $html .= $rel->render($expanded, $buttons);
1136
            }
1137
        }
1138
1139
        self::$logger->debug('<<renderRelationField ['.$html.']');
1140
1141
        return $html;
1142
    }
1143
1144
    /**
1145
     * {@inheritdoc}
1146
     */
1147
    public function renderAllFields($mode, $filterFields = array(), $readOnlyFields = array())
1148
    {
1149
        self::$logger->debug('>>renderAllFields(mode=['.$mode.'], filterFields=['.var_export($filterFields, true).'], readOnlyFields=['.var_export($readOnlyFields, true).'])');
1150
1151
        $html = '';
1152
1153
        // get the class attributes
1154
        $properties = array_keys($this->record->getDataLabels());
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1155
1156
        $orignalMode = $mode;
1157
1158
        foreach ($properties as $propName) {
1159
            if (!in_array($propName, $this->record->getDefaultAttributes()) && !in_array($propName, $filterFields)) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1160
                // render readonly fields in the supplied array
1161
                if (in_array($propName, $readOnlyFields)) {
1162
                    $mode = 'view';
1163
                } else {
1164
                    $mode = $orignalMode;
1165
                }
1166
1167
                if (!is_object($this->record->getPropObject($propName))) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1168
                    continue;
1169
                }
1170
1171
                $reflection = new ReflectionClass($this->record->getPropObject($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1172
                $propClass = $reflection->getShortName();
1173
1174
                // exclude non-Relation transient attributes from create and edit screens
1175
                if ($propClass != 'Relation' && ($mode == 'edit' || $mode == 'create') && in_array($propName, $this->record->getTransientAttributes())) {
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1176
                    continue;
1177
                }
1178
1179
                switch (mb_strtoupper($propClass)) {
1180
                    case 'INTEGER':
1181
                        if ($mode == 'view') {
1182
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1183
                        } else {
1184
                            $html .= $this->renderIntegerField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1185
                        }
1186
                    break;
1187
                    case 'DOUBLE':
1188
                        if ($mode == 'view') {
1189
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1190
                        } else {
1191
                            $html .= $this->renderDoubleField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1192
                        }
1193
                    break;
1194
                    case 'DATE':
1195
                        if ($mode == 'view') {
1196
                            $value = $this->record->get($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1197
                            if ($value == '0000-00-00') {
1198
                                $value = '';
1199
                            }
1200
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $value);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1201
                        } else {
1202
                            $date = new DateBox($this->record->getPropObject($propName), $this->record->getDataLabel($propName), $propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1203
                            $html .= $date->render();
1204
                        }
1205
                    break;
1206
                    case 'TIMESTAMP':
1207
                        if ($mode == 'view') {
1208
                            $value = $this->record->get($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1209
                            if ($value == '0000-00-00 00:00:00') {
1210
                                $value = '';
1211
                            }
1212
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $value);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1213
                        } else {
1214
                            $timestamp = new DateBox($this->record->getPropObject($propName), $this->record->getDataLabel($propName), $propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1215
                            $html .= $timestamp->render();
1216
                        }
1217
                    break;
1218
                    case 'STRING':
1219
                        $html .= $this->renderStringField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1220
                    break;
1221
                    case 'TEXT':
1222
                        $html .= $this->renderTextField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1223
                    break;
1224
                    case 'BOOLEAN':
1225
                        if ($mode == 'view') {
1226
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1227
                        } else {
1228
                            $html .= $this->renderBooleanField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1229
                        }
1230
                    break;
1231
                    case 'ENUM':
1232
                        if ($mode == 'view') {
1233
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1234
                        } else {
1235
                            $enum = $this->record->getPropObject($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1236
                            $html .= $this->renderEnumField($propName, $this->record->getDataLabel($propName), $mode, $enum->getOptions(), $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1237
                        }
1238
                    break;
1239
                    case 'DENUM':
1240
                        if ($mode == 'view') {
1241
                            $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), 'view', $this->record->getPropObject($propName)->getDisplayValue());
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1242
                        } else {
1243
                            $denum = $this->record->getPropObject($propName);
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1244
                            $html .= $this->renderDEnumField($propName, $this->record->getDataLabel($propName), $mode, $denum->getOptions(), $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1245
                        }
1246
                    break;
1247
                    case 'RELATION':
1248
                        $html .= $this->renderRelationField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1249
                    break;
1250
                    default:
1251
                        $html .= $this->renderDefaultField($propName, $this->record->getDataLabel($propName), $mode, $this->record->get($propName));
0 ignored issues
show
Bug introduced by
The property record does not seem to exist. Did you mean Record?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1252
                    break;
1253
                }
1254
            }
1255
        }
1256
1257
        self::$logger->debug('<<renderAllFields ['.$html.']');
1258
1259
        return $html;
1260
    }
1261
}
1262