|
Learning with Texts - Fork
2.10.0-fork
Learn foreign languages with texts
|
Core utility functions that do not require a complete session. More...
Namespaces | |
| Lwt | |
Functions | |
| get_version () | |
| get_version_number () | |
| tohtml ($s) | |
| showRequest () | |
| get_execution_time () | |
| get_setting_data () | |
| remove_spaces ($s, $remove) | |
| get_mecab_path ($mecab_args='') | |
| find_latin_sentence_end ($matches, $noSentenceEnd) | |
| my_die ($text) | |
| quickMenu () | |
| pagestart_kernel_nobody ($title, $addcss='') | |
| pageend () | |
| echodebug ($var, $text) | |
| get_statuses () | |
| str_replace_first ($needle, $replace, $haystack) | |
| annotation_to_json ($ann) | |
| getreq ($s) | |
| getsess ($s) | |
| url_base () | |
| make_score_random_insert_update ($type) | |
| getsqlscoreformula ($method) | |
| error_message_with_hide ($msg, $noback) | |
| langFromDict ($url) | |
| targetLangFromDict ($url) | |
| parseSQLFile ($filename) | |
Variables | |
| const | LWT_APP_VERSION '2.10.0-fork' |
| const | LWT_RELEASE_DATE "2024-04-01" |
Core utility functions that do not require a complete session.
PHP version 8.1
| annotation_to_json | ( | $ann | ) |
Convert annotations in a JSON format.
| string | $ann | Annotations. |
| echodebug | ( | $var, | |
| $text | |||
| ) |
Debug function only.
| mixed | $var | A printable variable to debug |
| string | $text | Echoed text in HTML page |
@global bool $debug This functions doesn't do anything is $debug is false.
| error_message_with_hide | ( | $msg, | |
| $noback | |||
| ) |
Display a error message vanishing after a few seconds.
| string | $msg | Message to display. |
| bool | $noback | If true, don't display a button to go back |
| find_latin_sentence_end | ( | $matches, | |
| $noSentenceEnd | |||
| ) |
Find end-of-sentence characters in a sentence using latin alphabet.
| string[] | $matches | All the matches from a capturing regex |
| string | $noSentenceEnd | If different from '', can declare that a string a not the end of a sentence. |
| get_execution_time | ( | ) |
Get the time since the last call
| get_mecab_path | ( | $mecab_args = '' | ) |
Returns path to the MeCab application. MeCab can split Japanese text word by word
| string | $mecab_args | Arguments to add |
| get_setting_data | ( | ) |
Reload $setting_data if necessary
| get_statuses | ( | ) |
Return an associative array of all possible statuses
| get_version | ( | ) |
Return LWT version for humans
Version is hardcoded in this function. For instance 1.6.31 (October 03 2016)
@global bool $debug If true adds a red "DEBUG"
@psalm-return '2.9.1-fork (December 29 2023) DEBUG'|'2.9.1-fork (December 29 2023)'
| get_version_number | ( | ) |
Return a machine readable version number.
| getreq | ( | $s | ) |
Get a request when possible. Otherwise, return an empty string.
| string | $s | Request key |
| getsess | ( | $s | ) |
Get a session variable when possible. Otherwise, return an empty string.
| string | $s | Session variable key |
| getsqlscoreformula | ( | $method | ) |
SQL formula for computing score.
| int | $method | Score for tomorrow (2), the day after it (3) or never (any value). |
@psalm-return ' GREATEST(-125, CASE WHEN WoStatus > 5 THEN 100 WHEN WoStatus = 1 THEN ROUND(-7 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 2 THEN ROUND(6.9 - 3.5 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 3 THEN ROUND(20 - 2.3 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 4 THEN ROUND(46.4 - 1.75 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 5 THEN ROUND(100 - 1.4 * DATEDIFF(NOW(),WoStatusChanged)) END)'|' GREATEST(-125, CASE WHEN WoStatus > 5 THEN 100 WHEN WoStatus = 1 THEN ROUND(-7 -7 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 2 THEN ROUND(3.4 - 3.5 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 3 THEN ROUND(17.7 - 2.3 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 4 THEN ROUND(44.65 - 1.75 * DATEDIFF(NOW(),WoStatusChanged)) WHEN WoStatus = 5 THEN ROUND(98.6 - 1.4 * DATEDIFF(NOW(),WoStatusChanged)) END)'|'0'
| langFromDict | ( | $url | ) |
Get a two-letter language code from dictionary source language.
| string | $url | Input URL, usually Google Translate or LibreTranslate |
| make_score_random_insert_update | ( | $type | ) |
Make a random score for a new word.
| 'iv'|'id'|'u'|string | $type Type of insertion
|
| my_die | ( | $text | ) |
Make the script crash and prints an error message
| string | $text | Error text to output |
| pageend | ( | ) |
Add a closing body tag.
@global bool $debug Show the requests if true @global float $dspltime Total execution time since the PHP session started
| pagestart_kernel_nobody | ( | $title, | |
$addcss = '' |
|||
| ) |
Start a page without connecting to the database with a complete header and a non-closed body.
| string | $title | Title of the page |
| string | $addcss | Some CSS to be embed in a style tag |
@global string $tbpref The database table prefix if true @global int $debug Show the requests if true
| parseSQLFile | ( | $filename | ) |
Parse a SQL file by returning an array of the different queries it contains.
| string | $filename | File name |
| quickMenu | ( | ) |
Display the main menu of navigation as a dropdown
| remove_spaces | ( | $s, | |
| $remove | |||
| ) |
Remove all spaces from a string.
| string | $s | Input string |
| string | bool | $remove | Do not do anything if empty or false |
| showRequest | ( | ) |
Echo debugging informations.
| str_replace_first | ( | $needle, | |
| $replace, | |||
| $haystack | |||
| ) |
| targetLangFromDict | ( | $url | ) |
Get a two-letter language code from dictionary target language
| string | $url | Input URL, usually Google Translate or LibreTranslate |
| tohtml | ( | $s | ) |
Escape special HTML characters.
| string | $s | String to escape. |
| url_base | ( | ) |
Get the base URL of the application