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

PHP core_text类代码示例

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

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



在下文中一共展示了core_text类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: validation

 /**
  * Form validation
  *
  * @param array $data
  * @param array $files
  * @return array $errors An array of validataion errors for the form.
  */
 function validation($data, $files)
 {
     global $COURSE, $DB;
     $errors = parent::validation($data, $files);
     $name = trim($data['name']);
     if (isset($data['idnumber'])) {
         $idnumber = trim($data['idnumber']);
     } else {
         $idnumber = '';
     }
     if ($data['id'] and $grouping = $DB->get_record('groupings', array('id' => $data['id']))) {
         if (core_text::strtolower($grouping->name) != core_text::strtolower($name)) {
             if (groups_get_grouping_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupingnameexists', 'group', $name);
             }
         }
         if (!empty($idnumber) && $grouping->idnumber != $idnumber) {
             if (groups_get_grouping_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             }
         }
     } else {
         if (groups_get_grouping_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupingnameexists', 'group', $name);
         } else {
             if (!empty($idnumber) && groups_get_grouping_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             }
         }
     }
     return $errors;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:39,代码来源:grouping_form.php


示例2: 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


示例3: validation

    function validation($data, $files) {
        global $DB, $CFG;
        $id = optional_param('id', -1, PARAM_INT);
        $errors = array();
        $errors = parent::validation($data, $files);
        if ($data['schoolid'] == 0) {
            $errors['schoolid'] = get_string('schoolrequired', 'local_collegestructure');
        }
        if ($data['id'] < 0) {
            $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
            $exam1 = core_text::strtolower($examtypes1->examtype);
            $exam2 = core_text::strtolower($data['examtype']);
            if ($exam1 == $exam2) {
                $errors['examtype'] = get_string('examexits', 'local_examtype');
            }
        }

        if ($data['id'] > 0) {
            $exists = $DB->get_field('local_examtypes', 'examtype', array('id' => $id));
            if (!($exists === $data['examtype'] )) {
                $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
                $exam1 = core_text::strtolower($examtypes1->examtype);
                $exam2 = core_text::strtolower($data['examtype']);
                if ($exam1 == $exam2) {
                    $errors['examtype'] = get_string('examexits', 'local_examtype');
                }
            }
        }
        return $errors;
    }
开发者ID:anilch,项目名称:Personel,代码行数:30,代码来源:edit_form.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: config_form_criteria

 /**
  * Add appropriate form elements to the criteria form
  *
  * @param stdClass $data details of overall criterion
  */
 public function config_form_criteria($data)
 {
     global $OUTPUT;
     $prefix = 'criteria-' . $this->id;
     if (count($data->criteria) > 2) {
         echo $OUTPUT->box_start();
         if (!empty($this->description)) {
             $badge = new badge($this->badgeid);
             echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
         }
         echo $OUTPUT->heading($this->get_title(), 2);
         $agg = $data->get_aggregation_methods();
         if (!$data->is_locked() && !$data->is_active()) {
             $editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id));
             $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action'));
             echo $OUTPUT->box($editaction, array('criteria-header'));
             $url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey()));
             echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null, null, array('aria-describedby' => 'overall'));
             echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall'));
         } else {
             echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix');
         }
         echo $OUTPUT->box_end();
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:award_criteria_overall.php


示例6: get_user_devices

 /**
  * Return the user devices for a specific app.
  *
  * @param string $appname the app name .
  * @param int $userid if empty take the current user.
  * @return array all the devices
  */
 public function get_user_devices($appname, $userid = null)
 {
     global $USER, $DB;
     if (empty($userid)) {
         $userid = $USER->id;
     }
     $devices = array();
     $params = array('appid' => $appname, 'userid' => $userid);
     // First, we look all the devices registered for this user in the Moodle core.
     // We are going to allow only ios devices (since these are the ones that supports PUSH notifications).
     $userdevices = $DB->get_records('user_devices', $params);
     foreach ($userdevices as $device) {
         if (core_text::strtolower($device->platform)) {
             // Check if the device is known by airnotifier.
             if (!($airnotifierdev = $DB->get_record('message_airnotifier_devices', array('userdeviceid' => $device->id)))) {
                 // We have to create the device token in airnotifier.
                 if (!$this->create_token($device->pushid)) {
                     continue;
                 }
                 $airnotifierdev = new stdClass();
                 $airnotifierdev->userdeviceid = $device->id;
                 $airnotifierdev->enable = 1;
                 $airnotifierdev->id = $DB->insert_record('message_airnotifier_devices', $airnotifierdev);
             }
             $device->id = $airnotifierdev->id;
             $device->enable = $airnotifierdev->enable;
             $devices[] = $device;
         }
     }
     return $devices;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:38,代码来源:manager.php


示例7: 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


示例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

 /**
  * Define this form - called by the parent constructor
  */
 public function definition()
 {
     global $COURSE, $USER;
     $mform = $this->_form;
     $params = $this->_customdata;
     $mform->addElement('header', 'uploadgrades', get_string('uploadgrades', 'assignfeedback_offline'));
     $fileoptions = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'csv', 'maxfiles' => 1, 'return_types' => FILE_INTERNAL);
     $mform->addElement('filepicker', 'gradesfile', get_string('uploadafile'), null, $fileoptions);
     $mform->addRule('gradesfile', get_string('uploadnofilefound'), 'required', null, 'client');
     $mform->addHelpButton('gradesfile', 'gradesfile', 'assignfeedback_offline');
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     $mform->addHelpButton('encoding', 'encoding', 'grades');
     $radio = array();
     $radio[] = $mform->createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
     $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
     $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcolon', 'grades'), 'colon');
     $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepsemicolon', 'grades'), 'semicolon');
     $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
     $mform->addHelpButton('separator', 'separator', 'grades');
     $mform->setDefault('separator', 'comma');
     $mform->addElement('checkbox', 'ignoremodified', '', get_string('ignoremodified', 'assignfeedback_offline'));
     $mform->addHelpButton('ignoremodified', 'ignoremodified', 'assignfeedback_offline');
     $mform->addElement('hidden', 'id', $params['cm']);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'action', 'viewpluginpage');
     $mform->setType('action', PARAM_ALPHA);
     $mform->addElement('hidden', 'pluginaction', 'uploadgrades');
     $mform->setType('pluginaction', PARAM_ALPHA);
     $mform->addElement('hidden', 'plugin', 'offline');
     $mform->setType('plugin', PARAM_PLUGIN);
     $mform->addElement('hidden', 'pluginsubtype', 'assignfeedback');
     $mform->setType('pluginsubtype', PARAM_PLUGIN);
     $this->add_action_buttons(true, get_string('uploadgrades', 'assignfeedback_offline'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:38,代码来源:uploadgradesform.php


示例11: col_name

 /**
  * Determine output for the name column.
  *
  * @param stdClass   $recording The recording row being worked on.
  * @return string    The output to display.
  */
 public function col_name($recording)
 {
     if (\core_text::strlen($recording->name) > 60) {
         return \core_text::substr($recording->name, 0, 55) . '&#8230;';
     }
     return $recording->name;
 }
开发者ID:collegemathieu,项目名称:moodle-mod_webexactivity,代码行数:13,代码来源:admin_recordings_table.php


示例12: 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


示例13: definition

 /**
  * Definition method.
  */
 public function definition()
 {
     global $COURSE;
     $mform = $this->_form;
     if (isset($this->_customdata)) {
         // Hardcoding plugin names here is hacky.
         $features = $this->_customdata;
     } else {
         $features = array();
     }
     // Course id needs to be passed for auth purposes.
     $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
     $mform->setType('id', PARAM_INT);
     $mform->addElement('header', 'general', get_string('pluginname', 'gradeimport_direct'));
     // Data upload from copy/paste.
     $mform->addElement('textarea', 'userdata', 'Data', array('rows' => 10, 'class' => 'gradeimport_data_area'));
     $mform->addRule('userdata', null, 'required');
     $mform->setType('userdata', PARAM_RAW);
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     if (!empty($features['verbosescales'])) {
         $options = array(1 => get_string('yes'), 0 => get_string('no'));
         $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options);
     }
     $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options);
     $mform->setType('previewrows', PARAM_INT);
     $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
     $mform->setType('groupid', PARAM_INT);
     $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
 }
开发者ID:jtibbetts,项目名称:moodle,代码行数:34,代码来源:import_form.php


示例14: iplookup_find_location

/**
 * Returns location information
 * @param string $ip
 * @return array
 */
function iplookup_find_location($ip)
{
    global $CFG;
    $info = array('city' => null, 'country' => null, 'longitude' => null, 'latitude' => null, 'error' => null, 'note' => '', 'title' => array());
    if (!empty($CFG->geoip2file) and file_exists($CFG->geoip2file)) {
        $reader = new GeoIp2\Database\Reader($CFG->geoip2file);
        $record = $reader->city($ip);
        if (empty($record)) {
            $info['error'] = get_string('iplookupfailed', 'error', $ip);
            return $info;
        }
        $info['city'] = core_text::convert($record->city->name, 'iso-8859-1', 'utf-8');
        $info['title'][] = $info['city'];
        $countrycode = $record->country->isoCode;
        $countries = get_string_manager()->get_list_of_countries(true);
        if (isset($countries[$countrycode])) {
            // Prefer our localized country names.
            $info['country'] = $countries[$countrycode];
        } else {
            $info['country'] = $record->country->names['en'];
        }
        $info['title'][] = $info['country'];
        $info['longitude'] = $record->location->longitude;
        $info['latitude'] = $record->location->latitude;
        $info['note'] = get_string('iplookupmaxmindnote', 'admin');
        return $info;
    } else {
        require_once $CFG->libdir . '/filelib.php';
        if (strpos($ip, ':') !== false) {
            // IPv6 is not supported by geoplugin.net.
            $info['error'] = get_string('invalidipformat', 'error');
            return $info;
        }
        $ipdata = download_file_content('http://www.geoplugin.net/json.gp?ip=' . $ip);
        if ($ipdata) {
            $ipdata = preg_replace('/^geoPlugin\\((.*)\\)\\s*$/s', '$1', $ipdata);
            $ipdata = json_decode($ipdata, true);
        }
        if (!is_array($ipdata)) {
            $info['error'] = get_string('cannotgeoplugin', 'error');
            return $info;
        }
        $info['latitude'] = (double) $ipdata['geoplugin_latitude'];
        $info['longitude'] = (double) $ipdata['geoplugin_longitude'];
        $info['city'] = s($ipdata['geoplugin_city']);
        $countrycode = $ipdata['geoplugin_countryCode'];
        $countries = get_string_manager()->get_list_of_countries(true);
        if (isset($countries[$countrycode])) {
            // prefer our localized country names
            $info['country'] = $countries[$countrycode];
        } else {
            $info['country'] = s($ipdata['geoplugin_countryName']);
        }
        $info['note'] = get_string('iplookupgeoplugin', 'admin');
        $info['title'][] = $info['city'];
        $info['title'][] = $info['country'];
        return $info;
    }
}
开发者ID:gabrielrosset,项目名称:moodle,代码行数:64,代码来源:lib.php


示例15: quote

 /**
  * Gets quoted csv variable string.
  *
  * @param string $varstr csv variable string
  * @return quoted csv variable string
  */
 public function quote($varstr)
 {
     if ($this->_excelcsv) {
         return core_text::convert('"' . str_replace('"', "'", $varstr) . '"', 'UTF-8', 'UTF-16LE');
     } else {
         return '"' . str_replace('"', "'", $varstr) . '"';
     }
 }
开发者ID:michaudg,项目名称:moodle-mod_ouwiki,代码行数:14,代码来源:csv_writer.php


示例16: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (empty($data['shorten']) and core_text::strlen($data['search']) < core_text::strlen($data['replace'])) {
         $errors['shorten'] = get_string('required');
     }
     return $errors;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:form.php


示例17: block_course_overview_update_myorder

/**
 * Sets user course sorting preference in course_overview block
 *
 * @param array $sortorder list of course ids
 */
function block_course_overview_update_myorder($sortorder)
{
    $value = implode(',', $sortorder);
    if (core_text::strlen($value) > 1333) {
        // The value won't fit into the user preference. Remove courses in the end of the list (mostly likely user won't even notice).
        $value = preg_replace('/,[\\d]*$/', '', core_text::substr($value, 0, 1334));
    }
    set_user_preference('course_overview_course_sortorder', $value);
}
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:locallib.php


示例18: csv_quote

function csv_quote($value)
{
    global $excel;
    if ($excel) {
        return core_text::convert('"' . str_replace('"', "'", $value) . '"', 'UTF-8', 'UTF-16LE');
    } else {
        return '"' . str_replace('"', "'", $value) . '"';
    }
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:9,代码来源:index.php


示例19: definition

 function definition()
 {
     global $COURSE;
     $mform =& $this->_form;
     if (isset($this->_customdata)) {
         // hardcoding plugin names here is hacky
         $features = $this->_customdata;
     } else {
         $features = array();
     }
     // course id needs to be passed for auth purposes
     $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
     $mform->setType('id', PARAM_INT);
     $mform->addElement('header', 'general', get_string('importfile', 'grades'));
     // Restrict the possible upload file types.
     if (!empty($features['acceptedtypes'])) {
         $acceptedtypes = $features['acceptedtypes'];
     } else {
         $acceptedtypes = '*';
     }
     // File upload.
     $mform->addElement('filepicker', 'userfile', get_string('file'), null, array('accepted_types' => $acceptedtypes));
     $mform->addRule('userfile', null, 'required');
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     $mform->addHelpButton('encoding', 'encoding', 'grades');
     if (!empty($features['includeseparator'])) {
         $radio = array();
         $radio[] = $mform->createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
         $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
         $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcolon', 'grades'), 'colon');
         $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepsemicolon', 'grades'), 'semicolon');
         $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
         $mform->addHelpButton('separator', 'separator', 'grades');
         $mform->setDefault('separator', 'comma');
     }
     if (!empty($features['verbosescales'])) {
         $options = array(1 => get_string('yes'), 0 => get_string('no'));
         $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options);
         $mform->addHelpButton('verbosescales', 'verbosescales', 'grades');
     }
     $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options);
     // TODO: localize
     $mform->addHelpButton('previewrows', 'rowpreviewnum', 'grades');
     $mform->setType('previewrows', PARAM_INT);
     $mform->addElement('checkbox', 'forceimport', get_string('forceimport', 'grades'));
     $mform->addHelpButton('forceimport', 'forceimport', 'grades');
     $mform->setDefault('forceimport', false);
     $mform->setType('forceimport', PARAM_BOOL);
     $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
     $mform->setType('groupid', PARAM_INT);
     $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:54,代码来源:grade_import_form.php


示例20: get_label_name

/**
 * @uses LABEL_MAX_NAME_LENGTH
 * @param object $label
 * @return string
 */
function get_label_name($label)
{
    $name = strip_tags(format_string($label->intro, true));
    if (core_text::strlen($name) > LABEL_MAX_NAME_LENGTH) {
        $name = core_text::substr($name, 0, LABEL_MAX_NAME_LENGTH) . "...";
    }
    if (empty($name)) {
        // arbitrary name
        $name = get_string('modulename', 'label');
    }
    return $name;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:17,代码来源:lib.php



注:本文中的core_text类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP core_user类代码示例发布时间:2022-05-23
下一篇:
PHP core_tag_tag类代码示例发布时间: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