28 use Luracast\Restler\Routes;
30 require_once
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/api/class/api.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/api/class/api_access.class.php';
36 $langs->load(
"admin");
44 if (empty($conf->global->MAIN_MODULE_API))
46 dol_syslog(
"Call Dolibarr API interfaces with module REST disabled");
47 print $langs->trans(
"WarningModuleNotActive",
'Api').
'.<br><br>';
48 print $langs->trans(
"ToActivateModule");
55 $api->r->addAPIClass(
'Luracast\\Restler\\Resources');
56 $api->r->setSupportedFormats(
'JsonFormat',
'XmlFormat');
57 $api->r->addAuthenticationClass(
'DolibarrApiAccess',
'');
59 $listofapis = array();
62 foreach ($modulesdir as $dir)
70 if (is_resource($handle))
72 while (($file = readdir($handle)) !==
false)
74 if (is_readable($dir.$file) && preg_match(
"/^(mod.*)\.class\.php$/i", $file, $reg))
76 $modulename = $reg[1];
80 $module = $part = $obj = strtolower(preg_replace(
'/^mod/i',
'', $modulename));
82 if ($module ==
'societe') {
85 if ($module ==
'categorie') {
89 if ($module ==
'facture') {
90 $part =
'compta/facture';
93 if ($module ==
'ficheinter') {
96 $module =
'fichinter';
99 if (empty($conf->$module->enabled)) $enabled =
false;
110 $dir_part = DOL_DOCUMENT_ROOT.
'/'.$part.
'/class/';
113 if (is_resource($handle_part))
115 while (($file_searched = readdir($handle_part)) !==
false)
117 if (is_readable($dir_part.$file_searched) && preg_match(
"/^api_(.*)\.class\.php$/i", $file_searched, $reg))
119 $classname = ucwords($reg[1]);
120 require_once $dir_part.$file_searched;
121 if (class_exists($classname))
123 dol_syslog(
"Found API classname=".$classname.
" into ".$dir);
124 $listofapis[] = $classname;
162 $listofapis = Routes::toArray();
168 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
172 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
173 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
179 $url =
'<a href="'.$urlwithroot.
'/api/index.php/login?login='.urlencode($user->login).
'&password=yourpassword" target="_blank">'.$urlwithroot.
'/api/index.php/login?login='.urlencode($user->login).
'&password=yourpassword[&reset=1]</a>';
180 $message .= $langs->trans(
"UrlToGetKeyToUseAPIs").
':<br>';
181 $message .=
img_picto(
'',
'globe').
' '.$url;
188 print $langs->trans(
"ListOfAvailableAPIs").
':<br>';
189 foreach ($listofapis[
'v1'] as $key => $val)
191 if ($key ==
'login')
continue;
192 if ($key ==
'index')
continue;
196 foreach ($val as $method => $val2)
198 $newclass = $val2[
'className'];
200 if (preg_match(
'/restler/i', $newclass))
continue;
202 if ($oldclass != $newclass)
204 print "\n<br>\n".$langs->trans(
"Class").
': '.$newclass.
'<br>'.
"\n";
205 $oldclass = $newclass;
208 $url = $urlwithroot.
'/api/index.php/'.$key;
209 $url .=
'?api_key=token';
210 print img_picto(
'',
'globe').
' '.$method.
' <a href="'.$url.
'" target="_blank">'.$url.
"</a><br>\n";
217 print $langs->trans(
"OnlyActiveElementsAreExposed", DOL_URL_ROOT.
'/admin/modules.php');
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolGetModulesDirs($subdir= '')
Return list of modules directories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.