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_edit').click(function () {saimod_sys_locale_edit($(this).attr('name'));});
$('.content_delete').click(function(){saimod_sys_locale_delete($(this).attr('name'));}); $('.content_delete').click(function(){saimod_sys_locale_delete($(this).attr('name'));});
$('.content_add').click(function(){saimod_sys_locale_add();}); $('.content_add').click(function(){saimod_sys_locale_add();});
$('#localetab a').click(function (e) {e.preventDefault(); $(this).tab('show');});
} }
function saimod_sys_locale_add(){ function saimod_sys_locale_add(){
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=addmode',function(){ $('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=addmode',function(){

View File

@ -10,29 +10,54 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){
$vars = array(); $vars = array();
$vars['langhead'] = ''; $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
foreach (self::getLanguages() as $lang){ if(\SYSTEM\system::isSystemDbInfoPG()){
$vars['langhead'] .= '<th>'.$lang.'</th>'; $res = $con->query('SELECT "category", COUNT(*) as "count" FROM system.locale_string GROUP BY "category" ORDER BY "category" ASC;');
$languages[] = $lang; } 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);
} }
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){ if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.locale_string ORDER BY "category" ASC;'); $res = $con->query('SELECT * FROM system.locale_string ORDER BY "category" ASC;');
} else { } else {
$res = $con->query('SELECT * FROM system_locale_string ORDER BY category ASC;'); $res = $con->query('SELECT * FROM system_locale_string ORDER BY category ASC;');
} }
$vars['content'] = '';
while($r = $res->next()){ $langhead = '';
$content = ''; foreach (self::getLanguages() as $lang){
foreach ($languages as $columns){ $langhead .= '<th>'.$lang.'</th>';
$content .= '<td>'.$r[$columns].'</td>'; $languages[] = $lang;
}
$r['content'] = $content;
$vars['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/list_entry.tpl'), $r);
} }
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/list.tpl'), $vars); 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){
$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/tabs.tpl'), $vars);
} }
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_edit($id, $lang, $newtext){ 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()); $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = null; $res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){ 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 { } else {
$res = $con->prepare('addText' ,'INSERT INTO system_locale_string (id, category) VALUES (?, ?);', array($id, $category)); $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()); $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = null; $res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){ 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 { } else {
$res = $con->prepare('deleteText' ,'DELETE FROM system_locale_string WHERE id=?;', array($id)); $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

@ -40,6 +40,7 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_registerform(){ 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);} 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>';} 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 { class saigui extends \SYSTEM\PAGE\Page {
public function html(){ 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])){ if(isset($pg[SAI_MOD_POSTFIELD])){
$classname = \str_replace('.', '\\', $pg[SAI_MOD_POSTFIELD]); $classname = \str_replace('.', '\\', $pg[SAI_MOD_POSTFIELD]);
$pg[SAI_MOD_POSTFIELD] = \str_replace('.', '_', $pg[SAI_MOD_POSTFIELD]); $pg[SAI_MOD_POSTFIELD] = \str_replace('.', '_', $pg[SAI_MOD_POSTFIELD]);