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


PHP core_text::specialtoascii方法代码示例

本文整理汇总了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));
 }
开发者ID:rushi963,项目名称:moodle,代码行数:8,代码来源:text_test.php

示例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;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:37,代码来源:file_archive.php

示例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();
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:73,代码来源:define_role_table_advanced.php

示例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);
         }
     }
 }
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:32,代码来源:file_adapter.php


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