本文整理汇总了PHP中core_text::specialtoascii方法的典型用法代码示例。如果您正苦于以下问题:PHP core_text::specialtoascii方法的具体用法?PHP core_text::specialtoascii怎么用?PHP core_text::specialtoascii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_text
的用法示例。
在下文中一共展示了core_text::specialtoascii方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_specialtoascii
/**
* Tests the static specialtoascii method.
*/
public function test_specialtoascii()
{
$str = "Žluťoučký koníček";
$this->assertSame('Zlutoucky konicek', core_text::specialtoascii($str));
}
示例2: mangle_pathname
/**
* Tries to convert $localname into another encoding,
* please note that it may fail really badly.
*
* @param string $localname name of file in utf-8 encoding
* @return string
*/
protected function mangle_pathname($localname)
{
if ($this->encoding === 'utf-8') {
return $localname;
}
$converted = core_text::convert($localname, 'utf-8', $this->encoding);
$original = core_text::convert($converted, $this->encoding, 'utf-8');
if ($original === $localname) {
$result = $converted;
} else {
// try ascii conversion
$converted2 = core_text::specialtoascii($localname);
$converted2 = core_text::convert($converted2, 'utf-8', $this->encoding);
$original2 = core_text::convert($converted, $this->encoding, 'utf-8');
if ($original2 === $localname) {
//this looks much better
$result = $converted2;
} else {
//bad luck - the file name may not be usable at all
$result = $converted;
}
}
$result = preg_replace('/\\.\\.+/', '', $result);
$result = ltrim($result);
// no leading /
if ($result === '.') {
$result = '';
}
return $result;
}
示例3: read_submitted_permissions
public function read_submitted_permissions()
{
global $DB;
$this->errors = array();
// Role short name. We clean this in a special way. We want to end up
// with only lowercase safe ASCII characters.
$shortname = optional_param('shortname', null, PARAM_RAW);
if (!is_null($shortname)) {
$this->role->shortname = $shortname;
$this->role->shortname = core_text::specialtoascii($this->role->shortname);
$this->role->shortname = core_text::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
if (empty($this->role->shortname)) {
$this->errors['shortname'] = get_string('errorbadroleshortname', 'core_role');
}
}
if ($DB->record_exists_select('role', 'shortname = ? and id <> ?', array($this->role->shortname, $this->roleid))) {
$this->errors['shortname'] = get_string('errorexistsroleshortname', 'core_role');
}
// Role name.
$name = optional_param('name', null, PARAM_TEXT);
if (!is_null($name)) {
$this->role->name = $name;
// Hack: short names of standard roles are equal to archetypes, empty name means localised via lang packs.
$archetypes = get_role_archetypes();
if (!isset($archetypes[$shortname]) and html_is_blank($this->role->name)) {
$this->errors['name'] = get_string('errorbadrolename', 'core_role');
}
}
if ($this->role->name !== '' and $DB->record_exists_select('role', 'name = ? and id <> ?', array($this->role->name, $this->roleid))) {
$this->errors['name'] = get_string('errorexistsrolename', 'core_role');
}
// Description.
$description = optional_param('description', null, PARAM_RAW);
if (!is_null($description)) {
$this->role->description = $description;
}
// Legacy type.
$archetype = optional_param('archetype', null, PARAM_RAW);
if (isset($archetype)) {
$archetypes = get_role_archetypes();
if (isset($archetypes[$archetype])) {
$this->role->archetype = $archetype;
} else {
$this->role->archetype = '';
}
}
// Assignable context levels.
foreach ($this->allcontextlevels as $cl => $notused) {
$assignable = optional_param('contextlevel' . $cl, null, PARAM_BOOL);
if (!is_null($assignable)) {
if ($assignable) {
$this->contextlevels[$cl] = $cl;
} else {
unset($this->contextlevels[$cl]);
}
}
}
// Allowed roles.
$allow = optional_param_array('allowassign', null, PARAM_INT);
if (!is_null($allow)) {
$this->allowassign = $allow;
}
$allow = optional_param_array('allowoverride', null, PARAM_INT);
if (!is_null($allow)) {
$this->allowoverride = $allow;
}
$allow = optional_param_array('allowswitch', null, PARAM_INT);
if (!is_null($allow)) {
$this->allowswitch = $allow;
}
// Now read the permissions for each capability.
parent::read_submitted_permissions();
}
示例4: send_discussion
/**
* Send a discussion and its posts to the export
*
* @param \stdClass $discussion
* @param \stdClass[] $posts
* @return void
*/
public function send_discussion($discussion, $posts)
{
$discname = format_string($discussion->name);
foreach ($posts as $post) {
$postuser = hsuforum_extract_postuser($post, hsuforum_get_cm_forum($this->cm), \context_module::instance($this->cm->id));
$author = fullname($postuser);
$attachments = $this->process_attachments($post);
$options = new \stdClass();
$options->para = false;
$options->trusted = $post->messagetrust;
$options->context = \context_module::instance($this->cm->id);
$message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', \context_module::instance($this->cm->id)->id, 'mod_hsuforum', 'post', $post->id);
$message = format_text($message, $post->messageformat, $options, $this->cm->course);
$message = \core_text::specialtoascii(html_to_text($message));
if ($post->id == $discussion->firstpost) {
$this->format->export_discussion($post->id, $discname, $author, $post->created, $message, $attachments);
} else {
$private = '';
if (!empty($post->privatereply)) {
$private = get_string('yes');
}
$this->format->export_post($post->id, $discname, format_string($post->subject), $author, $post->created, $message, $attachments, $private);
}
}
}