Fix: increase speed

This commit is contained in:
Regis Houssin
2012-08-02 08:02:49 +02:00
parent e717f491c1
commit fe4fc7f8dc

View File

@@ -226,12 +226,17 @@ function dol_getprefix()
* To link to a module file from a core file, then this function can be used * To link to a module file from a core file, then this function can be used
* *
* @param string $relpath Relative path to file (Ie: mydir/myfile, ../myfile, ...) * @param string $relpath Relative path to file (Ie: mydir/myfile, ../myfile, ...)
* @param string $classname Class name
* @return int false if include fails. * @return int false if include fails.
*/ */
function dol_include_once($relpath) function dol_include_once($relpath, $classname='')
{ {
global $conf,$langs,$user,$mysoc; // Other global var must be retreived with $GLOBALS['var'] global $conf,$langs,$user,$mysoc; // Other global var must be retreived with $GLOBALS['var']
return @include_once(dol_buildpath($relpath)); if (! empty($classname) && ! class_exists($classname)) {
return @include dol_buildpath($relpath);
} else {
return @include_once dol_buildpath($relpath);
}
} }
@@ -270,7 +275,7 @@ function dol_buildpath($path,$type=0)
} }
} }
} }
if ($type == 2) else if ($type == 2)
{ {
$res = DOL_MAIN_URL_ROOT.$path; // Standard value $res = DOL_MAIN_URL_ROOT.$path; // Standard value
if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used