dolibarr 20.0.2
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) ---Put here 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;
54
58 public $depends = array('mymodule');
59
63 public $widgettype = 'graph';
64
65
72 public function __construct(DoliDB $db, $param = '')
73 {
74 global $user, $conf, $langs;
75 // Translations
76 $langs->loadLangs(array("boxes", "mymodule@mymodule"));
77
78 parent::__construct($db, $param);
79
80 $this->boxlabel = $langs->transnoentitiesnoconv("MyWidget");
81
82 $this->param = $param;
83
84 // Condition when module is enabled or not
85 // $this->enabled = getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0;
86 // Condition when module is visible by user (test on permission)
87 // $this->hidden = !$user->hasRight('mymodule', 'myobject', 'read');
88 }
89
96 public function loadBox($max = 5)
97 {
98 global $langs;
99
100 // Use configuration value for max lines count
101 $this->max = $max;
102
103 //dol_include_once("/mymodule/class/mymodule.class.php");
104
105 // Populate the head at runtime
106 $text = $langs->trans("MyModuleBoxDescription", $max);
107 $this->info_box_head = array(
108 // Title text
109 'text' => $text,
110 // Add a link
111 'sublink' => 'http://example.com',
112 // Sublink icon placed after the text
113 'subpicto' => 'object_mymodule@mymodule',
114 // Sublink icon HTML alt text
115 'subtext' => '',
116 // Sublink HTML target
117 'target' => '',
118 // HTML class attached to the picto and link
119 'subclass' => 'center',
120 // Limit and truncate with "…" the displayed text length, 0 = disabled
121 'limit' => 0,
122 // Adds translated " (Graph)" to a hidden form value's input (?)
123 'graph' => false
124 );
125
126 // Populate the contents at runtime
127 $this->info_box_contents = array(
128 0 => array( // First line
129 0 => array( // First Column
130 // HTML properties of the TR element. Only available on the first column.
131 'tr' => 'class="left"',
132 // HTML properties of the TD element
133 'td' => '',
134
135 // Main text for content of cell
136 'text' => 'First cell of first line',
137 // Link on 'text' and 'logo' elements
138 'url' => 'http://example.com',
139 // Link's target HTML property
140 'target' => '_blank',
141 // Fist line logo (deprecated. Include instead logo html code into text or text2, and set asis property to true to avoid HTML cleaning)
142 //'logo' => 'monmodule@monmodule',
143 // Unformatted text, added after text. Useful to add/load javascript code
144 'textnoformat' => '',
145
146 // Main text for content of cell (other method)
147 //'text2' => '<p><strong>Another text</strong></p>',
148
149 // Truncates 'text' element to the specified character length, 0 = disabled
150 'maxlength' => 0,
151 // Prevents HTML cleaning (and truncation)
152 'asis' => false,
153 // Same for 'text2'
154 'asis2' => true
155 ),
156 1 => array( // Another column
157 // No TR for n≠0
158 'td' => '',
159 'text' => 'Second cell',
160 )
161 ),
162 1 => array( // Another line
163 0 => array( // TR
164 'tr' => 'class="left"',
165 'text' => 'Another line'
166 ),
167 1 => array( // TR
168 'tr' => 'class="left"',
169 'text' => ''
170 )
171 ),
172 2 => array( // Another line
173 0 => array( // TR
174 'tr' => 'class="left"',
175 'text' => ''
176 ),
177 1 => array( // TR
178 'tr' => 'class="left"',
179 'text' => ''
180 )
181 ),
182 );
183 }
184
193 public function showBox($head = null, $contents = null, $nooutput = 0)
194 {
195 // You may make your own code here…
196 // … or use the parent's class function using the provided head and contents templates
197 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
198 }
199}
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.