Passed
Branchfeature/useWidgetsNamespaces (eb4650)
by Robin
02:57
created

AppUi::BasicEditor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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) 2022 by SI4YOU ({@link https://www.siforyou.com})
22
 */
23
namespace Capwelton\LibApp\Ui;
24
25
26
27
28
use Capwelton\LibApp\AppObject;
29
use Capwelton\LibApp\Ui\Page\AppErrorPage;
30
use Capwelton\LibApp\Ui\Page\AppPage;
31
use Capwelton\Widgets\Widgets\Layout\WidgetFlexLayout;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Layout\WidgetFlexLayout 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\Widgets\Widgets\Layout\WidgetLayout;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Layout\WidgetLayout 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...
33
use Capwelton\LibApp\Ui\Items\AppChip;
34
use Capwelton\LibApp\Ui\Items\AppShapeSquare;
35
use Capwelton\LibApp\Ui\Items\AppShapeCircle;
36
use Capwelton\LibApp\Ui\Items\AppShapeTriangle;
37
use Capwelton\LibApp\Exceptions\AppException;
38
use Capwelton\LibApp\Set\AppCustomField;
39
use Capwelton\LibOrm\Criteria\ORMCriteria;
0 ignored issues
show
Bug introduced by
The type Capwelton\LibOrm\Criteria\ORMCriteria 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...
40
41
/**
42
 * The app_Ui class
43
 */
44
class AppUi extends AppObject
45
{    
46
    public function __call($name, $arguments)
47
    {
48
        $App = $this->App();
49
        $Ui = $App->Ui();
50
        if(strpos($name, $App->classPrefix) !== false){
51
            list(, $name) = explode($App->classPrefix, $name);
52
        }
53
        
54
        if(method_exists($Ui, $name)){
55
            return call_user_func_array(array($Ui, $name), $arguments);
56
        }
57
        
58
        $components = $App->getComponents();
59
        foreach ($components as $component){
60
            try{
61
                $componentUi = $component->ui();
62
                if(isset($componentUi) && method_exists($componentUi, $name)){
63
                    return call_user_func_array(array($componentUi, $name), $arguments);
64
                }
65
            }catch(\Exception $e){}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
66
        }
67
        
68
        $rc = new \ReflectionClass($this);
69
        throw new AppException(sprintf($App->translate('The method %s does on exist on object %s'), $name, $rc->getShortName()));
70
    }
71
72
    /**
73
     * Return App page widget
74
     *
75
     * @return AppPage
76
     */
77
    public function Page($id = null, WidgetLayout $layout = null)
78
    {
79
        $App = $this->App();
80
        $page = new AppPage($id, $layout);
81
        $page->setApp($App);
82
        $page->setNumberFormat($App->numberFormat(1.1111111));
83
        $page->addMessageInfo();
84
        
85
        $addon = $App->getAddon();
86
        if($addon){
0 ignored issues
show
introduced by
$addon is of type bab_addonInfos, thus it always evaluated to true.
Loading history...
87
            $components = $App->getComponents();
88
            foreach ($components as $component){
89
                $stylePath = $component->getStylePath();
90
                if($stylePath){
91
                    $page->addStyleSheet($stylePath.'style.css');
92
                }
93
            }
94
            
95
        }
96
        return $page;
97
    }
98
99
    /**
100
     * Return App page widget
101
     *
102
     * @return AppErrorPage
103
     */
104
    public function ErrorPage($id = null, WidgetFlexLayout $layout = null)
105
    {
106
        $App = $this->App();
107
        $page = new AppErrorPage($id, $layout);
108
        $page->setApp($App);
109
        $page->setNumberFormat($App->numberFormat(1.1111111));
110
        $page->addMessageInfo();
111
        
112
        return $page;
113
    }
114
115
    /**
116
     * @return WidgetLayout
117
     */
118
    public function Toolbar()
119
    {
120
        $W = bab_Widgets();
121
122
        return $W->FlowItems()->addClass(\Func_Icons::ICON_LEFT_16, 'widget-toolbar');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $W->FlowItems()->...T_16, 'widget-toolbar') returns the type Widget_FlowLayout which is incompatible with the documented return type Capwelton\Widgets\Widgets\Layout\WidgetLayout.
Loading history...
123
    }
124
125
126
    /**
127
     * @return AppExportSelectEditor
128
     */
129
    public function ExportSelectEditor($id, AppTableModelView $tableview, $filter = null)
130
    {
131
        return new AppExportSelectEditor($this->App(), $id, $tableview, $filter);
132
    }
133
    
134
    public function Chip($label, $labelIcon = null, $action = null, $actionIcon = null, $id = null)
135
    {
136
        return new AppChip($this->App(), $label, $labelIcon, $action, $actionIcon, $id);
137
    }
138
    
139
    public function CustomFieldTableView($id = null)
140
    {
141
        return new AppCustomFieldTableView($this->App(), $id);
142
    }
143
    
144
    public function CustomFieldEditor(AppCustomField $customField = null, $id = null, $layout = null)
145
    {
146
        return new AppCustomFieldEditor($this->App(), $customField, $id, $layout);
147
    }
148
    
149
    /**
150
     * @param string 		$id
151
     * @param WidgetLayout $layout
152
     * @return AppEditor
153
     * @see AppEditor
154
     */
155
    public function BasicEditor($id = null, WidgetLayout $layout = null)
156
    {
157
        $editor = new AppEditor($this->App(), $id, $layout);
158
        $editor->setHiddenValue('tg', $this->App()->controllerTg);
159
        return $editor;
160
    }
161
    
162
    /**
163
     * @param ORMCriteria $criteria
164
     * @return AppCriteriaEditor
165
     */
166
    public function CriteriaEditor(ORMCriteria $criteria = null)
167
    {
168
        return new AppCriteriaEditor($this->App(), $criteria);
169
    }
170
    
171
    public function ShapeSquare($size = 15, $color = 'black')
172
    {
173
        return new AppShapeSquare($this->App(), $size, $color);
174
    }
175
    
176
    public function ShapeCircle($size = 15, $color = 'black')
177
    {
178
        return new AppShapeCircle($this->App(), $size, $color);
179
    }
180
    
181
    public function ShapeTriangle($size = 15, $color = 'black')
182
    {
183
        return new AppShapeTriangle($this->App(), $size, $color);
184
    }
185
    
186
    /**
187
     * @param string 		$id
188
     * @param WidgetLayout $layout
189
     * @return AppEditor
190
     * @see AppTableModelViewColumnSettingsEditor
191
     */
192
    public function TableModelViewColumnSettingsEditor(AppTableModelView $view, $id = null, WidgetLayout $layout = null)
193
    {
194
        $editor = new AppTableModelViewColumnSettingsEditor($this->App(), $view, $id, $layout);
195
        $editor->setHiddenValue('tg', $this->App()->controllerTg);
196
        return $editor;
197
    }
198
}