28 require_once
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/api/class/api.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/api/class/api_access.class.php';
34 $langs->load(
"admin");
42 if (empty($conf->global->MAIN_MODULE_API))
44 dol_syslog(
"Call Dolibarr API interfaces with module REST disabled");
45 print $langs->trans(
"WarningModuleNotActive",
'Api').
'.<br><br>';
46 print $langs->trans(
"ToActivateModule");
53 $api->r->addAPIClass(
'Luracast\\Restler\\Resources');
54 $api->r->setSupportedFormats(
'JsonFormat',
'XmlFormat');
55 $api->r->addAuthenticationClass(
'DolibarrApiAccess',
'');
57 $listofapis = array();
60 foreach ($modulesdir as $dir)
68 if (is_resource($handle))
70 while (($file = readdir($handle))!==
false)
72 if (is_readable($dir.$file) && preg_match(
"/^(mod.*)\.class\.php$/i",$file,$reg))
78 $module=$part=$obj=strtolower(preg_replace(
'/^mod/i',
'',$modulename));
80 if ($module ==
'societe') {
83 if ($module ==
'categorie') {
87 if ($module ==
'facture') {
88 $part =
'compta/facture';
91 if ($module ==
'ficheinter') {
97 if (empty($conf->$module->enabled)) $enabled=
false;
109 $dir_part = DOL_DOCUMENT_ROOT.
'/'.$part.
'/class/';
112 if (is_resource($handle_part))
114 while (($file_searched = readdir($handle_part))!==
false)
116 if (is_readable($dir_part.$file_searched) && preg_match(
"/^api_(.*)\.class\.php$/i",$file_searched,$reg))
118 $classname = ucwords($reg[1]);
119 require_once $dir_part.$file_searched;
120 if (class_exists($classname))
122 dol_syslog(
"Found API classname=".$classname.
" into ".$dir);
123 $listofapis[] = $classname;
164 $listofapis=Routes::toArray();
170 $linkback=
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
174 $urlwithouturlroot=preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'',trim($dolibarr_main_url_root));
175 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;
181 $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>';
182 $message.=$langs->trans(
"UrlToGetKeyToUseAPIs").
':<br>';
183 $message.=
img_picto(
'',
'object_globe.png').
' '.$url;
190 print $langs->trans(
"ListOfAvailableAPIs").
':<br>';
191 foreach($listofapis[
'v1'] as $key => $val)
193 if ($key ==
'login')
continue;
194 if ($key ==
'index')
continue;
198 foreach($val as $method => $val2)
200 $newclass=$val2[
'className'];
202 if (preg_match(
'/restler/i', $newclass))
continue;
204 if ($oldclass != $newclass)
206 print "\n<br>\n".$langs->trans(
"Class").
': '.$newclass.
'<br>'.
"\n";
207 $oldclass = $newclass;
210 $url=$urlwithroot.
'/api/index.php/'.$key;
211 $url.=
'?api_key=token';
212 print img_picto(
'',
'object_globe.png').
' '.$method.
' <a href="'.$url.
'" target="_blank">'.$url.
"</a><br>\n";
219 print $langs->trans(
"OnlyActiveElementsAreExposed", DOL_URL_ROOT.
'/admin/modules.php');
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print
Draft customers invoices.
dolGetModulesDirs($subdir='')
Return list of modules directories.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)