当前位置: 首页>>代码示例>>PHP>>正文


PHP textlib类代码示例

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


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

示例1: validation

 /**
  * Form validation
  *
  * @param array $data
  * @param array $files
  * @return array $errors An array of errors
  */
 function validation($data, $files)
 {
     global $COURSE, $DB, $CFG;
     $errors = parent::validation($data, $files);
     $name = trim($data['name']);
     if ($data['id'] and $group = $DB->get_record('groups', array('id' => $data['id']))) {
         if (textlib::strtolower($group->name) != textlib::strtolower($name)) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
         if (!empty($CFG->groupenrolmentkeypolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) {
             // enforce password policy only if changing password
             $errmsg = '';
             if (!check_password_policy($data['enrolmentkey'], $errmsg)) {
                 $errors['enrolmentkey'] = $errmsg;
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     return $errors;
 }
开发者ID:numbas,项目名称:moodle,代码行数:32,代码来源:group_form.php

示例2: 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', 'local_users'), $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', 'local_users'), $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', 'local_users'), $choices);
        $mform->setType('previewrows', PARAM_INT);

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

示例3: 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 (textlib::strtolower($grouping->name) != textlib::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:saurabh947,项目名称:MoodleLearning,代码行数:39,代码来源:grouping_form.php

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

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

示例6: csv_quote

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

示例7: definition

 function definition() {
     $mform =& $this->_form;
     $mform->addElement('file', 'userfile', get_string('csvtextfile', 'facetoface'));
     $mform->setType('userfile', PARAM_FILE);
     $mform->addRule('userfile', null, 'required');
     $encodings = textlib::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     $mform->addElement('checkbox', 'suppressemail', '', get_string('suppressemailforattendees', 'facetoface'));
 }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:9,代码来源:bulkadd_attendees.php

示例8: validate

 /**
  * Validates a value using a range comparison
  *
  * @param     string    $value      Value to be checked
  * @param     mixed     $options    Int for length, array for range
  * @access    public
  * @return    boolean   true if value is valid
  */
 function validate($value, $options = null)
 {
     $length = textlib::strlen($value);
     switch ($this->name) {
         case 'minlength':
             return $length >= $options;
         case 'maxlength':
             return $length <= $options;
         default:
             return $length >= $options[0] && $length <= $options[1];
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:20,代码来源:Range.php

示例9: EncodeHeader

 /**
  * Use internal moodles own textlib to encode mimeheaders.
  * Fall back to phpmailers inbuilt functions if not 
  */
 public function EncodeHeader($str, $position = 'text')
 {
     $encoded = textlib::encode_mimeheader($str, $this->CharSet);
     if ($encoded !== false) {
         $encoded = str_replace("\n", $this->LE, $encoded);
         if ($position == 'phrase') {
             return "\"{$encoded}\"";
         }
         return $encoded;
     }
     return parent::EncodeHeader($str, $position);
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:16,代码来源:moodle_phpmailer.php

示例10: 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 (textlib::strlen($name) > LABEL_MAX_NAME_LENGTH) {
        $name = textlib::substr($name, 0, LABEL_MAX_NAME_LENGTH)."...";
    }

    if (empty($name)) {
        // arbitrary name
        $name = get_string('modulename','label');
    }

    return $name;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:18,代码来源:lib.php

示例11: game_cross_new

function game_cross_new($game, $attemptid, &$crossm)
{
    global $DB, $USER;
    $cross = new CrossDB();
    $questions = array();
    $infos = array();
    $answers = array();
    $recs = game_questions_shortanswer($game);
    if ($recs == false) {
        print_error('game_cross_continue: ' . get_string('no_words', 'game'));
    }
    $infos = array();
    $reps = array();
    foreach ($recs as $rec) {
        if ($game->param7 == false) {
            if (textlib::strpos($rec->answertext, ' ')) {
                continue;
                //spaces not allowed
            }
        }
        $rec->answertext = game_upper($rec->answertext);
        $answers[$rec->answertext] = game_repairquestion($rec->questiontext);
        $infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
        $a = array('gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
        if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false) {
            $reps[$rec->answertext] = $rec2->r;
        }
    }
    $cross->setwords($answers, $game->param1, $reps);
    //game->param2 is maximum words in crossword
    if ($cross->computedata($crossm, $crossd, $lettets, $game->param2)) {
        $new_crossd = array();
        foreach ($crossd as $rec) {
            $info = $infos[$rec->answertext];
            if ($info != false) {
                $rec->sourcemodule = $info[0];
                $rec->questionid = $info[1];
                $rec->glossaryentryid = $info[2];
                $rec->attachment = $info[3];
            }
            $new_crossd[] = $rec;
        }
        $cross->savecross($game, $crossm, $new_crossd, $attemptid);
    }
    if (count($crossd) == 0) {
        print_error('game_cross_continue: ' . get_string('no_words', 'game'));
    }
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:48,代码来源:play.php

示例12: 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 = textlib::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     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->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);
     }
     $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options);
     // TODO: localize
     $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:masaterutakeno,项目名称:MoodleMobile,代码行数:46,代码来源:grade_import_form.php

示例13: validation

 public function validation($data, $files)
 {
     global $DB, $CFG;
     $errors = parent::validation($data, $files);
     $instance = $this->instance;
     if ($instance->password !== '') {
         if ($data['guestpassword'] !== $instance->password) {
             $plugin = enrol_get_plugin('guest');
             if ($plugin->get_config('showhint')) {
                 $hint = textlib::substr($instance->password, 0, 1);
                 $errors['guestpassword'] = get_string('passwordinvalidhint', 'enrol_guest', $hint);
             } else {
                 $errors['guestpassword'] = get_string('passwordinvalid', 'enrol_guest');
             }
         }
     }
     return $errors;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:18,代码来源:locallib.php

示例14: action

 protected function action($message, $level, $options = null)
 {
     $columns = $this->columns;
     if ($this->datecol) {
         $columns[$this->datecol] = time();
     }
     if ($this->levelcol) {
         $columns[$this->levelcol] = $level;
     }
     $message = clean_param($message, PARAM_NOTAGS);
     // Check if the message exceeds the 255 character limit in the database,
     // if it does, shorten it so that it can be inserted successfully.
     if (textlib::strlen($message) > 255) {
         $message = textlib::substr($message, 0, 252) . '...';
     }
     $columns[$this->messagecol] = $message;
     return $this->insert_log_record($this->logtable, $columns);
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:18,代码来源:database_logger.class.php

示例15: check_table

 protected function check_table(xmldb_table $xmldb_table, array $metacolumns)
 {
     global $DB;
     $o = '';
     $wrong_fields = array();
     // Get and process XMLDB fields
     if ($xmldb_fields = $xmldb_table->getFields()) {
         $o .= '<ul>';
         foreach ($xmldb_fields as $xmldb_field) {
             // Get the type of the column, we only will process CHAR (VARCHAR2) ones
             if ($xmldb_field->getType() != XMLDB_TYPE_CHAR) {
                 continue;
             }
             $o .= '<li>' . $this->str['field'] . ': ' . $xmldb_field->getName() . ' ';
             // Get current semantic from dictionary, we only will process B (BYTE) ones
             // suplying the SQL code to change them to C (CHAR) semantic
             $params = array('table_name' => textlib::strtoupper($DB->get_prefix() . $xmldb_table->getName()), 'column_name' => textlib::strtoupper($xmldb_field->getName()), 'data_type' => 'VARCHAR2');
             $currentsemantic = $DB->get_field_sql('
                 SELECT char_used
                   FROM user_tab_columns
                  WHERE table_name = :table_name
                    AND column_name = :column_name
                    AND data_type = :data_type', $params);
             // If using byte semantics, we'll need to change them to char semantics
             if ($currentsemantic == 'B') {
                 $info = '(' . $this->str['expected'] . " 'CHAR', " . $this->str['actual'] . " 'BYTE')";
                 $o .= '<font color="red">' . $this->str['wrong'] . " {$info}</font>";
                 // Add the wrong field to the list
                 $obj = new stdClass();
                 $obj->table = $xmldb_table;
                 $obj->field = $xmldb_field;
                 $wrong_fields[] = $obj;
             } else {
                 $o .= '<font color="green">' . $this->str['ok'] . '</font>';
             }
             $o .= '</li>';
         }
         $o .= '</ul>';
     }
     return array($o, $wrong_fields);
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:41,代码来源:check_oracle_semantics.class.php


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