Tabable text table

This commit is contained in:
Ulf Gebhardt 2013-09-30 17:02:09 +02:00
parent d8e16ee98d
commit f68ce6c9e6
8 changed files with 72 additions and 31 deletions

View File

@ -1,8 +0,0 @@
<h3>Locale String <input type="submit" value="Add" class="btn content_add"></h3>
<br>
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>ID</th><th>Category</th>${langhead}
</tr>
${content}
</table>

View File

@ -2,6 +2,7 @@ function init__SYSTEM_SAI_saimod_sys_locale() {
$('.content_edit').click(function () {saimod_sys_locale_edit($(this).attr('name'));});
$('.content_delete').click(function(){saimod_sys_locale_delete($(this).attr('name'));});
$('.content_add').click(function(){saimod_sys_locale_add();});
$('#localetab a').click(function (e) {e.preventDefault(); $(this).tab('show');});
}
function saimod_sys_locale_add(){
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=addmode',function(){

View File

@ -7,32 +7,57 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
return \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS);
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){
$vars = array();
$vars['langhead'] = '';
foreach (self::getLanguages() as $lang){
$vars['langhead'] .= '<th>'.$lang.'</th>';
$languages[] = $lang;
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){
$vars = array();
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT "category", COUNT(*) as "count" FROM system.locale_string GROUP BY "category" ORDER BY "category" ASC;');
} else {
$res = $con->query('SELECT "category", COUNT(*) as "count" FROM system.locale_string GROUP BY "category" ORDER BY "category" ASC;');
}
$vars['tabopts'] = '';
$first = true;
while($r = $res->next()){
$vars2 = array( 'active' => ($first ? 'active' : ''),
'tab_id' => $r['category']);
$first = false;
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tabopt.tpl'), $vars2);
}
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.locale_string ORDER BY "category" ASC;');
} else {
$res = $con->query('SELECT * FROM system_locale_string ORDER BY category ASC;');
}
$vars['content'] = '';
while($r = $res->next()){
$content = '';
$langhead = '';
foreach (self::getLanguages() as $lang){
$langhead .= '<th>'.$lang.'</th>';
$languages[] = $lang;
}
while($r = $res->next()){
$tabs[$r['category']]['tab_id'] = $r['category'];
$tabs[$r['category']]['content'] = isset($tabs[$r['category']]['content']) ? $tabs[$r['category']]['content'] : '';
$tabs[$r['category']]['langhead'] = $langhead;
$r['content'] = '';
foreach ($languages as $columns){
$content .= '<td>'.$r[$columns].'</td>';
}
$r['content'] = $content;
$vars['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/list_entry.tpl'), $r);
}
$r['content'] .= '<td>'.$r[$columns].'</td>';
}
$tabs[$r['category']]['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/list_entry.tpl'), $r);
}
$vars['tabs'] = '';
$first = true;
foreach($tabs as $tab){
$tab['active'] = ($first ? 'active' : '');
$first = false;
$vars['tabs'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tab.tpl'), $tab);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/list.tpl'), $vars);
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tabs.tpl'), $vars);
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_edit($id, $lang, $newtext){
@ -51,7 +76,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){
throw new \SYSTEM\LOG\ERROR("action_edit failed");
$res = $con->prepare('addText' ,'INSERT INTO system.locale_string (id, category) VALUES ($1, $2);', array($id, $category));
} else {
$res = $con->prepare('addText' ,'INSERT INTO system_locale_string (id, category) VALUES (?, ?);', array($id, $category));
}
@ -66,7 +91,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){
throw new \SYSTEM\LOG\ERROR("action_delete failed");
$res = $con->prepare('deleteText' ,'DELETE FROM system.locale_string WHERE id=$1;', array($id));
} else {
$res = $con->prepare('deleteText' ,'DELETE FROM system_locale_string WHERE id=?;', array($id));
}

View File

@ -0,0 +1,8 @@
<div class="tab-pane ${active}" id="tab_${tab_id}">
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>ID</th><th>Category</th>${langhead}
</tr>
${content}
</table>
</div>

View File

@ -0,0 +1 @@
<li class="${active}"><a href="#tab_${tab_id}">Group ${tab_id}</a></li>

View File

@ -0,0 +1,10 @@
<h3>Locale String <input type="submit" value="Add" class="btn content_add"></h3>
<br>
<div class="tabbable">
<ul class="nav nav-tabs" id="localetab">
${tabopts}
</ul>
<div class="tab-content">
${tabs}
</div>
</div>

View File

@ -13,7 +13,7 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
$vars['login_password_too_short'] = 'Password to short.';
$vars['isadmin'] = \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) ? "yes" : "no";
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI_ERROR));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI_ERROR));
if(\SYSTEM\SECURITY\Security::isLoggedIn()){
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/logout.tpl'), $vars);
@ -39,7 +39,8 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_registerform(){
$vars = \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI);
$vars = \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI);
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\SYSTEM\DBD\locale_string::VALUE_CATEGORY_SYSTEM_SAI_ERROR));
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/register.tpl'), $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}

View File

@ -6,7 +6,10 @@ define('SAI_MOD_POSTFIELD','sai_mod');
class saigui extends \SYSTEM\PAGE\Page {
public function html(){
$pg = array_merge($_POST,$_GET);
//Direct JSON Input
$pg = json_decode(file_get_contents("php://input"), true);
if(!$pg){
$pg = array_merge($_POST,$_GET);}
if(isset($pg[SAI_MOD_POSTFIELD])){
$classname = \str_replace('.', '\\', $pg[SAI_MOD_POSTFIELD]);
$pg[SAI_MOD_POSTFIELD] = \str_replace('.', '_', $pg[SAI_MOD_POSTFIELD]);