- bugfix: mytinytodo was not working when opened like 'path/index.php'

This commit is contained in:
Max Pozdeev 2010-02-06 17:51:44 +03:00
parent 06eb452104
commit 5ad4b37c19
2 changed files with 13 additions and 4 deletions

View file

@ -140,4 +140,13 @@ function formatDate3($format, $ay, $am, $ad, $lang)
return strtr($format, array('Y'=>$Y, 'F'=>$F, 'M'=>$M, 'n'=>$n, 'm'=>$m, 'd'=>$d, 'j'=>$j));
}
function url_dir($url)
{
$p = parse_url($url, PHP_URL_PATH);
if($p == '') return '/';
if(substr($p,-1) == '/') return $p;
if(false !== $pos = strrpos($p,'/')) return substr($p,0,$pos+1);
return '/';
}
?>

View file

@ -46,13 +46,13 @@ function get_mttinfo($v)
switch($v)
{
case 'template_uri':
$_mttinfo['template_uri'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH). 'themes/'. Config::get('template') . '/';
$_mttinfo['template_uri'] = url_dir($_SERVER['REQUEST_URI']). 'themes/'. Config::get('template') . '/';
return $_mttinfo['template_uri'];
case 'template_url':
$_mttinfo['template_url'] = get_mttinfo('siteurl'). 'themes/'. Config::get('template') . '/';
$_mttinfo['template_url'] = get_mttinfo('url'). 'themes/'. Config::get('template') . '/';
return $_mttinfo['template_url'];
case 'siteurl':
$_mttinfo['siteurl'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
case 'url':
$_mttinfo['siteurl'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). url_dir($_SERVER['REQUEST_URI']);
return $_mttinfo['siteurl'];
case 'title':
$_mttinfo['title'] = (Config::get('title') != '') ? htmlarray(Config::get('title')) : $lang->get('My Tiny Todolist');