本文整理汇总了PHP中csv_import_reader类的典型用法代码示例。如果您正苦于以下问题:PHP csv_import_reader类的具体用法?PHP csv_import_reader怎么用?PHP csv_import_reader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了csv_import_reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
/**
* The standard form definiton.
*/
public function definition()
{
$mform = $this->_form;
$selectedfields = $this->_customdata['selectedfields'];
$overrides = $this->_customdata['overrides'];
$fields = tool_downloaddata_processor::get_valid_course_fields();
if (empty($selectedfields)) {
$selectedfields = array(get_string('noselectedfields', 'tool_downloaddata'));
}
$mform->addElement('header', 'generalhdr', get_string('downloadcourses', 'tool_downloaddata'));
$formatchoices = array(tool_downloaddata_processor::FORMAT_CSV => get_string('formatcsv', 'tool_downloaddata'), tool_downloaddata_processor::FORMAT_XLS => get_string('formatxls', 'tool_downloaddata'));
$mform->addElement('select', 'format', get_string('format', 'tool_downloaddata'), $formatchoices);
$mform->setDefault('format', $this->_customdata['format']);
$encodings = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_downloaddata'), $encodings);
$mform->setDefault('encoding', $this->_customdata['encoding']);
$mform->disabledIf('encoding', 'format', 'noteq', tool_downloaddata_processor::FORMAT_CSV);
$delimiters = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_downloaddata'), $delimiters);
$mform->setDefault('delimiter_name', $this->_customdata['delimiter_name']);
$mform->disabledIf('delimiter_name', 'format', 'noteq', tool_downloaddata_processor::FORMAT_CSV);
$useoverrides = array('true' => 'Yes', 'false' => 'No');
$mform->addElement('select', 'useoverrides', get_string('useoverrides', 'tool_downloaddata'), $useoverrides);
$mform->setDefault('useoverrides', $this->_customdata['useoverrides']);
$mform->addHelpButton('useoverrides', 'useoverrides', 'tool_downloaddata');
$sortbycategorypath = array('true' => 'Yes', 'false' => 'No');
$mform->addElement('select', 'sortbycategorypath', get_string('sortbycategorypath', 'tool_downloaddata'), $sortbycategorypath);
$mform->setDefault('sortbycategorypath', $this->_customdata['sortbycategorypath']);
$mform->addHelpButton('sortbycategorypath', 'sortbycategorypath', 'tool_downloaddata');
$mform->addElement('header', 'fieldshdr', get_string('fields', 'tool_downloaddata'));
$mform->setExpanded('fieldshdr', true);
// Creating the field selection elements.
$objs = array();
$objs[0] = $mform->createElement('select', 'availablefields', get_string('available', 'tool_downloaddata'), $fields, 'size="10"');
$objs[0]->setMultiple(true);
$objs[1] = $mform->createElement('select', 'selectedfields', get_string('selected', 'tool_downloaddata'), $selectedfields, 'size="10"');
$objs[1]->setMultiple(true);
$group = $mform->addElement('group', 'fieldsgroup', get_string('fields', 'tool_downloaddata'), $objs, ' ', false);
$mform->addHelpButton('fieldsgroup', 'fields', 'tool_downloaddata');
// Creating the buttons for the field selection elements.
$objs = array();
$objs[] = $mform->createElement('submit', 'addfieldselection', get_string('addfieldselection', 'tool_downloaddata'));
$objs[] = $mform->createElement('submit', 'removefieldselection', get_string('removefieldselection', 'tool_downloaddata'));
$objs[] = $mform->createElement('submit', 'addallfields', get_string('addallfields', 'tool_downloaddata'));
$objs[] = $mform->createElement('submit', 'removeallfields', get_string('removeallfields', 'tool_downloaddata'));
$group = $mform->addElement('group', 'buttonsgroup', '', $objs, array(' ', '<br/>'), false);
$mform->addElement('header', 'overrideshdr', get_string('overrides', 'tool_downloaddata'));
$mform->addElement('textarea', 'overrides', get_string('overrides', 'tool_downloaddata'), 'wrap="virtual" rows="3" cols="45"');
$mform->setType('overrides', PARAM_RAW);
$mform->setDefault('overrides', $overrides);
$mform->addHelpButton('overrides', 'overrides', 'tool_downloaddata');
if (empty($overrides)) {
$mform->setExpanded('overrideshdr', false);
} else {
$mform->setExpanded('overrideshdr', true);
}
$this->add_action_buttons(false, get_string('download', 'tool_downloaddata'));
$template = '<label class="qflabel" style="vertical-align:top">{label}</label> {element}';
$mform->defaultRenderer()->setGroupElementTemplate($template, 'fieldsgroup');
}
示例2: definition_expimp_settings
/**
*
*/
protected function definition_expimp_settings()
{
$mform =& $this->_form;
$mform->addElement('header', 'expimpsettingshdr', get_string('expimpsettings', 'dataformview_csv'));
// Enable import (param4).
$mform->addElement('advcheckbox', 'param4', get_string('export', 'grades'), get_string('enable'), null, array(0, 1));
$mform->setDefault('param4', 1);
// Enable import (param4).
$mform->addElement('advcheckbox', 'param5', get_string('import'), get_string('enable'), null, array(0, 1));
$mform->setDefault('param5', 1);
// Allow update existing entries (param4)
// $mform->addElement('advcheckbox', 'updateexisting', null, get_string('allowupdateexisting', 'dataformview_csv'), null, array(0, 1));
// $mform->disabledIf('updateexisting', 'importenable', 'eq', 0);.
// Delimiter.
$delimiters = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter', get_string('csvdelimiter', 'dataform'), $delimiters);
$mform->setDefault('delimiter', 'comma');
// Enclosure.
$mform->addElement('text', 'enclosure', get_string('csvenclosure', 'dataform'), array('size' => '10'));
$mform->setType('enclosure', PARAM_NOTAGS);
$mform->setDefault('enclosure', '');
// Encoding.
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $choices);
$mform->setDefault('encoding', 'UTF-8');
}
示例3: definition
/**
* The form's definition.
*/
public function definition()
{
$mform =& $this->_form;
$data = $this->_customdata;
$mform->addElement('hidden', 'action', 'upload_group_data');
$mform->setType('action', PARAM_ALPHA);
$mform->addElement('hidden', 'id', $data['id']);
$mform->setType('id', PARAM_INT);
$mform->addElement('html', get_string('upload_help', 'block_upload_group'));
$mform->addElement('header', 'upload_group_data', get_string('upload_group_data', 'block_upload_group'));
// Add a file manager.
$mform->addElement('filepicker', 'group_data', '');
// Add the encoding option.
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'block_upload_group'), $choices);
$mform->setDefault('encoding', 'UTF-8');
// Add the delimiter option.
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter', get_string('delimiter', 'block_upload_group'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
$mform->addElement('select', 'preview_num', get_string('row_preview_num', 'block_upload_group'), $choices);
$mform->setType('preview_num', PARAM_INT);
$this->add_action_buttons(true, get_string('submit_group_data', 'block_upload_group'));
}
示例4: definition
/**
* Defines the form, which will have:
* - Input for courses csv.
* - Input for users csv.
* - Input for logs csv.
* - Select for csv delimiter.
* - Select for files encoding.
*/
public function definition()
{
$mform = $this->_form;
$mform->addElement('header', 'settingsheader', get_string('upload', 'block_mycourse_recommendations'));
$mform->addElement('static', 'description', '', get_string('upload_desc', 'block_mycourse_recommendations'));
$mform->addElement('static', 'description', get_string('coursefile', 'block_mycourse_recommendations'), get_string('coursefile_desc', 'block_mycourse_recommendations'));
$mform->addElement('filepicker', 'courses', '');
$mform->addRule('courses', null, 'required');
$mform->addElement('static', 'description', get_string('usersfile', 'block_mycourse_recommendations'), get_string('usersfile_desc', 'block_mycourse_recommendations'));
$mform->addElement('filepicker', 'users', '');
$mform->addRule('users', null, 'required');
$mform->addElement('static', 'description', get_string('logsfile', 'block_mycourse_recommendations'), get_string('logsfile_desc', 'block_mycourse_recommendations'));
$mform->addElement('filepicker', 'logs', '');
$mform->addRule('logs', null, 'required');
$choices = \csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$choices = \core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$this->add_action_buttons(false, get_string('uploaddata', 'block_mycourse_recommendations'));
}
示例5: definition
public function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$mform->addElement('header', 'settingsheader', get_string('upload'));
$mform->addElement('filepicker', 'userfile', get_string('file'));
$mform->addRule('userfile', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$choices = textlib::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
$mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploaduser'), $choices);
$mform->setType('previewrows', PARAM_INT);
$choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'tool_uploaduser'), UU_ADDINC => get_string('uuoptype_addinc', 'tool_uploaduser'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'tool_uploaduser'), UU_UPDATE => get_string('uuoptype_update', 'tool_uploaduser'));
$mform->addElement('select', 'uutype', get_string('uuoptype', 'tool_uploaduser'), $choices);
$this->add_action_buttons(false, get_string('uploadusers', 'tool_uploaduser'));
}
示例6: definition
function definition() {
global $CFG;
$mform = & $this->_form;
$course = $this->_customdata['course'];
$context = $this->_customdata['context'];
// the upload manager is used directly in post precessing, moodleform::save_files() is not used yet
//$this->set_upload_manager(new upload_manager('attachment'));
$mform->addElement('header', 'general', ''); //fill in the data depending on page params
//later using set_data
$mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile'));
$mform->addRule('attachment', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$choices = textlib::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$roles = get_assignable_roles($context);
$mform->addElement('select', 'roleassign', get_string('roleassign', 'local_mass_enroll'), $roles);
$mform->setDefault('roleassign', 5); //student
$ids = array (
'idnumber' => get_string('idnumber', 'local_mass_enroll'),
'username' => get_string('username', 'local_mass_enroll'),
'email' => get_string('email')
);
$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids);
$mform->setDefault('firstcolumn', 'idnumber');
$mform->addElement('selectyesno', 'creategroups', get_string('creategroups', 'local_mass_enroll'));
$mform->setDefault('creategroups', 1);
$mform->addElement('selectyesno', 'creategroupings', get_string('creategroupings', 'local_mass_enroll'));
$mform->setDefault('creategroupings', 1);
$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
$mform->setDefault('mailreport', 1);
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons(true, get_string('enroll', 'local_mass_enroll'));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
}
示例7: definition
function definition()
{
global $DB, $CFG;
$mform = $this->_form;
$instance = $this->_customdata;
$cmid = $instance['cmid'];
// Course module id goes hidden as well
$mform->addElement('hidden', 'cmid', $cmid);
$mform->setType('cmid', PARAM_INT);
// Course module id goes hidden as well
$mform->addElement('hidden', 'upload', true);
$mform->setType('upload', PARAM_BOOL);
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'mod_emarking'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$mform->addHelpButton('delimiter_name', 'csvdelimiter', 'mod_emarking');
// Archivo de respuestas a procesar CSV
$mform->addElement('filepicker', 'answersfile', get_string('answersfile', 'mod_emarking'), null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 10, 'accepted_types' => array('.csv'), 'return_types' => FILE_INTERNAL));
$mform->addRule('answersfile', get_string('answersfileisrequired', 'mod_emarking'), 'required', null, 'client');
$mform->setType('answersfile', PARAM_FILE);
$mform->addHelpButton('answersfile', 'answersfile', 'mod_emarking');
$this->add_action_buttons(true, get_string('submit'));
}
示例8: definition
function definition()
{
$mform = $this->_form;
$mform->addElement('header', 'settingsheader', get_string('upload'));
$mform->addElement('filepicker', 'userfile', get_string('file'));
$mform->addRule('userfile', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
$mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploaduser'), $choices);
$mform->setType('previewrows', PARAM_INT);
$this->add_action_buttons(false, get_string('uploadusers', 'tool_uploaduser'));
}
示例9: definition
/**
* Form definition
*/
public function definition()
{
$mform =& $this->_form;
$course = $this->_customdata['course'];
$config = get_config('local_mass_enroll');
$mform->addElement('header', 'general', '');
// Fill in the data depending on page params.
// Later using set_data.
$mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile'));
$mform->addRule('attachment', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$choices = \core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$ids = array('idnumber' => get_string('idnumber', 'local_mass_enroll'), 'username' => get_string('username', 'local_mass_enroll'), 'email' => get_string('email'));
$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids);
$mform->setDefault('firstcolumn', 'idnumber');
$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
$mform->setDefault('mailreport', (int) $config->mailreportdefault);
// Buttons.
$this->add_action_buttons(true, get_string('unenroll', 'local_mass_enroll'));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
}
示例10: definition
function definition() {
global $CFG;
$mform =& $this->_form;
$mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
$choices = csv_import_reader::get_delimiter_list();
$key = array_search(';', $choices);
if (! $key === FALSE) {
// array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
unset($choices[$key]);
}
$typesarray = array();
$str = get_string('csvwithselecteddelimiter', 'data');
$typesarray[] = $mform->createElement('radio', 'exporttype', null, $str . ' ', 'csv');
$typesarray[] = $mform->createElement('select', 'delimiter_name', null, $choices);
//temporarily commenting out Excel export option. See MDL-19864
//$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
$mform->addGroup($typesarray, 'exportar', '', array(''), false);
$mform->addRule('exportar', null, 'required');
$mform->setDefault('exporttype', 'csv');
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
foreach($this->_datafields as $field) {
if($field->text_export_supported()) {
$html = '<div title="' . s($field->field->description) . '" ' .
'class="d-inline-block">' . $field->field->name . '</div>';
$name = ' (' . $field->name() . ')';
$mform->addElement('advcheckbox', 'field_' . $field->field->id, $html, $name, array('group' => 1));
$mform->setDefault('field_' . $field->field->id, 1);
} else {
$a = new stdClass();
$a->fieldtype = $field->name();
$str = get_string('unsupportedexport', 'data', $a);
$mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, $str);
}
}
$this->add_checkbox_controller(1, null, null, 1);
$context = context_module::instance($this->_cm->id);
if (has_capability('mod/data:exportuserinfo', $context)) {
$mform->addElement('checkbox', 'exportuser', get_string('includeuserdetails', 'data'));
}
$mform->addElement('checkbox', 'exporttime', get_string('includetime', 'data'));
if ($this->_data->approval) {
$mform->addElement('checkbox', 'exportapproval', get_string('includeapproval', 'data'));
}
$this->add_action_buttons(true, get_string('exportentries', 'data'));
}
示例11: csv_load
/**
* Load up the above text through the csv import.
*
* @param string $content Text to be imported into the gradebook.
* @return array All text separated by commas now in an array.
*/
protected function csv_load($content)
{
// Import the csv strings.
$this->iid = csv_import_reader::get_new_iid('grade');
$this->csvimport = new csv_import_reader($this->iid, 'grade');
$this->csvimport->load_csv_content($content, 'utf8', 'comma');
$this->columns = $this->csvimport->get_columns();
$this->csvimport->init();
while ($line = $this->csvimport->next()) {
$testarray[] = $line;
}
return $testarray;
}
示例12: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
$mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
$choices = csv_import_reader::get_delimiter_list();
$key = array_search(';', $choices);
if (!$key === FALSE) {
// array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
unset($choices[$key]);
}
$typesarray = array();
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv');
$typesarray[] =& MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices);
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
$mform->addGroup($typesarray, 'exportar', '', array(''), false);
$mform->addRule('exportar', null, 'required');
$mform->setDefault('exporttype', 'csv');
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
foreach ($this->_datafields as $field) {
if ($field->text_export_supported()) {
$mform->addElement('advcheckbox', 'field_' . $field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group' => 1));
$mform->setDefault('field_' . $field->field->id, 1);
} else {
$a = new object();
$a->fieldtype = $field->name();
$mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a));
}
}
$this->add_checkbox_controller(1, null, null, 1);
require_once $CFG->libdir . '/portfoliolib.php';
if (has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->_cm->id))) {
if ($portfoliooptions = portfolio_instance_select(portfolio_instances(), call_user_func(array('data_portfolio_caller', 'supported_formats')), 'data_portfolio_caller', '', true, true)) {
$mform->addElement('header', 'notice', get_string('portfolionotfile', 'data') . ':');
$portfoliooptions[0] = get_string('none');
ksort($portfoliooptions);
$mform->addElement('select', 'portfolio', get_string('portfolio', 'portfolio'), $portfoliooptions);
}
}
$this->add_action_buttons(true, get_string('exportdatabaserecords', 'data'));
}
示例13: validation
function validation($data, $files)
{
global $CFG;
$errors = array();
// Use csv importer from Moodle
$iid = csv_import_reader::get_new_iid('emarking-predefined-comments');
$reader = new csv_import_reader($iid, 'emarking-predefined-comments');
$content = $data['comments'];
$reader->load_csv_content($content, 'utf8', "tab");
// Validate columns, minimum number and first two to be userid and attemptid
if (count($reader->get_columns()) < 0) {
$errors['comments'] = get_string('onecolumnrequired', 'mod_emarking');
}
$reader->init();
$current = 0;
while ($line = $reader->next()) {
$current++;
}
if ($current < 1) {
$errors['comments'] = get_string('twolinesrequired', 'mod_emarking');
}
return $errors;
}
示例14: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
$mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
$choices = csv_import_reader::get_delimiter_list();
$key = array_search(';', $choices);
if (!$key === FALSE) {
// array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
unset($choices[$key]);
}
$typesarray = array();
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv');
$typesarray[] =& MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices);
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
$typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
$mform->addGroup($typesarray, 'exportar', '', array(''), false);
$mform->addRule('exportar', null, 'required');
$mform->setDefault('exporttype', 'csv');
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
}
$mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
foreach ($this->_datafields as $field) {
if ($field->text_export_supported()) {
$mform->addElement('advcheckbox', 'field_' . $field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group' => 1));
$mform->setDefault('field_' . $field->field->id, 1);
} else {
$a = new stdClass();
$a->fieldtype = $field->name();
$mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a));
}
}
$this->add_checkbox_controller(1, null, null, 1);
$this->add_action_buttons(true, get_string('exportentries', 'data'));
}
示例15: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
$cmid = $this->_customdata['id'];
$mform->addElement('filepicker', 'recordsfile', get_string('csvfile', 'data'));
$delimiters = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'fielddelimiter', get_string('fielddelimiter', 'data'), $delimiters);
$mform->setDefault('fielddelimiter', 'comma');
$mform->addElement('text', 'fieldenclosure', get_string('fieldenclosure', 'data'));
$textlib = textlib_get_instance();
$choices = $textlib->get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'admin'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$submit_string = get_string('submit');
// data id
$mform->addElement('hidden', 'd');
$mform->setType('d', PARAM_INT);
$this->add_action_buttons(false, $submit_string);
}