Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramComputer committed Dec 31, 2023
2 parents cf3f99b + 9f56838 commit 8100db5
Show file tree
Hide file tree
Showing 41 changed files with 1,857 additions and 1,190 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
docker/*
# Documentation
docs/*
!docs/**/index.html
!docs/**/info.html
# NPM, for debugging only
node_modules/*
# Phive products
Expand All @@ -13,11 +15,12 @@ tools/*
# phpDocumentor cache
.phpdoc/*

*.md
.dockerignore
.git
.gitignore

# MarkDown and PHP documentation generation
Doxyfile

# Media files for LWT
media/*
Empty file modified INSTALL.sh
100644 → 100755
Empty file.
14 changes: 12 additions & 2 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
require_once __DIR__ . '/inc/ajax_edit_impr_text.php';


/**
* @var string Version of this current LWT API.
*/
define('LWT_API_VERSION', "0.1.1");

/**
* @var string Date of the last released change of the LWT API.
*/
define('LWT_API_RELEASE_DATE', "2023-12-29");

/**
* Send JSON response and exit.
*
Expand Down Expand Up @@ -126,8 +136,8 @@ function endpoint_exits($method, $requestUri)
function rest_api_version($get_req): array
{
return array(
"version" => "0.1.1",
"release_date" => "2023-12-29"
"version" => LWT_API_VERSION,
"release_date" => LWT_API_RELEASE_DATE
);
}

Expand Down
18 changes: 9 additions & 9 deletions bulk_translate_words.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@ function bulk_do_content($tid, $sl, $tl, $pos): void
}
</style>
<script type="text/javascript">
WBLINK1 = '<?php echo $wb1; ?>';
WBLINK2 = '<?php echo $wb2; ?>';
WBLINK3 = '<?php echo $wb3; ?>';
LWT_DATA.language.dict_link1 = '<?php echo $wb1; ?>';
LWT_DATA.language.dict_link2 = '<?php echo $wb2; ?>';
LWT_DATA.language.translator_link = '<?php echo $wb3; ?>';
$('h3,h4,title').addClass('notranslate');

function clickDictionary() {
if ($(this).hasClass( "dict1" ))
WBLINK = WBLINK1;
WBLINK = LWT_DATA.language.dict_link1;
if ($(this).hasClass( "dict2" ))
WBLINK = WBLINK2;
WBLINK = LWT_DATA.language.dict_link2;
if ($(this).hasClass( "dict3" ))
WBLINK = WBLINK3;
WBLINK = LWT_DATA.language.translator_link;
let dict_link = WBLINK;
let popup;
if (dict_link.startsWith('*')) {
Expand Down Expand Up @@ -240,9 +240,9 @@ function() { $(this).prev().val('').focus(); }
$(this).parent().css('position', 'relative');
$(this).after(
'<div class="dict">' +
(WBLINK1 ? '<span class="dict1">D1</span>' : '') +
(WBLINK2 ? '<span class="dict2">D2</span>' : '') +
(WBLINK3 ? '<span class="dict3">Tr</span>' : '') +
(LWT_DATA.language.dict_link1 ? '<span class="dict1">D1</span>' : '') +
(LWT_DATA.language.dict_link2 ? '<span class="dict2">D2</span>' : '') +
(LWT_DATA.language.translator_link ? '<span class="dict3">Tr</span>' : '') +
'</div>'
);
});
Expand Down
2 changes: 1 addition & 1 deletion check_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function change_textboxes_language() {
$('#TxText').attr('lang', language_data[lid]);
}

$(document).ready(ask_before_exiting);
$(document).ready(lwt_form_check.askBeforeExit);
$(document).ready(change_textboxes_language);
</script>
<form class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Expand Down
195 changes: 195 additions & 0 deletions db/schema/baseline.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
-- Basefile to install LWT

CREATE TABLE IF NOT EXISTS archivedtexts (
AtID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
AtLgID tinyint(3) unsigned NOT NULL,
AtTitle varchar(200) NOT NULL,
AtText text NOT NULL,
AtAnnotatedText longtext NOT NULL,
AtAudioURI varchar(200) DEFAULT NULL,
AtSourceURI varchar(1000) DEFAULT NULL,
PRIMARY KEY (AtID),
KEY AtLgID (AtLgID),
KEY AtLgIDSourceURI (AtSourceURI(20),AtLgID)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS languages (
LgID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
LgName varchar(40) NOT NULL,
LgDict1URI varchar(200) NOT NULL,
LgDict2URI varchar(200) DEFAULT NULL,
LgGoogleTranslateURI varchar(200) DEFAULT NULL,
LgExportTemplate varchar(1000) DEFAULT NULL,
LgTextSize smallint(5) unsigned NOT NULL DEFAULT '100',
LgCharacterSubstitutions varchar(500) NOT NULL,
LgRegexpSplitSentences varchar(500) NOT NULL,
LgExceptionsSplitSentences varchar(500) NOT NULL,
LgRegexpWordCharacters varchar(500) NOT NULL,
LgRemoveSpaces tinyint(1) unsigned NOT NULL DEFAULT '0',
LgSplitEachChar tinyint(1) unsigned NOT NULL DEFAULT '0',
LgRightToLeft tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (LgID),
UNIQUE KEY LgName (LgName)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS sentences (
SeID mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
SeLgID tinyint(3) unsigned NOT NULL,
SeTxID smallint(5) unsigned NOT NULL,
SeOrder smallint(5) unsigned NOT NULL,
SeText text, SeFirstPos smallint(5) unsigned NOT NULL,
PRIMARY KEY (SeID),
KEY SeLgID (SeLgID),
KEY SeTxID (SeTxID),
KEY SeOrder (SeOrder)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS settings (
StKey varchar(40) NOT NULL,
StValue varchar(40) DEFAULT NULL,
PRIMARY KEY (StKey)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS textitems2 (
Ti2WoID mediumint(8) unsigned NOT NULL,
Ti2LgID tinyint(3) unsigned NOT NULL,
Ti2TxID smallint(5) unsigned NOT NULL,
Ti2SeID mediumint(8) unsigned NOT NULL,
Ti2Order smallint(5) unsigned NOT NULL,
Ti2WordCount tinyint(3) unsigned NOT NULL,
Ti2Text varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (Ti2TxID,Ti2Order,Ti2WordCount), KEY Ti2WoID (Ti2WoID)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS temptextitems (
TiCount smallint(5) unsigned NOT NULL,
TiSeID mediumint(8) unsigned NOT NULL,
TiOrder smallint(5) unsigned NOT NULL,
TiWordCount tinyint(3) unsigned NOT NULL,
TiText varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS tempwords (
WoText varchar(250) DEFAULT NULL,
WoTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
WoTranslation varchar(500) NOT NULL DEFAULT '*',
WoRomanization varchar(100) DEFAULT NULL,
WoSentence varchar(1000) DEFAULT NULL,
WoTaglist varchar(255) DEFAULT NULL,
PRIMARY KEY(WoTextLC)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS texts (
TxID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
TxLgID tinyint(3) unsigned NOT NULL,
TxTitle varchar(200) NOT NULL,
TxText text NOT NULL,
TxAnnotatedText longtext NOT NULL,
TxAudioURI varchar(200) DEFAULT NULL,
TxSourceURI varchar(1000) DEFAULT NULL,
TxPosition smallint(5) DEFAULT 0,
TxAudioPosition float DEFAULT 0,
PRIMARY KEY (TxID),
KEY TxLgID (TxLgID),
KEY TxLgIDSourceURI (TxSourceURI(20),TxLgID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS words (
WoID mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
WoLgID tinyint(3) unsigned NOT NULL,
WoText varchar(250) NOT NULL,
WoTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
WoStatus tinyint(4) NOT NULL,
WoTranslation varchar(500) NOT NULL DEFAULT '*',
WoRomanization varchar(100) DEFAULT NULL,
WoSentence varchar(1000) DEFAULT NULL,
WoWordCount tinyint(3) unsigned NOT NULL DEFAULT 0,
WoCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
WoStatusChanged timestamp NOT NULL DEFAULT '1970-01-01 12:00:00',
WoTodayScore double NOT NULL DEFAULT '0',
WoTomorrowScore double NOT NULL DEFAULT '0',
WoRandom double NOT NULL DEFAULT '0',
PRIMARY KEY (WoID),
UNIQUE KEY WoTextLCLgID (WoTextLC,WoLgID),
KEY WoLgID (WoLgID),
KEY WoStatus (WoStatus),
KEY WoTranslation (WoTranslation(20)),
KEY WoCreated (WoCreated),
KEY WoStatusChanged (WoStatusChanged),
KEY WoWordCount(WoWordCount),
KEY WoTodayScore (WoTodayScore),
KEY WoTomorrowScore (WoTomorrowScore),
KEY WoRandom (WoRandom)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS tags (
TgID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
TgText varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
TgComment varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (TgID),
UNIQUE KEY TgText (TgText)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS wordtags (
WtWoID mediumint(8) unsigned NOT NULL,
WtTgID smallint(5) unsigned NOT NULL,
PRIMARY KEY (WtWoID,WtTgID),
KEY WtTgID (WtTgID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS tags2 (
T2ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
T2Text varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
T2Comment varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (T2ID),
UNIQUE KEY T2Text (T2Text)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS texttags (
TtTxID smallint(5) unsigned NOT NULL,
TtT2ID smallint(5) unsigned NOT NULL,
PRIMARY KEY (TtTxID,TtT2ID), KEY TtT2ID (TtT2ID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS newsfeeds (
NfID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
NfLgID tinyint(3) unsigned NOT NULL,
NfName varchar(40) NOT NULL,
NfSourceURI varchar(200) NOT NULL,
NfArticleSectionTags text NOT NULL,
NfFilterTags text NOT NULL,
NfUpdate int(12) unsigned NOT NULL,
NfOptions varchar(200) NOT NULL,
PRIMARY KEY (NfID),
KEY NfLgID (NfLgID),
KEY NfUpdate (NfUpdate)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS feedlinks (
FlID mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
FlTitle varchar(200) NOT NULL,
FlLink varchar(400) NOT NULL,
FlDescription text NOT NULL,
FlDate datetime NOT NULL,
FlAudio varchar(200) NOT NULL,
FlText longtext NOT NULL,
FlNfID tinyint(3) unsigned NOT NULL,
PRIMARY KEY (FlID),
KEY FlLink (FlLink),
KEY FlDate (FlDate),
UNIQUE KEY FlTitle (FlNfID,FlTitle)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS archtexttags (
AgAtID smallint(5) unsigned NOT NULL,
AgT2ID smallint(5) unsigned NOT NULL,
PRIMARY KEY (AgAtID,AgT2ID),
KEY AgT2ID (AgT2ID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2 changes: 1 addition & 1 deletion delete_word.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function delete_word(wid) {
const context = window.parent.document;
const elem = $('.word' + wid, context);
let title = "";
if (!window.parent.document.getElementById('frame-l').JQ_TOOLTIP) {
if (!window.parent.document.getElementById('frame-l').LWT_DATA.settings.jQuery_tooltip) {
const ann = elem.attr('data_ann');
title = make_tooltip(
<?php echo prepare_textdata_js(get_term($wid)); ?>,
Expand Down
1 change: 1 addition & 0 deletions do_feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ function dummy_function_2($currentlang, $currentfeed): void

function do_page(): void
{
session_start();
$currentlang = validateLang(
(string) processDBParam("filterlang", 'currentlanguage', '', false)
);
Expand Down
24 changes: 15 additions & 9 deletions do_test_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,11 @@ function do_test_test_interaction_globals($wb1, $wb2, $wb3)
{
?>
<script type="text/javascript">
WBLINK1 = <?php echo json_encode($wb1); ?>;
WBLINK2 = <?php echo json_encode($wb2); ?>;
WBLINK3 = <?php echo json_encode($wb3); ?>;
LANG = getLangFromDict(WBLINK3);
if (LANG && LANG != WBLINK3) {
LWT_DATA.language.dict_link1 = <?php echo json_encode($wb1); ?>;
LWT_DATA.language.dict_link2 = <?php echo json_encode($wb2); ?>;
LWT_DATA.language.translator_link = <?php echo json_encode($wb3); ?>;
LANG = getLangFromDict(LWT_DATA.language.translator_link);
if (LANG && LANG != LWT_DATA.language.translator_link) {
$("html").attr('lang', LANG);
}
OPENED = 0;
Expand All @@ -702,9 +702,14 @@ function do_test_test_interaction_globals($wb1, $wb2, $wb3)
*/
function do_test_test_javascript_clickable($wo_record, $solution)
{
global $tbpref;
$wid = $wo_record['WoID'];
$abbr = getLanguageCode($wo_record['WoLgID'], LWT_LANGUAGES_ARRAY);
$phoneticText = phonetic_reading($wo_record['WoText'], $abbr);
$voiceApi = get_first_value(
"SELECT LgTTSVoiceAPI AS value FROM {$tbpref}languages
WHERE LgID = " . $wo_record['WoLgID']
);
?>
<script type="text/javascript">
/**
Expand All @@ -719,8 +724,9 @@ function read_word() {
}
}

SOLUTION = <?php echo prepare_textdata_js($solution); ?>;
WID = <?php echo $wid; ?>;
LWT_DATA.test.solution = <?php echo prepare_textdata_js($solution); ?>;
LWT_DATA.word.id = <?php echo $wid; ?>;
LWT_DATA.language.ttsVoiceApi = <?php echo json_encode($voiceApi); ?>;

$(document).on('keydown', keydown_event_do_test_test);
$('.word')
Expand Down Expand Up @@ -877,8 +883,8 @@ function prepare_test_frames()
*/
function insert_new_word(word_id, solution, group) {

SOLUTION = solution;
WID = word_id;
LWT_DATA.test.solution = solution;
LWT_DATA.word.id = word_id;

$('#term-test').html(group);

Expand Down
Loading

0 comments on commit 8100db5

Please sign in to comment.