Documentation

AnkiDeckImportController extends VocabularyBaseController
in package

Import a deck built in Anki as new LWT terms (issue #228).

Two steps, because LWT cannot guess any of the mapping: an .apkg carries no language, and field names in a shared deck are arbitrary.

GET /vocabulary/anki-deck/import upload form POST /vocabulary/anki-deck/import upload -> configure, or configure -> import

The uploaded file is parked in a temp path between the two steps, keyed by a token held in the session so the second request cannot be pointed at an arbitrary path.

Table of Contents

Constants

SESSION_KEY  : mixed = 'lwt_anki_deck_import'

Properties

$bulkService  : WordBulkService|null
$contextService  : WordContextService|null
$crudService  : WordCrudService|null
Lazy-loaded services.
$discoveryService  : WordDiscoveryService|null
$expressionService  : ExpressionService|null
$linkingService  : WordLinkingService|null
$multiWordService  : MultiWordService|null
$sentenceService  : SentenceService|null
$textStatisticsService  : TextStatisticsService|null
$uploadService  : WordUploadService|null
$viewPath  : string
View base path.
$importService  : AnkiDeckImportService|null
$languageFacade  : LanguageFacade
$reader  : ForeignApkgReader

Methods

__construct()  : mixed
Constructor.
index()  : void
setViewPath()  : void
Set custom view path.
getBulkService()  : WordBulkService
Get WordBulkService (lazy loaded).
getContextService()  : WordContextService
Get WordContextService (lazy loaded).
getCrudService()  : WordCrudService
Get WordCrudService (lazy loaded).
getDiscoveryService()  : WordDiscoveryService
Get WordDiscoveryService (lazy loaded).
getExpressionService()  : ExpressionService
Get ExpressionService (lazy loaded).
getLinkingService()  : WordLinkingService
Get WordLinkingService (lazy loaded).
getMultiWordService()  : MultiWordService
Get MultiWordService (lazy loaded).
getSentenceService()  : SentenceService
Get SentenceService (lazy loaded).
getTextStatisticsService()  : TextStatisticsService
Get TextStatisticsService (lazy loaded).
getUploadService()  : WordUploadService
Get WordUploadService (lazy loaded).
render()  : void
Render a view.
csrfField()  : string
esc()  : string
fieldSelect()  : string
forgetParkedFile()  : void
handleImport()  : void
Step 2: apply the chosen mapping.
handleUpload()  : void
Step 1: accept the upload, park it, show the mapping form.
importSvc()  : AnkiDeckImportService
optionalField()  : string|null
parkedFile()  : string|null
The parked upload for this session, if it is still there.
rememberParkedFile()  : void
renderMappingForm()  : void
renderSummary()  : void
renderUploadForm()  : void
statusLabel()  : string

Constants

Properties

Methods

index()

public index(array<string, string> $params) : void
Parameters
$params : array<string, string>

Route params (unused).

setViewPath()

Set custom view path.

public setViewPath(string $path) : void
Parameters
$path : string

View path

render()

Render a view.

protected render(string $view[, array<string|int, mixed> $data = [] ]) : void
Parameters
$view : string

View name (without .php)

$data : array<string|int, mixed> = []

View data

fieldSelect()

private fieldSelect(string $name, string $label, array<int, string> $fieldNames, bool $optional) : string
Parameters
$name : string
$label : string
$fieldNames : array<int, string>
$optional : bool
Return values
string

optionalField()

private optionalField(string $key) : string|null
Parameters
$key : string
Return values
string|null

parkedFile()

The parked upload for this session, if it is still there.

private parkedFile() : string|null

Reading the path from the session rather than the request is what stops step 2 being pointed at an arbitrary file on disk.

Return values
string|null

renderUploadForm()

private renderUploadForm(string|null $error) : void
Parameters
$error : string|null
On this page

Search results