Skip to content

Commit

Permalink
Merge all features from dev branch.
Browse files Browse the repository at this point in the history
New databse migration strategy.
Fixes feeds (#168).
Adds missing documentation to Docker (#146, #160).
Changes in PHP and JS globals.
Fixes reading position was not set.
Read text through API (#153, #155).
Fixes word was not saved/deleted.
Fixes #170 and #69.
Updates API (#175).
Adds dependency to php-xml (#178, #181).
Updates makefile (#179).
Adds MeCab support on Mac (#135).
Adds the option to hide/show word romanization (#119).
Raises URL size limit to 2048 (#144).
  • Loading branch information
HugoFara committed Jan 3, 2024
2 parents 403b2b4 + 5b54442 commit 0bc776f
Show file tree
Hide file tree
Showing 70 changed files with 5,825 additions and 4,505 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/*
2 changes: 1 addition & 1 deletion INSTALL.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apt_get_cmd=$(which apt-get)
yum_cmd=$(which yum)

packages="apache2 libapache2-mod-php php php-mbstring php-mysql mysql-server"
packages="apache2 libapache2-mod-php php php-xml php-mbstring php-mysql mysql-server"

echo "Installing dependencies"
if [ ! -z $apt_get_cmd ]; then
Expand Down
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ info.html: $(ONE_FILE_DOC)
doc: $(ONE_FILE_DOC) Doxyfile
php docs/info.php > docs/info.html
doxygen Doxyfile
./node_modules/.bin/jsdoc -c jsdoc.json
php tools/phpDocumentor

# Regenerate code documentation
code_doc: Doxyfile
Expand All @@ -25,19 +27,16 @@ minify: src/js/ src/css/ src/themes/

# Do not minify for development version!
no-minify: src/js/ src/css/ src/themes/
cp -r src/js/ .
cp src/js/third_party/* js/
cp src/js/pgm.js js/
cat src/js/* >> pgm/js
rm js/pgm.js
cat src/js/third_party/* >> js/pgm.js
rm -rf js/third_party
cat src/js/*.js >> js/pgm.js
cp -r src/css .
cp -r src/themes/ .
cp -r src/themes .

# Clear documentation
clean-doc:
rm docs/info.html
rm -rf docs/html

# Clear documentation, deprecated, use clean-doc instead
clean: clean-doc
clean: clean-doc
75 changes: 39 additions & 36 deletions all_words_wellknown.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/**
* \file
* \brief Setting all unknown words to Well Known (99)
*
* Call: all_words_wellknown.php?text=[textid]
*
* Call: all_words_wellknown.php?text=[textid]
* (mark all words as well-known)
* all_words_wellknown.php?text=[textid]&status=[statusint]
* all_words_wellknown.php?text=[textid]&status=[statusint]
* (mark with a specific status, normally 98 or 99)
*
*
* PHP version 8.1
*
*
* @category Helper_Frame
* @package Lwt
* @author LWT Project <[email protected]>
Expand All @@ -23,9 +23,9 @@

/**
* Make the SQL query for all words in the text.
*
*
* @param int $txid Text id
*
*
* @return mysqli_result|true SQL query.
*/
function all_words_wellknown_get_words($txid)
Expand Down Expand Up @@ -69,23 +69,23 @@ function all_words_wellknown_process_word($status, $term, $termlc, $langid): arr
} else {
$message = runsql(
"INSERT INTO {$tbpref}words (
WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,"
. make_score_random_insert_update('iv') .
WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,"
. make_score_random_insert_update('iv') .
")
VALUES(
$langid, " .
convert_string_to_sqlsyntax($term) . ", " .
convert_string_to_sqlsyntax($termlc) . ", $status, NOW(), " .
$langid, " .
convert_string_to_sqlsyntax($term) . ", " .
convert_string_to_sqlsyntax($termlc) . ", $status, NOW(), " .
make_score_random_insert_update('id') .
")",
")",
''
);
if (!is_numeric($message)) {
my_die("ERROR: Could not modify words! Message: $message");
}
if ((int)$message == 0) {
error_message_with_hide(
"WARNING: No rows modified! Message: $message",
"WARNING: No rows modified! Message: $message",
false
);
}
Expand All @@ -94,7 +94,7 @@ function all_words_wellknown_process_word($status, $term, $termlc, $langid): arr
}
$javascript = '';
if (getSettingWithDefault('set-tooltip-mode') == 1 && $rows > 0) {
$javascript .= "title = make_tooltip(" .
$javascript .= "title = make_tooltip(" .
prepare_textdata_js($term) . ", '*', '', '$status');";
}
$javascript .= "$('.TERM" . strToClassName($termlc) . "', context)
Expand Down Expand Up @@ -131,7 +131,10 @@ function all_words_wellknown_main_loop($txid, $status): array
$res = all_words_wellknown_get_words($txid);
while ($record = mysqli_fetch_assoc($res)) {
list($modified_rows, $new_js) = all_words_wellknown_process_word(
$status, $record['Ti2Text'], $record['Ti2TextLC'], $langid
$status,
$record['Ti2Text'],
$record['Ti2TextLC'],
$langid
);
$javascript .= $new_js;
$count += $modified_rows;
Expand All @@ -143,7 +146,7 @@ function all_words_wellknown_main_loop($txid, $status): array
"UPDATE {$tbpref}words
JOIN {$tbpref}textitems2
ON Ti2WoID = 0 AND LOWER(Ti2Text) = WoTextLC AND Ti2LgID = WoLgID
SET Ti2WoID = WoID",
SET Ti2WoID = WoID",
''
);

Expand All @@ -152,44 +155,44 @@ function all_words_wellknown_main_loop($txid, $status): array

/**
* Display the number of edited words.
*
*
* @param int $status New status
* @param int $count Number of edited words.
*
* @param int $count Number of edited words.
*
* @return void
*
*
* @since 2.5.3-fork Improved messages (more clear, and can handle singular/plural)
*/
function all_words_wellknown_count_terms($status, $count)
{
{
$message = "<p>";
if ($status == 98) {
if ($count > 1) {
$message .= "Ignored all $count words!";
} else if ($count == 1) {
} elseif ($count == 1) {
$message .= "Ignored 1 word.";
} else {
$message .= "No new word ignored!";
}
}
} else {
if ($count > 1) {
$message .= "You know all $count words well!";
} else if ($count == 1) {
} elseif ($count == 1) {
$message .= "1 new word added as known";
} else {
$message .= "No new known word added!";
}
}
}
$message .= "</p>";
echo $message;
}

/**
* Execute JavaScript to change the display of all words.
*
*
* @param int $txid Text ID
* @param string $javascript JavaScript-formatted string.
*
*
* @return void
*/
function all_words_wellknown_javascript($txid, $javascript)
Expand All @@ -209,10 +212,10 @@ function all_words_wellknown_javascript($txid, $javascript)

/**
* Make the main content of the page for all well-known words.
*
*
* @param int $txid Text ID
* @param int $status New status to apply to words.
*
*
* @return void
*/
function all_words_wellknown_content($txid, $status)
Expand All @@ -224,26 +227,26 @@ function all_words_wellknown_content($txid, $status)

/**
* Make a full HTML page for all well-known words.
*
*
* @param int $txid Text ID
* @param int $status New status to apply to words.
*
*
* @return void
*/
function all_words_wellknown_full($txid, $status)
function all_words_wellknown_full($txid, $status)
{
if ($status == 98) {
pagestart("Setting all blue words to Ignore", false);
pagestart("Setting all blue words to Ignore", false);
} else {
pagestart("Setting all blue words to Well-known", false);
pagestart("Setting all blue words to Well-known", false);
}
all_words_wellknown_content($txid, $status);
pageend();
}

if (isset($_REQUEST['text'])) {
all_words_wellknown_full(
(int) $_REQUEST['text'],
(int) $_REQUEST['text'],
isset($_REQUEST['stat']) ? (int) $_REQUEST['stat'] : 99
);
}
Expand Down
Loading

0 comments on commit 0bc776f

Please sign in to comment.