* MTTPATH constant added

This commit is contained in:
Max Pozdeev 2010-02-06 20:35:39 +03:00
parent 77f8034d61
commit 301a75f779
8 changed files with 37 additions and 28 deletions

View file

@ -1,12 +1,12 @@
<?php
require_once('./db/config.php');
require_once('./lang/class.default.php');
require_once('./lang/'. $config['lang']. '.php');
if(!defined('MTTPATH')) define('MTTPATH', dirname(__FILE__) .'/');
$l = new Lang();
require_once(MTTPATH. 'db/config.php');
require_once(MTTPATH. 'lang/class.default.php');
require_once(MTTPATH. 'lang/'. $config['lang']. '.php');
header('Content-type: text/javascript');
echo $l->makeJS();
echo Lang::instance()->makeJS();
?>

View file

@ -10,9 +10,8 @@ set_error_handler('myErrorHandler');
set_exception_handler('myExceptionHandler');
require_once('./init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.Config::get('lang').'.php');
$lang = new Lang();
$lang = Lang::instance();
if(isset($_GET['loadLists']))
{

View file

@ -116,7 +116,7 @@ class Config
$s .= "\$config['$param'] = '".str_replace(array("\\","'"),array("\\\\","\\'"),$val)."';\n";
}
}
$f = fopen('./db/config.php', 'w');
$f = fopen(MTTPATH. 'db/config.php', 'w');
if($f === false) throw new Exception("Error while saving config file");
fwrite($f, "<?php\n\$config = array();\n$s?>");
fclose($f);

View file

@ -8,9 +8,8 @@
$dontStartSession = 1;
require_once('./init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.Config::get('lang').'.php');
$lang = new Lang();
$lang = Lang::instance();
$listId = (int)_get('list');

View file

@ -5,12 +5,9 @@
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
*/
require_once('./init.php');
require_once('init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.Config::get('lang').'.php');
$lang = new Lang();
$lang = Lang::instance();
if($lang->rtl()) Config::set('rtl', 1);
@ -18,7 +15,7 @@ if(!is_int(Config::get('firstdayofweek')) || Config::get('firstdayofweek')<0 ||
$_mttinfo = array();
define('TEMPLATEPATH', './themes/'.Config::get('template').'/');
define('TEMPLATEPATH', MTTPATH. 'themes/'.Config::get('template').'/');
require(TEMPLATEPATH. 'index.php');

View file

@ -1,7 +1,9 @@
<?php
require_once('common.php');
require_once('./db/config.php');
if(!defined('MTTPATH')) define('MTTPATH', dirname(__FILE__) .'/');
require_once(MTTPATH. 'common.php');
require_once(MTTPATH. 'db/config.php');
ini_set('display_errors', 'On');
@ -12,7 +14,7 @@ unset($config);
# MySQL Database Connection
if(Config::get('db') == 'mysql')
{
require_once('class.db.mysql.php');
require_once(MTTPATH. 'class.db.mysql.php');
$db = new Database_Mysql;
$db->connect(Config::get('mysql.host'), Config::get('mysql.user'), Config::get('mysql.password'), Config::get('mysql.db'));
$db->dq("SET NAMES utf8");
@ -21,19 +23,21 @@ if(Config::get('db') == 'mysql')
# SQLite3 (pdo_sqlite)
else
{
require_once('class.db.sqlite3.php');
require_once(MTTPATH. 'class.db.sqlite3.php');
$db = new Database_Sqlite3;
$db->connect('./db/todolist.db');
$db->connect(MTTPATH. 'db/todolist.db');
}
$db->prefix = Config::get('prefix');
require_once(MTTPATH. 'lang/class.default.php');
require_once(MTTPATH. 'lang/'.Config::get('lang').'.php');
$needAuth = (Config::get('password') != '') ? 1 : 0;
if($needAuth && !isset($dontStartSession))
{
if(Config::get('session') == 'files')
{
session_save_path(realpath('./tmp/sessions/'));
session_save_path(MTTPATH. 'tmp/sessions/');
ini_set('session.gc_maxlifetime', '1209600'); # 14 days session file minimum lifetime
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 10);

View file

@ -6,7 +6,9 @@
class DefaultLang
{
protected static $instance;
protected $rtl = 0;
private $default_js = array
(
'confirmDelete' => "Are you sure you want to delete the task?",
@ -157,6 +159,16 @@ class DefaultLang
{
return $this->rtl ? 1 : 0;
}
public static function instance()
{
if (!isset(self::$instance)) {
//$c = __CLASS__;
$c = 'Lang';
self::$instance = new $c;
}
return self::$instance;
}
}
?>

View file

@ -8,9 +8,7 @@
require_once('./init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.Config::get('lang').'.php');
$lang = new Lang();
$lang = Lang::instance();
if($needAuth && !is_logged())
{
@ -62,7 +60,7 @@ function __($s)
function getLangs()
{
if (!$h = opendir('./lang')) return false;
if (!$h = opendir(MTTPATH. 'lang')) return false;
$a = array();
while(false !== ($file = readdir($h)))
{