• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP csv_import_reader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中csv_import_reader的典型用法代码示例。如果您正苦于以下问题:PHP csv_import_reader类的具体用法?PHP csv_import_reader怎么用?PHP csv_import_reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了csv_import_reader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
 }
开发者ID:alexandru-elisei,项目名称:moodle-tool_downloaddata,代码行数:63,代码来源:courses_form.php


示例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');
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:29,代码来源:form.php


示例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'));
 }
开发者ID:at-tools,项目名称:moodle-block_uploadgroups,代码行数:36,代码来源:forms.php


示例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'));
 }
开发者ID:julenpardo,项目名称:moodle-block_mycourse_recommendations,代码行数:38,代码来源:import_form.php


示例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'));
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:28,代码来源:uploaduser_form.php


示例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);
	}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:60,代码来源:mass_enroll_form.php


示例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'));
 }
开发者ID:hansnok,项目名称:emarking,代码行数:31,代码来源:upload_answers_form.php


示例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'));
 }
开发者ID:janeklb,项目名称:moodle,代码行数:25,代码来源:user_form.php


示例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);
 }
开发者ID:rogiervandongen,项目名称:moodle-local_mass_enroll,代码行数:37,代码来源:mass_unenroll_form.php


示例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 . '&nbsp;', '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'));
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:53,代码来源:export_form.php


示例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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:load_data_test.php


示例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') . '&nbsp;', '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'));
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:51,代码来源:export_form.php


示例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;
 }
开发者ID:eduagdo,项目名称:emarking,代码行数:23,代码来源:predefined_comments_form.php


示例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') . '&nbsp;', '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'));
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:42,代码来源:export_form.php


示例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);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:20,代码来源:import_form.php


示例16: execute

 public function execute()
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/csvlib.class.php';
     require_once $CFG->libdir . '/moodlelib.php';
     $csvfilepath = $this->arguments[0];
     if ($csvfilepath[0] != '/') {
         $csvfilepath = $this->cwd . DIRECTORY_SEPARATOR . $csvfilepath;
     }
     $iid = \csv_import_reader::get_new_iid('userprofile');
     $type = 'userprofile';
     $csvreader = new \csv_import_reader($iid, $type);
     if (false === ($csvfile = file_get_contents($csvfilepath))) {
         cli_error('Unable to load csv file. ' . error_get_last()['message']);
     }
     if (!$csvreader->load_csv_content($csvfile, 'utf-8', 'comma')) {
         cli_error('Unalbe to parse csv file. ' . $csvreader->get_error());
     }
     if (!$csvreader->init()) {
         cli_error('Unable to initialise csv reading');
     }
     $columns = $csvreader->get_columns();
     $columnsids = array_flip($columns);
     while (false !== ($row = $csvreader->next())) {
         $category = $this->get_or_create_category($row[$columnsids['categoryname']], $row[$columnsids['categorysortorder']]);
         $userfield = new \stdClass();
         $userfield->shortname = $row[$columnsids['shortname']];
         $userfield->name = $row[$columnsids['name']];
         $userfield->datatype = $row[$columnsids['datatype']];
         $userfield->description = $row[$columnsids['description']];
         $userfield->descriptionformat = $row[$columnsids['descriptionformat']];
         $userfield->categoryid = $category->id;
         $userfield->sortorder = $row[$columnsids['sortorder']];
         $userfield->required = $row[$columnsids['required']];
         $userfield->locked = $row[$columnsids['locked']];
         $userfield->visible = $row[$columnsids['visible']];
         $userfield->forceunique = $row[$columnsids['forceunique']];
         $userfield->signup = $row[$columnsids['signup']];
         $userfield->defaultdata = $row[$columnsids['defaultdata']];
         $userfield->defaultdataformat = $row[$columnsids['defaultdataformat']];
         $userfield->param1 = $row[$columnsids['param1']];
         $userfield->param2 = $row[$columnsids['param2']];
         $userfield->param3 = $row[$columnsids['param3']];
         $userfield->param4 = $row[$columnsids['param4']];
         $userfield->param5 = $row[$columnsids['param5']];
         $this->get_or_create_userfield($userfield);
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:48,代码来源:UserProfileFieldsImport.php


示例17: definition

	function definition() {
		global $CFG;
		$mform = & $this->_form;

		//$mform->addElement('header', 'general', get_string('bulkenrol','block_learning_plan')); //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');

         $mform->addElement('hidden','roleassign');
		$mform->setDefault('roleassign', 5); //student
		$mform->setType('roleassign','int');
		$ids = array (
			'username' => get_string('username', 'local_mass_enroll'),
			'idnumber' => get_string('idnumber', 'local_mass_enroll'),
			'email' => get_string('email')
		);
		$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'block_learning_plan'), $ids);
		$mform->setDefault('firstcolumn', 'username');

		//$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
		//$mform->setDefault('mailreport', 1);

		$this->add_action_buttons(true, get_string('enroll_lp', 'block_learning_plan'));
	}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:40,代码来源:bulk_enroll_form.php


示例18: load_csv_content

 /**
  * Load CSV content for previewing.
  *
  * @param string $text The grade data being imported.
  * @param string $encoding The type of encoding the file uses.
  * @param string $separator The separator being used to define each field.
  * @param int $previewrows How many rows are being previewed.
  */
 public function load_csv_content($text, $encoding, $separator, $previewrows)
 {
     $this->raise_limits();
     $this->iid = csv_import_reader::get_new_iid('grade');
     $csvimport = new csv_import_reader($this->iid, 'grade');
     $csvimport->load_csv_content($text, $encoding, $separator);
     $this->error = $csvimport->get_error();
     // Get header (field names).
     $this->headers = $csvimport->get_columns();
     $this->trim_headers();
     $csvimport->init();
     $this->previewdata = array();
     for ($numlines = 0; $numlines <= $previewrows; $numlines++) {
         $lines = $csvimport->next();
         if ($lines) {
             $this->previewdata[] = $lines;
         }
     }
 }
开发者ID:jtibbetts,项目名称:moodle,代码行数:27,代码来源:load_data.php


示例19: time

$today = time();
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
// array of all valid fields for validation
$STD_FIELDS = array('id', 'firstname', 'lastname', 'username', 'email', 'city', 'country', 'lang', 'timezone', 'mailformat', 'maildisplay', 'maildigest', 'htmleditor', 'ajax', 'autosubscribe', 'institution', 'department', 'idnumber', 'skype', 'msn', 'aim', 'yahoo', 'icq', 'phone1', 'phone2', 'address', 'url', 'description', 'descriptionformat', 'password', 'auth', 'oldusername', 'deleted');
$PRF_FIELDS = array();
if ($prof_fields = $DB->get_records('user_info_field')) {
    foreach ($prof_fields as $prof_field) {
        $PRF_FIELDS[] = 'profile_field_' . $prof_field->shortname;
    }
}
unset($prof_fields);
if (empty($iid)) {
    $mform1 = new admin_uploaduser_form1();
    if ($formdata = $mform1->get_data()) {
        $iid = csv_import_reader::get_new_iid('uploaduser');
        $cir = new csv_import_reader($iid, 'uploaduser');
        $content = $mform1->get_file_content('userfile');
        $readcount = $cir->load_csv_content($content, $formdata->encoding, $formdata->delimiter_name);
        unset($content);
        if ($readcount === false) {
            print_error('csvloaderror', '', $returnurl);
        } else {
            if ($readcount == 0) {
                print_error('csvemptyfile', 'error', $returnurl);
            }
        }
        // test if columns ok
        $filecolumns = uu_validate_user_upload_columns($cir, $STD_FIELDS, $PRF_FIELDS, $returnurl);
        // continue to form2
    } else {
        echo $OUTPUT->header();
开发者ID:richheath,项目名称:moodle,代码行数:31,代码来源:uploaduser.php


示例20: definition_csv_settings


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ctools_export_ui类代码示例发布时间:2022-05-23
下一篇:
PHP csv_export_writer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap