AppToolbar::display()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 2
nc 2
nop 1
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) 2022 by SI4YOU ({@link https://www.siforyou.com})
23
 */
24
namespace Capwelton\LibApp\Ui;
25
26
use Capwelton\Widgets\Widgets\Abstracts\WidgetCanvas;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Abstracts\WidgetCanvas 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...
27
use Capwelton\Widgets\Widgets\Helpers\WidgetAction;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Helpers\WidgetAction 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...
28
use Capwelton\Widgets\Widgets\Interfaces\WidgetDisplayableInterface;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widget...getDisplayableInterface 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...
29
use Capwelton\Widgets\Widgets\Item\WidgetFrame;
0 ignored issues
show
Bug introduced by
The type Capwelton\Widgets\Widgets\Item\WidgetFrame 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\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...
31
32
class AppToolbar extends WidgetFrame
33
{
34
    
35
    public $local = false;
36
    
37
    public function __construct($id = null, WidgetLayout $layout = null)
38
    {
39
        if(! isset($layout)){
40
            $W = bab_Widgets();
41
            $layout = $W->FlowLayout()->setHorizontalSpacing(1, 'em');
42
            $layout->setVerticalAlign('top');
43
        }
44
        
45
        parent::__construct($id, $layout);
46
    }
47
    
48
    /**
49
     * @param string $labelText
50
     * @param string $iconName
51
     * @param WidgetAction $action
52
     * @param string $id
53
     * @return app_Toolbar
54
     */
55
    public function addButton($labelText = null, $iconName = null, $action = null, $id = null)
56
    {
57
        $W = bab_Widgets();
58
        $button = $W->Link($labelText, $action, $id);
59
        if(isset($iconName)){
60
            $button->addClass('icon', $iconName);
61
        }
62
        
63
        $this->addItem($button);
64
        
65
        return $this;
66
    }
67
    
68
    public function addInstantForm(WidgetDisplayableInterface $form, $labelText = null, $iconName = null, $action = null, $id = null)
69
    {
70
        $W = bab_Widgets();
71
        if(isset($iconName)){
72
            $content = $W->Icon($labelText, $iconName);
73
        }
74
        else{
75
            $content = $labelText;
76
        }
77
        $button = $W->Link($content, $action, $id);
78
        
79
        $this->addItem($W->VBoxItems($button->addClass('widget-instant-button'), $form->addClass('widget-instant-form'))
80
            ->addClass('widget-instant-container'));
81
        
82
        if($form->getTitle() === null){
83
            $form->setTitle($labelText);
84
        }
85
        
86
        return $this;
87
    }
88
    
89
    public function display(WidgetCanvas $canvas)
90
    {
91
        if(! $this->local){
92
            $this->addClass('widget-toolbar');
93
        }
94
        else{
95
            $this->addClass('app-toolbar');
96
        }
97
        $this->addClass(\Func_Icons::ICON_LEFT_16);
98
        
99
        return parent::display($canvas);
100
    }
101
}