Issues (538)

programs/Ui/AppCustomFieldTableView.php (11 issues)

1
<?php
2
3
// -------------------------------------------------------------------------
4
// OVIDENTIA http://www.ovidentia.org
5
// Ovidentia is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
8
// any later version.
9
//
10
// This program is distributed in the hope that it will be useful, but
11
// WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18
// USA.
19
// -------------------------------------------------------------------------
20
/**
21
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
22
 * @copyright Copyright (c) 2009 by CANTICO ({@link http://www.cantico.fr})
23
 */
24
namespace Capwelton\LibApp\Ui;
25
26
/**
27
 * list of customfield of articles from back office
28
 */
29
use Capwelton\Widgets\Widgets\Abstracts\WidgetItem;
0 ignored issues
show
The type Capwelton\Widgets\Widgets\Abstracts\WidgetItem 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...
30
use Capwelton\Widgets\Widgets\Item\WidgetLink;
0 ignored issues
show
The type Capwelton\Widgets\Widgets\Item\WidgetLink 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...
31
use Capwelton\Widgets\Widgets\Table\WidgetTableModelView;
0 ignored issues
show
The type Capwelton\Widgets\Widget...le\WidgetTableModelView 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...
32
use Capwelton\LibApp\Set\AppCustomFieldSet;
33
use Capwelton\LibOrm\ORMRecordSet;
0 ignored issues
show
The type Capwelton\LibOrm\ORMRecordSet 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...
34
use Capwelton\LibOrm\ORMRecord;
0 ignored issues
show
The type Capwelton\LibOrm\ORMRecord 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...
35
36
class AppCustomFieldTableView extends AppTableModelView
37
{
38
    
39
    /**
40
     * @param ORMRecord $record
41
     * @param string $fieldPath
42
     * @return WidgetItem
43
     */
44
    protected function computeCellContent(ORMRecord $record, $fieldPath)
45
    {
46
        $W = bab_Widgets();
47
        $App = $record->App();
48
        
49
        switch ($fieldPath) {
50
            
51
            case '_actions_':
52
                $box = $W->FlowItems();
53
                if($record->isUpdatable()){
54
                    $box->addItem($W->Link('', $App->Controller()
55
                        ->CustomField()
56
                        ->edit($record->id))
57
                        ->addClass('icon', \Func_Icons::ACTIONS_DOCUMENT_EDIT)
58
                        ->setOpenMode(WidgetLink::OPEN_DIALOG_AND_RELOAD));
59
                }
60
                if($record->isDeletable()){
61
                    $box->addItem($W->Link('', $App->Controller()
62
                        ->CustomField()
63
                        ->confirmDelete($record->id))
64
                        ->addClass('icon', \Func_Icons::ACTIONS_EDIT_DELETE)
65
                        ->setOpenMode(WidgetLink::OPEN_DIALOG_AND_RELOAD)
66
                        ->setDialogClass('box red'));
0 ignored issues
show
The method setDialogClass() does not exist on Widget_Link. ( Ignorable by Annotation )

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

66
                        ->/** @scrutinizer ignore-call */ setDialogClass('box red'));

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...
67
                }
68
                return $box;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $box returns the type Widget_FlowLayout which is incompatible with the documented return type Capwelton\Widgets\Widgets\Abstracts\WidgetItem.
Loading history...
69
            
70
            case 'mandatory':
71
            case 'visible_in_shop':
72
                if(self::getRecordFieldValue($record, $fieldPath)){
73
                    return $W->Label($App->translate('Yes'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $W->Label($App->translate('Yes')) returns the type Widget_Label which is incompatible with the documented return type Capwelton\Widgets\Widgets\Abstracts\WidgetItem.
Loading history...
74
                }
75
                else{
76
                    return $W->Label($App->translate('No'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $W->Label($App->translate('No')) returns the type Widget_Label which is incompatible with the documented return type Capwelton\Widgets\Widgets\Abstracts\WidgetItem.
Loading history...
77
                }
78
                break;
79
        }
80
        
81
        return parent::computeCellContent($record, $fieldPath);
82
    }
83
    
84
    /**
85
     * {@inheritdoc}
86
     * @see WidgetTableModelView::addDefaultColumns()
87
     */
88
    public function addDefaultColumns(ORMRecordSet $recordSet)
89
    {
90
        $App = $this->App();
91
        
92
        /* @var $recordSet AppCustomFieldSet */
93
        $this->addColumn(app_TableModelViewColumn($recordSet->name));
94
        $this->addColumn(app_TableModelViewColumn($recordSet->description));
95
        $this->addColumn(app_TableModelViewColumn($recordSet->object));
96
        $this->addColumn(app_TableModelViewColumn($recordSet->fieldtype));
97
        $this->addColumn(WidgetTableModelViewColumn($recordSet->mandatory, $App->translate('Mandatory'))->addClass('widget-10em'));
0 ignored issues
show
The function WidgetTableModelViewColumn was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

97
        $this->addColumn(/** @scrutinizer ignore-call */ WidgetTableModelViewColumn($recordSet->mandatory, $App->translate('Mandatory'))->addClass('widget-10em'));
Loading history...
98
        $this->addColumn(app_TableModelViewColumn($recordSet->importable)->addClass('widget-10em'));
99
        $this->addColumn(WidgetTableModelViewColumn($recordSet->searchable, $App->translate('Searchable'))->addClass('widget-10em'));
100
        $this->addColumn(WidgetTableModelViewColumn($recordSet->visible, $App->translate('Visible in list'))->addClass('widget-10em'));
101
        $this->addColumn(WidgetTableModelViewColumn('_actions_', '')->setSortable(false)
102
            ->addClass('widget-column-thin', 'widget-nowrap', \Func_Icons::ICON_LEFT_SYMBOLIC));
103
        if($App->onlineShop){
0 ignored issues
show
Bug Best Practice introduced by
The property onlineShop does not exist on Capwelton\LibApp\Func_App. Since you implemented __get, consider adding a @property annotation.
Loading history...
104
            $this->addColumn(WidgetTableModelViewColumn($recordSet->visible_in_shop, $App->translate('Visible in online shop')));
105
        }
106
        
107
        $this->setDefaultSortField('name:up');
108
    }
109
}