diff --git a/src/index.php b/src/index.php index 6e5d9f8..54f2e2a 100644 --- a/src/index.php +++ b/src/index.php @@ -79,7 +79,7 @@ function js_options() "lang" => Lang::instance()->jsStrings(), "mttUrl" => get_mttinfo('mtt_url'), "homeUrl" => get_mttinfo('url'), -// "apiUrl" => get_mttinfo('api_url'), + "apiUrl" => get_mttinfo('api_url'), "needAuth" => need_auth() ? true : false, "isLogged" => is_logged() ? true : false, "showdate" => Config::get('showdate') ? true : false, diff --git a/src/init.php b/src/init.php index 372c919..b22fdfb 100644 --- a/src/init.php +++ b/src/init.php @@ -309,24 +309,10 @@ function get_unsafe_mttinfo($v) switch($v) { case 'theme_url': - if (!isset($_mttinfo['theme_url'])) { - if ( Config::getUrl('url') == '' && Config::getUrl('mtt_url') == '' - && (!defined('MTT_USE_HTTPS') || !MTT_USE_HTTPS) ) { - $_mttinfo['theme_url'] = url_dir(getRequestUri()). 'content/'. MTT_THEME. '/'; - } else { - $_mttinfo['theme_url'] = get_unsafe_mttinfo('mtt_url'). 'content/'. MTT_THEME. '/'; - } - } + $_mttinfo['theme_url'] = get_unsafe_mttinfo('mtt_uri'). 'content/'. MTT_THEME. '/'; return $_mttinfo['theme_url']; case 'content_url': - if (!isset($_mttinfo['content_url'])) { - if ( Config::getUrl('url') == '' && Config::getUrl('mtt_url') == '' - && (!defined('MTT_USE_HTTPS') || !MTT_USE_HTTPS) ) { - $_mttinfo['content_url'] = url_dir(getRequestUri()). 'content/'; - } else { - $_mttinfo['content_url'] = get_unsafe_mttinfo('mtt_url'). 'content/'; - } - } + $_mttinfo['content_url'] = get_unsafe_mttinfo('mtt_uri'). 'content/'; return $_mttinfo['content_url']; case 'url': /* full url to homepage: directory with root index.php or custom index file in the root. */ @@ -345,11 +331,22 @@ function get_unsafe_mttinfo($v) $_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 0 ); } return $_mttinfo['mtt_url']; + case 'mtt_uri': + $_mttinfo['mtt_uri'] = Config::getUrl('mtt_url'); // need to have a trailing slash + if ($_mttinfo['mtt_uri'] == '') { + if ( '' != $url = Config::getUrl('url') ) { + $_mttinfo['mtt_uri'] = url_dir($url); + } + else { + $_mttinfo['mtt_uri'] = url_dir(getRequestUri()); + } + } + return $_mttinfo['mtt_uri']; case 'api_url': /* URL for API, like http://localhost/mytinytodo/api/. No need to set by default. */ $_mttinfo['api_url'] = Config::getUrl('api_url'); // need to have a trailing slash if ($_mttinfo['api_url'] == '') { - $_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/'; + $_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_uri'). 'api.php?_path=/'; } return $_mttinfo['api_url']; case 'title':