diff --git a/dbd/sql/mysql/data/sai_api.sql b/dbd/sql/mysql/data/sai_api.sql index 630dc7f..4100d79 100644 --- a/dbd/sql/mysql/data/sai_api.sql +++ b/dbd/sql/mysql/data/sai_api.sql @@ -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'); -- diff --git a/dbd/sql/mysql/data/system_page.sql b/dbd/sql/mysql/data/system_page.sql index 54341f6..10af820 100644 --- a/dbd/sql/mysql/data/system_page.sql +++ b/dbd/sql/mysql/data/system_page.sql @@ -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'); diff --git a/sai/modules/saimod_sys_text/js/saimod_sys_text.js b/sai/modules/saimod_sys_text/js/saimod_sys_text.js index 8f3bf3e..ce18e69 100644 --- a/sai/modules/saimod_sys_text/js/saimod_sys_text.js +++ b/sai/modules/saimod_sys_text/js/saimod_sys_text.js @@ -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; diff --git a/sai/modules/saimod_sys_text/qq/SYS_SAIMOD_TEXT_GETTEXT.php b/sai/modules/saimod_sys_text/qq/SYS_SAIMOD_TEXT_GETTEXT.php new file mode 100644 index 0000000..eb5d0cc --- /dev/null +++ b/sai/modules/saimod_sys_text/qq/SYS_SAIMOD_TEXT_GETTEXT.php @@ -0,0 +1,11 @@ + ($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){ diff --git a/sai/modules/saimod_sys_text/tpl/edit.tpl b/sai/modules/saimod_sys_text/tpl/edit.tpl new file mode 100644 index 0000000..1227a32 --- /dev/null +++ b/sai/modules/saimod_sys_text/tpl/edit.tpl @@ -0,0 +1,21 @@ +