本文整理汇总了PHP中textlib_get_instance函数的典型用法代码示例。如果您正苦于以下问题:PHP textlib_get_instance函数的具体用法?PHP textlib_get_instance怎么用?PHP textlib_get_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了textlib_get_instance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
function validation($data, $files)
{
global $COURSE, $CFG;
$errors = parent::validation($data, $files);
$textlib = textlib_get_instance();
$name = trim(stripslashes($data['name']));
if ($data['id'] and $group = get_record('groups', '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->enrol_manual_usepasswordpolicy) 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;
}
示例2: definition
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', 'admin'), $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');
}
}
$textlib = textlib_get_instance();
$choices = $textlib->get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'admin'), $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', 'admin'), $choices);
$mform->setType('previewrows', PARAM_INT);
$choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'admin'), UU_ADDINC => get_string('uuoptype_addinc', 'admin'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'admin'), UU_UPDATE => get_string('uuoptype_update', 'admin'));
$mform->addElement('select', 'uutype', get_string('uuoptype', 'admin'), $choices);
$this->add_action_buttons(false, get_string('uploadusers', 'admin'));
}
示例3: sort_ignore_case
private static function sort_ignore_case($a, $b)
{
$tl = textlib_get_instance();
$alower = $tl->strtolower($a);
$blower = $tl->strtolower($b);
return $alower > $blower ? 1 : $alower < $blower ? -1 : 0;
}
示例4: my_link_sort
function my_link_sort($a, $b)
{
$tl = textlib_get_instance();
$a = $tl->strtolower(substr($a->link, strpos($a->link, '>') + 1));
$b = $tl->strtolower(substr($b->link, strpos($b->link, '>') + 1));
return strcmp($a, $b);
}
示例5: test_format_text_email
function test_format_text_email()
{
$this->assertEqual('This is a test', format_text_email('<p>This is a <strong>test</strong></p>', FORMAT_HTML));
$this->assertEqual('This is a test', format_text_email('<p class="frogs">This is a <strong class=\'fishes\'>test</strong></p>', FORMAT_HTML));
$this->assertEqual('& so is this', format_text_email('<p>& so is this</p>', FORMAT_HTML));
$tl = textlib_get_instance();
$this->assertEqual('Two bullets: ' . $tl->code2utf8(8226) . ' ' . $tl->code2utf8(8226), format_text_email('<p>Two bullets: • •</p>', FORMAT_HTML));
$this->assertEqual($tl->code2utf8(0x7fd2) . $tl->code2utf8(0x7fd2), format_text_email('<p>習習</p>', FORMAT_HTML));
}
示例6: csv_quote
function csv_quote($value) {
global $excel;
if($excel) {
$tl=textlib_get_instance();
return $tl->convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE');
} else {
return '"'.str_replace('"',"'",$value).'"';
}
}
示例7: format_title
public function format_title($title, $max = 64)
{
$textlib = textlib_get_instance();
if ($textlib->strlen($title) <= $max) {
return s($title);
} else {
return s($textlib->substr($title, 0, $max - 3) . '...');
}
}
示例8: quote
/**
* Gets quoted csv variable string.
*
* @param string $varstr csv variable string
* @return quoted csv variable string
*/
public function quote($varstr)
{
if ($this->_excelcsv) {
$tl = textlib_get_instance();
return $tl->convert('"' . str_replace('"', "'", $varstr) . '"', 'UTF-8', 'UTF-16LE');
} else {
return '"' . str_replace('"', "'", $varstr) . '"';
}
}
示例9: game_cross_continue
function game_cross_continue($id, $game, $attempt, $cross, $g = '', $endofgame = '')
{
if ($endofgame) {
if ($g == '') {
game_updateattempts($game, $attempt, -1, true);
$endofgame = false;
}
}
if ($attempt != false and $cross != false) {
return game_cross_play($id, $game, $attempt, $cross, $g, false, false, $endofgame, false, false, false, false);
}
if ($attempt == false) {
$attempt = game_addattempt($game);
}
$textlib = textlib_get_instance();
$cross = new CrossDB();
$questions = array();
$infos = array();
$answers = array();
$recs = game_questions_shortanswer($game);
if ($recs == false) {
error('game_cross_continue: ' . get_string('cross_nowords', 'game'));
}
$infos = 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);
}
$cross->setwords($answers, $game->param1);
if ($cross->computedata($crossm, $crossd, $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->save($game, $crossm, $new_crossd, $attempt->id);
game_updateattempts($game, $attempt, 0, 0);
return game_cross_play($id, $game, $attempt, $crossm, '', false, false, false, false, false, false, false);
}
if (count($crossd) == 0) {
error('game_cross_continue: ' . get_string('cross_nowords', 'game'));
}
}
示例10: get_label_name
/**
* @uses LABEL_MAX_NAME_LENGTH
* @param object $label
* @return string
*/
function get_label_name($label)
{
$textlib = textlib_get_instance();
$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;
}
示例11: EncodeHeader
/**
* Use internal moodles own textlib to encode mimeheaders.
* Fall back to phpmailers inbuilt functions if not
*/
public function EncodeHeader($str, $position = 'text')
{
$textlib = textlib_get_instance();
$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);
}
示例12: get_ezproxy_name
function get_ezproxy_name($ezproxy)
{
$textlib = textlib_get_instance();
//$name = addslashes(strip_tags(format_string(stripslashes($ezproxy->name),true)));
$name = addslashes(strip_tags(format_string(stripslashes($ezproxy->name), true)));
if ($textlib->strlen($name) > EZPROXY_MAX_NAME_LENGTH) {
$name = $textlib->substr($name, 0, EZPROXY_MAX_NAME_LENGTH) . "...";
}
if (empty($name)) {
// arbitrary name
$name = get_string('modulename', 'ezproxy');
}
return $name;
}
示例13: accordion_update_instance
function accordion_update_instance($accordion)
{
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
$textlib = textlib_get_instance();
$accordion->name = addslashes(strip_tags(format_string(stripslashes($accordion->content), true)));
$accordion->title = addslashes(strip_tags(format_string(stripslashes($accordion->title), true)));
if ($textlib->strlen($accordion->name) > ACCORDION_MAX_NAME_LENGTH) {
$accordion->name = $textlib->substr($accordion->name, 0, ACCORDION_MAX_NAME_LENGTH) . "...";
}
$accordion->timemodified = time();
$accordion->id = $accordion->instance;
return update_record("accordion", $accordion);
}
示例14: game_cross_new
function game_cross_new($game, $attemptid, &$crossm)
{
global $DB, $USER;
$textlib = textlib_get_instance();
$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] = $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);
if ($cross->computedata($crossm, $crossd, $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->save($game, $crossm, $new_crossd, $attemptid);
}
if (count($crossd) == 0) {
print_error('game_cross_continue: ' . get_string('no_words', 'game'));
}
}
示例15: output
function output()
{
global $CFG;
$stradd = get_string('add');
$manualform = '<input type="text" name="tag" /><input type="submit" value="' . $stradd . '" />';
$manualform = $this->enclose_in_form($manualform);
$iptcform = '';
$deleteform = '';
$tags = array();
if ($tagrecords = get_records_select('lightboxgallery_image_meta', $this->sql_select(), 'description', 'id,description')) {
$errorlevel = error_reporting(E_PARSE);
$textlib = textlib_get_instance();
foreach ($tagrecords as $tagrecord) {
$tags[$tagrecord->id] = $tagrecord->description;
//$textlib->typo3cs->utf8_decode($tagrecord->description, 'iso-8859-1');
}
error_reporting($errorlevel);
}
$path = $CFG->dataroot . '/' . $this->gallery->course . '/' . $this->gallery->folder . '/' . $this->image;
$size = getimagesize($path, $info);
if (isset($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (isset($iptc['2#025'])) {
$iptcform = '<input type="hidden" name="iptc" value="1" />';
sort($iptc['2#025']);
foreach ($iptc['2#025'] as $tag) {
$tag = strtolower($tag);
$exists = $tags && in_array($tag, array_values($tags));
//eric 將 htmlentities($tag); 改為htmlentities($tag,ENT_QUOTES,'UTF-8')
$tag = htmlentities($tag, ENT_QUOTES, 'UTF-8');
$iptcform .= '<label ' . ($exists ? 'class="tag-exists"' : '') . '><input type="checkbox" name="iptctags[]" value="' . $tag . '" />' . $tag . '</label><br />';
}
$iptcform .= '<input type="submit" value="' . $stradd . '" />';
$iptcform = '<span class="tag-head"> ' . get_string('tagsiptc', 'lightboxgallery') . '</span>' . $this->enclose_in_form($iptcform);
}
}
$iptcform .= print_single_button($CFG->wwwroot . '/mod/lightboxgallery/edit/tag/import.php', array('id' => $this->gallery->id), get_string('tagsimport', 'lightboxgallery'), 'post', '_self', true);
if ($tags) {
$deleteform = '<input type="hidden" name="delete" value="1" />';
foreach ($tags as $tagid => $tagname) {
//eric 將 htmlentities($tagname) 改為 htmlentities($tagname, ENT_QUOTES,'UTF-8')
$deleteform .= '<label><input type="checkbox" name="deletetags[]" value="' . $tagid . '" />' . htmlentities($tagname, ENT_QUOTES, 'UTF-8') . '</label><br />';
}
$deleteform .= '<input type="submit" value="' . get_string('remove') . '" />';
$deleteform = '<span class="tag-head"> ' . get_string('tagscurrent', 'lightboxgallery') . '</span>' . $this->enclose_in_form($deleteform);
}
return $manualform . $iptcform . $deleteform;
}