dolibarr 21.0.0-alpha
mymodulewidget1.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
4 * Copyright (C) ---Replace with your own copyright and developer email---
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
28include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
29
30
38{
42 public $boxcode = "mymodulebox";
43
48 public $boximg = "mymodule@mymodule";
49
53 public $boxlabel = 'MyWidget';
54
58 public $lang = 'mymodule@mymodule';
59
63 public $depends = array('mymodule');
64
68 public $widgettype = 'graph';
69
70
77 public function __construct(DoliDB $db, $param = '')
78 {
79 global $user;
80
81 parent::__construct($db, $param);
82
83 $this->param = $param;
84
85 // Condition when module is enabled or not
86 // $this->enabled = getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0;
87 // Condition when module is visible by user (test on permission)
88 // $this->hidden = !$user->hasRight('mymodule', 'myobject', 'read');
89 }
90
97 public function loadBox($max = 5)
98 {
99 global $langs;
100
101 // Use configuration value for max lines count
102 $this->max = $max;
103
104 //dol_include_once("/mymodule/class/mymodule.class.php");
105
106 // Populate the head at runtime
107 $text = $langs->trans("MyModuleBoxDescription", $max);
108 $this->info_box_head = array(
109 // Title text
110 'text' => $text,
111 // Add a link
112 'sublink' => 'https://example.com',
113 // Sublink icon placed after the text
114 'subpicto' => 'object_mymodule@mymodule',
115 // Sublink icon HTML alt text
116 'subtext' => '',
117 // Sublink HTML target
118 'target' => '',
119 // HTML class attached to the picto and link
120 'subclass' => 'center',
121 // Limit and truncate with "…" the displayed text length, 0 = disabled
122 'limit' => 0,
123 // Adds translated " (Graph)" to a hidden form value's input (?)
124 'graph' => 0
125 );
126
127 // Populate the contents at runtime
128 $this->info_box_contents = array(
129 0 => array( // First line
130 0 => array( // First Column
131 // HTML properties of the TR element. Only available on the first column.
132 'tr' => 'class="left"',
133 // HTML properties of the TD element
134 'td' => '',
135
136 // Main text for content of cell
137 'text' => 'First cell of first line',
138 // Link on 'text' and 'logo' elements
139 'url' => 'https://example.com',
140 // Link's target HTML property
141 'target' => '_blank',
142 // Fist line logo (deprecated. Include instead logo html code into text or text2, and set asis property to true to avoid HTML cleaning)
143 //'logo' => 'monmodule@monmodule',
144 // Unformatted text, added after text. Useful to add/load javascript code
145 'textnoformat' => '',
146
147 // Main text for content of cell (other method)
148 //'text2' => '<p><strong>Another text</strong></p>',
149
150 // Truncates 'text' element to the specified character length, 0 = disabled
151 'maxlength' => 0,
152 // Prevents HTML cleaning (and truncation)
153 'asis' => 0,
154 // Same for 'text2'
155 'asis2' => 0
156 ),
157 1 => array( // Another column
158 // No TR for n≠0
159 'td' => '',
160 'text' => 'Second cell',
161 )
162 ),
163 1 => array( // Another line
164 0 => array( // TR
165 'tr' => 'class="left"',
166 'text' => 'Another line'
167 ),
168 1 => array( // TR
169 'tr' => 'class="left"',
170 'text' => ''
171 )
172 ),
173 2 => array( // Another line
174 0 => array( // TR
175 'tr' => 'class="left"',
176 'text' => ''
177 ),
178 1 => array( // TR
179 'tr' => 'class="left"',
180 'text' => ''
181 )
182 ),
183 );
184 }
185
186
187
188
189
190
199 public function showBox($head = null, $contents = null, $nooutput = 0)
200 {
201 // You may make your own code here…
202 // … or use the parent's class function using the provided head and contents templates
203 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
204 }
205}
Class to manage Dolibarr database access.
Class ModeleBoxes.
Class to manage the box.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data into info_box_contents array to show array later.
__construct(DoliDB $db, $param='')
Constructor.