當前位置: 首頁>>代碼示例>>PHP>>正文


PHP textlib::specialtoascii方法代碼示例

本文整理匯總了PHP中textlib::specialtoascii方法的典型用法代碼示例。如果您正苦於以下問題:PHP textlib::specialtoascii方法的具體用法?PHP textlib::specialtoascii怎麽用?PHP textlib::specialtoascii使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在textlib的用法示例。


在下文中一共展示了textlib::specialtoascii方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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 = textlib::specialtoascii($this->role->shortname);
         $this->role->shortname = textlib::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
         if (empty($this->role->shortname)) {
             $this->errors['shortname'] = get_string('errorbadroleshortname', 'role');
         }
     }
     if ($DB->record_exists_select('role', 'shortname = ? and id <> ?', array($this->role->shortname, $this->roleid))) {
         $this->errors['shortname'] = get_string('errorexistsroleshortname', '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', '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', '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]);
             }
         }
     }
     // Now read the permissions for each capability.
     parent::read_submitted_permissions();
 }
開發者ID:vinoth4891,項目名稱:clinique,代碼行數:60,代碼來源:lib.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 = textlib::convert($localname, 'utf-8', $this->encoding);
     $original = textlib::convert($converted, $this->encoding, 'utf-8');
     if ($original === $localname) {
         $result = $converted;
     } else {
         // try ascii conversion
         $converted2 = textlib::specialtoascii($localname);
         $converted2 = textlib::convert($converted2, 'utf-8', $this->encoding);
         $original2 = textlib::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:masaterutakeno,項目名稱:MoodleMobile,代碼行數:37,代碼來源:file_archive.php

示例3: test_specialtoascii

 /**
  * Tests the static specialtoascii method
  * @return void
  */
 public function test_specialtoascii()
 {
     $str = "Žluťoučký koníček";
     $this->assertSame(textlib::specialtoascii($str), 'Zlutoucky konicek');
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:9,代碼來源:textlib_test.php

示例4: foreach

if ($roles_in_file = roles_migration_get_incoming_roles()) {
    foreach ($roles_in_file as $role) {
        if (!isset($actions[$role->shortname])) {
            echo '<p>', get_string('role_ignored', 'report_rolesmigration', $role), '</p>';
            continue;
        }

        switch ($actions[$role->shortname]) {
            case 'skip':
                echo '<p>', get_string('role_ignored', 'report_rolesmigration', $role), '</p>';
                break;
            case 'create':
                if (!array_key_exists($role->shortname, $roles['create'])) {
                    print_error('new_shortname_undefined');
                }
                $new_role_shortname = textlib::specialtoascii($roles['create'][$role->shortname]['shortname']);
                $new_role_shortname = textlib::strtolower(clean_param($new_role_shortname, PARAM_ALPHANUMEXT));
                $new_role_name = $roles['create'][$role->shortname]['name'];

                // Code to make new role name/short name if same role name or shortname exists
                $fullname = $new_role_name;
                $shortname = $new_role_shortname;
                $currentfullname = "";
                $currentshortname = "";
                $counter = 0;

                do {
                    if ($counter) {
                        $suffixfull = " ".get_string("copyasnoun")." ".$counter;
                        $suffixshort = "_".$counter;
                    } else {
開發者ID:ncsu-delta,項目名稱:moodle-report_rolesmigration,代碼行數:31,代碼來源:do-import.php


注:本文中的textlib::specialtoascii方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。