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) 2019 by CAPWELTON ({@link http://www.capwelton.com}) |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
$W = bab_Widgets(); |
25
|
|
|
$W->includePhpClass('Widget_SuggestLineEdit'); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* A app_Chip |
29
|
|
|
*/ |
30
|
|
|
class app_Chip extends Widget_Widget |
31
|
|
|
{ |
32
|
|
|
protected $App; |
33
|
|
|
protected $label; |
34
|
|
|
protected $labelIcon; |
35
|
|
|
protected $action; |
36
|
|
|
protected $actionIcon; |
37
|
|
|
|
38
|
|
|
public function __construct(Func_App $App, $label, $labelIcon = null, $action = null, $actionIcon = null, $id = null) |
39
|
|
|
{ |
40
|
|
|
parent::__construct($id); |
41
|
|
|
|
42
|
|
|
$this->App = $App; |
43
|
|
|
$this->label = $label; |
44
|
|
|
$this->labelIcon = $labelIcon; |
45
|
|
|
$this->action = $action; |
46
|
|
|
$this->actionIcon = $actionIcon; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function App() |
50
|
|
|
{ |
51
|
|
|
return $this->App(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setApp(Func_App $App) |
55
|
|
|
{ |
56
|
|
|
$this->App = $App; |
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getClasses() |
61
|
|
|
{ |
62
|
|
|
$classes = parent::getClasses(); |
63
|
|
|
$classes[] = 'app-chip'; |
64
|
|
|
return $classes; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function chip() |
68
|
|
|
{ |
69
|
|
|
$W = bab_Widgets(); |
70
|
|
|
|
71
|
|
|
$html = "<div class='chip'>"; |
72
|
|
|
|
73
|
|
|
if(isset($this->labelIcon)){ |
74
|
|
|
$icon = $W->Label('')->setIconFormat(16, 'left')->setIcon($this->labelIcon); |
75
|
|
|
$html .= $icon->display($W->HtmlCanvas()); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$html .= $this->label; |
79
|
|
|
|
80
|
|
|
if(isset($this->action)){ |
81
|
|
|
$icon = $W->Link('', $this->action)->setIconFormat(16, 'left')->setOpenMode(Widget_Link::OPEN_DIALOG_AND_RELOAD); |
82
|
|
|
$icon->setIcon(isset($this->actionIcon) ? $this->actionIcon : Func_Icons::ACTIONS_DIALOG_CANCEL); |
83
|
|
|
$icon->addClass('chip-right-action'); |
84
|
|
|
$html .= $icon->display($W->HtmlCanvas()); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$html .= "</div>"; |
88
|
|
|
|
89
|
|
|
return $html; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function display(Widget_Canvas $canvas) |
93
|
|
|
{ |
94
|
|
|
$output = parent::display($canvas); |
95
|
|
|
$appAddon = bab_getAddonInfosInstance('libapp'); |
96
|
|
|
$output .= $canvas->loadAddonStyleSheet($appAddon, 'widgets/chip.css'); |
97
|
|
|
|
98
|
|
|
$output .= $canvas->html($this->getId(), $this->getClasses(), $this->chip()); |
99
|
|
|
|
100
|
|
|
return $output; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|