Passed
Push — master ( b52e35...baab09 )
by Laurent
03:12
created

app_CtrlRecord::remove()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 12
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 23
rs 9.8666
1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
22
 */
23
24
require_once dirname(__FILE__) . '/controller.class.php';
25
26
27
28
abstract class app_CtrlRecord extends app_Controller
29
{
30
    /**
31
     * This methods returns the Record classname managed by this controller.
32
     * The default method guess the record classname based on the controller name.
33
     * It can be overriden by inherited controllers.
34
     *
35
     * @return string
36
     */
37
    protected function getRecordClassName()
38
    {
39
        list(, $recordClassname) = explode('_Ctrl', $this->getClass());
40
        return $recordClassname;
41
    }
42
43
44
    /**
45
     * This methods returns the Record set managed by this controller.
46
     * The default method guess the record set based on the controller name.
47
     * It can be overriden by inherited controllers.
48
     *
49
     * @return app_RecordSet
50
     */
51
    protected function getRecordSet()
52
    {
53
        $App = $this->App();
54
        $recordClassname = $this->getRecordClassName();
55
        $recordSetClassname = $recordClassname . 'Set';
56
57
        $recordSet = $App->$recordSetClassname();
58
        return $recordSet;
59
    }
60
61
62
    /**
63
     * @return app_RecordSet
64
     */
65
    protected function getEditRecordSet()
66
    {
67
        return $this->getRecordSet();
68
    }
69
70
71
    /**
72
     * This methods returns the Record set used to save records
73
     *
74
     * @return app_RecordSet
75
     */
76
    protected function getSaveRecordSet()
77
    {
78
        return $this->getRecordSet();
79
    }
80
81
    /**
82
     * This methods returns the Record set used to delete records
83
     *
84
     * @return app_RecordSet
85
     */
86
    protected function getDeleteRecordSet()
87
    {
88
        return $this->getSaveRecordSet();
89
    }
90
91
92
    /**
93
     *
94
     * @param Widget_Action|Widget_Link|Widget_Action[]|Widget_Link[]|array $actions
95
     * @param Widget_Item $box
96
     * @return string
97
     */
98
    protected function createMenu($actions, $icon = true, $showLabel = false)
99
    {
100
        $canvas = bab_Widgets()->HtmlCanvas();
101
        $html = '';
102
        if ($actions instanceof Widget_Action) {
103
            $text = '';
104
            if ($showLabel) {
105
                $text = $actions->getTitle();
106
            }
107
            $html = '<li><a class="icon ' . $actions->getIcon() .  '" href="' . $actions->url() . '">' . $text . '</a></li>';
108
        } elseif ($actions instanceof Widget_Link) {
109
            $html = '<li>' . $actions->display($canvas) . '</li>';
110
        } elseif (is_array($actions)) {
0 ignored issues
show
introduced by
The condition is_array($actions) is always true.
Loading history...
111
            if (isset($actions['items'])) {
112
                $items = $actions['items'];
113
            } else {
114
                $items = $actions;
115
            }
116
            foreach ($items as $action) {
117
                $html .= $this->createMenu($action, true, true);
118
            }
119
            if (isset($actions['icon'])) {
120
121
                $html = '<li class="dropdown">'
122
                    . '<a href="#" class="' . $actions['icon'] . ' icon dropdown-toogle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'
123
                    . ($actions['icon'] === 'actions-context-menu'/*Func_Icons::ACTIONS_CONTEXT_MENU*/ ? '' : '<span class="caret"></span>')
124
                    . '</a>'
125
                    . '<ul class="dropdown-menu dropdown-menu-right ' . Func_Icons::ICON_LEFT_SYMBOLIC . '">'
126
                    . $html
127
                    . '</ul>';
128
            }
129
        }
130
131
        return $html;
132
    }
133
134
135
    /**
136
     *
137
     * @return string[]
138
     */
139
    protected function getAvailableModelViewTypes()
140
    {
141
        $App = $this->App();
142
        $Ui = $App->Ui();
143
144
        $types = array();
145
146
        $recordClassname = $this->getRecordClassName();
147
148
        $viewClassname =  $recordClassname . 'TableView';
149
        if (method_exists($Ui, $viewClassname)) {
150
            $types['table'] = array(
151
                'classname' => $viewClassname,
152
                'icon' => Func_Icons::ACTIONS_VIEW_LIST_TEXT,
153
                'label' => $App->translate('Detailed list')
154
            );
155
        }
156
157
        $viewClassname =  $recordClassname . 'CardsView';
158
        if (method_exists($Ui, $viewClassname)) {
159
            $types['cards'] = array(
160
                'classname' => $viewClassname,
161
                'icon' => 'actions-view-list-cards', //Func_Icons::ACTIONS_VIEW_LIST_CARDS
162
                'label' => $App->translate('Cards')
163
            );
164
        }
165
166
        $viewClassname =  $recordClassname . 'MapView';
167
        if (method_exists($Ui, $viewClassname)) {
168
            $types['map'] = array(
169
                'classname' => $viewClassname,
170
                'icon' => Func_Icons::APPS_PREFERENCES_SITE,
171
                'label' => $App->translate('Map')
172
            );
173
        }
174
175
        $viewClassname =  $recordClassname . 'CalendarView';
176
        if (method_exists($Ui, $viewClassname)) {
177
            $types['calendar'] = array(
178
                'classname' => $viewClassname,
179
                'icon' => Func_Icons::APPS_CALENDAR,
180
                'label' => $App->translate('Calendar')
181
            );
182
        }
183
184
        return $types;
185
    }
186
187
188
189
    /**
190
     * Returns an array of field names and descriptions that can be used in Full/CardFrames.
191
     *
192
     * @return string[]
193
     */
194
    public function getAvailableDisplayFields()
195
    {
196
        $App = $this->App();
197
        $recordSet = $this->getRecordSet();
198
199
        $availableFields = array();
200
201
        foreach ($recordSet->getFields() as $name => $field) {
202
            $fieldName = $field->getName();
203
            $fieldDescription = $field->getDescription();
204
            if (substr($fieldName, 0, 1) !== '_') {
205
                $fieldDescription = $App->translate($fieldDescription);
206
            }
207
            if (empty($fieldDescription)) {
208
                $fieldDescription = $fieldName;
209
            }
210
            $availableFields[$name] = array(
211
                'name' => $fieldName,
212
                'description' => $fieldDescription
213
            );
214
        }
215
216
        return $availableFields;
217
    }
218
219
220
221
    /**
222
     * Displays an editor of the record values corresponding to the fields of a custom section.
223
     *
224
     * @param int $id                   The id of the record to edit
225
     * @param int $customSectionId      The id of the section used to create the editor
226
     * @param string $itemId
227
     *
228
     * @throws app_AccessException
229
     * @return app_Page
230
     */
231
    public function editSection($id, $customSectionId, $itemId = null)
232
    {
233
        $W = bab_Widgets();
234
        $App = $this->App();
235
        $Ui = $App->Ui();
236
237
        $page = $App->Ui()->Page();
238
239
        $customSectionSet = $App->CustomSectionSet();
240
        $customSection = $customSectionSet->get(
241
            $customSectionSet->id->is($customSectionId)
242
        );
243
244
        $page->setTitle($customSection->name);
245
246
        $recordSet = $this->getEditRecordSet();
247
248
        $recordClassname = $this->getRecordClassName();
249
        $editorClassname =  $recordClassname . 'SectionEditor';
250
        /* @var $editor app_RecordEditor */
251
        $editor = $Ui->$editorClassname();
252
        if (!isset($itemId)) {
253
            $itemId = $this->getClass() . '_' . __FUNCTION__;
254
        }
255
        $editor->setId($itemId);
0 ignored issues
show
Bug introduced by
The method setId() does not exist on app_RecordEditor. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

255
        $editor->/** @scrutinizer ignore-call */ 
256
                 setId($itemId);
Loading history...
256
        $editor->setHiddenValue('tg', $App->controllerTg);
257
        $editor->setSaveAction($this->proxy()->save());
0 ignored issues
show
introduced by
The method save() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

257
        $editor->setSaveAction($this->proxy()->/** @scrutinizer ignore-call */ save());
Loading history...
258
        $editor->setName('data');
0 ignored issues
show
Bug introduced by
The method setName() does not exist on app_RecordEditor. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

258
        $editor->/** @scrutinizer ignore-call */ 
259
                 setName('data');
Loading history...
259
        $editor->addItem($W->Hidden()->setName('id'));
260
261
        $editor->recordSet = $recordSet;
262
        $section = $editor->sectionContent($customSectionId);
263
        $section->setSizePolicy('widget-60em');
264
265
        $editor->addItem($section);
266
267
        if (isset($id)) {
268
            $record = $recordSet->request($id);
269
            if (!$record->isUpdatable()) {
270
                throw new app_AccessException($App->translate('You do not have access to this page.'));
271
            }
272
            $editor->setRecord($record);
273
        } else {
274
            if (!$recordSet->isCreatable()) {
275
                throw new app_AccessException($App->translate('You do not have access to this page.'));
276
            }
277
            $record = $recordSet->newRecord();
278
            $editor->setRecord($record);
279
        }
280
281
        $editor->isAjax = bab_isAjaxRequest();
282
283
        $page->addItem($editor);
284
285
        return $page;
286
    }
287
288
289
    /**
290
     * @param string $itemId
291
     * @return string
292
     */
293
    public function getModelViewDefaultId($itemId = null)
294
    {
295
        if (!isset($itemId)) {
296
            $itemId = $this->getClass() . '_modelView';
297
        }
298
299
        return $itemId;
300
    }
301
302
    /**
303
     * Returns the xxxModelView associated to the RecordSet.
304
     *
305
     * @param array|null    $filter
306
     * @param string        $type
307
     * @param array|null    $columns    Optional list of columns. array($columnPath] => '1' | '0').
308
     * @param string|null   $itemId     Widget item id
309
     * @return app_TableModelView
310
     */
311
    protected function modelView($filter = null, $type = null, $columns = null, $itemId = null)
312
    {
313
        $App = $this->App();
314
        $Ui = $App->Ui();
315
316
        $recordSet = $this->getRecordSet();
317
318
        $recordClassname = $this->getRecordClassName();
319
320
        $itemId = $this->getModelViewDefaultId($itemId);
321
322
        if (!isset($type)) {
323
            $type = $this->getFilteredViewType($itemId);
324
        }
325
326
        //$types = $this->getAvailableModelViewTypes();
327
328
        switch ($type) {
329
            case 'cards':
330
                $tableviewClassname =  $recordClassname . 'CardsView';
331
                break;
332
333
            case 'map':
334
                $tableviewClassname =  $recordClassname . 'MapView';
335
                break;
336
337
            case 'calendar':
338
                $tableviewClassname =  $recordClassname . 'CalendarView';
339
                break;
340
341
            case 'table':
342
            default:
343
                $tableviewClassname =  $recordClassname . 'TableView';
344
                break;
345
        }
346
347
348
        /* @var $tableview widget_TableModelView */
349
        $tableview = $Ui->$tableviewClassname();
350
351
        $tableview->setRecordController($this);
0 ignored issues
show
Bug introduced by
The method setRecordController() does not exist on widget_TableModelView. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

351
        $tableview->/** @scrutinizer ignore-call */ 
352
                    setRecordController($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
352
353
        $tableview->setId($itemId);
354
355
        $tableview->setRecordSet($recordSet);
356
        $tableview->addDefaultColumns($recordSet);
357
        if (isset($filter)) {
358
            $tableview->setFilterValues($filter);
359
        }
360
        $filter = $tableview->getFilterValues();
361
362
        if (isset($filter['showTotal']) && $filter['showTotal']) {
363
            $tableview->displaySubTotalRow(true);
364
        }
365
366
        $conditions = $tableview->getFilterCriteria($filter);
367
368
        $conditions = $conditions->_AND_(
369
            $recordSet->isReadable()
370
        );
371
372
        $records = $recordSet->select($conditions);
373
374
375
        $tableview->setDataSource($records);
0 ignored issues
show
Bug introduced by
$records of type app_Record[] is incompatible with the type ORM_Iterator expected by parameter $iterator of widget_TableModelView::setDataSource(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

375
        $tableview->setDataSource(/** @scrutinizer ignore-type */ $records);
Loading history...
376
377
378
379
        if (isset($columns)) {
380
            $availableColumns = $tableview->getVisibleColumns();
381
382
            $remainingColumns = array();
383
            foreach ($availableColumns as $availableColumn) {
384
                $colPath = $availableColumn->getFieldPath();
385
                if (isset($columns[$colPath]) && $columns[$colPath] == '1') {
386
                    $remainingColumns[] = $availableColumn;
387
                }
388
            }
389
            $tableview->setColumns($remainingColumns);
390
        }
391
392
        $tableview->allowColumnSelection();
393
394
        return $tableview;
395
    }
396
397
398
399
400
    /**
401
     * @return app_Editor
402
     */
403
    protected function recordEditor($itemId = null)
404
    {
405
        $App = $this->App();
406
        $Ui = $App->Ui();
407
408
        $recordClassname = $this->getRecordClassName();
409
        $editorClassname =  $recordClassname . 'Editor';
410
        $editor = $Ui->$editorClassname();
411
        if (!isset($itemId)) {
412
            $itemId = $this->getClass() . '_' . __FUNCTION__;
413
        }
414
        $editor->setId($itemId);
415
        $editor->setHiddenValue('tg', $App->controllerTg);
416
        $editor->setSaveAction($this->proxy()->save());
417
        $editor->setName('data');
418
419
        $editor->isAjax = bab_isAjaxRequest();
420
421
        return $editor;
422
    }
423
424
425
426
    /**
427
     * @param widget_TableModelView $tableView
428
     * @return app_Toolbar
429
     */
430
    protected function toolbar($tableView)
431
    {
432
        $W = bab_Widgets();
433
        $App = $this->App();
434
435
        $proxy = $this->proxy();
436
437
        $filter = $tableView->getFilterValues();
438
439
        $toolbar = $W->FlowItems();
440
        $toolbar->addClass('widget-toolbar', Func_Icons::ICON_LEFT_16);
441
442
        $viewTypes = $this->getAvailableModelViewTypes();
443
444
        if (count($viewTypes) > 1) {
445
            $viewsBox = $W->Items();
446
            $viewsBox->setSizePolicy('pull-right');
447
//            $viewsBox->addClass('btn-group', Func_Icons::ICON_LEFT_16);
448
            $toolbar->addItem($viewsBox);
449
450
            $filteredViewType = $this->getFilteredViewType($tableView->getId());
451
452
            foreach ($viewTypes as $viewTypeId => $viewType) {
453
                $viewsBox->addItem(
454
                    $W->Link(
455
                        '',
456
                        $proxy->setFilteredViewType($tableView->getId(), $viewTypeId)
0 ignored issues
show
introduced by
The method setFilteredViewType() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

456
                        $proxy->/** @scrutinizer ignore-call */ 
457
                                setFilteredViewType($tableView->getId(), $viewTypeId)
Loading history...
457
                    )->addClass('icon', $viewType['icon'] . ($filteredViewType=== $viewTypeId ? ' active' : ''))
458
//                    ->setSizePolicy('btn btn-xs btn-default ' . ($filteredViewType === $viewTypeId ? 'active' : ''))
459
                    ->setTitle($viewType['label'])
460
                    ->setAjaxAction()
461
                );
462
            }
463
        }
464
465
        if (method_exists($proxy, 'exportSelect')) {
466
            $toolbar->addItem(
467
                $W->Link(
468
                    $App->translate('Export'),
469
                    $proxy->exportSelect($filter)
470
                )->addClass('icon', Func_Icons::ACTIONS_DOCUMENT_DOWNLOAD)
471
                ->setOpenMode(Widget_Link::OPEN_DIALOG)
472
            );
473
        }
474
475
        if (method_exists($proxy, 'printList')) {
476
            $toolbar->addItem(
477
                $W->Link(
478
                    $App->translate('Print'),
479
                    $proxy->printList($filter)
480
                )->addClass('icon', Func_Icons::ACTIONS_DOCUMENT_PRINT)
481
                ->setOpenMode(Widget_Link::OPEN_POPUP)
482
            );
483
        }
484
485
        return $toolbar;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $toolbar returns the type Widget_FlowLayout which is incompatible with the documented return type app_Toolbar.
Loading history...
486
    }
487
488
489
490
491
    /**
492
     * @param string $itemId
493
     * @return boolean
494
     */
495
    public function toggleFilterVisibility($itemId)
496
    {
497
        $W = bab_Widgets();
498
499
        $filterVisibility = $this->getFilterVisibility($itemId);
500
        $filterVisibility = !$filterVisibility;
501
        $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility);
502
503
        return true;
504
    }
505
506
507
    /**
508
     * @param string $itemId
509
     * @return boolean
510
     */
511
    protected function getFilterVisibility($itemId)
512
    {
513
        $W = bab_Widgets();
514
        $filterVisibility = $W->getUserConfiguration($itemId . '/filterVisibility');
515
        if (!isset($filterVisibility)) {
516
            $filterVisibility = false;
517
            $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility);
518
        }
519
        return $filterVisibility;
520
    }
521
522
523
    /**
524
     * Returns the current filtered view type (table, cards...)
525
     * @param string        $itemId     The model view widget id
526
     * @return string
527
     */
528
    protected function getFilteredViewType($itemId)
529
    {
530
        $W = bab_Widgets();
531
        $type = $W->getUserConfiguration($itemId . '/viewType');
532
        if (!isset($type)) {
533
            $type = 'table';
534
        }
535
        return $type;
536
    }
537
538
539
    /**
540
     * Sets the current filtered view type (table, cards...)
541
     * @param string        $itemId     The model view widget id
542
     * @param string        $type       'table, 'cards'...
543
     */
544
    public function setFilteredViewType($itemId, $type = null)
545
    {
546
        $W = bab_Widgets();
547
        $W->setUserConfiguration($itemId . '/viewType', $type);
548
549
        return true;
550
    }
551
552
553
    /**
554
     * @param array     $filter
555
     * @param string    $type
556
     * @param string    $itemId
557
     */
558
    public function filteredView($filter = null, $type = null, $itemId = null)
559
    {
560
        $W = bab_Widgets();
561
562
        $view = $this->modelView($filter, $type, null, $itemId);
563
        $view->setAjaxAction();
564
565
        $filter = $view->getFilterValues();
566
567
        $filterPanel = $view->advancedFilterPanel($filter);
568
569
        if ($this->getFilterVisibility($itemId)) {
570
            $filterPanel->addClass('show-filter');
571
        } else {
572
            $filterPanel->addClass('hide-filter');
573
        }
574
        $toolbar = $this->toolbar($view);
575
576
        $box = $W->VBoxItems(
577
            $toolbar,
578
            $filterPanel
579
        );
580
        $box->setReloadAction($this->proxy()->filteredView(null, null, $view->getId()));
0 ignored issues
show
introduced by
The method filteredView() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

580
        $box->setReloadAction($this->proxy()->/** @scrutinizer ignore-call */ filteredView(null, null, $view->getId()));
Loading history...
581
582
        return $box;
583
    }
584
585
586
587
    /**
588
     * @param array $filter
589
     * @param string $type
590
     * @return array
591
     */
592
    protected function getListItemMenus($filter = null, $type = null)
593
    {
594
        $itemMenus = array();
595
596
//         $tabs = $this->getTabs();
597
598
//         if (count($tabs) > 0) {
599
//             $itemMenus['all'] = array (
600
//                 'label' => $App->translate('All'),
601
//                 'action' => $this->proxy()->setCurrentTab('all')
602
//             );
603
//         }
604
//         foreach ($tabs as $tab) {
605
//             $itemMenus[$tab] = array(
606
//                 'label' => $tab,
607
//                 'action' => $this->proxy()->setCurrentTab($tab)
608
//             );
609
//         }
610
611
        return $itemMenus;
612
    }
613
614
615
616
    /**
617
     * @param array	$filter
618
     * @param string $type
619
     * @return Widget_Page
620
     */
621
    public function displayList($filter = null, $type = null)
622
    {
623
        $W = bab_Widgets();
624
625
        $page = $W->BabPage();
626
        $page->addClass('app-page-list');
627
628
        $itemMenus = $this->getListItemMenus();
629
630
        foreach ($itemMenus as $itemMenuId => $itemMenu) {
631
            $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']);
0 ignored issues
show
Deprecated Code introduced by
The function Widget_BabPage::addItemMenu() has been deprecated: Replaced by Widget_Tabs ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

631
            /** @scrutinizer ignore-deprecated */ $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
632
        }
633
634
        $filteredView = $this->filteredView($filter, $type);
635
636
        $page->addItem($filteredView);
637
638
        return $page;
639
    }
640
641
642
    /**
643
     *
644
     * @param array $filter
645
     * @return Widget_Page
646
     */
647
    public function exportSelect($filter = null)
648
    {
649
        $App = $this->App();
650
        $Ui = $App->Ui();
651
652
        $page = $App->Ui()->Page();
653
        $page->addClass('app-page-editor');
654
655
        $page->setTitle($App->translate('Export list'));
656
657
        $tableview = $this->modelView($filter, 'table');
658
659
        $editor = $Ui->ExportSelectEditor(__METHOD__, $tableview, $filter);
660
661
        $editor->setSaveAction(
662
            $this->proxy()->exportList(),
0 ignored issues
show
introduced by
The method exportList() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

662
            $this->proxy()->/** @scrutinizer ignore-call */ exportList(),
Loading history...
663
            $App->translate('Export')
664
        );
665
        $page->addItem($editor);
666
667
        return $page;
668
    }
669
670
671
672
673
674
    /**
675
     * @param	array	$filter
676
     */
677
    public function exportList($filter = null, $format = 'csv', $columns = null, $inline = true, $filename = 'export')
678
    {
679
        $App = $this->App();
680
681
        $page = $App->Ui()->Page();
682
        $page->addClass('app-page-list');
683
684
        $tableview = $this->modelView($filter, 'table', $columns);
685
        $tableview->allowColumnSelection(false);
686
687
        switch ($format) {
688
            case 'xlsx':
689
                $tableview->downloadXlsx($filename . '.xlsx');
690
                break;
691
            case 'xls':
692
                $tableview->downloadExcel($filename . '.xls');
693
                break;
694
            case 'ssv':
695
                $tableview->downloadCsv($filename . '.csv', ';', $inline, 'Windows-1252');
696
                break;
697
            case 'csv':
698
            default:
699
                $tableview->downloadCsv($filename . '.csv', ',', $inline, bab_charset::getIso());
700
                break;
701
        }
702
    }
703
704
705
    /**
706
     * Returns a page with the record information.
707
     *
708
     * @param int	$id
709
     * @return app_Page
710
     */
711
    public function display($id, $view = '')
712
    {
713
        $App = $this->App();
714
        $page = $App->Ui()->Page();
715
716
        $recordSet = $this->getRecordSet();
717
718
        $record = $recordSet->request($id);
719
720
        if (!$record->isReadable()) {
721
            throw new app_AccessException($App->translate('You do not have access to this page.'));
722
        }
723
724
        $W = bab_Widgets();
725
        $Ui = $App->Ui();
726
727
        $recordClassname = $this->getRecordClassName();
728
        $fullFrameClassname =  $recordClassname . 'FullFrame';
729
        $fullFrame = $Ui->$fullFrameClassname($record, $view);
730
731
732
        $maxHistory = 8;
733
        $historyFrame = $W->VBoxItems(
734
            $App->Controller()->Search(false)->history($record->getRef(), $maxHistory, 0, true)
0 ignored issues
show
Bug introduced by
The method Search() does not exist on app_Controller. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

734
            $App->Controller()->/** @scrutinizer ignore-call */ Search(false)->history($record->getRef(), $maxHistory, 0, true)

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
735
        );
736
        $fullFrame->addItem(
737
            $W->Section(
738
                $App->translate('History'),
739
                $historyFrame,
740
                2
741
            )->setFoldable(true)
742
            ->addClass('compact')
743
        );
744
745
        $page->addItem($fullFrame);
746
747
748
        // Actions
749
        $page->addContextItem($this->getDisplayActionFrame($page, $record));
750
751
        return $page;
752
    }
753
754
755
756
    protected function getDisplayActionFrame(Widget_Page $page, app_Record $record)
757
    {
758
        $actionsFrame = $page->ActionsFrame();
0 ignored issues
show
Bug introduced by
The method ActionsFrame() does not exist on Widget_Page. It seems like you code against a sub-type of Widget_Page such as app_Page. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

758
        /** @scrutinizer ignore-call */ 
759
        $actionsFrame = $page->ActionsFrame();
Loading history...
759
        return $actionsFrame;
760
    }
761
762
763
764
    /**
765
     * Returns a page containing an editor for the record.
766
     *
767
     * @param string|null id    A record id or null for a new record editor.
0 ignored issues
show
Bug introduced by
The type id was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
768
     * @return Widget_Page
769
     */
770
    public function edit($id = null, $view = '')
771
    {
772
        $W = bab_Widgets();
773
        $App = $this->App();
774
775
        $recordSet = $this->getEditRecordSet();
776
777
        $page = $W->BabPage();
778
        $page->addClass('app-page-editor');
779
780
        $page->setTitle($App->translate($recordSet->getDescription()));
781
782
        $editor = $this->recordEditor();
783
784
        if (isset($id)) {
785
            $record = $recordSet->request($id);
786
            if (!$record->isUpdatable()) {
787
                throw new app_AccessException($App->translate('You do not have access to this page.'));
788
            }
789
        } else {
790
            if (!$recordSet->isCreatable()) {
791
                throw new app_AccessException($App->translate('You do not have access to this page.'));
792
            }
793
            $record = $recordSet->newRecord();
794
        }
795
        $editor->setRecord($record);
796
797
        $page->addItem($editor);
798
799
        return $page;
800
    }
801
802
    /**
803
     * Returns a page containing an editor for the tags record.
804
     *
805
     * @param string|null id    A record id or null for a new record editor.
806
     * @return Widget_Page
807
     */
808
    public function editTags($id = null, $view = '')
809
    {
810
        $W = bab_Widgets();
811
        $App = $this->App();
812
        $Ui = $App->Ui();
813
814
        $recordSet = $this->getEditRecordSet();
815
816
        $page = $W->BabPage();
817
        $page->addClass('app-page-editor');
818
819
        $page->setTitle($App->translate($recordSet->getDescription()));
820
821
        $editor = $Ui->TagsEditor();
0 ignored issues
show
Bug introduced by
The method TagsEditor() does not exist on app_Ui. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

821
        /** @scrutinizer ignore-call */ 
822
        $editor = $Ui->TagsEditor();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
822
823
        if (isset($id)) {
824
            $record = $recordSet->request($id);
825
            if (!$record->isUpdatable()) {
826
                throw new app_AccessException($App->translate('You do not have access to this page.'));
827
            }
828
            $editor->setRecord($record);
829
        } else {
830
            if (!$recordSet->isCreatable()) {
831
                throw new app_AccessException($App->translate('You do not have access to this page.'));
832
            }
833
            $record = $recordSet->newRecord();
834
            $editor->setRecord($record);
835
        }
836
837
        $page->addItem($editor);
838
839
        return $page;
840
    }
841
842
843
    public function ok()
844
    {
845
        return true;
846
    }
847
848
849
850
    /**
851
     *
852
     * @param  $data
853
     */
854
    public function create($data)
855
    {
856
857
    }
858
859
860
    /**
861
     *
862
     * @param  $data
863
     */
864
    public function update($data)
865
    {
866
867
    }
868
869
870
871
    /**
872
     *
873
     */
874
    public function read($id)
875
    {
876
877
    }
878
879
880
    /**
881
     * Get the message to display on delete next page
882
     * @return string | true
883
     */
884
    protected function getDeletedMessage(ORM_Record $record)
885
    {
886
        $App = $this->App();
887
        $recordSet = $this->getRecordSet();
888
889
        $recordTitle = $record->getRecordTitle();
890
891
        $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"');
892
        return $message;
893
    }
894
895
    /**
896
     * Get the message to display on create next page
897
     * @return string | true
898
     */
899
    protected function getCreatedMessage()
900
    {
901
        return true;
902
    }
903
904
    /**
905
     * Get the message to display on modification next page
906
     * @param app_Record $record The record before the modification
907
     * @return string | true
908
     */
909
    protected function getModifedMessage(ORM_Record $record)
910
    {
911
        return true;
912
    }
913
914
915
    /**
916
     * Method to check reord before saving
917
     * @param app_Record $record
918
     */
919
    protected function preSave(ORM_Record $record, $data)
920
    {
921
922
    }
923
924
925
    /**
926
     * Method for post save actions on record
927
     * @param app_Record $record
928
     */
929
    protected function postSave(ORM_Record $record, $data)
930
    {
931
932
    }
933
934
935
    /**
936
     * Save a record
937
     *
938
     * @requireSaveMethod
939
     *
940
     * @param array $data
941
     */
942
    public function save($data = null)
943
    {
944
        $this->requireSaveMethod();
945
        $App = $this->App();
946
        $recordSet = $this->getSaveRecordSet();
947
        $pk = $recordSet->getPrimaryKey();
948
        $message = null;
949
950
        if (!empty($data[$pk])) {
951
            $record = $recordSet->request($data[$pk]);
952
            unset($data[$pk]);
953
954
            if (!$record->isUpdatable()) {
955
                throw new app_AccessException('Access denied');
956
            }
957
958
            $message = $this->getModifedMessage($record);
959
        } else {
960
961
            $record = $recordSet->newRecord();
962
963
            if (!$recordSet->isCreatable()) {
964
                throw new app_AccessException('Access denied');
965
            }
966
967
            $message = $this->getCreatedMessage();
968
        }
969
970
        if (!isset($record)) {
971
            throw new app_SaveException($App->translate('The record does not exists'));
972
        }
973
974
975
        if (!isset($data)) {
976
            throw new app_SaveException($App->translate('Nothing to save'));
977
        }
978
979
        $record->setFormInputValues($data);
980
981
982
        $this->preSave($record, $data);
983
        if ($record->save()) {
984
            $this->postSave($record, $data);
985
            if (is_string($message)) {
0 ignored issues
show
introduced by
The condition is_string($message) is always false.
Loading history...
986
                $this->addMessage($message);
987
            }
988
989
            $this->addReloadSelector('.depends-' . $this->getRecordClassName());
990
            return true;
991
        }
992
993
        return true;
994
    }
995
996
997
    /**
998
     * Deletes the specified record.
999
     *
1000
     * @requireDeleteMethod
1001
     *
1002
     * @param string $id        The record id
1003
     * @return boolean
1004
     */
1005
    public function delete($id)
1006
    {
1007
        $this->requireDeleteMethod();
1008
        $recordSet = $this->getDeleteRecordSet();
1009
1010
        $record = $recordSet->request($id);
1011
1012
        if (!$record->isDeletable()) {
1013
            throw new app_AccessException('Sorry, You are not allowed to perform this operation');
1014
        }
1015
        $deletedMessage = $this->getDeletedMessage($record);
1016
1017
        if ($record->delete()) {
1018
            $this->addMessage($deletedMessage);
1019
        }
1020
1021
        $this->addReloadSelector('.depends-' . $record->getClassName());
1022
1023
        return true;
1024
    }
1025
1026
1027
    /**
1028
     * Displays a page asking to confirm the deletion of a record.
1029
     *
1030
     * @param int $id
1031
     */
1032
    public function confirmDelete($id)
1033
    {
1034
        $W = bab_Widgets();
1035
        $App = $this->App();
1036
        $Ui = $App->Ui();
1037
1038
        $recordSet = $this->getRecordSet();
1039
        $record = $recordSet->get($id);
1040
1041
        $page = $Ui->Page();
1042
1043
        $page->addClass('app-page-editor');
1044
        $page->setTitle($App->translate('Deletion'));
1045
1046
        if (!isset($record)) {
1047
            $page->addItem(
1048
                $W->Label($App->translate('This element does not exists.'))
1049
            );
1050
            $page->addClass('alert', 'alert-warning');
1051
            return $page;
1052
        }
1053
1054
1055
        $form = new app_Editor($App);
1056
1057
        $form->addItem($W->Hidden()->setName('id'));
1058
1059
        $recordTitle = $record->getRecordTitle();
1060
1061
        $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"';
1062
        $form->addItem($W->Title($subTitle, 5));
1063
1064
        $form->addItem($W->Title($App->translate('Confirm delete?'), 6));
1065
1066
        $form->addItem($W->Html(bab_toHtml($App->translate('It will not be possible to undo this deletion.'))));
1067
1068
        $confirmedAction = $this->proxy()->delete($id);
0 ignored issues
show
Bug introduced by
The method delete() does not exist on app_Controller. Did you maybe mean deletedItemPage()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1068
        $confirmedAction = $this->proxy()->/** @scrutinizer ignore-call */ delete($id);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1069
        $parameters = $confirmedAction->getParameters();
1070
        foreach ($parameters as $key => $value) {
1071
            $form->setHiddenValue($key, $value);
1072
        }
1073
        $form->addButton(
1074
            $W->SubmitButton()
1075
                ->setAjaxAction($confirmedAction)
1076
                ->setLabel($App->translate('Delete'))
1077
         );
1078
        $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog'));
1079
        $page->addItem($form);
1080
1081
        return $page;
1082
    }
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
    /**
1093
     * Deletes the specified record.
1094
     *
1095
     * @requireDeleteMethod
1096
     *
1097
     * @param string $id        The record id
1098
     * @return boolean
1099
     */
1100
    public function remove($id)
1101
    {
1102
        $this->requireDeleteMethod();
1103
        $recordSet = $this->getDeleteRecordSet();
1104
1105
        $record = $recordSet->request($id);
1106
1107
        if (!$record->isRemovable()) {
1108
            throw new app_AccessException('Sorry, You are not allowed to perform this operation');
1109
        }
1110
1111
        $App = $this->App();
1112
        $deletedMessage = $App->translate('The element has been moved to the trash');
1113
1114
        if ($recordSet->delete($recordSet->id->is($record->id), app_TraceableRecord::DELETED_STATUS_IN_TRASH)) {
0 ignored issues
show
Unused Code introduced by
The call to ORM_RecordSet::delete() has too many arguments starting with app_TraceableRecord::DELETED_STATUS_IN_TRASH. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1114
        if ($recordSet->/** @scrutinizer ignore-call */ delete($recordSet->id->is($record->id), app_TraceableRecord::DELETED_STATUS_IN_TRASH)) {

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1115
            if (is_string($deletedMessage)) {
0 ignored issues
show
introduced by
The condition is_string($deletedMessage) is always true.
Loading history...
1116
                $this->addMessage($deletedMessage);
1117
            }
1118
        }
1119
1120
        $this->addReloadSelector('.depends-' . $record->getClassName());
1121
1122
        return true;
1123
    }
1124
1125
1126
    /**
1127
     * Displays a page asking to confirm the deletion of a record.
1128
     *
1129
     * @param int $id
1130
     */
1131
    public function confirmRemove($id)
1132
    {
1133
        $W = bab_Widgets();
1134
        $App = $this->App();
1135
        $Ui = $App->Ui();
1136
1137
        $recordSet = $this->getRecordSet();
1138
        $record = $recordSet->get($id);
1139
1140
        $page = $Ui->Page();
1141
1142
        $page->addClass('app-page-editor');
1143
        $page->setTitle($App->translate('Move to trash'));
1144
1145
        $form = new app_Editor($App);
1146
1147
        $recordTitle = $record->getRecordTitle();
1148
1149
        $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"';
1150
        $form->addItem($W->Title($subTitle, 5));
1151
1152
        $form->addItem($W->Title($App->translate('Confirm delete?'), 6));
1153
1154
//         $form->addItem($W->Html(bab_toHtml($App->translate('It will not be possible to undo this deletion.'))));
1155
1156
        $confirmedAction = $this->proxy()->remove($id);
0 ignored issues
show
introduced by
The method remove() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1156
        $confirmedAction = $this->proxy()->/** @scrutinizer ignore-call */ remove($id);
Loading history...
1157
        $parameters = $confirmedAction->getParameters();
1158
        foreach ($parameters as $key => $value) {
1159
            $form->setHiddenValue($key, $value);
1160
        }
1161
        $form->addButton(
1162
            $W->SubmitButton()
1163
            ->setAjaxAction($confirmedAction)
1164
            ->setLabel($App->translate('Move to trash'))
1165
            );
1166
        $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog'));
1167
        $page->addItem($form);
1168
1169
        return $page;
1170
    }
1171
1172
1173
1174
1175
    /**
1176
     * Restores the specified record.
1177
     *
1178
     * @requireDeleteMethod
1179
     *
1180
     * @param string $id        The record id
1181
     * @return boolean
1182
     */
1183
    public function restore($id)
1184
    {
1185
        $this->requireSaveMethod();
1186
        $recordSet = $this->getRecordSet();
1187
1188
        $records = $recordSet->select($recordSet->id->is($id), true);
0 ignored issues
show
Unused Code introduced by
The call to app_RecordSet::select() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1188
        /** @scrutinizer ignore-call */ 
1189
        $records = $recordSet->select($recordSet->id->is($id), true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1189
1190
        $record = null;
1191
        foreach ($records as $record) {
1192
        }
1193
        if (! isset($record)) {
1194
            throw new app_AccessException('Sorry, You are not allowed to perform this operation');
1195
        }
1196
        if (!$record->isUpdatable()) {
1197
            throw new app_AccessException('Sorry, You are not allowed to perform this operation');
1198
        }
1199
1200
        $App = $this->App();
1201
        $deletedMessage = $App->translate('The element has been restored from the trash');
1202
1203
        $record->deleted = app_TraceableRecord::DELETED_STATUS_EXISTING;
0 ignored issues
show
Bug Best Practice introduced by
The property deleted does not exist on app_Record. Since you implemented __set, consider adding a @property annotation.
Loading history...
1204
        $record->save();
1205
        $this->addMessage($deletedMessage);
1206
1207
        $this->addReloadSelector('.depends-' . $record->getClassName());
1208
1209
        return true;
1210
    }
1211
1212
    /**
1213
     * Displays a page asking to confirm the deletion of a record.
1214
     *
1215
     * @param int $id
1216
     */
1217
    public function confirmRestore($id)
1218
    {
1219
        $W = bab_Widgets();
1220
        $App = $this->App();
1221
        $Ui = $App->Ui();
1222
1223
        $recordSet = $this->getRecordSet();
1224
        $records = $recordSet->select($recordSet->id->is($id), true);
0 ignored issues
show
Unused Code introduced by
The call to app_RecordSet::select() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1224
        /** @scrutinizer ignore-call */ 
1225
        $records = $recordSet->select($recordSet->id->is($id), true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1225
1226
        $record = null;
1227
        foreach ($records as $record) {
1228
        }
1229
        if (! isset($record)) {
1230
            throw new app_AccessException('Sorry, You are not allowed to perform this operation');
1231
        }
1232
1233
        $page = $Ui->Page();
1234
1235
        $page->addClass('app-page-editor');
1236
        $page->setTitle($App->translate('Restore from trash'));
1237
1238
        $form = new app_Editor($App);
1239
1240
        $recordTitle = $record->getRecordTitle();
1241
1242
        $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"';
1243
        $form->addItem($W->Title($subTitle, 5));
1244
1245
        $confirmedAction = $this->proxy()->restore($id);
0 ignored issues
show
introduced by
The method restore() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1245
        $confirmedAction = $this->proxy()->/** @scrutinizer ignore-call */ restore($id);
Loading history...
1246
        $parameters = $confirmedAction->getParameters();
1247
        foreach ($parameters as $key => $value) {
1248
            $form->setHiddenValue($key, $value);
1249
        }
1250
        $form->addButton(
1251
            $W->SubmitButton()
1252
                ->setAjaxAction($confirmedAction)
1253
                ->setLabel($App->translate('Restore from trash'))
1254
        );
1255
        $form->addButton($W->SubmitButton()->setLabel($App->translate('Cancel'))->addClass('widget-close-dialog'));
1256
        $page->addItem($form);
1257
1258
        return $page;
1259
    }
1260
1261
    /**
1262
     * @param array     $filter
1263
     * @param string    $type
1264
     * @param string    $itemId
1265
     */
1266
    public function filteredTrash($filter = null, $type = null, $itemId = null)
1267
    {
1268
        $W = bab_Widgets();
1269
1270
        $view = $this->modelView($filter, $type, null, $itemId);
1271
        $view->setAjaxAction();
1272
1273
        if (isset($filter)) {
1274
            $view->setFilterValues($filter);
1275
        }
1276
        $filter = $view->getFilterValues();
1277
1278
        if (isset($filter['showTotal']) && $filter['showTotal']) {
1279
            $view->displaySubTotalRow(true);
1280
        }
1281
1282
1283
        $recordSet = $this->getRecordSet();
1284
        $view->setRecordSet($recordSet);
1285
        $view->addDefaultColumns($recordSet);
1286
1287
        $conditions = $view->getFilterCriteria($filter);
1288
        $conditions = $conditions->_AND_(
1289
            $recordSet->isReadable()
1290
        );
1291
1292
        $conditions = $conditions->_AND_(
1293
            $recordSet->deleted->is(app_TraceableRecord::DELETED_STATUS_IN_TRASH)
0 ignored issues
show
Bug Best Practice introduced by
The property deleted does not exist on app_RecordSet. Since you implemented __get, consider adding a @property annotation.
Loading history...
1294
        );
1295
1296
        $records = $recordSet->select($conditions, true);
0 ignored issues
show
Unused Code introduced by
The call to app_RecordSet::select() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1296
        /** @scrutinizer ignore-call */ 
1297
        $records = $recordSet->select($conditions, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1297
1298
        $view->setDataSource($records);
0 ignored issues
show
Bug introduced by
$records of type app_Record[] is incompatible with the type ORM_Iterator expected by parameter $iterator of widget_TableModelView::setDataSource(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1298
        $view->setDataSource(/** @scrutinizer ignore-type */ $records);
Loading history...
1299
1300
        $view->allowColumnSelection();
1301
1302
        $filterPanel = $view->advancedFilterPanel($filter);
1303
1304
//         $toolbar = $this->toolbar($view);
1305
1306
        $box = $W->VBoxItems(
1307
//             $toolbar,
1308
            $filterPanel
1309
        );
1310
        $box->setReloadAction($this->proxy()->filteredTrash(null, null, $view->getId()));
0 ignored issues
show
introduced by
The method filteredTrash() does not exist on app_Controller. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1310
        $box->setReloadAction($this->proxy()->/** @scrutinizer ignore-call */ filteredTrash(null, null, $view->getId()));
Loading history...
1311
1312
        return $box;
1313
    }
1314
1315
1316
1317
    public function displayTrash()
1318
    {
1319
        $App = $this->App();
1320
        $Ui = $App->Ui();
1321
1322
        $page = $Ui->Page();
1323
1324
//         $page->setTitle($App->translate('Trash'));
1325
1326
1327
        $trashView = $this->filteredTrash();
1328
1329
        $page->addItem($trashView);
1330
1331
        $itemMenus = $this->getListItemMenus();
1332
        foreach ($itemMenus as $itemMenuId => $itemMenu) {
1333
            $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']);
0 ignored issues
show
Deprecated Code introduced by
The function Widget_BabPage::addItemMenu() has been deprecated: Replaced by Widget_Tabs ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1333
            /** @scrutinizer ignore-deprecated */ $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1334
        }
1335
        $page->setCurrentItemMenu('displayTrash');
0 ignored issues
show
Deprecated Code introduced by
The function Widget_BabPage::setCurrentItemMenu() has been deprecated: Replaced by Widget_Tabs ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1335
        /** @scrutinizer ignore-deprecated */ $page->setCurrentItemMenu('displayTrash');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1336
1337
        return $page;
1338
    }
1339
1340
    protected function getClass()
1341
    {
1342
        return get_class($this);
1343
    }
1344
}
1345