_escaped_fragment fix for _lang support, cleaned saimod api, new dialog for api, cache header, sai now fully links to sai.php not api.php

This commit is contained in:
Ulf Gebhardt 2015-04-11 22:02:28 +02:00
parent 41111f1f8b
commit 22b6d8cc2c
16 changed files with 81 additions and 86 deletions

View File

@ -5,7 +5,6 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1, 42, 1, 0, NULL, 'js', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (2, 42, 1, 0, NULL, 'css', NULL);
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (3, 42, 0, 0, NULL, 'page', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5, 42, 4, -1, NULL, '_escaped_fragment_', 'STRING');
-- system_api
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (10, 42, 0, -1, NULL, 'call', NULL);
@ -30,6 +29,7 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (56, 42, 2, 55, NULL, 'group', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 42, 4, -1, NULL, '_lang', 'LANG');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 42, 4, -1, NULL, '_result', 'RESULT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (92, 42, 4, -1, NULL, '_escaped_fragment_', 'STRING');
-- specific stuff for mods
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_login', 'action', NULL);

View File

@ -22,4 +22,5 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (51, 0, 2, 10, 'pages', 'state', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 0, 4, -1, NULL, '_lang', 'LANG');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 0, 4, -1, NULL, '_result', 'RESULT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 0, 4, -1, NULL, '_result', 'RESULT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (92, 42, 4, -1, NULL, '_escaped_fragment_', 'STRING');

View File

@ -3,6 +3,10 @@ INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`,
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (2, 'log', 42, 'start', 0, 0, '#log_entries', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_log&action=filter', '', '');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (10, 'api', 42, 'api', -1, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_api', 'init_saimod_sys_api', '\\SYSTEM\\SAI\\saimod_sys_api');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (11, 'all', 42, 'api', 10, 0, '#tab_api', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_api&action=list&group=${group}', 'init_saimod_sys_api_list', '\\SYSTEM\\SAI\\saimod_sys_api');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (12, 'delete', 42, 'api', 10, 1, '#tab_api', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_api&action=deletedialog&group=${group}&ID=${id}', 'init_saimod_sys_api_delete', '\\SYSTEM\\SAI\\saimod_sys_api');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (13, 'new', 42, 'api', 10, 1, '#tab_api', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_api&action=newdialog', 'init_saimod_sys_api_new', '\\SYSTEM\\SAI\\saimod_sys_api');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (20, 'cache', 42, 'cache', -1, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_cache', 'init_saimod_sys_cache', '\\SYSTEM\\SAI\\saimod_sys_cache');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (30, 'config', 42, 'config', -1, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_config', 'init_saimod_sys_config', '\\SYSTEM\\SAI\\saimod_sys_config');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (40, 'cron', 42, 'cron', -1, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_cron', 'init_saimod_sys_cron', '\\SYSTEM\\SAI\\saimod_sys_cron');

View File

@ -5,7 +5,9 @@ function init_saimod_sys_api() {
$(this).parent().addClass('active');
});
api_menu();
}
function init_saimod_sys_api_new(){
$('#addcall').click(function() {
$.ajax({ url: './sai.php',
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
@ -19,9 +21,7 @@ function init_saimod_sys_api() {
verify: $('#new_call_verify').val()},
type: 'GET',
success: function(data) {
console.log("new api call added");
saimod_sys_api_loadcontent();
}
system.load('api;group.'+$('#new_call_group').val());}
});
});
}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_API_GROUPS extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT "group", count(*) as "count" FROM system.api GROUP BY "group" ORDER BY "group" ASC;',
//mys
'SELECT `group`, count(*) as `count` FROM system_api GROUP BY `group` ORDER BY `group` ASC;'
);}}

View File

@ -3,45 +3,13 @@ namespace SYSTEM\SAI;
class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_api(){
$vars = array();
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT "group", count(*) as "count" FROM system.api GROUP BY "group" ORDER BY "group" ASC;');
} else {
$res = $con->query('SELECT `group`, count(*) as `count` FROM system_api GROUP BY `group` ORDER BY `group` ASC;');
}
$vars['tabopts'] = '';
$first = true;
$res = \SYSTEM\DBD\SYS_SAIMOD_API_GROUPS::QQ();
while($r = $res->next()){
$vars2 = array( 'active' => ($first ? '' : ''),
'tab_id' => $r['group']);
$first = false;
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tabopt.tpl'), $vars2);
}
/*if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.api ORDER BY "group", "ID" ASC;');
} else {
$res = $con->query('SELECT * FROM system_api ORDER BY `group`, `ID` ASC;');
}
while($r = $res->next()){
$tabs[$r['group']]['tab_id'] = $r['group'];
$tabs[$r['group']]['content'] = isset($tabs[$r['group']]['content']) ? $tabs[$r['group']]['content'] : '';
$r['tr_class'] = self::tablerow_class($r['type']);
$r['type'] = self::type_names($r['type']);
$tabs[$r['group']]['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/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_api/tpl/tab.tpl'), $tab);}*/
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tabs.tpl'), $vars);
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tabopt.tpl'), array( 'tab_id' => $r['group']));}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/saimod_sys_api.tpl'), $vars);
}
public static function sai_mod__system_sai_saimod_sys_api_action_list($group=null){
@ -55,13 +23,15 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
$r['type'] = self::type_names($r['type']);
$tab['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/list_entry.tpl'), $r);
}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tab.tpl'), $tab);
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/saimod_sys_api_list.tpl'), $tab);
}
public static function sai_mod__system_sai_saimod_sys_api_action_deletedialog($ID,$group){
$res = \SYSTEM\DBD\SYS_SAIMOD_API_SINGLE_SELECT::Q1(array($ID,$group));
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/delete_dialog.tpl'), $res);
}
public static function sai_mod__system_sai_saimod_sys_api_action_newdialog(){
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/new_dialog.tpl'));}
public static function sai_mod__system_sai_saimod_sys_api_action_addcall($ID,$group,$type,$parentID,$parentValue,$name,$verify){
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API)){

View File

@ -0,0 +1,26 @@
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>ID</th>
<td><input type="text" id="new_call_id" placeholder="new id" style="width: 140px;"></td>
</tr>
<th>Group</th>
<td><input type="text" id="new_call_group" placeholder="new group" style="width: 140px;"></td>
</tr>
<th>Type</th>
<td><input type="text" id="new_call_type" placeholder="new type" style="width: 140px;"></td>
</tr>
<th>ParentID</th>
<td><input type="text" id="new_call_parentid" placeholder="parent id" style="width: 140px;"></td>
</tr>
<th>ParentValue</th>
<td><input type="text" id="new_call_parentvalue" placeholder="parent value" style="width: 140px;"></td>
</tr>
<th>Name</th>
<td><input type="text" id="new_call_name" placeholder="name" style="width: 140px;"></td>
</tr>
<th>Verify</th>
<td><input type="text" id="new_call_verify" placeholder="verify" style="width: 140px;"></td>
</tr>
</table>
<button type="button" class="btn-small" onClick="system.load('api');">Back</button>
<button type="button" class="btn-small btn-success" id="addcall" style="float: right;">Add</button>

View File

@ -0,0 +1,12 @@
<h4>System API</h4>
<hr>
<div class="tabbable">
<ul class="nav nav-tabs" id="tabs_api">
<li><a href="#!api" id="menu_all">All</a></li>
${tabopts}
<button onClick="system.load('api(new)',true);" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">New</button>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_api"></div>
</div>
</div>

View File

@ -1 +1 @@
<li class="${active}"><a href="#!api;group.${tab_id}" id="menu_group_${tab_id}">Group ${tab_id}</a></li>
<li><a href="#!api;group.${tab_id}" id="menu_group_${tab_id}">Group ${tab_id}</a></li>

View File

@ -1,32 +0,0 @@
<h4>System API</h4>
<hr>
<div class="tabbable">
<ul class="nav nav-tabs" id="tabs_api">
<li><a href="#!api" id="menu_all">All</a></li>
${tabopts}
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_api"></div>
</div>
</div>
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>ID</th>
<th>Group</th>
<th>Type</th>
<th>ParentID</th>
<th>ParentValue</th>
<th>Name</th>
<th>Verify</th>
</tr>
<tr>
<td><input type="text" id="new_call_id" placeholder="new id" style="width: 140px;"></td>
<td><input type="text" id="new_call_group" placeholder="new group" style="width: 140px;"></td>
<td><input type="text" id="new_call_type" placeholder="new type" style="width: 140px;"></td>
<td><input type="text" id="new_call_parentid" placeholder="parent id" style="width: 140px;"></td>
<td><input type="text" id="new_call_parentvalue" placeholder="parent value" style="width: 140px;"></td>
<td><input type="text" id="new_call_name" placeholder="name" style="width: 140px;"></td>
<td><input type="text" id="new_call_verify" placeholder="verify" style="width: 140px;"></td>
</tr>
</table>
<button type="button" class="btn-small btn-success" id="addcall">Add</button>

View File

@ -12,7 +12,7 @@ class saimod_sys_cache extends \SYSTEM\SAI\SaiModule {
$r = $res->next();
$result = '<h4>Cache</h4><hr>'.
$result = '<h4>System Cache</h4><hr>'.
'Entries: '.$r['count'].' showing 100'.
'<table class="sai_table table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'CacheID'.'</th>'.'<th>'.'Ident'.'</th>'.'<th>'.'Data'.'</th>'.'</tr>';

View File

@ -3,14 +3,17 @@ namespace SYSTEM\SAI;
class saimod_sys_langswitcher extends \SYSTEM\SAI\SaiModule {
public static function html_li_menu(){
return self::lang_menu('./sai.php');}
public static function right_public(){return true;}
public static function right_right(){return true;}
public static function lang_menu($endpoint = './api.php'){
$result = '';
$langs = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS);
foreach($langs as $lang){
$result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_langswitcher/tpl/language.tpl'),array('lang' => $lang));}
$result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_langswitcher/tpl/language.tpl'),array('lang' => $lang,'endpoint' => $endpoint));}
return $result;
}
public static function right_public(){return true;}
public static function right_right(){return true;}
//public static function css(){}
//public static function js(){}

View File

@ -1 +1 @@
<a href="javascript:system.language('${lang}');"><img src="./api.php?call=files&amp;cat=saistart_sys_sai&amp;id=flag_${lang}.png" alt="${lang}" width="16" height="11"></a>&nbsp;
<a href="javascript:system.language('${lang}');"><img src="${endpoint}?call=files&amp;cat=saistart_sys_sai&amp;id=flag_${lang}.png" alt="${lang}" width="16" height="11"></a>&nbsp;

View File

@ -32,7 +32,7 @@ class default_page extends \SYSTEM\PAGE\Page {
private static function css(){
$result = '<link rel="stylesheet" href="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/css/libs/bootstrap.min.css').'" type="text/css" />'.
'<link rel="stylesheet" href="./api.php?call=files&amp;cat=sys&amp;id=system.css" type="text/css" />'.
'<link rel="stylesheet" href="./sai.php?call=files&amp;cat=sys&amp;id=system.css" type="text/css" />'.
'<link rel="stylesheet" href="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/css/sai.css').'" type="text/css" />';
return $result;
}
@ -40,7 +40,7 @@ class default_page extends \SYSTEM\PAGE\Page {
private static function js(){
$result = '<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/js/libs/jquery.min.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/js/libs/bootstrap.min.js').'" type="text/javascript"></script>'.
'<script type="text/javascript" language="JavaScript" src="./api.php?call=files&amp;cat=sys&amp;id=system.js"></script>'.
'<script type="text/javascript" language="JavaScript" src="./sai.php?call=files&amp;cat=sys&amp;id=system.js"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/js/sai.js').'" type="text/javascript"></script>'.
'<script src="https://www.google.com/jsapi" type="text/javascript"></script>'.
'<script src="https://maps.google.com/maps/api/js?v=3&amp;sensor=false" type="text/javascript"></script>'.

View File

@ -4,7 +4,7 @@
<title>${title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="fragment" content="!start">
<link rel="icon" type="image/png" href="./api.php?call=files&amp;cat=saistart_sys_sai&amp;id=logo.png"/>
<link rel="icon" type="image/png" href="./sai.php?call=files&amp;cat=saistart_sys_sai&amp;id=logo.png"/>
${css}
${js}
</head>
@ -13,7 +13,7 @@
<div class="navbar-inner">
<ul class="nav">
<a id="sai_logo" class="brand-logo" href="#!start">
<img src="./api.php?call=files&amp;cat=saistart_sys_sai&amp;id=logo.png" height="24" width="24"/>
<img src="./sai.php?call=files&amp;cat=saistart_sys_sai&amp;id=logo.png" height="24" width="24"/>
</a>
<a id="sai_brand" class="brand" >SAI</a>
${menu_start}