Started phasing out $opt['rootpath']. Replaced by Config class. Also optimized some class files (cookie, template). Minor changes.
This commit is contained in:
@ -9,8 +9,8 @@
|
||||
|
||||
require_once __DIR__ . '/../lib/core.php';
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/db.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/labels.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/db.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/labels.inc.php');
|
||||
|
||||
class OcSmarty extends Smarty
|
||||
{
|
||||
@ -40,14 +40,14 @@ class OcSmarty extends Smarty
|
||||
function OcSmarty()
|
||||
{
|
||||
global $opt, $sqldebugger;
|
||||
require_once($opt['rootpath'] . 'lib2/bench.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/bench.inc.php');
|
||||
$this->bench = new CBench();
|
||||
$this->bench->start();
|
||||
|
||||
// configuration
|
||||
$this->template_dir = $opt['stylepath'];
|
||||
$this->compile_dir = $opt['rootpath'] . 'cache2/smarty/compiled/';
|
||||
$this->cache_dir = $opt['rootpath'] . 'cache2/smarty/cache/';
|
||||
$this->compile_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/smarty/compiled/';
|
||||
$this->cache_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/smarty/cache/';
|
||||
$this->plugins_dir = array('plugins', dirname(__FILE__).'/smarty/ocplugins');
|
||||
|
||||
// disable caching ... if caching is enabled, 1 hour is default
|
||||
@ -55,7 +55,7 @@ class OcSmarty extends Smarty
|
||||
$this->cache_lifetime = 3600; // default
|
||||
|
||||
// register additional functions
|
||||
require_once($opt['rootpath'] . 'lib2/smarty/ocplugins/block.nocache.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/smarty/ocplugins/block.nocache.php');
|
||||
$this->register_block('nocache', 'smarty_block_nocache', false);
|
||||
$this->load_filter('pre', 't');
|
||||
|
||||
@ -69,7 +69,7 @@ class OcSmarty extends Smarty
|
||||
// process debug level
|
||||
if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER)
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/sqldebugger.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/sqldebugger.class.php');
|
||||
}
|
||||
else if (($opt['debug'] & DEBUG_OUTOFSERVICE) == DEBUG_OUTOFSERVICE)
|
||||
{
|
||||
@ -281,9 +281,9 @@ class OcSmarty extends Smarty
|
||||
$this->bench->stop();
|
||||
$this->assign('sys_runtime', $this->bench->diff());
|
||||
|
||||
$this->assign('screen_css_time',filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_screen.css"));
|
||||
$this->assign('screen_msie_css_time',filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_screen_msie.css"));
|
||||
$this->assign('print_css_time',filemtime($opt['rootpath'] . "resource2/" . $opt['template']['style'] . "/css/style_print.css"));
|
||||
$this->assign('screen_css_time',filemtime($GLOBALS['container']->get('ocde.config')->getBaseDir() . "/resource2/" . $opt['template']['style'] . "/css/style_screen.css"));
|
||||
$this->assign('screen_msie_css_time',filemtime($GLOBALS['container']->get('ocde.config')->getBaseDir() . "/resource2/" . $opt['template']['style'] . "/css/style_screen_msie.css"));
|
||||
$this->assign('print_css_time',filemtime($GLOBALS['container']->get('ocde.config')->getBaseDir() . "/resource2/" . $opt['template']['style'] . "/css/style_print.css"));
|
||||
|
||||
// check if the template is compiled
|
||||
// if not, check if translation works correct
|
||||
@ -302,7 +302,7 @@ class OcSmarty extends Smarty
|
||||
|
||||
if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER)
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/sqldebugger.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/sqldebugger.class.php');
|
||||
|
||||
parent::fetch($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
|
||||
|
||||
|
@ -13,6 +13,10 @@
|
||||
// load Composer autoloader, if not yet done
|
||||
require_once __DIR__ . '/../lib/core.php';
|
||||
|
||||
if (!isset($opt)) {
|
||||
$opt = array();
|
||||
}
|
||||
|
||||
// check for broken browsers
|
||||
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
|
||||
$useragent_msie = preg_match('/MSIE ([1-9]+).[0-9]+/',$useragent,$ua_matches) && !strpos($useragent,"Opera");
|
||||
@ -27,9 +31,9 @@ require_once __DIR__ . '/../lib/core.php';
|
||||
fix_magic_quotes_gpc();
|
||||
|
||||
// set options
|
||||
require_once($opt['rootpath'] . 'config2/settings-dist.inc.php');
|
||||
require_once($opt['rootpath'] . 'config2/settings.inc.php');
|
||||
require_once($opt['rootpath'] . 'config2/verify-settings.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/settings-dist.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/settings.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/verify-settings.inc.php');
|
||||
|
||||
foreach ($opt['page']['banned_user_agents'] as $ua)
|
||||
if (strpos($useragent, $ua) !== false)
|
||||
@ -48,10 +52,9 @@ require_once __DIR__ . '/../lib/core.php';
|
||||
$opt['debug'] = $opt['debug'] & ~DEBUG_TRANSLATE;
|
||||
}
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/errorhandler.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/errorhandler.inc.php');
|
||||
configure_php();
|
||||
|
||||
require($opt['rootpath'] . 'lib2/cookie.class.php');
|
||||
normalize_settings();
|
||||
set_language();
|
||||
set_usercountry();
|
||||
@ -68,26 +71,24 @@ require_once __DIR__ . '/../lib/core.php';
|
||||
}
|
||||
else
|
||||
$opt['template']['style'] = $opt['template']['default']['style'];
|
||||
$opt['stylepath'] = $opt['rootpath'] . 'templates2/' . $opt['template']['style'] . '/';
|
||||
$opt['stylepath'] = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/templates2/' . $opt['template']['style'] . '/';
|
||||
|
||||
check_useragent();
|
||||
|
||||
/* setup smarty
|
||||
*
|
||||
*/
|
||||
require($opt['rootpath'] . 'lib2/OcSmarty.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/OcSmarty.class.php');
|
||||
$tpl = new OcSmarty();
|
||||
|
||||
// include all we need
|
||||
require_once($opt['rootpath'] . 'lib2/logic/const.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/geomath.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/error.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/util.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/db.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/login.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/menu.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/labels.inc.php');
|
||||
// require_once($opt['rootpath'] . 'lib2/throttle.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/const.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/error.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/util.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/db.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/login.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/menu.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/labels.inc.php');
|
||||
|
||||
// apply post configuration
|
||||
if (function_exists('post_config'))
|
||||
@ -194,6 +195,10 @@ function set_language()
|
||||
{
|
||||
global $opt, $cookie;
|
||||
|
||||
if ($cookie === null) {
|
||||
$cookie = new cookie();
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['locale']))
|
||||
$opt['template']['locale'] = strtoupper($_REQUEST['locale']);
|
||||
else
|
||||
@ -213,7 +218,7 @@ function set_language()
|
||||
|
||||
$cookie->set('locale', $opt['template']['locale'], $opt['template']['default']['locale']);
|
||||
|
||||
bindtextdomain('messages', $opt['rootpath'] . 'cache2/translate');
|
||||
bindtextdomain('messages', $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate');
|
||||
|
||||
// setup the PHP locale
|
||||
setlocale(LC_MONETARY, $opt['locale'][$opt['template']['locale']]['locales']);
|
||||
@ -349,6 +354,11 @@ function helppagelink($ocpage, $title='Instructions')
|
||||
{
|
||||
global $opt, $translate;
|
||||
|
||||
if ($translate === null) {
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/translate.inc.php');
|
||||
$translate = createTranslate();
|
||||
}
|
||||
|
||||
$helppage = sql_value("SELECT `helppage` FROM `helppages`
|
||||
WHERE `ocpage`='&1' AND `language`='&2'",
|
||||
"", $ocpage, $opt['template']['locale']);
|
||||
|
@ -8,8 +8,6 @@
|
||||
* See doc/cookies.txt for more information in cookies.
|
||||
***************************************************************************/
|
||||
|
||||
$cookie = new cookie();
|
||||
|
||||
class cookie
|
||||
{
|
||||
var $changed = false;
|
||||
|
@ -320,7 +320,6 @@
|
||||
|
||||
if (isset($db['debug']) && ($db['debug'] == true))
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/sqldebugger.class.php');
|
||||
$result = $sqldebugger->execute($filtered_sql, $dblink, ($dblink===$db['dblink_slave']), $db['slave_server']);
|
||||
if ($result === false)
|
||||
{
|
||||
@ -332,7 +331,7 @@
|
||||
// measure time
|
||||
if ($opt['db']['warn']['time'] > 0)
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/bench.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/bench.inc.php');
|
||||
$cSqlExecution = new Cbench;
|
||||
$cSqlExecution->start();
|
||||
}
|
||||
@ -973,7 +972,6 @@
|
||||
str_replace("\n","\r\n",$error) . "\n" . print_r(debug_backtrace(), true),
|
||||
"From: ".$opt['mail']['from']))
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/mail.class.php');
|
||||
$mail = new mail();
|
||||
$mail->subject = $opt['db']['error']['subject'];
|
||||
$mail->to = $opt['db']['error']['mail'];
|
||||
@ -1027,7 +1025,6 @@
|
||||
$warnmessage . "\n" . print_r(debug_backtrace(), true),
|
||||
"From: ".$opt['mail']['from']))
|
||||
{
|
||||
require_once($opt['rootpath'] . 'lib2/mail.class.php');
|
||||
$mail = new mail();
|
||||
$mail->name = 'sql_warn';
|
||||
$mail->subject = $opt['db']['warn']['subject'];
|
||||
|
@ -101,4 +101,3 @@ class attribute
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
?>
|
@ -8,8 +8,8 @@
|
||||
* add/remove etc. is executed instantly
|
||||
***************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/logtypes.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/rowEditor.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/logtypes.inc.php');
|
||||
|
||||
class cache
|
||||
{
|
||||
@ -635,4 +635,3 @@ class cache
|
||||
$this->getCacheId()) == 1);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -6,10 +6,10 @@
|
||||
***************************************************************************/
|
||||
|
||||
// try to include cache file
|
||||
if (!file_exists($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php'))
|
||||
if (!file_exists($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/labels-' . $opt['template']['locale'] . '.inc.php'))
|
||||
labels::CreateCacheFile();
|
||||
|
||||
require($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php');
|
||||
require($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/labels-' . $opt['template']['locale'] . '.inc.php');
|
||||
|
||||
class labels
|
||||
{
|
||||
@ -19,7 +19,7 @@ class labels
|
||||
{
|
||||
global $opt;
|
||||
|
||||
$f = fopen($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php', 'w');
|
||||
$f = fopen($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/labels-' . $opt['template']['locale'] . '.inc.php', 'w');
|
||||
fwrite($f, "<?php\n");
|
||||
|
||||
$a = array();
|
||||
@ -128,4 +128,3 @@ class labels
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
@ -8,16 +8,6 @@
|
||||
* add/remove etc. is executed instantly
|
||||
***************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/mail.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/statpic.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/countriesList.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/picture.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/cache.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/cracklib.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/crypt.class.php');
|
||||
require_once($opt['rootpath'] . 'lib2/translate.class.php');
|
||||
|
||||
class user
|
||||
{
|
||||
var $nUserId = 0;
|
||||
|
@ -7,9 +7,8 @@
|
||||
* set has to be commited with save
|
||||
*
|
||||
***************************************************************************/
|
||||
global $opt;
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/logic/const.inc.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/const.inc.php');
|
||||
|
||||
class useroptions
|
||||
{
|
||||
@ -140,5 +139,3 @@ class useroptions
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -26,8 +26,8 @@ class mail extends Smarty
|
||||
{
|
||||
global $opt;
|
||||
|
||||
$this->template_dir = $opt['rootpath'] . 'templates2/mail/';
|
||||
$this->compile_dir = $opt['rootpath'] . 'cache2/smarty/compiled/';
|
||||
$this->template_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/templates2/mail/';
|
||||
$this->compile_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/smarty/compiled/';
|
||||
$this->plugins_dir = array('plugins', 'ocplugins');
|
||||
|
||||
// disable caching ...
|
||||
@ -131,4 +131,3 @@ class mail extends Smarty
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
define('MNU_ROOT', 0);
|
||||
|
||||
global $opt;
|
||||
require_once($opt['rootpath'] . 'lib2/translate.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/translate.class.php');
|
||||
$menu = new Menu();
|
||||
|
||||
class Menu
|
||||
@ -23,7 +22,7 @@ class Menu
|
||||
{
|
||||
global $opt;
|
||||
|
||||
$this->sMenuFilename = $opt['rootpath'] . 'cache2/menu-' . $opt['template']['locale'] . '.inc.php';
|
||||
$this->sMenuFilename = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/menu-' . $opt['template']['locale'] . '.inc.php';
|
||||
|
||||
if (!file_exists($this->sMenuFilename))
|
||||
$this->CreateCacheFile();
|
||||
@ -102,7 +101,7 @@ class Menu
|
||||
{
|
||||
global $opt;
|
||||
|
||||
$dir = $opt['rootpath'] . 'cache2/';
|
||||
$dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/';
|
||||
if ($dh = opendir($dir))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
@ -275,4 +274,3 @@ class Menu
|
||||
return '';
|
||||
}
|
||||
}
|
||||
?>
|
@ -5,28 +5,6 @@
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/translateAccess.php');
|
||||
require_once($opt['rootpath'] . 'lib2/translationHandler.class.php');
|
||||
|
||||
function createTranslate($backtrace_level = 0)
|
||||
{
|
||||
$access = new translateAccess();
|
||||
|
||||
if ($access->hasAccess())
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$translateMode = $cookie->get('translate_mode');
|
||||
|
||||
if ($translateMode)
|
||||
return new translateEdit($translateMode == 'all', $backtrace_level);
|
||||
}
|
||||
|
||||
return new translate();
|
||||
}
|
||||
|
||||
$translate = createTranslate();
|
||||
|
||||
class translate
|
||||
{
|
||||
/* translate the given string
|
||||
@ -85,6 +63,10 @@ class translate
|
||||
global $translationHandler;
|
||||
global $opt;
|
||||
|
||||
if ($translationHandler === null) {
|
||||
$translationHandler = new TranslationHandler();
|
||||
}
|
||||
|
||||
if (!isset($language))
|
||||
{
|
||||
global $locale;
|
||||
@ -102,73 +84,3 @@ class translate
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
class translateEdit extends translate
|
||||
{
|
||||
private $editAll;
|
||||
private $backtrace_level;
|
||||
|
||||
public function __construct($editAll = true, $backtrace_level = 0)
|
||||
{
|
||||
$this->editAll = $editAll;
|
||||
$this->backtrace_level = $backtrace_level;
|
||||
}
|
||||
|
||||
function t($message, $style, $resource_name, $line, $plural='', $count=1, $lang=null)
|
||||
{
|
||||
global $opt;
|
||||
|
||||
if ($message == '')
|
||||
return '';
|
||||
|
||||
if ($message == 'INTERNAL_LANG')
|
||||
return parent::t($message, $style, $resource_name, $line, $plural, $count);
|
||||
|
||||
if ($plural != '' && $count!=1)
|
||||
$message = $plural;
|
||||
|
||||
$search = $this->prepare_text($message);
|
||||
$language = $opt['template']['locale'];
|
||||
|
||||
if (!isset($language))
|
||||
{
|
||||
global $locale;
|
||||
|
||||
$language = $locale;
|
||||
}
|
||||
|
||||
$rs = sql("SELECT `sys_trans`.`id` , `sys_trans_text`.`text` FROM `sys_trans` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id` = `sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang` = '&1' WHERE `sys_trans`.`text` = '&2'", $language, $search);
|
||||
$r = sql_fetch_assoc($rs);
|
||||
|
||||
$trans = $r['text'];
|
||||
$trans = $this->v($trans);
|
||||
|
||||
if ($trans && !$this->editAll)
|
||||
{
|
||||
return $trans;
|
||||
}
|
||||
|
||||
if (empty($r['id']))
|
||||
{
|
||||
global $translationHandler;
|
||||
|
||||
if (empty($resource_name))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
$item = $backtrace[$this->backtrace_level];
|
||||
$resource_name = $item['file'];
|
||||
$line = $item['line'];
|
||||
}
|
||||
|
||||
$translationHandler->addText($search, $resource_name, $line);
|
||||
|
||||
return $this->t($message, $style, $resource_name, $line, $plural, $count);
|
||||
}
|
||||
|
||||
$text = $trans ? $trans : gettext($search);
|
||||
|
||||
return $text . ' <a href= translate.php?action=edit&id=' . $r['id'] . '>Edit</a>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
25
htdocs/lib2/translate.inc.php
Normal file
25
htdocs/lib2/translate.inc.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
function createTranslate($backtrace_level = 0)
|
||||
{
|
||||
$access = new translateAccess();
|
||||
|
||||
if ($access->hasAccess())
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$translateMode = $cookie->get('translate_mode');
|
||||
|
||||
if ($translateMode)
|
||||
return new translateEdit($translateMode == 'all', $backtrace_level);
|
||||
}
|
||||
|
||||
return new translate();
|
||||
}
|
||||
|
||||
$translate = createTranslate();
|
@ -5,8 +5,7 @@
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/logic/const.inc.php');
|
||||
require_once($opt['rootpath'] . 'lib2/logic/useroptions.class.php');
|
||||
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/const.inc.php');
|
||||
|
||||
class translateAccess
|
||||
{
|
||||
@ -43,5 +42,3 @@ class translateAccess
|
||||
$this->languages = explode(',', $options->getOptValue(USR_OPT_TRANSLANG));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
74
htdocs/lib2/translateEdit.class.php
Normal file
74
htdocs/lib2/translateEdit.class.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
class translateEdit extends translate
|
||||
{
|
||||
private $editAll;
|
||||
private $backtrace_level;
|
||||
|
||||
public function __construct($editAll = true, $backtrace_level = 0)
|
||||
{
|
||||
$this->editAll = $editAll;
|
||||
$this->backtrace_level = $backtrace_level;
|
||||
}
|
||||
|
||||
function t($message, $style, $resource_name, $line, $plural='', $count=1, $lang=null)
|
||||
{
|
||||
global $opt;
|
||||
|
||||
if ($message == '')
|
||||
return '';
|
||||
|
||||
if ($message == 'INTERNAL_LANG')
|
||||
return parent::t($message, $style, $resource_name, $line, $plural, $count);
|
||||
|
||||
if ($plural != '' && $count!=1)
|
||||
$message = $plural;
|
||||
|
||||
$search = $this->prepare_text($message);
|
||||
$language = $opt['template']['locale'];
|
||||
|
||||
if (!isset($language))
|
||||
{
|
||||
global $locale;
|
||||
|
||||
$language = $locale;
|
||||
}
|
||||
|
||||
$rs = sql("SELECT `sys_trans`.`id` , `sys_trans_text`.`text` FROM `sys_trans` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id` = `sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang` = '&1' WHERE `sys_trans`.`text` = '&2'", $language, $search);
|
||||
$r = sql_fetch_assoc($rs);
|
||||
|
||||
$trans = $r['text'];
|
||||
$trans = $this->v($trans);
|
||||
|
||||
if ($trans && !$this->editAll)
|
||||
{
|
||||
return $trans;
|
||||
}
|
||||
|
||||
if (empty($r['id']))
|
||||
{
|
||||
global $translationHandler;
|
||||
|
||||
if (empty($resource_name))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
$item = $backtrace[$this->backtrace_level];
|
||||
$resource_name = $item['file'];
|
||||
$line = $item['line'];
|
||||
}
|
||||
|
||||
$translationHandler->addText($search, $resource_name, $line);
|
||||
|
||||
return $this->t($message, $style, $resource_name, $line, $plural, $count);
|
||||
}
|
||||
|
||||
$text = $trans ? $trans : gettext($search);
|
||||
|
||||
return $text . ' <a href= translate.php?action=edit&id=' . $r['id'] . '>Edit</a>';
|
||||
}
|
||||
}
|
@ -5,8 +5,6 @@
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
$translationHandler = new TranslationHandler();
|
||||
|
||||
class TranslationHandler
|
||||
{
|
||||
/* create all files in cache2/translate
|
||||
@ -32,12 +30,12 @@ class TranslationHandler
|
||||
if (!isset($opt['locale'][$language_upper]))
|
||||
return;
|
||||
|
||||
if (!is_dir($opt['rootpath'] . 'cache2/translate/' . $language_lower))
|
||||
mkdir($opt['rootpath'] . 'cache2/translate/' . $language_lower);
|
||||
if (!is_dir($opt['rootpath'] . 'cache2/translate/' . $language_lower . '/LC_MESSAGES'))
|
||||
mkdir($opt['rootpath'] . 'cache2/translate/' . $language_lower . '/LC_MESSAGES');
|
||||
if (!is_dir($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower))
|
||||
mkdir($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower);
|
||||
if (!is_dir($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower . '/LC_MESSAGES'))
|
||||
mkdir($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower . '/LC_MESSAGES');
|
||||
|
||||
$f = fopen($opt['rootpath'] . 'cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.po', 'w');
|
||||
$f = fopen($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.po', 'w');
|
||||
|
||||
fwrite($f, 'msgid ""' . "\n");
|
||||
fwrite($f, 'msgstr ""' . "\n");
|
||||
@ -65,7 +63,7 @@ class TranslationHandler
|
||||
|
||||
fclose($f);
|
||||
|
||||
@exec('msgfmt -o ' . escapeshellcmd($opt['rootpath'] . 'cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.mo') . ' ' . escapeshellcmd($opt['rootpath'] . 'cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.po'));
|
||||
@exec('msgfmt -o ' . escapeshellcmd($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.mo') . ' ' . escapeshellcmd($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate/' . $language_lower . '/LC_MESSAGES/messages.po'));
|
||||
}
|
||||
|
||||
/* escape string for po-file
|
||||
@ -151,7 +149,7 @@ class TranslationHandler
|
||||
// generic load
|
||||
global $opt;
|
||||
|
||||
$filename = $opt['rootpath'] . '/config2/nodetext/' . $file;
|
||||
$filename = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/nodetext/' . $file;
|
||||
if (file_exists($filename))
|
||||
{
|
||||
$fhandle = fopen($filename, 'r');
|
||||
@ -205,4 +203,3 @@ class TranslationHandler
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -13,17 +13,16 @@
|
||||
* to the root.
|
||||
***************************************************************************/
|
||||
|
||||
// setup rootpath
|
||||
if (!isset($opt['rootpath'])) $opt['rootpath'] = './';
|
||||
require_once __DIR__ . '/../lib/core.php';
|
||||
|
||||
// chicken-egg problem ...
|
||||
require($opt['rootpath'] . 'lib2/const.inc.php');
|
||||
require($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/const.inc.php');
|
||||
|
||||
// do all output in HTML format
|
||||
$opt['gui'] = GUI_HTML;
|
||||
|
||||
// include the main library
|
||||
require($opt['rootpath'] . 'lib2/common.inc.php');
|
||||
require($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/common.inc.php');
|
||||
|
||||
// https protection?
|
||||
if ($opt['page']['allowhttps'] == false)
|
||||
@ -31,4 +30,3 @@
|
||||
if (isset($_SERVER['HTTPS']))
|
||||
$tpl->redirect($opt['page']['absolute_url']);
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user