dolibarr 22.0.5
contributing.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
20// Load Dolibarr environment
21require '../../../../main.inc.php';
22
30// Protection if external user
31if ($user->socid > 0) {
33}
34
35// Includes
36require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php';
37
38// Load documentation translations
39$langs->load('uxdocumentation');
40
41//
42$documentation = new Documentation($db);
43
44$morejs = [
45 '/includes/ace/src/ace.js',
46 '/includes/ace/src/ext-statusbar.js',
47 '/includes/ace/src/ext-language_tools.js',
48];
49// Output html head + body - Param is Title
50$documentation->docHeader('Contributing', $morejs);
51
52// Set view for menu and breadcrumb
53// Menu must be set in constructor of documentation class
54$documentation->view = array('Resources', 'Contributing');
55
56// Output sidebar
57$documentation->showSidebar(); ?>
58
59<div class="doc-wrapper">
60
61 <?php $documentation->showBreadCrumb(); ?>
62
63 <div class="doc-content-wrapper">
64
65 <h1 class="documentation-title"><?php echo $langs->trans('DocHowContribute'); ?></h1>
66 <p class="documentation-text"><?php echo $langs->trans('DocHowContributeDescription'); ?></p>
67
68 <!-- Summary -->
69 <?php $documentation->showSummary(); ?>
70
71 <!-- First Step -->
72 <div class="documentation-section" id="contributesection-step1">
73 <h2 class="documentation-title"><?php echo $langs->trans('DocContributeStep1'); ?></h2>
74 <p class="documentation-text"><?php echo $langs->trans('DocContributeStep1Description'); ?></p>
75
76 <?php
77 $lines = array(
78 '<?php',
79 '/*',
80 ' * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>',
81 ' * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>',
82 ' *',
83 ' * This program is free software; you can redistribute it and/or modify',
84 ' * it under the terms of the GNU General Public License as published by',
85 ' * the Free Software Foundation; either version 3 of the License, or',
86 ' * (at your option) any later version.',
87 ' *',
88 ' * This program is distributed in the hope that it will be useful,',
89 ' * but WITHOUT ANY WARRANTY; without even the implied warranty of',
90 ' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the',
91 ' * GNU General Public License for more details.',
92 ' *',
93 ' * You should have received a copy of the GNU General Public License',
94 ' * along with this program. If not, see <https://www.gnu.org/licenses/>.',
95 ' */',
96 '',
97 '// Load Dolibarr environment',
98 'require \'../../../../main.inc.php\';',
99 '',
100 '
105',
106 '',
107 '// Protection if external user',
108 'if ($user->socid > 0) {',
109 ' accessforbidden();',
110 '}',
111 '',
112 '// Includes',
113 'require_once DOL_DOCUMENT_ROOT . \'/admin/tools/ui/class/documentation.class.php\';',
114 '',
115 '// Load documentation translations',
116 '$langs->load(\'uxdocumentation\');',
117 '',
118 '// Hooks',
119 '$hookmanager->initHooks(array(\'uidocumentation\'));',
120 '',
121 '//',
122 '$documentation = new Documentation($db);',
123 '',
124 '// Add more js',
125 '$morejs = [',
126 ' \'/includes/ace/src/ace.js\',',
127 ' \'/includes/ace/src/ext-statusbar.js\',',
128 ' \'/includes/ace/src/ext-language_tools.js\',',
129 '];',
130 '// Output html head + body - First param is title',
131 '$documentation->docHeader(\'DocMyPageTitle\', $morejs);',
132 '',
133 '// Set view for menu and breadcrumb',
134 '// Menu must be set in constructor of documentation class',
135 '$documentation->view = array(\'MyPageKey1\', \'MyPageKey2\');',
136 '',
137 '// Output sidebar',
138 '$documentation->showSidebar(); ?>',
139 '',
140 '<div class="doc-wrapper">',
141 '',
142 ' <?php $documentation->showBreadCrumb(); ?>',
143 ' <div class="doc-content-wrapper">',
144 ' ',
145 ' <h1 class="documentation-title"><?php print $langs->trans(\'DocMyPageTitle\'); ?></h1>',
146 ' <p class="documentation-text"><?php print $langs->trans(\'DocMyPageDescription\'); ?></p>',
147 ' ',
148 ' <!-- Summary -->',
149 ' <?php $documentation->showSummary(); ?>',
150 ' ',
151 ' <!-- Section 1 -->',
152 ' <div class="documentation-section" id="my-section-name">',
153 ' ',
154 ' <h2 class="documentation-title"><?php print $langs->trans(\'DocMySectionTitle\'); ?></h2>',
155 ' <p class="documentation-text"><?php print $langs->trans(\'DocMySectionText\'); ?></p>',
156 ' ',
157 ' <div class="documentation-example">',
158 ' <div class="div-table-responsive">',
159 ' <p><?php print $langs->trans(\'DocMySectionExample\'); ?></p>',
160 ' </div>',
161 ' </div>',
162 ' <?php',
163 ' $lines = array(',
164 ' \'<div class="div-table-responsive">\',',
165 ' \' <p>Here you can put an example of your component</p>\',',
166 ' \'</div>\',',
167 ' );',
168 ' print $documentation->showCode($lines, \'html\'); ?>',
169 ' ',
170 ' <p class="documentation-text"><?php print $langs->trans(\'DocMySectionText2\'); ?></p>',
171 ' </div>',
172 ' ',
173 ' <!-- Section 2-->',
174 ' <div class="documentation-section" id="my-section2-name">',
175 ' ',
176 ' <h2 class="documentation-title"><?php print $langs->trans(\'DocMySectionTitle\'); ?></h2>',
177 ' <p class="documentation-text"><?php print $langs->trans(\'DocMySectionText\'); ?></p>',
178 ' ',
179 ' <!-- Display messages -->',
180 ' <div class="warning"><?php print $langs->trans(\'DocExampleWarning\'); ?></div>',
181 ' <div class="info"><?php print $langs->trans(\'DocExampleInfo\'); ?></div>',
182 ' <div class="error"><?php print $langs->trans(\'DocExampleError\'); ?></div>',
183 ' <div class="green"><?php print $langs->trans(\'DocExampleGreen\'); ?></div>',
184 ' </div>',
185 ' ',
186 ' </div>',
187 '</div>',
188 '',
189 '<?php',
190 '// Output close body + html',
191 '$documentation->docFooter();',
192 '?>',
193 );
194 echo $documentation->showCode($lines, 'php'); ?>
195 </div>
196
197 <!-- Second Step -->
198 <div class="documentation-section" id="contributesection-step2">
199
200 <h2 class="documentation-title"><?php print $langs->trans('DocContributeStep2'); ?></h2>
201 <p class="documentation-text"><?php print $langs->trans('DocContributeStep2Description'); ?></p>
202 <p class="documentation-text"><?php print $langs->trans('DocContributeAddMenuEntry'); ?></p>
203
204 <?php
205 $lines = array(
206 '<?php',
207 '// in SetMenu() function, search "Components" and fill submenu',
208 ' ',
209 '// Components',
210 '$this->menu[\'Components\'] = array(',
211 ' // url,',
212 ' // icon,',
213 ' \'submenu\' => array(',
214 ' ',
215 ' // Others menu entries ...',
216 ' ',
217 ' // My new menu entry',
218 ' \'MyComponent\' => array(',
219 ' // Url to my documentation page',
220 ' \'url\' => dol_buildpath($this->baseUrl.\'/components/mycomponenturl.php\', 1),',
221 ' // My component icon, use fontawesome class',
222 ' \'icon\' => \'fas fa-mouse\', // use fontawesome class here',
223 ' // You can add another submenu into this array',
224 ' \'submenu\' => array(),',
225 ' // Here is for build summary (LangKeySection => nameOfYourDiv)',
226 ' \'summary\' => array(',
227 ' \'MyLangKey1\' => \'#my-component-section1-div\',',
228 ' \'MyLangKey2\' => \'#my-component-section2-div\',',
229 ' ),',
230 ' ),',
231 ' )',
232 ');',
233 );
234 echo $documentation->showCode($lines, 'php'); ?>
235 </div>
236
237 <!-- Third Step -->
238 <div class="documentation-section" id="contributesection-step3">
239
240 <h2 class="documentation-title"><?php print $langs->trans('DocContributeStep3'); ?></h2>
241 <p class="documentation-text"><?php print $langs->trans('DocContributeStep3Description'); ?></p>
242
243 <?php
244 $lines = array(
245 '<?php',
246 '',
247 '// Set view for menu and breadcrumb',
248 '$documentation->view = array(\'Components\', \'MyComponent\');',
249 );
250 echo $documentation->showCode($lines, 'php'); ?>
251 </div>
252
253 </div>
254
255</div>
256
257<?php
258// Output close body + html
259$documentation->docFooter();
260?>
Class to manage UI documentation.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.