本文整理汇总了PHP中textlib_get_instance函数的典型用法代码示例。如果您正苦于以下问题:PHP textlib_get_instance函数的具体用法?PHP textlib_get_instance怎么用?PHP textlib_get_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了textlib_get_instance函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:26,代码来源:group_form.php
示例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'));
}
开发者ID:vuchannguyen,项目名称:web,代码行数:29,代码来源:uploaduser_form.php
示例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;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:7,代码来源:move_forum_feature.php
示例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);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:7,代码来源:subscribers.php
示例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));
}
开发者ID:r007,项目名称:PMoodle,代码行数:9,代码来源:testweblib.php
示例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).'"';
}
}
开发者ID:nuckey,项目名称:moodle,代码行数:9,代码来源:index.php
示例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) . '...');
}
}
开发者ID:rtsfc,项目名称:moodle-block_papercut,代码行数:9,代码来源:block_papercut.php
示例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) . '"';
}
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:15,代码来源:csv_writer.php
示例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'));
}
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:56,代码来源:play.php
示例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;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:18,代码来源:lib.php
示例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);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:17,代码来源:moodle_phpmailer.php
示例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;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:14,代码来源:lib.php
示例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);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:15,代码来源:lib.php
示例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'));
}
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:48,代码来源:play.php
示例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;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:48,代码来源:tag.class.php
示例16: setupPersonalStorage
/**
*
*/
function setupPersonalStorage()
{
global $CFG;
$textlib = textlib_get_instance();
// Finally, create the default user filesystem folder, if not available
$user = run('users:instance', array('user_id' => $this->owner));
$this->username = $user->getUserName();
$base_folder = $CFG->dataroot . 'files/' . $textlib->substr($this->username, 0, 1);
$personal_folder = $base_folder . "/" . $this->username;
if (!file_exists($base_folder)) {
mkdir($base_folder);
}
if (!file_exists($personal_folder)) {
mkdir($personal_folder);
}
}
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:19,代码来源:class_folder.php
示例17: get_content
function get_content()
{
global $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
$archetypes = array();
foreach ($modinfo->cms as $cm) {
// Exclude activities which are not visible or have no link (=label)
if (!$cm->uservisible or !$cm->has_view()) {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}
textlib_get_instance()->asort($modfullnames);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = '<img src="' . $OUTPUT->pix_url('f/html') . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/resources.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
} else {
$icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
}
}
return $this->content;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:46,代码来源:block_activity_modules.php
示例18: 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')) {
$textlib = textlib_get_instance();
$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:raymondAntonio,项目名称:moodle,代码行数:19,代码来源:locallib.php
示例19: test_asort
public function test_asort()
{
global $SESSION;
$SESSION->lang = 'en';
// make sure we test en language to get consistent results, hopefully all systems have this locale
$arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
textlib_get_instance()->asort($arr);
$this->assertIdentical(array_keys($arr), array(1, 'b', 0));
$this->assertIdentical(array_values($arr), array('aa', 'ab', 'cc'));
if (extension_loaded('intl')) {
$error = 'Collation aware sorting not supported';
} else {
$error = 'Collation aware sorting not supported, PHP extension "intl" is not available.';
}
$arr = array('a' => 'áb', 'b' => 'ab', 1 => 'aa', 0 => 'cc');
textlib_get_instance()->asort($arr);
$this->assertIdentical(array_keys($arr), array(1, 'b', 'a', 0), $error);
unset($SESSION->lang);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:19,代码来源:testtextlib.php
示例20: validation
function validation($data, $files)
{
global $COURSE;
$errors = parent::validation($data, $files);
$textlib = textlib_get_instance();
$name = trim(stripslashes($data['name']));
if ($data['id'] and $grouping = get_record('groupings', '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);
}
}
} else {
if (groups_get_grouping_by_name($COURSE->id, $name)) {
$errors['name'] = get_string('groupingnameexists', 'group', $name);
}
}
return $errors;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:19,代码来源:grouping_form.php
注:本文中的textlib_get_instance函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论