saimod text adv result feature proto, fixed saimod text notag feature
This commit is contained in:
parent
59af1d3bb3
commit
45543a45b8
11
dbd/qq/SYS_TEXT_GET_ID_ADV.php
Normal file
11
dbd/qq/SYS_TEXT_GET_ID_ADV.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace SYSTEM\DBD;
|
||||||
|
class SYS_TEXT_GET_ID_ADV extends \SYSTEM\DB\QP {
|
||||||
|
public static function get_class(){return \get_class();}
|
||||||
|
public static function mysql(){return
|
||||||
|
'SELECT system_text.*, a.username as author_name, ae.username as author_edit_name FROM system_text'.
|
||||||
|
' LEFT JOIN system_user AS a ON system_text.author = a.id'.
|
||||||
|
' LEFT JOIN system_user AS ae ON system_text.author_edit = ae.id'.
|
||||||
|
' WHERE system_text.id = ? and lang = ?;';
|
||||||
|
}
|
||||||
|
}
|
||||||
12
dbd/qq/SYS_TEXT_GET_TAG_ADV.php
Normal file
12
dbd/qq/SYS_TEXT_GET_TAG_ADV.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace SYSTEM\DBD;
|
||||||
|
class SYS_TEXT_GET_TAG_ADV extends \SYSTEM\DB\QP {
|
||||||
|
public static function get_class(){return \get_class();}
|
||||||
|
public static function mysql(){return
|
||||||
|
'SELECT system_text.*, system_text_tag.*, a.username as author_name, ae.username as author_edit_name FROM system_text'.
|
||||||
|
' LEFT JOIN system_text_tag ON system_text.id = system_text_tag.id'.
|
||||||
|
' LEFT JOIN system_user AS a ON system_text.author = a.id'.
|
||||||
|
' LEFT JOIN system_user AS ae ON system_text.author_edit = ae.id'.
|
||||||
|
' WHERE tag = ? and lang = ?;';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -28,6 +28,29 @@ class text {
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
public static function tag_adv($tag, $lang = NULL,$fallback = true) {
|
||||||
|
if($lang == NULL){
|
||||||
|
$lang = \SYSTEM\locale::get();}
|
||||||
|
|
||||||
|
if(!\SYSTEM\locale::isLang($lang)){
|
||||||
|
throw new \Exception("The requested language is not supported: ".$lang);}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
$res = \SYSTEM\DBD\SYS_TEXT_GET_TAG_ADV::QQ(array($tag,$lang));
|
||||||
|
while($row = $res->next()){
|
||||||
|
$result[$row['id']] = $row;}
|
||||||
|
|
||||||
|
if($fallback){
|
||||||
|
$result2 = array();
|
||||||
|
$res = \SYSTEM\DBD\SYS_TEXT_GET_TAG_ADV::QQ(array($tag,\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)));
|
||||||
|
while($row = $res->next()){
|
||||||
|
$result2[$row['id']] = $row;}
|
||||||
|
if(count($result) < count($result2)){
|
||||||
|
new \SYSTEM\LOG\WARNING('Texts with tag: '.$tag.' - '.(count($result2)-count($result)).' ids not found for lang: '.$lang.' - fallback to default lang.');}
|
||||||
|
$result = array_merge($result2,$result);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
//return textstring with certain id and lang
|
//return textstring with certain id and lang
|
||||||
public static function get($id, $lang = NULL,$fallback = true) {
|
public static function get($id, $lang = NULL,$fallback = true) {
|
||||||
if($lang == NULL){
|
if($lang == NULL){
|
||||||
@ -42,6 +65,19 @@ class text {
|
|||||||
return self::get($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));}
|
return self::get($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));}
|
||||||
return $res ? $res['text'] : '';
|
return $res ? $res['text'] : '';
|
||||||
}
|
}
|
||||||
|
public static function get_adv($id, $lang = NULL,$fallback = true) {
|
||||||
|
if($lang == NULL){
|
||||||
|
$lang = \SYSTEM\locale::get();}
|
||||||
|
|
||||||
|
if(!\SYSTEM\locale::isLang($lang)){
|
||||||
|
throw new \Exception("The requested language is not supported: ".$lang);}
|
||||||
|
|
||||||
|
$res = \SYSTEM\DBD\SYS_TEXT_GET_ID_ADV::Q1(array($id,$lang));
|
||||||
|
if($fallback && !$res && $lang != \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)){
|
||||||
|
new \SYSTEM\LOG\WARNING('Text with id: '.$id.' not found for lang: '.$lang.' - fallback to default lang.');
|
||||||
|
return self::get_adv($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
public static function save($id, $new_id, $lang, $tags, $text){
|
public static function save($id, $new_id, $lang, $tags, $text){
|
||||||
if($new_id == self::NEW_ENTRY){
|
if($new_id == self::NEW_ENTRY){
|
||||||
|
|||||||
@ -3,9 +3,8 @@ namespace SYSTEM\DBD;
|
|||||||
class SYS_SAIMOD_TEXT_TEXT_NOTAG extends \SYSTEM\DB\QP {
|
class SYS_SAIMOD_TEXT_TEXT_NOTAG extends \SYSTEM\DB\QP {
|
||||||
public static function get_class(){return \get_class();}
|
public static function get_class(){return \get_class();}
|
||||||
public static function mysql(){return
|
public static function mysql(){return
|
||||||
'SELECT system_text_tag.tag, system_text.*, a.username as author_name, ae.username as author_edit_name'.
|
'SELECT system_text.*, a.username as author_name, ae.username as author_edit_name'.
|
||||||
' FROM system_text_tag'.
|
' FROM system_text'.
|
||||||
' LEFT JOIN system_text ON system_text_tag.id = system_text.id'.
|
|
||||||
' LEFT JOIN system_user as a ON system_text.author = a.id'.
|
' LEFT JOIN system_user as a ON system_text.author = a.id'.
|
||||||
' LEFT JOIN system_user as ae ON system_text.author_edit = ae.id'.
|
' LEFT JOIN system_user as ae ON system_text.author_edit = ae.id'.
|
||||||
' WHERE (a.username LIKE ? OR ae.username LIKE ? OR text LIKE ?)'.
|
' WHERE (a.username LIKE ? OR ae.username LIKE ? OR text LIKE ?)'.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user