sai text edit fixes

This commit is contained in:
Ulf Gebhardt 2014-06-01 21:18:26 +02:00
parent 6d892fc9db
commit 2e2d80e77d
5 changed files with 56 additions and 38 deletions

View File

@ -16,8 +16,9 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (30, 42, 2, 3, 'edit', 'id', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (31, 42, 2, 3, 'edit', 'lang', 'LANG');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (32, 42, 2, 3, 'edit', 'newtext', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (33, 42, 2, 3, 'delete', 'id', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (32, 42, 2, 3, 'edit', 'category', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (33, 42, 2, 3, 'edit', 'newtext', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (34, 42, 2, 3, 'editmode', 'entry', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (35, 42, 2, 3, 'add', 'id', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (36, 42, 2, 3, 'add', 'category', 'INT');
@ -28,6 +29,9 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (43, 42, 2, 3, 'rn', 'cat', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (44, 42, 2, 3, 'rn', 'id', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (45, 42, 2, 3, 'rn', 'newid', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (47, 42, 2, 3, 'delete', 'id', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (200, 42, 2, 3, 'tab', 'name', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (50, 42, 3, 3, 'filter', 'filter', 'STRING');

View File

@ -1,4 +1,4 @@
<tr class="tableentry">
<tr class="tableentry" text_id="${id}">
<td>${id}</td>
<td class="contenttext">${lang}</td>
</tr>

View File

@ -1,7 +1,8 @@
//saving content data
var cData = {group: '',
lang: '',
id: ''};
id: ''};
function init__SYSTEM_SAI_saimod_sys_locale() {
if(!cData.lang && !cData.group) {
cData.group = $('.groups').first().attr('id');
@ -27,12 +28,15 @@ function init__SYSTEM_SAI_saimod_sys_locale() {
saimod_sys_locale_loadcontent(cData.lang, cData.group);
});
$('#changetext').click(function(){
saimod_sys_locale_savecontent(cData.id, cData.lang, $('#contenttextarea').html());
saimod_sys_locale_savecontent(cData.id, cData.lang);
});
}
function saimod_sys_locale_savecontent(id, lang, newtext){
function saimod_sys_locale_savecontent(id, lang){
tinyMCE.triggerSave();
newtext = $('#contenttextarea').val();
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_locale',
@ -43,27 +47,44 @@ function saimod_sys_locale_savecontent(id, lang, newtext){
newtext: newtext},
type: 'GET',
success: function(data) {
if (data.status == false){
alert("Addition could not be applied.");
} else {
alert("Addition has been saved.");}
}
if (data.status == false){
$('#modal_success').hide();
$('#modal_fail').show();
} else {
$('#modal_fail').hide();
$('#modal_success').show();
saimod_sys_locale_loadcontent(cData.lang,cData.group);
$('#modal').modal('hide');
}
}
});
}7
}
function saimod_sys_locale_loadsinglecontent(id, lang){
$('#contenttextarea').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=singleload&id='+id+'&lang='+lang, function(){
$('#modaltitle').html(id);
cData.id = id;
tinymce.init({selector:'textarea'});
$('#modal').modal('show');
tinymce.init({selector:'textarea'});
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_locale',
action: 'singleload',
id: id,
lang: lang},
type: 'GET',
success: function(data) {
tinyMCE.activeEditor.setContent(data);
$('#modal_success').hide();
$('#modal_fail').hide();
$('#modaltitle').html(id);
cData.id = id;
$('#modal').modal('show');
}
});
}
function saimod_sys_locale_loadcontent(id, group){
$('#tab-content').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=load&id='+id+'&group='+group, function(){
$('.tableentry').click(function(){
saimod_sys_locale_loadsinglecontent($(this).children().first().html(), cData.lang);
saimod_sys_locale_loadsinglecontent($(this).attr('text_id'), cData.lang);
});
});
}
@ -88,13 +109,6 @@ function saimod_sys_locale_add(){
});
});
});
//
//window.location = SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=add&id='+$('#new').attr('value')+'&lang=deDE&newtext='+$('#areacontent').val();
//window.location = SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale';
//function(data){
// if (data.status == false){ alert("false"); } else { alert("true");}
//});
// });
}
function saimod_sys_locale_delete(buttonID){

View File

@ -45,28 +45,28 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
return $entries;
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_singleload($lang, $id){
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_singleload($id, $lang){
$con = new \SYSTEM\DB\Connection();
$result = "";
$query = 'SELECT `'.$id.'` FROM `'.\SYSTEM\DBD\system_locale_string::NAME_MYS.'` WHERE id=\''.$lang.'\' ORDER BY category ASC;';
$query = 'SELECT `'.$lang.'` FROM `'.\SYSTEM\DBD\system_locale_string::NAME_MYS.'` WHERE id=\''.$id.'\' ORDER BY category ASC;';
new \SYSTEM\LOG\WARNING($query);
$res = $con->query($query);
$entries = '';
$temparr = array();
while($r = $res->next()){
$entries .= $r[$id];
$entries .= $r[$lang];
}
return $entries;
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_edit($id, $lang, $newtext){
$charset = 'utf-8';
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_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 id=$2;', array($newtext, $id));
$res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_PG.' SET "'.$lang.'"=$1 WHERE category = $1 AND id=$2;', array($newtext, $category, $id));
} else {
$res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' SET '.$lang.'=? WHERE id=?;', array($newtext, $id));
$res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' SET '.$lang.'=? WHERE category = ? AND id=?;', array($newtext, $category, $id));
}
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no rows affected")) : \SYSTEM\LOG\JsonResult::ok();
}

View File

@ -16,13 +16,13 @@
<h4 class="modal-title" id="modaltitle">${id}</h4>
</div>
<div class="modal-body">
<textarea id="contenttextarea" name="content" style="width:100%">
</textarea>
<textarea id="contenttextarea" name="content" style="width:100%"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="changetext">Save changes</button>
<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" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="changetext">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->