Documentation

session_utility.php

\file \brief 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

Tags
author

HugoFara hugo.farajallah@protonmail.com

license

Unlicense http://unlicense.org/

link
https://hugofara.github.io/lwt/docs/html/session__utility_8php.html
since
2.0.3-fork

Table of Contents

Functions

get_tags()  : array<string|int, string>
Return the list of all tags.
get_texttags()  : array<string|int, string>
Return the list of all text tags.
getTextTitle()  : string
get_tag_selectoptions()  : string
get_texttag_selectoptions()  : string
get_txtag_selectoptions()  : string
get_archivedtexttag_selectoptions()  : string
saveWordTags()  : void
Save the tags for words.
saveTextTags()  : void
Save the tags for texts.
saveArchivedTextTags()  : void
Save the tags for archived texts.
getWordTags()  : string
getTextTags()  : string
Return a HTML-formatted list of the text tags.
getArchivedTextTags()  : string
Return a HTML-formatted list of the text tags for an archived text.
addtaglist()  : string
addarchtexttaglist()  : string
addtexttaglist()  : string
removetaglist()  : string
removearchtexttaglist()  : string
removetexttaglist()  : string
load_feeds()  : void
write_rss_to_db()  : string
print_last_feed_update()  : void
get_nf_option()  : null|string|array<string|int, string>
get_links_from_new_feed()  : array<string|int, array<string|int, false|null|string>|null|string>|false
get_links_from_rss()  : array<string|int, array<string|int, false|null|string>>|false
get_text_from_rsslink()  : array<string|int, array<string|int, array<string|int, mixed>|mixed|null|string>>|null|string
getPreviousAndNextTextLinks()  : string
Return navigation arrows to previous and next texts.
echo_lwt_logo()  : void
Return an HTML formatted logo of the application.
getprefixes()  : array<string|int, string>
Return all different database prefixes that are in use.
media_paths_search()  : array<string|int, array<string|int, mixed>>
Return the list of media files found in folder, recursively.
get_media_paths()  : array<string|int, mixed>
Return the paths for all media files.
selectmediapathoptions()  : string
Get the different options to display as acceptable media files.
selectmediapath()  : string
Select the path for a media (audio or video).
get_seconds_selectoptions()  : string
get_playbackrate_selectoptions()  : string
remove_soft_hyphens()  : string|array<string|int, string>
replace_supp_unicode_planes_char()  : null|string|array<string|int, string>
makeCounterWithTotal()  : string
encodeURI()  : string
print_file_path()  : void
Echo the path of a file using the theme directory. Echo the base file name of file is not found
get_file_path()  : string
Get the path of a file using the theme directory
get_sepas()  : mixed
get_first_sepa()  : mixed
get_mobile_display_mode_selectoptions()  : string
Prepare options for mobile.
get_sentence_count_selectoptions()  : string
get_words_to_do_buttons_selectoptions()  : string
get_regex_selectoptions()  : string
get_tooltip_selectoptions()  : string
get_themes_selectoptions()  : string
processSessParam()  : string|int
Get a session value and update it if necessary.
processDBParam()  : string|int
Get a database value and update it if necessary.
getWordTagList()  : string
get_last_key()  : int
Return the last inserted ID in the database
get_checked()  : string
If $value is true, return an HTML-style checked attribute.
get_selected()  : string
Return an HTML attribute if $value is equal to $selval.
do_test_test_get_projection()  : string
Create a projection operator do perform word test.
do_test_test_from_selection()  : string
Prepare the SQL when the text is a selection.
make_status_controls_test_table()  : string
Make the plus and minus controls in a test table for a word.
get_languages_selectoptions()  : string
Return options as HTML code to insert in a language select.
get_languagessize_selectoptions()  : string
get_wordstatus_radiooptions()  : string
get_wordstatus_selectoptions()  : string
get_annotation_position_selectoptions()  : string
get_paging_selectoptions()  : string
get_wordssort_selectoptions()  : string
get_tagsort_selectoptions()  : string
get_textssort_selectoptions()  : string
get_andor_selectoptions()  : string
get_set_status_option()  : string
get_status_name()  : string
get_status_abbr()  : string
get_colored_status_msg()  : string
get_multiplewordsactions_selectoptions()  : string
get_multipletagsactions_selectoptions()  : string
get_allwordsactions_selectoptions()  : string
get_alltagsactions_selectoptions()  : string
get_multipletextactions_selectoptions()  : string
get_multiplearchivedtextactions_selectoptions()  : string
get_texts_selectoptions()  : string
makePager()  : void
Makes HTML content for a text of style "Page 1 of 3".
makeStatusCondition()  : string
checkStatusRange()  : bool
makeStatusClassFilter()  : string
Adds HTML attributes to create a filter over words learning status.
makeStatusClassFilterHelper()  : void
Replace $status in $array by -1
createTheDictLink()  : string
Create and verify a dictionary URL link
createDictLinksInEditWin()  : string
Returns dictionnary links formatted as HTML.
makeOpenDictStr()  : string
Create a dictionnary open URL from an pseudo-URL
makeOpenDictStrJS()  : string
makeOpenDictStrDynSent()  : string
Create a dictionnary open URL from an pseudo-URL
createDictLinksInEditWin2()  : string
Returns dictionnary links formatted as HTML.
makeDictLinks()  : string
createDictLinksInEditWin3()  : string
checkTest()  : string
Return checked attribute if $val is in array $_REQUEST[$name]
strToHex()  : string
strToClassName()  : string
Escapes everything to "¤xx" but not 0-9, a-z, A-Z, and unicode >= (hex 00A5, dec 165)
anki_export()  : never
tsv_export()  : never
flexible_export()  : never
mask_term_in_sentence_v2()  : string
repl_tab_nl()  : string
Replace all white space characters by a simple space ' '.
mask_term_in_sentence()  : string
return_textwordcount()  : array<string|int, array<string|int, array<string|int, float|int|null|string>|float|int|null|string>>
Return statistics about a list of text ID.
textwordcount()  : void
Compute and echo word statistics about a list of text ID.
texttodocount()  : string
texttodocount2()  : string
Return the number of words left to do in this text.
sentences_containing_word_lc_query()  : string
Return a SQL string to find sentences containing a word.
sentences_from_word()  : mysqli_result|true
Perform a SQL query to find sentences containing a word.
getSentence()  : array<string|int, string>
Format the sentence(s) $seid containing $wordlc highlighting $wordlc.
sentences_with_word()  : array<string|int, array<string|int, string>>
Return sentences containing a word.
example_sentences_area()  : void
Prepare the area to for examples sentences of a word.
get20Sentences()  : string
Show 20 sentences containg $wordlc.
get_languages()  : array<string, int>
Return a dictionary of languages name - id
getLanguage()  : string
Get language name from its ID
getLanguageCode()  : string
Try to get language code from its ID
getScriptDirectionTag()  : string
Return a right-to-left direction indication in HTML if language is right-to-left.
insert_expression_from_mecab()  : array<string|int, array<string|int, string>>
Insert an expression to the database using MeCab.
insertExpressionFromMeCab()  : array{: string[], : string[]}
Insert an expression to the database using MeCab.
insert_standard_expression()  : array<string|int, array<string|int, null|string>>
Insert an expression without using a tool like MeCab.
new_expression_interactable()  : void
Prepare a JavaScript dialog to insert a new expression. Use elements in global JavaScript scope.
new_expression_interactable2()  : void
Prepare a JavaScript dialog to insert a new expression.
insertExpressions()  : null|string
Alter the database to add a new word
restore_file()  : string
Restore the database from a file.
recreate_save_ann()  : string
Uses provided annotations, and annotations from database to update annotations.
create_ann()  : string
Create new annotations for a text.
insert_prefix_in_sql()  : mixed
create_save_ann()  : string
process_term()  : string
get_first_translation()  : string
get_annotation_link()  : string
trim_value()  : void
Like trim, but in place (modify variable)
phonetic_reading()  : string
Parses text be read by an automatic audio player.
refreshText()  : string
Refresh a text.
makeMediaPlayer()  : void
Create an HTML media player, audio or video.
makeVideoPlayer()  : void
Create an embed video player
makeAudioPlayer()  : void
Create an HTML audio player.
framesetheader()  : void
Echo a HEAD tag for using with frames
pagestart()  : void
Write a page header and start writing its body.
pagestart_nobody()  : void
Start a standard page with a complete header and a non-closed body.

Functions

get_tags()

Return the list of all tags.

get_tags([int $refresh = 0 ]) : array<string|int, string>
Parameters
$refresh : int = 0

If true, refresh all tags for session

Tags
global

string $tbpref Table name prefix

Return values
array<string|int, string>

All tags

get_texttags()

Return the list of all text tags.

get_texttags([int $refresh = 0 ]) : array<string|int, string>
Parameters
$refresh : int = 0

If true, refresh all text tags for session

Tags
global

string $tbpref Table name prefix

Return values
array<string|int, string>

All text tags

getTextTitle()

getTextTitle(mixed $textid) : string
Parameters
$textid : mixed
Return values
string

get_tag_selectoptions()

get_tag_selectoptions(mixed $v, mixed $l) : string
Parameters
$v : mixed
$l : mixed
Return values
string

get_texttag_selectoptions()

get_texttag_selectoptions(mixed $v, mixed $l) : string
Parameters
$v : mixed
$l : mixed
Return values
string

get_txtag_selectoptions()

get_txtag_selectoptions(mixed $l, mixed $v) : string
Parameters
$l : mixed
$v : mixed
Return values
string

get_archivedtexttag_selectoptions()

get_archivedtexttag_selectoptions(mixed $v, mixed $l) : string
Parameters
$v : mixed
$l : mixed
Return values
string

saveWordTags()

Save the tags for words.

saveWordTags(mixed $wid) : void
Parameters
$wid : mixed

saveTextTags()

Save the tags for texts.

saveTextTags(mixed $tid) : void
Parameters
$tid : mixed
Tags
global

string $tbpref Database table prefix.

saveArchivedTextTags()

Save the tags for archived texts.

saveArchivedTextTags(mixed $tid) : void
Parameters
$tid : mixed
Tags
global

string $tbpref Databse table prefix.

getWordTags()

getWordTags(mixed $wid) : string
Parameters
$wid : mixed
Return values
string

getTextTags()

Return a HTML-formatted list of the text tags.

getTextTags(int $tid) : string
Parameters
$tid : int

Text ID. Can be below 1 to create an empty list.

Tags
global

string $tbpref Database table prefix

Return values
string

UL list of text tags

getArchivedTextTags()

Return a HTML-formatted list of the text tags for an archived text.

getArchivedTextTags(int $tid) : string
Parameters
$tid : int

Text ID. Can be below 1 to create an empty list.

Tags
global

string $tbpref Database table prefix

Return values
string

UL list of text tags

addtaglist()

addtaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

addarchtexttaglist()

addarchtexttaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

addtexttaglist()

addtexttaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

removetaglist()

removetaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

removearchtexttaglist()

removearchtexttaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

removetexttaglist()

removetexttaglist(mixed $item, mixed $list) : string
Parameters
$item : mixed
$list : mixed
Return values
string

load_feeds()

load_feeds(mixed $currentfeed) : void
Parameters
$currentfeed : mixed

write_rss_to_db()

write_rss_to_db(mixed $texts) : string
Parameters
$texts : mixed
Return values
string

print_last_feed_update()

print_last_feed_update(mixed $diff) : void
Parameters
$diff : mixed

get_nf_option()

get_nf_option(mixed $str, mixed $option) : null|string|array<string|int, string>
Parameters
$str : mixed
$option : mixed
Tags
psalm-return

array<string, string>|null|string

Return values
null|string|array<string|int, string>
get_links_from_new_feed(mixed $NfSourceURI) : array<string|int, array<string|int, false|null|string>|null|string>|false
Parameters
$NfSourceURI : mixed
Tags
psalm-return

array{feed_title: null|string,...}|false

Return values
array<string|int, array<string|int, false|null|string>|null|string>|false
get_links_from_rss(mixed $NfSourceURI, mixed $NfArticleSection) : array<string|int, array<string|int, false|null|string>>|false
Parameters
$NfSourceURI : mixed
$NfArticleSection : mixed
Tags
psalm-return

false|list<array{title: null|string, desc: null|string, link: string, date: string, text?: false|string, audio: string}>

Return values
array<string|int, array<string|int, false|null|string>>|false
get_text_from_rsslink(mixed $feed_data, mixed $NfArticleSection, mixed $NfFilterTags[, mixed $NfCharset = null ]) : array<string|int, array<string|int, array<string|int, mixed>|mixed|null|string>>|null|string
Parameters
$feed_data : mixed
$NfArticleSection : mixed
$NfFilterTags : mixed
$NfCharset : mixed = null
Tags
psalm-return

array<array{TxTitle: mixed, TxAudioURI: mixed|null, TxText: string, TxSourceURI: mixed|string, message?: string, link?: list{mixed,...}}>|null|string

Return values
array<string|int, array<string|int, array<string|int, mixed>|mixed|null|string>>|null|string

Return navigation arrows to previous and next texts.

getPreviousAndNextTextLinks(int $textid, string $url, bool $onlyann, string $add) : string
Parameters
$textid : int

ID of the current text

$url : string

Base URL to append before $textid

$onlyann : bool

Restrict to annotated texts only

$add : string

Some content to add before the output

Return values
string

Arrows to previous and next texts.

Return an HTML formatted logo of the application.

echo_lwt_logo() : void
Tags
since
2.7.0

Do no longer indicate database prefix in logo

getprefixes()

Return all different database prefixes that are in use.

getprefixes() : array<string|int, string>
Tags
psalm-return

list

Return values
array<string|int, string>

A list of prefixes.

Return the list of media files found in folder, recursively.

media_paths_search(string $dir) : array<string|int, array<string|int, mixed>>
Parameters
$dir : string

Directory to search into.

Tags
psalm-return

array{paths: array, folders: array}

Return values
array<string|int, array<string|int, mixed>>

All paths found (matching files and folders) in "paths" and folders in "folders".

get_media_paths()

Return the paths for all media files.

get_media_paths() : array<string|int, mixed>
Return values
array<string|int, mixed>

Paths of media files, in the form array<string, string>

selectmediapathoptions()

Get the different options to display as acceptable media files.

selectmediapathoptions(string $dir) : string
Parameters
$dir : string

Directory containing files

Return values
string

HTML-formatted OPTION tags

selectmediapath()

Select the path for a media (audio or video).

selectmediapath(string $f) : string
Parameters
$f : string

HTML field name for media string in form. Will be used as this.form.[$f] in JS.

Return values
string

HTML-formatted string for media selection

get_seconds_selectoptions()

get_seconds_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_playbackrate_selectoptions()

get_playbackrate_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

remove_soft_hyphens()

remove_soft_hyphens(mixed $str) : string|array<string|int, string>
Parameters
$str : mixed
Tags
psalm-return

array|string

Return values
string|array<string|int, string>

replace_supp_unicode_planes_char()

replace_supp_unicode_planes_char(mixed $s) : null|string|array<string|int, string>
Parameters
$s : mixed
Tags
psalm-return

array|null|string

Return values
null|string|array<string|int, string>

makeCounterWithTotal()

makeCounterWithTotal(mixed $max, mixed $num) : string
Parameters
$max : mixed
$num : mixed
Return values
string

encodeURI()

encodeURI(mixed $url) : string
Parameters
$url : mixed
Return values
string

print_file_path()

Echo the path of a file using the theme directory. Echo the base file name of file is not found

print_file_path(string $filename) : void
Parameters
$filename : string

Filename

get_file_path()

Get the path of a file using the theme directory

get_file_path(string $filename) : string
Parameters
$filename : string

Filename

Return values
string

File path if it exists, otherwise the filename

get_mobile_display_mode_selectoptions()

Prepare options for mobile.

get_mobile_display_mode_selectoptions("0"|"1"|"2" $v) : string
Parameters
$v : "0"|"1"|"2"

Current mobile type

Return values
string

get_sentence_count_selectoptions()

get_sentence_count_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_words_to_do_buttons_selectoptions()

get_words_to_do_buttons_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_regex_selectoptions()

get_regex_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_tooltip_selectoptions()

get_tooltip_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_themes_selectoptions()

get_themes_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

processSessParam()

Get a session value and update it if necessary.

processSessParam(string $reqkey, string $sesskey, string|int $default, bool $isnum) : string|int
Parameters
$reqkey : string

If in $_REQUEST, update the session with $_REQUEST[$reqkey]

$sesskey : string

Field of the session to get or update

$default : string|int

Default value to return

$isnum : bool

If true, convert the result to an int

Return values
string|int

The required data unless $isnum is specified

processDBParam()

Get a database value and update it if necessary.

processDBParam(string $reqkey, string $dbkey, string $default, bool $isnum) : string|int
Parameters
$reqkey : string

If in $_REQUEST, update the database with $_REQUEST[$reqkey]

$dbkey : string

Field of the database to get or update

$default : string

Default value to return

$isnum : bool

If true, convert the result to an int

Return values
string|int

The string data unless $isnum is specified

getWordTagList()

getWordTagList(mixed $wid[, mixed $before = ' ' ][, mixed $brack = 1 ][, mixed $tohtml = 1 ]) : string
Parameters
$wid : mixed
$before : mixed = ' '
$brack : mixed = 1
$tohtml : mixed = 1
Return values
string

get_last_key()

Return the last inserted ID in the database

get_last_key() : int
Tags
since
2.6.0-fork

Officially returns a int in documentation, as it was the case

Return values
int

get_checked()

If $value is true, return an HTML-style checked attribute.

get_checked(mixed $value) : string
Parameters
$value : mixed

Some value that can be evaluated as a boolean

Tags
psalm-return

' checked="checked" '|''

Return values
string

' checked="checked" ' if value is true, '' otherwise

get_selected()

Return an HTML attribute if $value is equal to $selval.

get_selected(mixed $value, mixed $selval) : string
Parameters
$value : mixed
$selval : mixed
Tags
psalm-return

' selected="selected" '|''

Return values
string

''|' selected="selected" ' Depending if inputs are equal

do_test_test_get_projection()

Create a projection operator do perform word test.

do_test_test_get_projection(string $key, array<string|int, mixed>|int $value) : string
Parameters
$key : string

Type of test.

  • 'words': selection from words
  • 'texts': selection from texts
  • 'lang': selection from language
  • 'text': selection from single text
$value : array<string|int, mixed>|int

Object to select.

Tags
global

string $tbpref

Return values
string

SQL projection necessary

do_test_test_from_selection()

Prepare the SQL when the text is a selection.

do_test_test_from_selection(mixed $selection_type, string $selection_data) : string
Parameters
$selection_type : mixed
$selection_data : string

Comma separated ID of elements to test.

Return values
string

SQL formatted string suitable to projection (inserted in a "FROM ")

make_status_controls_test_table()

Make the plus and minus controls in a test table for a word.

make_status_controls_test_table(int $score, int $status, int $wordid) : string
Parameters
$score : int

Score associated to this word

$status : int

Status for this word

$wordid : int

Word ID

Return values
string

the HTML-formatted string to use

get_languages_selectoptions()

Return options as HTML code to insert in a language select.

get_languages_selectoptions(string|int|null $v, string $dt) : string
Parameters
$v : string|int|null

Selected language ID

$dt : string

Default value to display

Return values
string

get_languagessize_selectoptions()

get_languagessize_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_wordstatus_radiooptions()

get_wordstatus_radiooptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_wordstatus_selectoptions()

get_wordstatus_selectoptions(mixed $v, mixed $all, mixed $not9899[, mixed $off = true ]) : string
Parameters
$v : mixed
$all : mixed
$not9899 : mixed
$off : mixed = true
Return values
string

get_annotation_position_selectoptions()

get_annotation_position_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_paging_selectoptions()

get_paging_selectoptions(mixed $currentpage, mixed $pages) : string
Parameters
$currentpage : mixed
$pages : mixed
Return values
string

get_wordssort_selectoptions()

get_wordssort_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_tagsort_selectoptions()

get_tagsort_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_textssort_selectoptions()

get_textssort_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_andor_selectoptions()

get_andor_selectoptions(mixed $v) : string
Parameters
$v : mixed
Return values
string

get_set_status_option()

get_set_status_option(mixed $n[, mixed $suffix = "" ]) : string
Parameters
$n : mixed
$suffix : mixed = ""
Return values
string

get_status_name()

get_status_name(mixed $n) : string
Parameters
$n : mixed
Return values
string

get_status_abbr()

get_status_abbr(mixed $n) : string
Parameters
$n : mixed
Return values
string

get_colored_status_msg()

get_colored_status_msg(mixed $n) : string
Parameters
$n : mixed
Return values
string

get_multiplewordsactions_selectoptions()

get_multiplewordsactions_selectoptions() : string
Return values
string

get_multipletagsactions_selectoptions()

get_multipletagsactions_selectoptions() : string
Return values
string

get_allwordsactions_selectoptions()

get_allwordsactions_selectoptions() : string
Return values
string

get_alltagsactions_selectoptions()

get_alltagsactions_selectoptions() : string
Return values
string

get_multipletextactions_selectoptions()

get_multipletextactions_selectoptions() : string
Return values
string

get_multiplearchivedtextactions_selectoptions()

get_multiplearchivedtextactions_selectoptions() : string
Return values
string

get_texts_selectoptions()

get_texts_selectoptions(mixed $lang, mixed $v) : string
Parameters
$lang : mixed
$v : mixed
Return values
string

makePager()

Makes HTML content for a text of style "Page 1 of 3".

makePager(mixed $currentpage, mixed $pages, mixed $script, mixed $formname) : void
Parameters
$currentpage : mixed
$pages : mixed
$script : mixed
$formname : mixed

makeStatusCondition()

makeStatusCondition(mixed $fieldname, mixed $statusrange) : string
Parameters
$fieldname : mixed
$statusrange : mixed
Return values
string

checkStatusRange()

checkStatusRange(mixed $currstatus, mixed $statusrange) : bool
Parameters
$currstatus : mixed
$statusrange : mixed
Return values
bool

makeStatusClassFilter()

Adds HTML attributes to create a filter over words learning status.

makeStatusClassFilter(int<0, 5>|98|99|599 $status) : string
Parameters
$status : int<0, 5>|98|99|599

Word learning status 599 is a special status combining 5 and 99 statuses. 0 return an empty string

Return values
string

CSS class filter to exclude $status

makeStatusClassFilterHelper()

Replace $status in $array by -1

makeStatusClassFilterHelper(int $status, array<string|int, int> &$array) : void
Parameters
$status : int

A value in $array

$array : array<string|int, int>

Any array of values

Create and verify a dictionary URL link

createTheDictLink(string $u, string $t) : string

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

Parameters
$u : string

Dictionary URL. It may contain 'lwt_term' that will get parsed

$t : string

Text that substite the 'lwt_term'

Tags
since
2.7.0-fork

It is recommended to use "lwt_term" instead of "###"

Return values
string

Dictionary link formatted

createDictLinksInEditWin()

Returns dictionnary links formatted as HTML.

createDictLinksInEditWin(int $lang, string $word, string $sentctljs, bool $openfirst) : string
Parameters
$lang : int

Language ID

$word : string
$sentctljs : string
$openfirst : bool

True if we should open right frames with translation first

Tags
global

string $tbpref Database table prefix

Return values
string

HTML-formatted interface

makeOpenDictStr()

Create a dictionnary open URL from an pseudo-URL

makeOpenDictStr(string $url, string $txt) : string
Parameters
$url : string

An URL, starting with a "*" is deprecated.

  • If it contains a "popup" query, open in new window
  • Otherwise open in iframe
$txt : string

Clickable text to display

Return values
string

HTML-formatted string

makeOpenDictStrJS()

makeOpenDictStrJS(mixed $url) : string
Parameters
$url : mixed
Return values
string

makeOpenDictStrDynSent()

Create a dictionnary open URL from an pseudo-URL

makeOpenDictStrDynSent(string $url, string $sentctljs, string $txt) : string
Parameters
$url : string

A string containing at least a URL

  • If it contains the query "lwt_popup", open in Popup
  • Starts with a '*': open in pop-up window (deprecated)
  • Otherwise open in iframe
$sentctljs : string

Clickable text to display

$txt : string

Clickable text to display

Tags
since
2.7.0-fork

Supports LibreTranslate, using other string that proper URL is deprecated.

Return values
string

HTML-formatted string

createDictLinksInEditWin2()

Returns dictionnary links formatted as HTML.

createDictLinksInEditWin2(int $lang, string $sentctljs, string $wordctljs) : string
Parameters
$lang : int

Language ID

$sentctljs : string
$wordctljs : string
Tags
global

string $tbpref Database table prefix

Return values
string

HTML formatted interface

makeDictLinks(mixed $lang, mixed $wordctljs) : string
Parameters
$lang : mixed
$wordctljs : mixed
Return values
string

createDictLinksInEditWin3()

createDictLinksInEditWin3(mixed $lang, mixed $sentctljs, mixed $wordctljs) : string
Parameters
$lang : mixed
$sentctljs : mixed
$wordctljs : mixed
Return values
string

checkTest()

Return checked attribute if $val is in array $_REQUEST[$name]

checkTest(mixed $val, string $name) : string
Parameters
$val : mixed

Value to look for, needle

$name : string

Key of request haystack.

Tags
psalm-return

' '|' checked="checked" '

Return values
string

' ' of ' checked="checked" ' if the qttribute should be checked.

strToHex()

strToHex(mixed $string) : string
Parameters
$string : mixed
Return values
string

strToClassName()

Escapes everything to "¤xx" but not 0-9, a-z, A-Z, and unicode >= (hex 00A5, dec 165)

strToClassName(string $string) : string
Parameters
$string : string

String to escape

Return values
string

anki_export()

anki_export(mixed $sql) : never
Parameters
$sql : mixed
Return values
never

tsv_export()

tsv_export(mixed $sql) : never
Parameters
$sql : mixed
Return values
never

flexible_export()

flexible_export(mixed $sql) : never
Parameters
$sql : mixed
Return values
never

mask_term_in_sentence_v2()

mask_term_in_sentence_v2(mixed $s) : string
Parameters
$s : mixed
Return values
string

repl_tab_nl()

Replace all white space characters by a simple space ' '.

repl_tab_nl(string $s) : string

The output string is also trimmed.

Parameters
$s : string

String to parse

Return values
string

String with only simple whitespaces.

mask_term_in_sentence()

mask_term_in_sentence(mixed $s, mixed $regexword) : string
Parameters
$s : mixed
$regexword : mixed
Return values
string

return_textwordcount()

Return statistics about a list of text ID.

return_textwordcount(string $texts_id) : array<string|int, array<string|int, array<string|int, float|int|null|string>|float|int|null|string>>

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

Parameters
$texts_id : string

Texts ID separated by comma

Tags
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>>}

Return values
array<string|int, array<string|int, array<string|int, float|int|null|string>|float|int|null|string>>

Statistics under the form of an array

textwordcount()

Compute and echo word statistics about a list of text ID.

textwordcount(string $textID) : void

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

Parameters
$textID : string

Text IDs separated by comma

Tags
global

string $tbpref Table name prefix

deprecated
2.9.0

Use return_textwordcount instead.

texttodocount()

texttodocount(mixed $text) : string
Parameters
$text : mixed
Return values
string

texttodocount2()

Return the number of words left to do in this text.

texttodocount2(string|int $textid) : string
Parameters
$textid : string|int

Text ID

Tags
global

string $tbpref Database table prefix

since
2.7.0-fork

Adapted to use LibreTranslate dictionary as well.

Return values
string

HTML result

sentences_containing_word_lc_query()

Return a SQL string to find sentences containing a word.

sentences_containing_word_lc_query(string $wordlc, int $lid) : string
Parameters
$wordlc : string

Word to look for in lowercase

$lid : int

Language ID

Return values
string

Query in SQL format

sentences_from_word()

Perform a SQL query to find sentences containing a word.

sentences_from_word(int|null $wid, string $wordlc, int $lid[, int $limit = -1 ]) : mysqli_result|true
Parameters
$wid : int|null

Word ID or mode

  • null: use $wordlc instead, simple search
  • -1: use $wordlc with a more complex search
  • 0 or above: sentences containing $wid
$wordlc : string

Word to look for in lowercase

$lid : int

Language ID

$limit : int = -1

Maximum number of sentences to return

Return values
mysqli_result|true

Query

getSentence()

Format the sentence(s) $seid containing $wordlc highlighting $wordlc.

getSentence(int $seid, string $wordlc, int $mode) : array<string|int, string>
Parameters
$seid : int

Sentence ID

$wordlc : string

Term text in lower case

$mode : int
  • Up to 1: return only the current sentence
  • Above 1: return previous sentence and current sentence
  • Above 2: return previous, current and next sentence
Tags
global

string $tbpref Database table prefix.

psalm-return

list{string, string}

Return values
array<string|int, string>

[0]=html, word in bold, [1]=text, word in }

sentences_with_word()

Return sentences containing a word.

sentences_with_word(int $lang, string $wordlc, int|null $wid[, int|null $mode = 0 ][, int $limit = 20 ]) : array<string|int, array<string|int, string>>
Parameters
$lang : int

Language ID

$wordlc : string

Word to look for in lowercase

$wid : int|null

Word ID

  • null: use $wordlc instead, simple search
  • -1: use $wordlc with a more complex search
  • 0 or above: find sentences containing $wid
$mode : int|null = 0

Sentences to get:

  • Up to 1 is 1 sentence,
  • 2 is previous and current sentence,
  • 3 is previous, current and next one
$limit : int = 20

Maximum number of sentences to return

Tags
psalm-return

list{0?: array{0: string, 1: string},...}

Return values
array<string|int, array<string|int, string>>

Array of sentences found

example_sentences_area()

Prepare the area to for examples sentences of a word.

example_sentences_area(mixed $lang, mixed $termlc, mixed $selector, mixed $wid) : void
Parameters
$lang : mixed
$termlc : mixed
$selector : mixed
$wid : mixed

get20Sentences()

Show 20 sentences containg $wordlc.

get20Sentences(int $lang, string $wordlc, int|null $wid, string $jsctlname, int $mode) : string
Parameters
$lang : int

Language ID

$wordlc : string

Term in lower case.

$wid : int|null

Word ID

$jsctlname : string

Path for the textarea of the sentence of the word being edited.

$mode : int
  • Up to 1: return only the current sentence
  • Above 1: return previous and current sentence
  • Above 2: return previous, current and next sentence
Tags
global

string $tbpref Database table prefix

Return values
string

HTML-formatted string of which elements are candidate sentences to use.

get_languages()

Return a dictionary of languages name - id

get_languages() : array<string, int>
Return values
array<string, int>

getLanguage()

Get language name from its ID

getLanguage(string|int $lid) : string
Parameters
$lid : string|int

Language ID

Tags
global

string $tbpref Table name prefix

Return values
string

Language name

getLanguageCode()

Try to get language code from its ID

getLanguageCode(int $lg_id, array<string|int, mixed> $languages_table) : string
Parameters
$lg_id : int

Language ID

$languages_table : array<string|int, mixed>

Table of languages, usually LWT_LANGUAGES_ARRAY

Tags
global

string $tbpref

Return values
string

If found, two-letter code (e. g. BCP 47) or four-letters for the langugae. '' otherwise.

getScriptDirectionTag()

Return a right-to-left direction indication in HTML if language is right-to-left.

getScriptDirectionTag(string|int|null $lid) : string
Parameters
$lid : string|int|null

Language ID

Return values
string

' dir="rtl" '|''

insert_expression_from_mecab()

Insert an expression to the database using MeCab.

insert_expression_from_mecab(string $text, string|int $lid, string|int $wid, int $len) : array<string|int, array<string|int, string>>
Parameters
$text : string

Text to insert

$lid : string|int

Language ID

$wid : string|int

Word ID

$len : int

Number of words in the expression

Tags
since
2.5.0-fork

Function added.

global

string $tbpref Table name prefix

psalm-return

list{array<int, string>, list{0?: string,...}}

Return values
array<string|int, array<string|int, string>>

Append text and values to insert to the database

insertExpressionFromMeCab()

Insert an expression to the database using MeCab.

insertExpressionFromMeCab(string $textlc, string $lid, string $wid, int $len, int $mode) : array{: string[], : string[]}
Parameters
$textlc : string

Text to insert in lower case

$lid : string

Language ID

$wid : string

Word ID

$len : int

Number of words in the expression

$mode : int

If equal to 0, add data in the output

Tags
since
2.5.0-fork

Function deprecated. $mode is unnused, data are always returned. The second return argument is always empty array.

deprecated

Use insert_expression_from_mecab instead.

global

string $tbpref Table name prefix

psalm-return

array{0: array<int, string>, 1: list}

Return values
array{: string[], : string[]}

Append text and SQL array.

insert_standard_expression()

Insert an expression without using a tool like MeCab.

insert_standard_expression(string $textlc, string|int $lid, string|int $wid, int $len, mixed $mode) : array<string|int, array<string|int, null|string>>
Parameters
$textlc : string

Text to insert in lower case

$lid : string|int

Language ID

$wid : string|int

Word ID

$len : int

Number of words in the expression

$mode : mixed

Unnused

Tags
since
2.5.0-fork

Mode is unnused and data are always added to the output.

since
2.5.2-fork

Fixed multi-words insertion for languages using no space

global

string $tbpref Table name prefix

psalm-return

list{array<int, null|string>, array<never, never>, list{0?: string,...}}

Return values
array<string|int, array<string|int, null|string>>

Append text, empty and sentence id

new_expression_interactable()

Prepare a JavaScript dialog to insert a new expression. Use elements in global JavaScript scope.

new_expression_interactable(mixed $hex, mixed $appendtext, mixed $sid, mixed $len) : void
Parameters
$hex : mixed
$appendtext : mixed
$sid : mixed
$len : mixed
Tags
deprecated

Use new_expression_interactable2 instead. The new function does not use global JS variables.

new_expression_interactable2()

Prepare a JavaScript dialog to insert a new expression.

new_expression_interactable2(string $hex, array<string|int, string> $appendtext, int $wid, int $len) : void
Parameters
$hex : string

Lowercase text, formatted version of the text.

$appendtext : array<string|int, string>

Text to append

$wid : int

Term ID

$len : int

Words count.

Tags
global

string $tbpref Database table prefix.

insertExpressions()

Alter the database to add a new word

insertExpressions(string $textlc, string|int $lid, mixed $wid, int $len, int $mode) : null|string
Parameters
$textlc : string

Text in lower case

$lid : string|int

Language ID

$wid : mixed
$len : int

Number of words in the expression

$mode : int

Function mode

  • 0: Default mode, do nothing special
  • 1: Runs an expresion inserter interactable
  • 2: Return the sql output
Tags
global

string $tbpref Table name prefix

Return values
null|string

If $mode == 2 return values to insert in textitems2, nothing otherwise.

restore_file()

Restore the database from a file.

restore_file(resource $handle, string $title) : string
Parameters
$handle : resource

Backup file handle

$title : string

File title

Tags
global

string $trbpref Database table prefix

global

int $debug Debug status

global

string $dbname Database name

since
2.0.3-fork

Function was broken

since
2.5.3-fork

Function repaired

since
2.7.0-fork

$handle should be for an uncompressed file.

Return values
string

Human-readable status message

recreate_save_ann()

Uses provided annotations, and annotations from database to update annotations.

recreate_save_ann(int $textid, string $oldann) : string
Parameters
$textid : int

Id of the text on which to update annotations

$oldann : string

Old annotations

Return values
string

Updated annotations for this text.

create_ann()

Create new annotations for a text.

create_ann(int $textid) : string
Parameters
$textid : int

Id of the text to create annotations for

Tags
since
2.9.0

Annotations "position" change, they are now equal to Ti2Order it was shifted by one index before.

Return values
string

Annotations for the text

insert_prefix_in_sql()

insert_prefix_in_sql(mixed $sql_line) : mixed
Parameters
$sql_line : mixed

create_save_ann()

create_save_ann(mixed $textid) : string
Parameters
$textid : mixed
Return values
string

process_term()

process_term(mixed $nonterm, mixed $term, mixed $trans, mixed $wordid, mixed $line) : string
Parameters
$nonterm : mixed
$term : mixed
$trans : mixed
$wordid : mixed
$line : mixed
Return values
string

get_first_translation()

get_first_translation(mixed $trans) : string
Parameters
$trans : mixed
Return values
string
get_annotation_link(mixed $textid) : string
Parameters
$textid : mixed
Return values
string

trim_value()

Like trim, but in place (modify variable)

trim_value(string &$value) : void
Parameters
$value : string

Value to be trimmed

phonetic_reading()

Parses text be read by an automatic audio player.

phonetic_reading(string $text, string $lang) : string

Some non-phonetic alphabet will need this, currently only Japanese is supported, using MeCab.

Parameters
$text : string

Text to be converted

$lang : string

Language code (usually BCP 47 or ISO 639-1)

Tags
since
2.9.0

Any language starting by "ja" or "jp" is considered phonetic.

Return values
string

Parsed text in a phonetic format.

refreshText()

Refresh a text.

refreshText(mixed $word, mixed $tid) : string
Parameters
$word : mixed
$tid : mixed
Tags
deprecated

No longer used, incompatible with new database system.

since
1.6.25-fork

Not compatible with the database

Return values
string

makeMediaPlayer()

Create an HTML media player, audio or video.

makeMediaPlayer(string $path[, int $offset = 0 ]) : void
Parameters
$path : string

URL or local file path

$offset : int = 0

Offset from the beginning of the video

makeVideoPlayer()

Create an embed video player

makeVideoPlayer(string $path[, int $offset = 0 ]) : void
Parameters
$path : string

URL or local file path

$offset : int = 0

Offset from the beginning of the video

makeAudioPlayer()

Create an HTML audio player.

makeAudioPlayer(string $audio[, int $offset = 0 ]) : void
Parameters
$audio : string

Audio URL

$offset : int = 0

Offset from the beginning of the video

framesetheader()

Echo a HEAD tag for using with frames

framesetheader(string $title) : void
Parameters
$title : string

Title to use

pagestart()

Write a page header and start writing its body.

pagestart(string $title, bool $close) : void
Parameters
$title : string

Title of the page

$close : bool

Set to true if you are closing the header

Tags
since
2.7.0

Show no text near the logo, page title enclosed in H1

global

bool $debug Show a DEBUG span if true

pagestart_nobody()

Start a standard page with a complete header and a non-closed body.

pagestart_nobody(string $title[, string $addcss = '' ]) : void
Parameters
$title : string

Title of the page

$addcss : string = ''

Some CSS to be embed in a style tag

Tags
global

string $tbpref The database table prefix if true

global

int $debug Show the requests if true


        
On this page

Search results