Fix for _m() usage with context in StatusNet main code.

This commit is contained in:
Brion Vibber 2010-03-13 12:12:06 -08:00
parent d2c4ff5f7c
commit 14c488ebb0

View File

@ -202,17 +202,20 @@ function _mdomain($backtrace)
static $cached; static $cached;
$path = $backtrace[0]['file']; $path = $backtrace[0]['file'];
if (!isset($cached[$path])) { if (!isset($cached[$path])) {
$final = 'statusnet'; // assume default domain
if (DIRECTORY_SEPARATOR !== '/') { if (DIRECTORY_SEPARATOR !== '/') {
$path = strtr($path, DIRECTORY_SEPARATOR, '/'); $path = strtr($path, DIRECTORY_SEPARATOR, '/');
} }
$cut = strpos($path, '/plugins/') + 9; $cut = strpos($path, '/plugins/');
if ($cut) {
$cut += strlen('/plugins/');
$cut2 = strpos($path, '/', $cut); $cut2 = strpos($path, '/', $cut);
if ($cut && $cut2) { if ($cut && $cut2) {
$cached[$path] = substr($path, $cut, $cut2 - $cut); $final = substr($path, $cut, $cut2 - $cut);
} else {
return null;
} }
} }
$cached[$path] = $final;
}
return $cached[$path]; return $cached[$path];
} }