本文整理汇总了PHP中core_text::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP core_text::strtolower方法的具体用法?PHP core_text::strtolower怎么用?PHP core_text::strtolower使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_text
的用法示例。
在下文中一共展示了core_text::strtolower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: definition
function definition()
{
global $DB;
$mform =& $this->_form;
$mform->addElement('hidden', 'username');
$mform->setType('username', PARAM_TEXT);
//doi/isbn
$select_list = array();
$books = $DB->get_records_sql('SELECT b.*, p.name as publisher FROM {rcommon_books} b JOIN {rcommon_publisher} p ON b.publisherid = p.id ORDER BY p.name, b.name ');
foreach ($books as $book) {
if (in_array(core_text::strtolower($book->format), rcommon_book::$allowedformats)) {
if (!isset($select_list[$book->publisher])) {
$select_list[$book->publisher] = array();
}
$select_list[$book->publisher][$book->isbn] = $book->name;
}
}
$mform->addElement('selectgroups', 'isbn', 'DOI / ISBN', $select_list);
$mform->addRule('isbn', null, 'required', null, 'client');
//key
$mform->addElement('text', 'credentials', get_string('key', 'local_rcommon'), array('maxlength' => 255, 'size' => 45));
$mform->setType('credentials', PARAM_TEXT);
$mform->addRule('credentials', null, 'required', null, 'client');
//buttons
$this->add_action_buttons();
}
示例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 (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;
}
示例4: 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;
}
示例5: definition
public function definition()
{
global $CFG;
$mform =& $this->_form;
// General options.
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size' => '48', 'maxlength' => '255'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
if ($CFG->branch < 29) {
$this->add_intro_editor(true, get_string('description'));
} else {
$this->standard_intro_elements();
}
// Advanced options.
$mform->addElement('header', 'galleryoptions', get_string('advanced'));
$mform->addElement('select', 'perpage', get_string('imagesperpage', 'lightboxgallery'), $this->get_perpage_options());
$mform->setType('perpage', PARAM_INTEGER);
$mform->addElement('select', 'perrow', get_string('imagesperrow', 'lightboxgallery'), $this->get_perrow_options());
$mform->setType('perrow', PARAM_INTEGER);
$yesno = array(0 => get_string('no'), 1 => get_string('yes'));
$mform->addElement('select', 'captionfull', get_string('captionfull', 'lightboxgallery'), $yesno);
$captionposopts = array('0' => get_string('position_bottom', 'lightboxgallery'), '1' => get_string('position_top', 'lightboxgallery'), '2' => get_string('hide'));
$mform->addElement('select', 'captionpos', get_string('captionpos', 'lightboxgallery'), $captionposopts);
$autoresizegroup = array();
$autoresizegroup[] =& $mform->createElement('select', 'autoresize', get_string('autoresize', 'lightboxgallery'), $this->get_autoresize_options());
$autoresizegroup[] =& $mform->createElement('checkbox', 'autoresizedisabled', null, get_string('disable'));
$mform->addGroup($autoresizegroup, 'autoresizegroup', get_string('autoresize', 'lightboxgallery'), ' ', false);
$mform->setType('autoresize', PARAM_INTEGER);
$mform->disabledIf('autoresizegroup', 'autoresizedisabled', 'checked');
$mform->addHelpButton('autoresizegroup', 'autoresize', 'lightboxgallery');
$mform->addElement('select', 'resize', sprintf('%s (%s)', get_string('edit_resize', 'lightboxgallery'), core_text::strtolower(get_string('upload'))), lightboxgallery_resize_options());
$mform->setType('resize', PARAM_INTEGER);
$mform->disabledIf('resize', 'autoresize', 'eq', 1);
$mform->disabledIf('resize', 'autoresizedisabled', 'checked');
$mform->addElement('select', 'comments', get_string('allowcomments', 'lightboxgallery'), $yesno);
$mform->setType('comments', PARAM_INTEGER);
$mform->addElement('select', 'ispublic', get_string('makepublic', 'lightboxgallery'), $yesno);
$mform->setType('ispublic', PARAM_INTEGER);
if (lightboxgallery_rss_enabled()) {
$mform->addElement('select', 'rss', get_string('allowrss', 'lightboxgallery'), $yesno);
$mform->setType('rss', PARAM_INTEGER);
} else {
$mform->addElement('static', 'rssdisabled', get_string('allowrss', 'lightboxgallery'), get_string('rssglobaldisabled', 'admin'));
}
$mform->addElement('select', 'extinfo', get_string('extendedinfo', 'lightboxgallery'), $yesno);
$mform->setType('extinfo', PARAM_INTEGER);
// Module options.
$features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
$this->standard_coursemodule_elements($features);
$this->add_action_buttons();
}
示例6: get_books_structure_publisher
function get_books_structure_publisher($publisher, $isbn = false)
{
global $OUTPUT;
set_time_limit(0);
$books = get_books($publisher);
try {
if (!empty($books)) {
// Fix bug, when there is just one received book
if (!is_array($books) || !isset($books[0])) {
$books = array($books);
}
echo '<ol>';
foreach ($books as $book) {
// Disable scorm import
$bookformat = core_text::strtolower($book['formato']);
if (!in_array($bookformat, rcommon_book::$allowedformats)) {
continue;
}
$codisbn = $book['isbn'];
// Si se ha especificado un isbn guarda el libro
if (!$isbn || $codisbn == $isbn) {
$message = 'ISBN: ' . $codisbn;
// Obtiene los datos del indice del libro
try {
$instance = new StdClass();
$instance->isbn = $codisbn;
$instance->name = $book['titulo'];
$instance->summary = $book['titulo'];
$instance->format = $bookformat;
$instance->levelid = isset($book['nivel']) ? $book['nivel'] : false;
$instance->publisherid = $publisher->id;
rcommon_book::add_update($instance);
get_book_structure($publisher, $codisbn);
echo '<li>' . $OUTPUT->notification($message, 'notifysuccess') . '</li>';
} catch (Exception $e) {
$message .= " - Error: " . $e->getMessage();
echo '<li>' . $OUTPUT->notification($message) . '</li>';
}
}
}
echo '</ol>';
return true;
} else {
echo get_string('nobooks', 'local_rcommon');
return true;
}
} catch (Exception $fault) {
$message = rcommon_ws_error('get_books_structure_publisher', $fault->getMessage());
throw new Exception($message);
}
return false;
}
示例7: get_non_empty_children
/**
* Returns list of children which are either files matching the specified extensions
* or folders that contain at least one such file.
*
* @param string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
* @return array of file_info instances
*/
public function get_non_empty_children($extensions = '*')
{
$items = $this->gallery->get_items();
$result = array();
foreach ($items as $item) {
$file = $item->get_file();
$extension = core_text::strtolower(pathinfo($file->get_filename(), PATHINFO_EXTENSION));
if ($file->is_directory() || $extensions === '*' || !empty($extension) && in_array('.' . $extension, $extensions)) {
$fileinfo = new file_info_stored($this->browser, $this->context, $file, $this->urlbase, $this->topvisiblename, $this->itemidused, $this->readaccess, $this->writeaccess, false);
if (!$file->is_directory() || $fileinfo->count_non_empty_children($extensions)) {
$result[] = $fileinfo;
}
}
}
return $result;
}
示例8: validation
/**
* Custom form validation
*
* @param array $data
* @param array $files
* @return array
*/
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
if (isset($data['rawname'])) {
$newname = core_text::strtolower($data['rawname']);
$tag = $this->_customdata['tag'];
if ($tag->name != $newname) {
// The name has changed, let's make sure it's not another existing tag.
if (core_tag_tag::get_by_name($tag->tagcollid, $newname)) {
// Something exists already, so flag an error.
$errors['rawname'] = get_string('namesalreadybeeingused', 'tag');
}
}
}
return $errors;
}
示例9: is_related
/**
* Checks if $query is one of the available subplugins.
*
* @param string $query The string to search for
* @return bool Returns true if found, false if not
*/
public function is_related($query)
{
if (parent::is_related($query)) {
return true;
}
$subplugins = core_component::get_plugin_list('tinymce');
foreach ($subplugins as $name => $dir) {
if (stripos($name, $query) !== false) {
return true;
}
$namestr = get_string('pluginname', 'tinymce_' . $name);
if (strpos(core_text::strtolower($namestr), core_text::strtolower($query)) !== false) {
return true;
}
}
return false;
}
示例10: is_related
/**
* Checks if $query is one of the available log plugins.
*
* @param string $query The string to search for
* @return bool Returns true if found, false if not
*/
public function is_related($query)
{
if (parent::is_related($query)) {
return true;
}
$query = core_text::strtolower($query);
$plugins = \tool_log\log\manager::get_store_plugins();
foreach ($plugins as $plugin => $fulldir) {
if (strpos(core_text::strtolower($plugin), $query) !== false) {
return true;
}
$localised = get_string('pluginname', $plugin);
if (strpos(core_text::strtolower($localised), $query) !== false) {
return true;
}
}
return false;
}
示例11: is_related
/**
* Check if this is $query is related to a choice
*
* @param string $query
* @return bool true if related, false if not
*/
public function is_related($query)
{
if (parent::is_related($query)) {
return true;
}
if (!$this->load_choices()) {
return false;
}
foreach ($this->choices as $key => $value) {
if (strpos(core_text::strtolower($key), $query) !== false) {
return true;
}
if (strpos(core_text::strtolower($value), $query) !== false) {
return true;
}
}
return false;
}
示例12: is_related
/**
* Checks if $query is one of the available dataformfield plugins.
*
* @param string $query The string to search for
* @return bool Returns true if found, false if not
*/
public function is_related($query)
{
if (parent::is_related($query)) {
return true;
}
$query = \core_text::strtolower($query);
$plugins = \core_component::get_plugin_list('dataformfield');
foreach ($plugins as $plugin => $fulldir) {
if (strpos(\core_text::strtolower($plugin), $query) !== false) {
return true;
}
$localised = get_string('pluginname', "dataformfield_{$plugin}");
if (strpos(\core_text::strtolower($localised), $query) !== false) {
return true;
}
}
return false;
}
示例13: user_create_user
/**
* Creates a user
*
* @param stdClass $user user to create
* @param bool $updatepassword if true, authentication plugin will update password.
* @return int id of the newly created user
*/
function user_create_user($user, $updatepassword = true)
{
global $DB;
// Set the timecreate field to the current time.
if (!is_object($user)) {
$user = (object) $user;
}
// Check username.
if ($user->username !== core_text::strtolower($user->username)) {
throw new moodle_exception('usernamelowercase');
} else {
if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {
throw new moodle_exception('invalidusername');
}
}
// Save the password in a temp value for later.
if ($updatepassword && isset($user->password)) {
// Check password toward the password policy.
if (!check_password_policy($user->password, $errmsg)) {
throw new moodle_exception($errmsg);
}
$userpassword = $user->password;
unset($user->password);
}
$user->timecreated = time();
$user->timemodified = $user->timecreated;
// Insert the user into the database.
$newuserid = $DB->insert_record('user', $user);
// Create USER context for this user.
$usercontext = context_user::instance($newuserid);
// Update user password if necessary.
if (isset($userpassword)) {
// Get full database user row, in case auth is default.
$newuser = $DB->get_record('user', array('id' => $newuserid));
$authplugin = get_auth_plugin($newuser->auth);
$authplugin->user_update_password($newuser, $userpassword);
}
// Trigger event.
$event = \core\event\user_created::create(array('objectid' => $newuserid, 'context' => $usercontext));
$event->trigger();
return $newuserid;
}
示例14: output
public function output()
{
global $CFG, $OUTPUT;
$stradd = get_string('add');
$fs = get_file_storage();
$storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image);
$image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm);
$manualform = '<input type="text" name="tag" /><input type="submit" value="' . $stradd . '" />';
$manualform = $this->enclose_in_form($manualform);
$iptcform = '';
$deleteform = '';
$path = $storedfile->copy_content_to_temp();
$tags = $image->get_tags();
$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 = core_text::strtolower($tag);
$exists = $tags && in_array($tag, array_values($tags));
$tag = htmlentities($tag);
$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);
}
}
$iptcaddurl = new moodle_url('/mod/lightboxgallery/edit/tag/import.php', array('id' => $this->gallery->id));
$iptcform .= $OUTPUT->single_button($iptcaddurl, get_string('tagsimport', 'lightboxgallery'));
if ($tags = $image->get_tags()) {
$deleteform = '<input type="hidden" name="delete" value="1" />';
foreach ($tags as $tag) {
$deleteform .= '<label><input type="checkbox" name="deletetags[]" value="' . $tag->id . '" /> ' . htmlentities(utf8_decode($tag->description)) . '</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;
}
示例15: replace_callback
protected static function replace_callback($langblock)
{
global $CFG;
static $parentcache;
if (!isset($parentcache)) {
$parentcache = array();
}
$mylang = current_language();
if (!array_key_exists($mylang, $parentcache)) {
$parentlang = get_parent_language($mylang);
$parentcache[$mylang] = $parentlang;
} else {
$parentlang = $parentcache[$mylang];
}
$blocklang = trim(core_text::strtolower($langblock[1]));
$blocktext = $langblock[2];
if ($mylang === $blocklang || $parentlang === $blocklang) {
return $blocktext;
}
return '';
}