public static function get_path($name, $trail = false)
{
$path = '';
switch (strtolower($name)) {
case 'base':
case 'habari':
$path = rtrim(dirname(Site::script_name()), '/\\');
if (self::$config_urldir != '') {
$path .= '/' . self::$config_urldir;
}
break;
case 'user':
if (Site::is('main')) {
$path = 'user';
} else {
$path = ltrim(str_replace(HABARI_PATH, '', Site::get_dir('config')), '/');
}
break;
case 'theme':
$theme = Themes::get_theme_dir();
if (file_exists(Site::get_dir('config') . '/themes/' . $theme)) {
$path = Site::get_path('user') . '/themes/' . $theme;
} elseif (file_exists(HABARI_PATH . '/3rdparty/themes/' . $theme)) {
$path = Site::get_path('habari') . '/3rdparty/themes/' . $theme;
} else {
$path = Site::get_path('base') . '/user/themes/' . $theme;
}
break;
}
$path .= Utils::trail($trail);
// if running Habari in docroot, get_url('base') will return
// a double slash. Let's fix that.
$path = str_replace('//', '/', $path);
$path = Plugins::filter('site_path_' . $name, $path);
return $path;
}