implemented state system (first step)
This commit is contained in:
parent
3488d84d0b
commit
ce4a8b12fa
@ -99,9 +99,13 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
||||
--
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (701, 42, 2, 700, 'load', 'id', 'LANG');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (702, 42, 2, 700, 'load', 'group', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (703, 42, 3, 700, 'tag', 'tag', 'STRING');
|
||||
--
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (710, 42, 2, 700, 'singleload', 'id', 'ALL');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (711, 42, 2, 700, 'singleload', 'lang', 'ALL');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (712, 42, 2, 700, 'edittext', 'id', 'ALL');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (713, 42, 2, 700, 'loadByTag', 'lang', 'LANG');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (714, 42, 2, 700, 'edittext', 'lang', 'LANG');
|
||||
--
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (720, 42, 2, 700, 'delete', 'id', 'ALL');
|
||||
--
|
||||
|
||||
@ -38,6 +38,8 @@ INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`,
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (104, 42, 'newright', 'security', 100, 0, 1, '#tab_security', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_security&action=newright', 'init_saimod_sys_security_newright', '\\SYSTEM\\SAI\\saimod_sys_security');
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (105, 42, 'delright', 'security', 100, 0, 1, '#tab_security', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_security&action=deleterightconfirm&id=${id}', 'init_saimod_sys_security_delright', '\\SYSTEM\\SAI\\saimod_sys_security');
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (110, 42, 'text', 'text', -1, 0, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_text', 'init_saimod_sys_text', '\\SYSTEM\\SAI\\saimod_sys_text');
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (111, 42, 'tag', 'text', 110, 0, 1, '#tab_content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_text&action=tag&tag=${tag}', 'init_saimod_sys_text_tag', '\\SYSTEM\\SAI\\saimod_sys_text');
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (112, 42, 'edittext', 'text', 110, 0, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_text&action=edittext&id=${id}&lang=${lang}', 'init_saimod_sys_text_edit', '\\SYSTEM\\SAI\\saimod_sys_text');
|
||||
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (120, 42, 'todo', 'todo', -1, 0, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo', 'init_saimod_sys_todo', '\\SYSTEM\\SAI\\saimod_sys_todo');
|
||||
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (121, 42, 'todolist', 'todo', 120, 0, 0, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todolist', 'init_saimod_sys_todo_todo', '\\SYSTEM\\SAI\\saimod_sys_todo');
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
//saving content data
|
||||
/*
|
||||
*
|
||||
* @type ModuleText
|
||||
* Object to manage text-modul data
|
||||
*
|
||||
* copyright - WebCraft Media GbR
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function init_saimod_sys_text() {
|
||||
//create Modul Object
|
||||
var moduleText = new ModuleText();
|
||||
moduleText.init();
|
||||
|
||||
|
||||
//load all texts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//angularModule();
|
||||
/*
|
||||
@ -82,11 +80,14 @@ function init_saimod_sys_text() {
|
||||
}); */
|
||||
}
|
||||
|
||||
function init_saimod_sys_text_test(){
|
||||
console.log(moduleText);
|
||||
};
|
||||
|
||||
ModuleText = function(){};
|
||||
|
||||
ModuleText.prototype.init = function(){
|
||||
//this.getTextsByTag("bla", "deDE");
|
||||
this.getTexts("deDE");
|
||||
};
|
||||
ModuleText.prototype.getTexts = function(lang){
|
||||
$.ajax({
|
||||
@ -100,7 +101,20 @@ ModuleText.prototype.getTexts = function(lang){
|
||||
//$('#tab'+lang).addClass('active');
|
||||
}});
|
||||
};
|
||||
ModuleText.prototype.getText = function(id){};
|
||||
ModuleText.prototype.getText = function(id, lang){
|
||||
$.ajax({
|
||||
url: 'sai.php',
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_text',
|
||||
action: 'singleload',
|
||||
id: id,
|
||||
language: lang},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
console.log("success");
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
ModuleText.prototype.getTextsByTag = function(tag, lang){
|
||||
$.ajax({
|
||||
url: 'sai.php',
|
||||
@ -116,6 +130,16 @@ ModuleText.prototype.getTextsByTag = function(tag, lang){
|
||||
ModuleText.prototype.updateText = function(){};
|
||||
ModuleText.prototype.deleteText = function(){};
|
||||
ModuleText.prototype.saveText = function(){};
|
||||
ModuleText.prototype.apiMenu = function(){
|
||||
$('#texttabs li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
if($('saimod_text_tagtab_'+system.cur_state().split('.')[1]).length){
|
||||
$('#saimod_text_tagtab_'+system.cur_state().split('.')[1]).parent().addClass('active');
|
||||
} else {
|
||||
$('#menu_all').parent().addClass('active');}
|
||||
};
|
||||
|
||||
var moduleText = new ModuleText();
|
||||
|
||||
function saimod_sys_text_newtext(){
|
||||
cData.editmode = true;
|
||||
|
||||
11
sai/modules/saimod_sys_text/qq/SYS_SAIMOD_TEXT_GETTEXT.php
Normal file
11
sai/modules/saimod_sys_text/qq/SYS_SAIMOD_TEXT_GETTEXT.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_TEXT_GETTEXT extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'',
|
||||
//mys
|
||||
"SELECT * FROM system_text WHERE id = ?"
|
||||
);}}
|
||||
@ -10,7 +10,6 @@ class saimod_sys_text extends \SYSTEM\SAI\SaiModule {
|
||||
$vars = array();
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_LOCALE_TAGS::QQ();
|
||||
$vars['tabopts'] = '';
|
||||
|
||||
$first = true;
|
||||
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/tabopt.tpl'), array( 'active' => ($first ? 'active' : ''), 'tag' => 'All'));
|
||||
while($r = $res->next()){
|
||||
@ -33,24 +32,26 @@ class saimod_sys_text extends \SYSTEM\SAI\SaiModule {
|
||||
//.\SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/editmode.tpl'), $vars);
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_load($lang){
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_loadAll(){
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
//$query = 'SELECT id, "'.$lang.'" FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE category='.$group.' ORDER BY category ASC;';
|
||||
} else {
|
||||
$query = 'SELECT * FROM system_text WHERE language=\''.$lang.'\';';
|
||||
$query = 'SELECT * FROM system_text;';
|
||||
new \SYSTEM\LOG\WARNING($query);
|
||||
}
|
||||
$res = $con->query($query);
|
||||
$entries = '';
|
||||
$temparr = array();
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/table_start.tpl'), array());
|
||||
while($r = $res->next()){
|
||||
$temparr['language'] = $lang;
|
||||
$temparr['id'] = $r['id'];
|
||||
$temparr['text'] = $r['text'];
|
||||
$temparr['author'] = $r['author'];
|
||||
$temparr['language'] = $r['language'];
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/entry.tpl'), $temparr);
|
||||
}
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/table_end.tpl'), array());
|
||||
return $entries;
|
||||
}
|
||||
|
||||
@ -67,38 +68,38 @@ class saimod_sys_text extends \SYSTEM\SAI\SaiModule {
|
||||
while($r = $res->next()){
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/entry.tpl'), $r);
|
||||
}
|
||||
return $entries;
|
||||
//$query = 'SELECT '.$lang.' FROM `'.\SYSTEM\DBD\system_locale_string::NAME_MYS.'` WHERE id=\''.$id.'\' ORDER BY category ASC;';
|
||||
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_singleload($id, $lang){
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_tag($tag = null){
|
||||
if ($tag) {
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$result = "";
|
||||
$query = "
|
||||
SELECT system_text_tag.tag, system_text.* FROM system_text_tag
|
||||
LEFT JOIN system_text ON system_text_tag.id = system_text.id
|
||||
WHERE tag = '".$tag."'";
|
||||
|
||||
$res = $con->query($query);
|
||||
$entries = '';
|
||||
while($r = $res->next()){
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/entry.tpl'), $r);
|
||||
}
|
||||
return $entries;
|
||||
} else {
|
||||
return self::sai_mod__SYSTEM_SAI_saimod_sys_text_action_loadAll();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_edittext($id, $lang){
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$result = "";
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
$query = 'SELECT "'.$lang.'" FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE id=\''.$id.'\' ORDER BY category ASC;';
|
||||
} else {
|
||||
$query = 'SELECT '.$lang.' FROM `'.\SYSTEM\DBD\system_locale_string::NAME_MYS.'` WHERE id=\''.$id.'\' ORDER BY category ASC;';
|
||||
}
|
||||
$res = $con->query($query);
|
||||
$entries = '';
|
||||
$temparr = array();
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_TEXT_GETTEXT::QQ(array($id));
|
||||
while($r = $res->next()){
|
||||
$entries .= $r[$lang];}
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_edit($id, $lang, $category, $newtext){
|
||||
//$charset = 'utf-8';
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = null;
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
$res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_PG.' SET "'.$lang.'"=$1 WHERE category = $2 AND id=$3;', array($newtext, $category, $id));
|
||||
} else {
|
||||
$res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' SET '.$lang.'=? WHERE category = ? AND id=?;', array($newtext, $category, $id));
|
||||
$entries .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_text/tpl/edit.tpl'), $r);
|
||||
}
|
||||
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no rows affected")) : \SYSTEM\LOG\JsonResult::ok();
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_add($id, $category){
|
||||
|
||||
21
sai/modules/saimod_sys_text/tpl/edit.tpl
Normal file
21
sai/modules/saimod_sys_text/tpl/edit.tpl
Normal file
@ -0,0 +1,21 @@
|
||||
<h4>Texteditor</h4>
|
||||
<hr>
|
||||
<div class="tabbable">
|
||||
<div class="panel panel-default">
|
||||
<ul class="nav nav-tabs" id="langtabs_">
|
||||
${langs}
|
||||
</ul>
|
||||
<div class="panel-body">
|
||||
<input type="text" value="${title}" />
|
||||
<textarea id="contenttextarea" name="content" style="width:100%">${text}</textarea>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button type="button" id="del_text" class="btn-small btn-danger" style="float: left;">Delete</button>
|
||||
<button type="button" class="btn" data-dismiss="modal" id="edit_close">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="changetext">Save changes</button>
|
||||
<button type="button" class="btn btn-primary" id="newtext" style="display: none;">Save new text</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -1,6 +1,5 @@
|
||||
<tr class="tableentry" text_id="${id}">
|
||||
<tr class="tableentry" text_id="${id}" onClick="system.load('text(edittext);id.${id};lang.${language}');">
|
||||
<td>${id}</td>
|
||||
<td class="contenttext">${language}</td>
|
||||
<td class="contenttext">${text}</td>
|
||||
<td class="contenttext">${author}</td>
|
||||
</tr>
|
||||
@ -2,50 +2,14 @@
|
||||
<h4>Texts</h4>
|
||||
<hr>
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs" id="localetab">
|
||||
${tabopts}
|
||||
<ul class="nav nav-tabs" id="texttabs">
|
||||
<li><a href="#!text" id="menu_all">All</a></li>
|
||||
${tabopts}
|
||||
<input type="submit" value="Add" class="btn-small btn-success content_add" style="margin-left: 15px;">
|
||||
</ul>
|
||||
<div class="tab-content" id="tab_content">
|
||||
${tabs}
|
||||
<div class="tab-content" id="tab_content">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="editfield">
|
||||
<div class="modal fade" id="modal_main" style="width: 700px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modaltitle">${id}</h4>
|
||||
<div id="new_category_id" style="display: none;">
|
||||
<h5>Category ID</h5>
|
||||
<input id="new_category_id_input" type="text" placeholder="New category ID here..."/>
|
||||
</div>
|
||||
<div id="new_text_id" style="display: none;">
|
||||
<h5>Text ID</h5>
|
||||
<input id="new_text_id_input" type="text" placeholder="New text ID here..."/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="addtext" style="display: none;">
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs" id="langtabs_">
|
||||
${langs}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-body" id="modaltextarea" style="display: none;">
|
||||
<textarea id="contenttextarea" name="content" style="width:100%"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div id="modal_success" style="display: none;"><font color="green">Changes have been saved!</font></div>
|
||||
<div id="modal_fail" style="display: none;"><font color="red">Changes could not be saved!</font></div>
|
||||
<Button type="button" id="del_text" class="btn-small btn-danger" style="float: left;">Delete</button>
|
||||
<button type="button" class="btn" data-dismiss="modal" id="edit_close">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="changetext">Save changes</button>
|
||||
<button type="button" class="btn btn-primary" id="newtext" style="display: none;">Save new text</button>
|
||||
</div>
|
||||
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
1
sai/modules/saimod_sys_text/tpl/table_end.tpl
Normal file
1
sai/modules/saimod_sys_text/tpl/table_end.tpl
Normal file
@ -0,0 +1 @@
|
||||
</table>
|
||||
1
sai/modules/saimod_sys_text/tpl/table_start.tpl
Normal file
1
sai/modules/saimod_sys_text/tpl/table_start.tpl
Normal file
@ -0,0 +1 @@
|
||||
<table class="sai_table">
|
||||
@ -1 +1 @@
|
||||
<li class="saimod_text_tagtab groups" id="saimod_text_tagtab_${tag}"><a href="#">Tag ${tag}</a></li>
|
||||
<li><a href="#!text;tag.${tag}" id="saimod_text_tagtab_${tag}">Tag ${tag}</a></li>
|
||||
Loading…
x
Reference in New Issue
Block a user