Skip to content

Libraries JSONImport

Jakub Jakubiec edited this page Feb 24, 2014 · 1 revision
Library Extends Path
JSONImport /application/libraries/JSONImport.php

This library handles nilai data import from JSON file.

Design goal is ability to process huge data sets regardless of their size. So instead of loading data into memory and parsing using json_decode, we're processing input file line by line wherever possible. For that the file needs to be properly formatted. For more details about format see JSON Export.

Methods

__construct - Public

Called automatically validates parameters passed to constructor (requires 'user_id' to be set for the user that imports the data).

Arguments

Variable Type Default Required Description
$params array N/A Yes Parameters to initialize library. Currently 'user_id' is required

importFile - Public

Import selected file to current Nilai install, by adding all missing marks, skipping existing ones. All marks get saved for the user specified by passing 'user_id' setting while initializing the library.

Arguments

Variable Type Default Required Description
$filePath string N/A Yes Path to the localy copy of the file to be imported

validateUpload - Public

Checks if uploaded file meets all required criteria - is not empty (size > 0 bytes), didn't finish in error and filetype is JSON.

Arguments

Variable Type Default Required Description
$uploadedFile array N/A Yes Uploaded file data from `$_FILES` PHP array