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 (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 (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 (32, 42, 2, 3, 'edit', 'category', '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 (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 (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 (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'); 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 (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 (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 (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 (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'); 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>${id}</td>
<td class="contenttext">${lang}</td> <td class="contenttext">${lang}</td>
</tr> </tr>

View File

@ -2,6 +2,7 @@
var cData = {group: '', var cData = {group: '',
lang: '', lang: '',
id: ''}; id: ''};
function init__SYSTEM_SAI_saimod_sys_locale() { function init__SYSTEM_SAI_saimod_sys_locale() {
if(!cData.lang && !cData.group) { if(!cData.lang && !cData.group) {
cData.group = $('.groups').first().attr('id'); 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); saimod_sys_locale_loadcontent(cData.lang, cData.group);
}); });
$('#changetext').click(function(){ $('#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({ $.ajax({
url: SAI_ENDPOINT, url: SAI_ENDPOINT,
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_locale', data: { sai_mod: '.SYSTEM.SAI.saimod_sys_locale',
@ -44,26 +48,43 @@ function saimod_sys_locale_savecontent(id, lang, newtext){
type: 'GET', type: 'GET',
success: function(data) { success: function(data) {
if (data.status == false){ if (data.status == false){
alert("Addition could not be applied."); $('#modal_success').hide();
$('#modal_fail').show();
} else { } else {
alert("Addition has been saved.");} $('#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){ 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(){ 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); $('#modaltitle').html(id);
cData.id = id; cData.id = id;
tinymce.init({selector:'textarea'});
$('#modal').modal('show'); $('#modal').modal('show');
}
}); });
} }
function saimod_sys_locale_loadcontent(id, group){ 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(){ $('#tab-content').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_locale&action=load&id='+id+'&group='+group, function(){
$('.tableentry').click(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){ function saimod_sys_locale_delete(buttonID){

View File

@ -45,28 +45,28 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
return $entries; 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(); $con = new \SYSTEM\DB\Connection();
$result = ""; $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); new \SYSTEM\LOG\WARNING($query);
$res = $con->query($query); $res = $con->query($query);
$entries = ''; $entries = '';
$temparr = array(); $temparr = array();
while($r = $res->next()){ while($r = $res->next()){
$entries .= $r[$id]; $entries .= $r[$lang];
} }
return $entries; return $entries;
} }
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, $category, $newtext){
$charset = 'utf-8'; //$charset = 'utf-8';
$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()){
$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 { } 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(); return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no rows affected")) : \SYSTEM\LOG\JsonResult::ok();
} }

View File

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