|
Learning with Texts - Fork
2.10.0-fork
Learn foreign languages with texts
|
All the files needed for a LWT session. More...
Namespaces | |
| Lwt | |
Functions | |
| getPreviousAndNextTextLinks ($textid, $url, $onlyann, $add) | |
| echo_lwt_logo () | |
| getprefixes () | |
| media_paths_search ($dir) | |
| get_media_paths () | |
| selectmediapathoptions ($dir) | |
| selectmediapath ($f) | |
| get_seconds_selectoptions ($v) | |
| get_playbackrate_selectoptions ($v) | |
| remove_soft_hyphens ($str) | |
| replace_supp_unicode_planes_char ($s) | |
| makeCounterWithTotal ($max, $num) | |
| encodeURI ($url) | |
| print_file_path ($filename) | |
| get_file_path ($filename) | |
| get_sepas () | |
| get_first_sepa () | |
| get_mobile_display_mode_selectoptions ($v) | |
| get_sentence_count_selectoptions ($v) | |
| get_words_to_do_buttons_selectoptions ($v) | |
| get_regex_selectoptions ($v) | |
| get_tooltip_selectoptions ($v) | |
| get_themes_selectoptions ($v) | |
| processSessParam ($reqkey, $sesskey, $default, $isnum) | |
| processDBParam ($reqkey, $dbkey, $default, $isnum) | |
| getWordTagList ($wid, $before=' ', $brack=1, $tohtml=1) | |
| get_last_key () | |
| get_checked ($value) | |
| get_selected ($value, $selval) | |
| do_test_test_get_projection ($key, $value) | |
| do_test_test_from_selection ($selection_type, $selection_data) | |
| make_status_controls_test_table ($score, $status, $wordid) | |
| get_languages_selectoptions ($v, $dt) | |
| get_languagessize_selectoptions ($v) | |
| get_wordstatus_radiooptions ($v) | |
| get_wordstatus_selectoptions ($v, $all, $not9899, $off=true) | |
| get_annotation_position_selectoptions ($v) | |
| get_hts_selectoptions ($current_setting) | |
| get_paging_selectoptions ($currentpage, $pages) | |
| get_wordssort_selectoptions ($v) | |
| get_tagsort_selectoptions ($v) | |
| get_textssort_selectoptions ($v) | |
| get_andor_selectoptions ($v) | |
| get_set_status_option ($n, $suffix="") | |
| get_status_name ($n) | |
| get_status_abbr ($n) | |
| get_colored_status_msg ($n) | |
| get_multiplewordsactions_selectoptions () | |
| get_multipletagsactions_selectoptions () | |
| get_allwordsactions_selectoptions () | |
| get_alltagsactions_selectoptions () | |
| get_multipletextactions_selectoptions () | |
| Returns options for an HTML dropdown to choose a text along a criterion. | |
| get_multiplearchivedtextactions_selectoptions () | |
| get_texts_selectoptions ($lang, $v) | |
| makePager ($currentpage, $pages, $script, $formname) | |
| makeStatusCondition ($fieldname, $statusrange) | |
| checkStatusRange ($currstatus, $statusrange) | |
| makeStatusClassFilter ($status) | |
| makeStatusClassFilterHelper ($status, &$array) | |
| createTheDictLink ($u, $t) | |
| createDictLinksInEditWin ($lang, $word, $sentctljs, $openfirst) | |
| makeOpenDictStr ($url, $txt) | |
| makeOpenDictStrJS ($url) | |
| makeOpenDictStrDynSent ($url, $sentctljs, $txt) | |
| createDictLinksInEditWin2 ($lang, $sentctljs, $wordctljs) | |
| makeDictLinks ($lang, $wordctljs) | |
| createDictLinksInEditWin3 ($lang, $sentctljs, $wordctljs) | |
| checkTest ($val, $name) | |
| strToHex ($string) | |
| strToClassName ($string) | |
| anki_export ($sql) | |
| tsv_export ($sql) | |
| flexible_export ($sql) | |
| mask_term_in_sentence_v2 ($s) | |
| repl_tab_nl ($s) | |
| mask_term_in_sentence ($s, $regexword) | |
| return_textwordcount ($texts_id) | |
| textwordcount ($textID) | |
| todo_words_count ($textid) | |
| todo_words_content ($textid) | |
| texttodocount2 ($textid) | |
| sentences_containing_word_lc_query ($wordlc, $lid) | |
| sentences_from_word ($wid, $wordlc, $lid, $limit=-1) | |
| getSentence ($seid, $wordlc, $mode) | |
| sentences_with_word ($lang, $wordlc, $wid, $mode=0, $limit=20) | |
| example_sentences_area ($lang, $termlc, $selector, $wid) | |
| get20Sentences ($lang, $wordlc, $wid, $jsctlname, $mode) | |
| get_languages () | |
| getLanguage ($lid) | |
| getLanguageCode ($lg_id, $languages_table) | |
| getScriptDirectionTag ($lid) | |
| findMecabExpression ($text, $lid) | |
| insert_expression_from_mecab ($text, $lid, $wid, $len) | |
| insertExpressionFromMeCab ($textlc, $lid, $wid, $len, $mode) | |
| findStandardExpression ($textlc, $lid) | |
| insert_standard_expression ($textlc, $lid, $wid, $len, $mode) | |
| new_expression_interactable ($hex, $appendtext, $sid, $len) | |
| new_expression_interactable2 ($hex, $appendtext, $wid, $len) | |
| newMultiWordInteractable ($hex, $multiwords, $wid, $len) | |
| insertExpressions ($textlc, $lid, $wid, $len, $mode) | |
| restore_file ($handle, $title) | |
| recreate_save_ann ($textid, $oldann) | |
| create_ann ($textid) | |
| create_save_ann ($textid) | |
| truncateUserDatabase () | |
| process_term ($nonterm, $term, $trans, $wordid, $line) | |
| get_first_translation ($trans) | |
| get_annotation_link ($textid) | |
| trim_value (&$value) | |
| refreshText ($word, $tid) | |
| makeMediaPlayer ($path, $offset=0) | |
| makeVideoPlayer ($path, $offset=0) | |
| makeAudioPlayer ($audio, $offset=0) | |
| framesetheader ($title) | |
| pagestart ($title, $close) | |
| pagestart_nobody ($title, $addcss='') | |
All the files needed for a LWT session.
By requiring this file, you start a session, connect to the database and declare a lot of useful functions.
PHP version 8.1
| anki_export | ( | $sql | ) |
| checkTest | ( | $val, | |
| $name | |||
| ) |
Return checked attribute if $val is in array $_REQUEST[$name]
| mixed | $val | Value to look for, needle |
| string | $name | Key of request haystack. |
@psalm-return ' '|' checked="checked" '
| create_ann | ( | $textid | ) |
Create new annotations for a text.
| int | $textid | Id of the text to create annotations for |
| createDictLinksInEditWin | ( | $lang, | |
| $word, | |||
| $sentctljs, | |||
| $openfirst | |||
| ) |
Returns dictionnary links formatted as HTML.
| int | $lang | Language ID |
| string | $word | |
| string | $sentctljs | |
| bool | $openfirst | True if we should open right frames with translation first |
@global string $tbpref Database table prefix
| createDictLinksInEditWin2 | ( | $lang, | |
| $sentctljs, | |||
| $wordctljs | |||
| ) |
Returns dictionnary links formatted as HTML.
| int | $lang | Language ID |
| string | $sentctljs | |
| string | $wordctljs |
@global string $tbpref Database table prefix
| createTheDictLink | ( | $u, | |
| $t | |||
| ) |
Create and verify a dictionary URL link
Case 1: url without any ### or lwt_term: append UTF-8-term Case 2: url with one ### or lwt_term: substitute UTF-8-term Case 3: url with two (###|lwt_term)enc###: unsupported encoding changed, abandonned since 2.6.0-fork
| string | $u | Dictionary URL. It may contain 'lwt_term' that will get parsed |
| string | $t | Text that substite the 'lwt_term' |
| do_test_test_from_selection | ( | $selection_type, | |
| $selection_data | |||
| ) |
Prepare the SQL when the text is a selection.
| int | $selection_type,. | 2 is words selection and 3 is terms selection. |
| string | $selection_data | Comma separated ID of elements to test. |
| do_test_test_get_projection | ( | $key, | |
| $value | |||
| ) |
Create a projection operator do perform word test.
| string | $key | Type of test.
|
| array | int | $value | Object to select. |
@global string $tbpref
| echo_lwt_logo | ( | ) |
Return an HTML formatted logo of the application.
| example_sentences_area | ( | $lang, | |
| $termlc, | |||
| $selector, | |||
| $wid | |||
| ) |
Prepare the area to for examples sentences of a word.
| findMecabExpression | ( | $text, | |
| $lid | |||
| ) |
Find all occurences of an expression using MeCab.
| string | $text | Text to insert |
| string | int | $lid | Language ID |
| int | $len | Number of words in the expression |
@global string $tbpref Table name prefix
@psalm-return list{0?: array{SeID: int, TxID: int, position: int, term: string},...}
| findStandardExpression | ( | $textlc, | |
| $lid | |||
| ) |
Find all occurences of an expression, do not use parsers like MeCab.
@global string $tbpref Table name prefix
@psalm-return list{0?: array{SeID: int, SeTxID: int, position: int, term: null|string, term_display: null|string},...}
| flexible_export | ( | $sql | ) |
| framesetheader | ( | $title | ) |
Echo a HEAD tag for using with frames
| string | $title | Title to use |
| get20Sentences | ( | $lang, | |
| $wordlc, | |||
| $wid, | |||
| $jsctlname, | |||
| $mode | |||
| ) |
Show 20 sentences containg $wordlc.
| int | $lang | Language ID |
| string | $wordlc | Term in lower case. |
| int | null | $wid | Word ID |
| string | $jsctlname | Path for the textarea of the sentence of the word being edited. |
| int | $mode | * Up to 1: return only the current sentence
|
@global string $tbpref Database table prefix
| get_checked | ( | $value | ) |
If $value is true, return an HTML-style checked attribute.
| mixed | $value | Some value that can be evaluated as a boolean |
@psalm-return ' checked="checked" '|''
| get_file_path | ( | $filename | ) |
Get the path of a file using the theme directory
| string | $filename | Filename |
| get_languages | ( | ) |
Return a dictionary of languages name - id
| get_languages_selectoptions | ( | $v, | |
| $dt | |||
| ) |
Return options as HTML code to insert in a language select.
| string | int | null | $v | Selected language ID |
| string | $dt | Default value to display |
| get_last_key | ( | ) |
Return the last inserted ID in the database
| get_media_paths | ( | ) |
Return the paths for all media files.
| get_mobile_display_mode_selectoptions | ( | $v | ) |
Prepare options for mobile.
| "0"|"1"|"2" | $v Current mobile type |
| get_selected | ( | $value, | |
| $selval | |||
| ) |
Return an HTML attribute if $value is equal to $selval.
@psalm-return ' selected="selected" '|''
| getLanguage | ( | $lid | ) |
| getLanguageCode | ( | $lg_id, | |
| $languages_table | |||
| ) |
Try to get language code from its ID
| int | $lg_id | Language ID |
| array | $languages_table | Table of languages, usually LWT_LANGUAGES_ARRAY |
@global string $tbpref
| getprefixes | ( | ) |
Return all different database prefixes that are in use.
@psalm-return list<string>
| getPreviousAndNextTextLinks | ( | $textid, | |
| $url, | |||
| $onlyann, | |||
| $add | |||
| ) |
Return navigation arrows to previous and next texts.
| int | $textid | ID of the current text |
| string | $url | Base URL to append before $textid |
| bool | $onlyann | Restrict to annotated texts only |
| string | $add | Some content to add before the output |
| getScriptDirectionTag | ( | $lid | ) |
Return a right-to-left direction indication in HTML if language is right-to-left.
| string | int | null | $lid | Language ID |
| getSentence | ( | $seid, | |
| $wordlc, | |||
| $mode | |||
| ) |
Format the sentence(s) $seid containing $wordlc highlighting $wordlc.
| int | $seid | Sentence ID |
| string | $wordlc | Term text in lower case |
| int | $mode | * Up to 1: return only the current sentence
|
@global string $tbpref Database table prefix.
@psalm-return list{string, string}
| insert_expression_from_mecab | ( | $text, | |
| $lid, | |||
| $wid, | |||
| $len | |||
| ) |
Insert an expression to the database using MeCab.
| string | $text | Text to insert |
| string | int | $lid | Language ID |
| string | int | $wid | Word ID |
| int | $len | Number of words in the expression |
@global string $tbpref Table name prefix
@psalm-return list{array<int, string>, list{0?: string,...}}
| insert_standard_expression | ( | $textlc, | |
| $lid, | |||
| $wid, | |||
| $len, | |||
| $mode | |||
| ) |
Insert an expression without using a tool like MeCab.
| string | $textlc | Text to insert in lower case |
| string | int | $lid | Language ID |
| string | int | $wid | Word ID |
| int | $len | Number of words in the expression |
| mixed | $mode | Unnused |
@psalm-return list{array<int, null|string>, array<never, never>, list{0?: string,...}}
| insertExpressionFromMeCab | ( | $textlc, | |
| $lid, | |||
| $wid, | |||
| $len, | |||
| $mode | |||
| ) |
Insert an expression to the database using MeCab.
| string | $textlc | Text to insert in lower case |
| string | $lid | Language ID |
| string | $wid | Word ID |
| int | $len | Number of words in the expression |
| int | $mode | If equal to 0, add data in the output |
@global string $tbpref Table name prefix
@psalm-return array{0: array<int, string>, 1: list<string>}
| insertExpressions | ( | $textlc, | |
| $lid, | |||
| $wid, | |||
| $len, | |||
| $mode | |||
| ) |
Alter the database to add a new word
| string | $textlc | Text in lower case |
| string | int | $lid | Language ID |
| int | $len | Number of words in the expression |
| int | $mode | Function mode
|
@global string $tbpref Table name prefix
| make_status_controls_test_table | ( | $score, | |
| $status, | |||
| $wordid | |||
| ) |
Make the plus and minus controls in a test table for a word.
| int | $score | Score associated to this word |
| int | $status | Status for this word |
| int | $wordid | Word ID |
| makeAudioPlayer | ( | $audio, | |
$offset = 0 |
|||
| ) |
Create an HTML audio player.
| string | $audio | Audio URL |
| int | $offset | Offset from the beginning of the video |
Get the extension of a file.
| {string} | file File path |
Import audio data when jPlayer is ready.
Prepare media interactions with jPlayer.
| makeMediaPlayer | ( | $path, | |
$offset = 0 |
|||
| ) |
Create an HTML media player, audio or video.
| string | $path | URL or local file path |
| int | $offset | Offset from the beginning of the video |
File extension (if exists)
| makeOpenDictStr | ( | $url, | |
| $txt | |||
| ) |
Create a dictionnary open URL from an pseudo-URL
| string | $url | An URL, starting with a "*" is deprecated.
|
| string | $txt | Clickable text to display |
| makeOpenDictStrDynSent | ( | $url, | |
| $sentctljs, | |||
| $txt | |||
| ) |
Create a dictionnary open URL from an pseudo-URL
| string | $url | A string containing at least a URL
|
| string | $sentctljs | Clickable text to display |
| string | $txt | Clickable text to display |
| makePager | ( | $currentpage, | |
| $pages, | |||
| $script, | |||
| $formname | |||
| ) |
Makes HTML content for a text of style "Page 1 of 3".
| makeStatusClassFilter | ( | $status | ) |
Adds HTML attributes to create a filter over words learning status.
| int<0,5>|98|99|599 | $status Word learning status 599 is a special status combining 5 and 99 statuses. 0 return an empty string |
| makeStatusClassFilterHelper | ( | $status, | |
| & | $array | ||
| ) |
Replace $status in $array by -1
| int | $status | A value in $array |
| int[] | $array | Any array of values |
| makeVideoPlayer | ( | $path, | |
$offset = 0 |
|||
| ) |
Create an embed video player
| string | $path | URL or local file path |
| int | $offset | Offset from the beginning of the video |
| media_paths_search | ( | $dir | ) |
Return the list of media files found in folder, recursively.
| string | $dir | Directory to search into. |
@psalm-return array{paths: array, folders: array}
| new_expression_interactable | ( | $hex, | |
| $appendtext, | |||
| $sid, | |||
| $len | |||
| ) |
Prepare a JavaScript dialog to insert a new expression. Use elements in global JavaScript scope.
| new_expression_interactable2 | ( | $hex, | |
| $appendtext, | |||
| $wid, | |||
| $len | |||
| ) |
Prepare a JavaScript dialog to insert a new expression.
| string | $hex | Lowercase text, formatted version of the text. |
| string[] | $appendtext | Text to append |
| int | $wid | Term ID |
| int | $len | Words count. |
@global string $tbpref Database table prefix.
| newMultiWordInteractable | ( | $hex, | |
| $multiwords, | |||
| $wid, | |||
| $len | |||
| ) |
Prepare a JavaScript dialog to insert a new expression.
| string | $hex | Lowercase text, formatted version of the text. |
| string[][] | $multiwords | Multi-words to happen, format [textid][position][text] |
| int | $wid | Term ID |
| int | $len | Words count. |
@global string $tbpref Database table prefix.
| pagestart | ( | $title, | |
| $close | |||
| ) |
Write a page header and start writing its body.
| string | $title | Title of the page |
| bool | $close | Set to true if you are closing the header |
@global bool $debug Show a DEBUG span if true
| pagestart_nobody | ( | $title, | |
$addcss = '' |
|||
| ) |
Start a standard page 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
| print_file_path | ( | $filename | ) |
Echo the path of a file using the theme directory. Echo the base file name of file is not found
| string | $filename | Filename |
| processDBParam | ( | $reqkey, | |
| $dbkey, | |||
| $default, | |||
| $isnum | |||
| ) |
Get a database value and update it if necessary.
| string | $reqkey | If in $_REQUEST, update the database with $_REQUEST[$reqkey] |
| string | $dbkey | Field of the database to get or update |
| string | $default | Default value to return |
| bool | $isnum | If true, convert the result to an int |
| processSessParam | ( | $reqkey, | |
| $sesskey, | |||
| $default, | |||
| $isnum | |||
| ) |
Get a session value and update it if necessary.
| string | $reqkey | If in $_REQUEST, update the session with $_REQUEST[$reqkey] |
| string | $sesskey | Field of the session to get or update |
| string | int | $default | Default value to return |
| bool | $isnum | If true, convert the result to an int |
| recreate_save_ann | ( | $textid, | |
| $oldann | |||
| ) |
Uses provided annotations, and annotations from database to update annotations.
| int | $textid | Id of the text on which to update annotations |
| string | $oldann | Old annotations |
| refreshText | ( | $word, | |
| $tid | |||
| ) |
Refresh a text.
| remove_soft_hyphens | ( | $str | ) |
@psalm-return array<string>|string
| repl_tab_nl | ( | $s | ) |
Replace all white space characters by a simple space ' '. The output string is also trimmed.
| string | $s | String to parse |
| replace_supp_unicode_planes_char | ( | $s | ) |
@psalm-return array<string>|null|string
| restore_file | ( | $handle, | |
| $title | |||
| ) |
Restore the database from a file.
| resource | $handle | Backup file handle |
| string | $title | File title |
@global string $trbpref Database table prefix @global int $debug Debug status @global string $dbname Database name
| return_textwordcount | ( | $texts_id | ) |
Return statistics about a list of text ID.
It is useful for unknown percent with this fork.
The echo is an output array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int} Total number of words, number of expression, statistics, total unique, number of unique expressions, unique statistics
| string | $texts_id | Texts ID separated by comma |
@global string $tbpref Table name prefix
@psalm-return array{total: array<float|int|string, float|int|null|string>, expr: array<float|int|string, float|int|null|string>, stat: array<float|int|string, array<float|int|string, float|int|null|string>>, totalu: array<float|int|string, float|int|null|string>, expru: array<float|int|string, float|int|null|string>, statu: array<float|int|string, array<float|int|string, float|int|null|string>>}
| selectmediapath | ( | $f | ) |
Select the path for a media (audio or video).
| string | $f | HTML field name for media string in form. Will be used as this.form.[$f] in JS. |
| selectmediapathoptions | ( | $dir | ) |
Get the different options to display as acceptable media files.
| string | $dir | Directory containing files |
| sentences_containing_word_lc_query | ( | $wordlc, | |
| $lid | |||
| ) |
Return a SQL string to find sentences containing a word.
| string | $wordlc | Word to look for in lowercase |
| int | $lid | Language ID |
| sentences_from_word | ( | $wid, | |
| $wordlc, | |||
| $lid, | |||
$limit = -1 |
|||
| ) |
Perform a SQL query to find sentences containing a word.
| int | null | $wid | Word ID or mode
|
| string | $wordlc | Word to look for in lowercase |
| int | $lid | Language ID |
| int | $limit | Maximum number of sentences to return |
| sentences_with_word | ( | $lang, | |
| $wordlc, | |||
| $wid, | |||
$mode = 0, |
|||
$limit = 20 |
|||
| ) |
Return sentences containing a word.
| int | $lang | Language ID |
| string | $wordlc | Word to look for in lowercase |
| int | null | $wid | Word ID
|
| int | null | $mode | Sentences to get:
|
| int | $limit | Maximum number of sentences to return |
@psalm-return list{0?: array{0: string, 1: string},...}
| strToClassName | ( | $string | ) |
Escapes everything to "¤xx" but not 0-9, a-z, A-Z, and unicode >= (hex 00A5, dec 165)
| string | $string | String to escape |
| texttodocount2 | ( | $textid | ) |
Prepare HTML interactions for the words left to do in this text.
| string | int | $textid | Text ID |
| textwordcount | ( | $textID | ) |
Compute and echo word statistics about a list of text ID.
It is useful for unknown percent with this fork.
The echo is an output array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int} Total number of words, number of expression, statistics, total unique, number of unique expressions, unique statistics
| string | $textID | Text IDs separated by comma |
@global string $tbpref Table name prefix
| todo_words_content | ( | $textid | ) |
Prepare HTML interactions for the words left to do in this text.
| int | $textid | Text ID |
@global string $tbpref
| todo_words_count | ( | $textid | ) |
Return the number of words left to do in this text.
| int | $textid | Text ID |
@global string $tbpref
| trim_value | ( | & | $value | ) |
Like trim, but in place (modify variable)
| string | $value | Value to be trimmed |
| truncateUserDatabase | ( | ) |
Truncate the database, remove all data belonging by the current user.
Keep settings.
@global $tbpref
| tsv_export | ( | $sql | ) |