Learning with Texts - Fork  2.10.0-fork
Learn foreign languages with texts
Namespaces | Functions
session_utility.php File Reference

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='')
 

Detailed Description

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

Function Documentation

◆ anki_export()

anki_export (   $sql)
Returns
never

◆ checkTest()

checkTest (   $val,
  $name 
)

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

Parameters
mixed$valValue to look for, needle
string$nameKey of request haystack.
Returns
string ' ' of ' checked="checked" ' if the qttribute should be checked.

@psalm-return ' '|' checked="checked" '

◆ create_ann()

create_ann (   $textid)

Create new annotations for a text.

Parameters
int$textidId of the text to create annotations for
Returns
string Annotations for the text
Since
2.9.0 Annotations "position" change, they are now equal to Ti2Order it was shifted by one index before.

◆ createDictLinksInEditWin()

createDictLinksInEditWin (   $lang,
  $word,
  $sentctljs,
  $openfirst 
)

Returns dictionnary links formatted as HTML.

Parameters
int$langLanguage ID
string$word
string$sentctljs
bool$openfirstTrue if we should open right frames with translation first
Returns
string HTML-formatted interface

@global string $tbpref Database table prefix

◆ createDictLinksInEditWin2()

createDictLinksInEditWin2 (   $lang,
  $sentctljs,
  $wordctljs 
)

Returns dictionnary links formatted as HTML.

Parameters
int$langLanguage ID
string$sentctljs
string$wordctljs
Returns
string HTML formatted interface

@global string $tbpref Database table prefix

◆ createTheDictLink()

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

Parameters
string$uDictionary URL. It may contain 'lwt_term' that will get parsed
string$tText that substite the 'lwt_term'
Returns
string Dictionary link formatted
Since
2.7.0-fork It is recommended to use "lwt_term" instead of "###"

◆ do_test_test_from_selection()

do_test_test_from_selection (   $selection_type,
  $selection_data 
)

Prepare the SQL when the text is a selection.

Parameters
int$selection_type,.2 is words selection and 3 is terms selection.
string$selection_dataComma separated ID of elements to test.
Returns
string SQL formatted string suitable to projection (inserted in a "FROM ")

◆ do_test_test_get_projection()

do_test_test_get_projection (   $key,
  $value 
)

Create a projection operator do perform word test.

Parameters
string$keyType of test.
  • 'words': selection from words
  • 'texts': selection from texts
  • 'lang': selection from language
  • 'text': selection from single text
array | int$valueObject to select.
Returns
string SQL projection necessary

@global string $tbpref

◆ echo_lwt_logo()

echo_lwt_logo ( )

Return an HTML formatted logo of the application.

Since
2.7.0 Do no longer indicate database prefix in logo

◆ example_sentences_area()

example_sentences_area (   $lang,
  $termlc,
  $selector,
  $wid 
)

Prepare the area to for examples sentences of a word.

◆ findMecabExpression()

findMecabExpression (   $text,
  $lid 
)

Find all occurences of an expression using MeCab.

Parameters
string$textText to insert
string | int$lidLanguage ID
int$lenNumber of words in the expression
Returns
(int|string)[][] Each found multi-word details

@global string $tbpref Table name prefix

@psalm-return list{0?: array{SeID: int, TxID: int, position: int, term: string},...}

◆ findStandardExpression()

findStandardExpression (   $textlc,
  $lid 
)

Find all occurences of an expression, do not use parsers like MeCab.

Parameters
string$textlcText to insert in lower case
string | int$lidLanguage ID
Returns
(int|null|string)[][] Each inserted mutli-word details

@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()

flexible_export (   $sql)
Returns
never

◆ framesetheader()

framesetheader (   $title)

Echo a HEAD tag for using with frames

Parameters
string$titleTitle to use
Returns
void

◆ get20Sentences()

get20Sentences (   $lang,
  $wordlc,
  $wid,
  $jsctlname,
  $mode 
)

Show 20 sentences containg $wordlc.

Parameters
int$langLanguage ID
string$wordlcTerm in lower case.
int | null$widWord ID
string$jsctlnamePath for the textarea of the sentence of the word being edited.
int$mode* Up to 1: return only the current sentence
  • Above 1: return previous and current sentence
  • Above 2: return previous, current and next sentence
Returns
string HTML-formatted string of which elements are candidate sentences to use.

@global string $tbpref Database table prefix

◆ get_checked()

get_checked (   $value)

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

Parameters
mixed$valueSome value that can be evaluated as a boolean
Returns
string ' checked="checked" ' if value is true, '' otherwise

@psalm-return ' checked="checked" '|''

◆ get_file_path()

get_file_path (   $filename)

Get the path of a file using the theme directory

Parameters
string$filenameFilename
Returns
string File path if it exists, otherwise the filename

◆ get_languages()

get_languages ( )

Return a dictionary of languages name - id

Returns
array<string, int>

◆ get_languages_selectoptions()

get_languages_selectoptions (   $v,
  $dt 
)

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

Parameters
string | int | null$vSelected language ID
string$dtDefault value to display

◆ get_last_key()

get_last_key ( )

Return the last inserted ID in the database

Returns
int
Since
2.6.0-fork Officially returns a int in documentation, as it was the case

◆ get_media_paths()

get_media_paths ( )

Return the paths for all media files.

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

◆ get_mobile_display_mode_selectoptions()

get_mobile_display_mode_selectoptions (   $v)

Prepare options for mobile.

Parameters
"0"|"1"|"2"$v Current mobile type

◆ get_selected()

get_selected (   $value,
  $selval 
)

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

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

@psalm-return ' selected="selected" '|''

◆ getLanguage()

getLanguage (   $lid)

Get language name from its ID

Parameters
string | int$lidLanguage ID
Returns
string Language name @global string $tbpref Table name prefix

◆ getLanguageCode()

getLanguageCode (   $lg_id,
  $languages_table 
)

Try to get language code from its ID

Parameters
int$lg_idLanguage ID
array$languages_tableTable of languages, usually LWT_LANGUAGES_ARRAY
Returns
string If found, two-letter code (e. g. BCP 47) or four-letters for the langugae. '' otherwise.

@global string $tbpref

◆ getprefixes()

getprefixes ( )

Return all different database prefixes that are in use.

Returns
string[] A list of prefixes.

@psalm-return list<string>

◆ getPreviousAndNextTextLinks()

getPreviousAndNextTextLinks (   $textid,
  $url,
  $onlyann,
  $add 
)

Return navigation arrows to previous and next texts.

Parameters
int$textidID of the current text
string$urlBase URL to append before $textid
bool$onlyannRestrict to annotated texts only
string$addSome content to add before the output
Returns
string Arrows to previous and next texts.

◆ getScriptDirectionTag()

getScriptDirectionTag (   $lid)

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

Parameters
string | int | null$lidLanguage ID
Returns
string ' dir="rtl" '|''

◆ getSentence()

getSentence (   $seid,
  $wordlc,
  $mode 
)

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

Parameters
int$seidSentence ID
string$wordlcTerm text in lower case
int$mode* Up to 1: return only the current sentence
  • Above 1: return previous sentence and current sentence
  • Above 2: return previous, current and next sentence
Returns
string[] [0]=html, word in bold, [1]=text, word in {}

@global string $tbpref Database table prefix.

@psalm-return list{string, string}

◆ insert_expression_from_mecab()

insert_expression_from_mecab (   $text,
  $lid,
  $wid,
  $len 
)

Insert an expression to the database using MeCab.

Parameters
string$textText to insert
string | int$lidLanguage ID
string | int$widWord ID
int$lenNumber of words in the expression
Returns
string[][] Append text and values to insert to the database
Since
2.5.0-fork Function added.
Deprecated:
Since 2.10.0 Use insertMecabExpression

@global string $tbpref Table name prefix

@psalm-return list{array<int, string>, list{0?: string,...}}

◆ insert_standard_expression()

insert_standard_expression (   $textlc,
  $lid,
  $wid,
  $len,
  $mode 
)

Insert an expression without using a tool like MeCab.

Parameters
string$textlcText to insert in lower case
string | int$lidLanguage ID
string | int$widWord ID
int$lenNumber of words in the expression
mixed$modeUnnused
Returns
(null|string)[][] Append text, empty and sentence id
Since
2.5.0-fork Mode is unnused and data are always added to the output.
2.5.2-fork Fixed multi-words insertion for languages using no space.
Deprecated:
Since 2.10.0-fork, use insertStandardExpression

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

◆ insertExpressionFromMeCab()

insertExpressionFromMeCab (   $textlc,
  $lid,
  $wid,
  $len,
  $mode 
)

Insert an expression to the database using MeCab.

Parameters
string$textlcText to insert in lower case
string$lidLanguage ID
string$widWord ID
int$lenNumber of words in the expression
int$modeIf equal to 0, add data in the output
Returns
array{string[], string[]} Append text and SQL array.
Since
2.5.0-fork Function deprecated. $mode is unnused, data are always returned. The second return argument is always empty array.
Deprecated:
Use insertMecabExpression instead.

@global string $tbpref Table name prefix

@psalm-return array{0: array<int, string>, 1: list<string>}

◆ insertExpressions()

insertExpressions (   $textlc,
  $lid,
  $wid,
  $len,
  $mode 
)

Alter the database to add a new word

Parameters
string$textlcText in lower case
string | int$lidLanguage ID
int$lenNumber of words in the expression
int$modeFunction mode
  • 0: Default mode, do nothing special
  • 1: Runs an expresion inserter interactable
  • 2: Return the sql output
Returns
null|string If $mode == 2 return values to insert in textitems2, nothing otherwise.

@global string $tbpref Table name prefix

◆ make_status_controls_test_table()

make_status_controls_test_table (   $score,
  $status,
  $wordid 
)

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

Parameters
int$scoreScore associated to this word
int$statusStatus for this word
int$wordidWord ID
Returns
string the HTML-formatted string to use

◆ makeAudioPlayer()

makeAudioPlayer (   $audio,
  $offset = 0 
)

Create an HTML audio player.

Parameters
string$audioAudio URL
int$offsetOffset from the beginning of the video
Returns
void

Get the extension of a file.

Parameters
{string}file File path
Returns
{string} File extension

Import audio data when jPlayer is ready.

Returns
{undefined}

Prepare media interactions with jPlayer.

Returns
{void}

◆ makeMediaPlayer()

makeMediaPlayer (   $path,
  $offset = 0 
)

Create an HTML media player, audio or video.

Parameters
string$pathURL or local file path
int$offsetOffset from the beginning of the video
Returns
void

File extension (if exists)

◆ makeOpenDictStr()

makeOpenDictStr (   $url,
  $txt 
)

Create a dictionnary open URL from an pseudo-URL

Parameters
string$urlAn URL, starting with a "*" is deprecated.
  • If it contains a "popup" query, open in new window
  • Otherwise open in iframe
string$txtClickable text to display
Returns
string HTML-formatted string

◆ makeOpenDictStrDynSent()

makeOpenDictStrDynSent (   $url,
  $sentctljs,
  $txt 
)

Create a dictionnary open URL from an pseudo-URL

Parameters
string$urlA 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
string$sentctljsClickable text to display
string$txtClickable text to display
Returns
string HTML-formatted string
Since
2.7.0-fork Supports LibreTranslate, using other string that proper URL is deprecated.

◆ makePager()

makePager (   $currentpage,
  $pages,
  $script,
  $formname 
)

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

Returns
void

◆ makeStatusClassFilter()

makeStatusClassFilter (   $status)

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

Parameters
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
Returns
string CSS class filter to exclude $status

◆ makeStatusClassFilterHelper()

makeStatusClassFilterHelper (   $status,
$array 
)

Replace $status in $array by -1

Parameters
int$statusA value in $array
int[]$arrayAny array of values

◆ makeVideoPlayer()

makeVideoPlayer (   $path,
  $offset = 0 
)

Create an embed video player

Parameters
string$pathURL or local file path
int$offsetOffset from the beginning of the video

◆ media_paths_search()

media_paths_search (   $dir)

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

Parameters
string$dirDirectory to search into.
Returns
array[] All paths found (matching files and folders) in "paths" and folders in "folders".

@psalm-return array{paths: array, folders: array}

◆ new_expression_interactable()

new_expression_interactable (   $hex,
  $appendtext,
  $sid,
  $len 
)

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

Deprecated:
Use newMultiWordInteractable instead. The new function does not use global JS variables.
Returns
void

◆ new_expression_interactable2()

new_expression_interactable2 (   $hex,
  $appendtext,
  $wid,
  $len 
)

Prepare a JavaScript dialog to insert a new expression.

Parameters
string$hexLowercase text, formatted version of the text.
string[]$appendtextText to append
int$widTerm ID
int$lenWords count.
Returns
void

@global string $tbpref Database table prefix.

Since
2.10.0-fork Fixes a bug inserting wrong title in tooltip

◆ newMultiWordInteractable()

newMultiWordInteractable (   $hex,
  $multiwords,
  $wid,
  $len 
)

Prepare a JavaScript dialog to insert a new expression.

Parameters
string$hexLowercase text, formatted version of the text.
string[][]$multiwordsMulti-words to happen, format [textid][position][text]
int$widTerm ID
int$lenWords count.
Returns
void

@global string $tbpref Database table prefix.

Since
2.10.0-fork Fixes a bug inserting wrong title in tooltip

◆ pagestart()

pagestart (   $title,
  $close 
)

Write a page header and start writing its body.

Parameters
string$titleTitle of the page
bool$closeSet to true if you are closing the header
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()

pagestart_nobody (   $title,
  $addcss = '' 
)

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

Parameters
string$titleTitle of the page
string$addcssSome 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()

print_file_path (   $filename)

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

Parameters
string$filenameFilename

◆ processDBParam()

processDBParam (   $reqkey,
  $dbkey,
  $default,
  $isnum 
)

Get a database value and update it if necessary.

Parameters
string$reqkeyIf in $_REQUEST, update the database with $_REQUEST[$reqkey]
string$dbkeyField of the database to get or update
string$defaultDefault value to return
bool$isnumIf true, convert the result to an int
Returns
string|int The string data unless $isnum is specified

◆ processSessParam()

processSessParam (   $reqkey,
  $sesskey,
  $default,
  $isnum 
)

Get a session value and update it if necessary.

Parameters
string$reqkeyIf in $_REQUEST, update the session with $_REQUEST[$reqkey]
string$sesskeyField of the session to get or update
string | int$defaultDefault value to return
bool$isnumIf true, convert the result to an int
Returns
string|int The required data unless $isnum is specified

◆ recreate_save_ann()

recreate_save_ann (   $textid,
  $oldann 
)

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

Parameters
int$textidId of the text on which to update annotations
string$oldannOld annotations
Returns
string Updated annotations for this text.

◆ refreshText()

refreshText (   $word,
  $tid 
)

Refresh a text.

Deprecated:
No longer used, incompatible with new database system.
Since
1.6.25-fork Not compatible with the database

◆ remove_soft_hyphens()

remove_soft_hyphens (   $str)
Returns
string|string[]

@psalm-return array<string>|string

◆ repl_tab_nl()

repl_tab_nl (   $s)

Replace all white space characters by a simple space ' '. The output string is also trimmed.

Parameters
string$sString to parse
Returns
string String with only simple whitespaces.

◆ replace_supp_unicode_planes_char()

replace_supp_unicode_planes_char (   $s)
Returns
null|string|string[]

@psalm-return array<string>|null|string

◆ restore_file()

restore_file (   $handle,
  $title 
)

Restore the database from a file.

Parameters
resource$handleBackup file handle
string$titleFile title
Returns
string Human-readable status message

@global string $trbpref Database table prefix @global int $debug Debug status @global string $dbname Database name

Since
2.0.3-fork Function was broken
2.5.3-fork Function repaired
2.7.0-fork $handle should be an uncompressed file.
2.9.1-fork It can read SQL with more or less than one instruction a line

◆ return_textwordcount()

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

Parameters
string$texts_idTexts ID separated by comma

@global string $tbpref Table name prefix

Returns
((float|int|null|string)[]|float|int|null|string)[][] Statistics under the form of an array

@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()

selectmediapath (   $f)

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

Parameters
string$fHTML field name for media string in form. Will be used as this.form.[$f] in JS.
Returns
string HTML-formatted string for media selection

◆ selectmediapathoptions()

selectmediapathoptions (   $dir)

Get the different options to display as acceptable media files.

Parameters
string$dirDirectory containing files
Returns
string HTML-formatted OPTION tags

◆ sentences_containing_word_lc_query()

sentences_containing_word_lc_query (   $wordlc,
  $lid 
)

Return a SQL string to find sentences containing a word.

Parameters
string$wordlcWord to look for in lowercase
int$lidLanguage ID
Returns
string Query in SQL format

◆ sentences_from_word()

sentences_from_word (   $wid,
  $wordlc,
  $lid,
  $limit = -1 
)

Perform a SQL query to find sentences containing a word.

Parameters
int | null$widWord ID or mode
  • null: use $wordlc instead, simple search
  • -1: use $wordlc with a more complex search
  • 0 or above: sentences containing $wid
string$wordlcWord to look for in lowercase
int$lidLanguage ID
int$limitMaximum number of sentences to return
Returns
mysqli_result|true Query

◆ sentences_with_word()

sentences_with_word (   $lang,
  $wordlc,
  $wid,
  $mode = 0,
  $limit = 20 
)

Return sentences containing a word.

Parameters
int$langLanguage ID
string$wordlcWord to look for in lowercase
int | null$widWord ID
  • null: use $wordlc instead, simple search
  • -1: use $wordlc with a more complex search
  • 0 or above: find sentences containing $wid
int | null$modeSentences to get:
  • Up to 1 is 1 sentence,
  • 2 is previous and current sentence,
  • 3 is previous, current and next one
int$limitMaximum number of sentences to return
Returns
string[][] Array of sentences found

@psalm-return list{0?: array{0: string, 1: string},...}

◆ strToClassName()

strToClassName (   $string)

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

Parameters
string$stringString to escape

◆ texttodocount2()

texttodocount2 (   $textid)

Prepare HTML interactions for the words left to do in this text.

Parameters
string | int$textidText ID
Returns
string HTML result
Since
2.7.0-fork Adapted to use LibreTranslate dictionary as well.
Deprecated:
Since 2.10.0, use todo_words_content instead

◆ textwordcount()

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

Parameters
string$textIDText IDs separated by comma

@global string $tbpref Table name prefix

Deprecated:
2.9.0 Use return_textwordcount instead.

◆ todo_words_content()

todo_words_content (   $textid)

Prepare HTML interactions for the words left to do in this text.

Parameters
int$textidText ID
Returns
string HTML result

@global string $tbpref

Since
2.7.0-fork Adapted to use LibreTranslate dictionary as well.

◆ todo_words_count()

todo_words_count (   $textid)

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

Parameters
int$textidText ID
Returns
int Number of words

@global string $tbpref

◆ trim_value()

trim_value ( $value)

Like trim, but in place (modify variable)

Parameters
string$valueValue to be trimmed

◆ truncateUserDatabase()

truncateUserDatabase ( )

Truncate the database, remove all data belonging by the current user.

Keep settings.

@global $tbpref

◆ tsv_export()

tsv_export (   $sql)
Returns
never