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

All the files needed for a LWT session. More...

Namespaces

namespace  Lwt
 

Functions

 get_tags ($refresh=0)
 
 get_texttags ($refresh=0)
 
 getTextTitle ($textid)
 
 get_tag_selectoptions ($v, $l)
 
 get_texttag_selectoptions ($v, $l)
 
 get_txtag_selectoptions ($l, $v)
 
 get_archivedtexttag_selectoptions ($v, $l)
 
 saveWordTags ($wid)
 
 saveTextTags ($tid)
 
 saveArchivedTextTags ($tid)
 
 getWordTags ($wid)
 
 getTextTags ($tid)
 
 getArchivedTextTags ($tid)
 
 addtaglist ($item, $list)
 
 addarchtexttaglist ($item, $list)
 
 addtexttaglist ($item, $list)
 
 removetaglist ($item, $list)
 
 removearchtexttaglist ($item, $list)
 
 removetexttaglist ($item, $list)
 
 load_feeds ($currentfeed)
 
 write_rss_to_db ($texts)
 
 print_last_feed_update ($diff)
 
 get_nf_option ($str, $option)
 
 get_links_from_new_feed ($NfSourceURI)
 
 get_links_from_rss ($NfSourceURI, $NfArticleSection)
 
 get_text_from_rsslink ($feed_data, $NfArticleSection, $NfFilterTags, $NfCharset=null)
 
 getPreviousAndNextTextLinks ($textid, $url, $onlyann, $add)
 
 echo_lwt_logo ()
 
 getprefixes ()
 
 selectmediapath ($f)
 
 selectmediapathoptions ($dir)
 
 get_seconds_selectoptions ($v)
 
 get_playbackrate_selectoptions ($v)
 
 error_message_with_hide ($msg, $noback)
 
 errorbutton ($msg)
 
 remove_soft_hyphens ($str)
 
 limitlength ($s, $l)
 
 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)
 
 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_paging_selectoptions ($currentpage, $pages)
 
 get_wordssort_selectoptions ($v)
 
 get_tagsort_selectoptions ($v)
 
 get_textssort_selectoptions ($v)
 
 get_yesno_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)
 
 textwordcount ($textID)
 
 texttodocount ($text)
 
 texttodocount2 ($textid)
 
 getSentence ($seid, $wordlc, $mode)
 
 get20Sentences ($lang, $wordlc, $wid, $jsctlname, $mode)
 
 areUnknownWordsInSentence ($sentno)
 
 get_languages ()
 
 getLanguage ($lid)
 
 getScriptDirectionTag ($lid)
 
 insertExpressionFromMeCab ($textlc, $lid, $wid, $len, $mode)
 
 new_expression_interactable ($hex, $appendtext, $sid, $len)
 
 insertExpressions ($textlc, $lid, $wid, $len, $mode)
 
 restore_file ($handle, $title)
 
 recreate_save_ann ($textid, $oldann)
 
 create_ann ($textid)
 
 insert_prefix_in_sql ($sql_line)
 
 create_save_ann ($textid)
 
 process_term ($nonterm, $term, $trans, $wordid, $line)
 
 get_first_translation ($trans)
 
 get_annotation_link ($textid)
 
 trim_value (&$value)
 
 refreshText ($word, $tid)
 
 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.

Function Documentation

◆ anki_export()

anki_export (   $sql)
Returns
never

◆ createTheDictLink()

createTheDictLink (   $u,
  $t 
)

Create and verify a dictionary URL link

Parameters
string$uDictionary URL. It may contain ### that will get parsed
string$tText that substite the ###
Returns
string Dictionary link formatted

◆ echo_lwt_logo()

echo_lwt_logo ( )

Return an HTML formatted logo of the application.

@global string $tbpref Table name prefix (optional)

◆ 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

◆ 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
' checked="checked" '|'' if value is true

◆ 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, string>

◆ get_last_key()

get_last_key ( )

Return the last inserted ID in the database

Returns
string|null

◆ get_links_from_new_feed()

get_links_from_new_feed (   $NfSourceURI)
Returns
((false|mixed|null|string)[]|null|string)[]|false

@psalm-return array<'feed_text'|'feed_title'|int, array{title: null|string, desc: null|string, link: string, encoded?: false|string, description?: false|string, content?: false|string, text?: mixed}|null|string>|false

◆ get_links_from_rss()

get_links_from_rss (   $NfSourceURI,
  $NfArticleSection 
)
Returns
(false|null|string)[][]|false

@psalm-return false|list<array{title: null|string, desc: null|string, link: string, date: string, text?: false|string, audio: 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
''|' selected="selected" ' Depending if inputs are equal

◆ get_tags()

get_tags (   $refresh = 0)

Return the list of all tags.

Parameters
int$refreshIf true, refresh all tags for session

@global string $tbpref Table name prefix

Returns
list<string> All tags

◆ get_text_from_rsslink()

get_text_from_rsslink (   $feed_data,
  $NfArticleSection,
  $NfFilterTags,
  $NfCharset = null 
)

@psalm-suppress NullIterator

◆ get_texttags()

get_texttags (   $refresh = 0)

Return the list of all text tags.

Parameters
int$refreshIf true, refresh all text tags for session

@global string $tbpref Table name prefix

Returns
list<string> All text tags

◆ getLanguage()

getLanguage (   $lid)

Get language name from its ID

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

◆ getprefixes()

getprefixes ( )

Return all different database prefixes that are in use.

Returns
(false|string)[] A list of prefixes.

@psalm-return list<false|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.

◆ getSentence()

getSentence (   $seid,
  $wordlc,
  $mode 
)
Returns
array{0: string, 1: string} [0]=html, word in bold, [1]=text, word in {}

◆ insertExpressionFromMeCab()

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

Insert an expression to the database using MeCab.

Parameters
string$textlc
string$lidLanguage ID
string$widWord ID
int$mode

@global string $tbpref Table name prefix

Returns
void

◆ insertExpressions()

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

Alter the database when to add a new word

Parameters
string$textlc
string$lidLanguage ID
string$len
int$modeFunction mode
  • 0: Default mode, do nothing special
  • 1: Runs an expresion inserter interactable
  • 2: Return the sql output @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

◆ 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

◆ new_expression_interactable()

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

Prepare a JavaScript dialog to insert a new expression

◆ 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;

@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

◆ 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

◆ 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.

◆ saveArchivedTextTags()

saveArchivedTextTags (   $tid)

Save the tags for archived texts.

Returns
void

◆ saveTextTags()

saveTextTags (   $tid)

Save the tags for texts.

Returns
void

◆ saveWordTags()

saveWordTags (   $wid)

Save the tags for words.

Returns
void

◆ selectmediapath()

selectmediapath (   $f)

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

Parameters
string$fPrevious media file URI
Returns
string HTML-formatted string for media selection

◆ selectmediapathoptions()

selectmediapathoptions (   $dir)

Get the dirrent options to dsplay as acceptable media files.

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

◆ 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)

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

Parameters
string | int$textidText ID
Returns
string HTML result

@global string $tbpref Table prefix

◆ textwordcount()

textwordcount (   $textID)

Compute and echo word statistics about a specific 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$textIDidentifier for this text

@global string $tbpref Table name prefix

◆ trim_value()

trim_value ( $value)

Like trim, but in place (modify variable)

Parameters
string$valueValue to be trimmed

◆ tsv_export()

tsv_export (   $sql)
Returns
never