function game_upper($str, $lang = '') { $str = textlib::strtoupper($str); $strings = get_string_manager()->load_component_strings('game', $lang == '' ? 'en' : $lang); if (!isset($strings['convertfrom'])) { return $str; } if (!isset($strings['convertto'])) { return $str; } $from = $strings['convertfrom']; $to = $strings['convertto']; $len = textlib::strlen($from); for ($i = 0; $i < $len; $i++) { $str = str_replace(textlib::substr($from, $i, 1), textlib::substr($to, $i, 1), $str); } return $str; }
protected function check_table(xmldb_table $xmldb_table, array $metacolumns) { global $DB; $o = ''; $wrong_fields = array(); // Get and process XMLDB fields if ($xmldb_fields = $xmldb_table->getFields()) { $o .= '<ul>'; foreach ($xmldb_fields as $xmldb_field) { // Get the type of the column, we only will process CHAR (VARCHAR2) ones if ($xmldb_field->getType() != XMLDB_TYPE_CHAR) { continue; } $o .= '<li>' . $this->str['field'] . ': ' . $xmldb_field->getName() . ' '; // Get current semantic from dictionary, we only will process B (BYTE) ones // suplying the SQL code to change them to C (CHAR) semantic $params = array('table_name' => textlib::strtoupper($DB->get_prefix() . $xmldb_table->getName()), 'column_name' => textlib::strtoupper($xmldb_field->getName()), 'data_type' => 'VARCHAR2'); $currentsemantic = $DB->get_field_sql(' SELECT char_used FROM user_tab_columns WHERE table_name = :table_name AND column_name = :column_name AND data_type = :data_type', $params); // If using byte semantics, we'll need to change them to char semantics if ($currentsemantic == 'B') { $info = '(' . $this->str['expected'] . " 'CHAR', " . $this->str['actual'] . " 'BYTE')"; $o .= '<font color="red">' . $this->str['wrong'] . " {$info}</font>"; // Add the wrong field to the list $obj = new stdClass(); $obj->table = $xmldb_table; $obj->field = $xmldb_field; $wrong_fields[] = $obj; } else { $o .= '<font color="green">' . $this->str['ok'] . '</font>'; } $o .= '</li>'; } $o .= '</ul>'; } return array($o, $wrong_fields); }
/** * Prints the page list tab content * * */ private function print_page_list_content() { global $OUTPUT; $page = $this->page; if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) { $fresh = wiki_refresh_cachedcontent($page); $page = $fresh['page']; } $pages = wiki_get_page_list($this->subwiki->id); $stdaux = new stdClass(); $strspecial = get_string('special', 'wiki'); foreach ($pages as $page) { // We need to format the title here to account for any filtering $letter = format_string($page->title, true, array('context' => $this->modcontext)); $letter = textlib::substr($letter, 0, 1); if (preg_match('/^[a-zA-Z]$/', $letter)) { $letter = textlib::strtoupper($letter); $stdaux->{$letter}[] = wiki_parser_link($page); } else { $stdaux->{$strspecial}[] = wiki_parser_link($page); } } $table = new html_table(); $table->head = array(get_string('pagelist', 'wiki') . $OUTPUT->help_icon('pagelist', 'wiki')); $table->attributes['class'] = 'wiki_editor generalbox'; $table->align = array('center'); foreach ($stdaux as $key => $elem) { $table->data[] = array($key); foreach ($elem as $e) { $table->data[] = array(html_writer::link($e['url'], format_string($e['content'], true, array('context' => $this->modcontext)))); } } echo html_writer::table($table); }
/** * Internal callback function. */ function uu_process_template_callback($username, $firstname, $lastname, $block) { switch ($block[3]) { case 'u': $repl = $username; break; case 'f': $repl = $firstname; break; case 'l': $repl = $lastname; break; default: return $block[0]; } switch ($block[1]) { case '+': $repl = textlib::strtoupper($repl); break; case '-': $repl = textlib::strtolower($repl); break; case '~': $repl = textlib::strtotitle($repl); break; } if (!empty($block[2])) { $repl = textlib::substr($repl, 0, $block[2]); } return $repl; }
/** * Tests the static strtoupper * @return void */ public function test_strtoupper() { $str = "Žluťoučký koníček"; $up = 'ŽLUŤOUČKÝ KONÍČEK'; $this->assertSame(textlib::strtoupper($str), $up); $iso2 = pack("H*", "ae6c75bb6f75e86bfd206b6f6eede8656b"); $this->assertSame(textlib::strtoupper($iso2, 'iso-8859-2'), textlib::convert($up, 'utf-8', 'iso-8859-2')); $win = pack("H*", "8e6c759d6f75e86bfd206b6f6eede8656b"); $this->assertSame(textlib::strtoupper($win, 'cp1250'), textlib::convert($up, 'utf-8', 'cp1250')); $str = '言語設定'; $this->assertSame(textlib::strtoupper($str), $str); $str = '简体中文'; $this->assertSame(textlib::strtoupper($str), $str); $str = pack("H*", "1b24423840386c405f446a1b2842"); //ISO-2022-JP $this->assertSame(textlib::strtoupper($str, 'ISO-2022-JP'), $str); $str = pack("H*", "8cbe8cea90dd92e8"); //SHIFT-JIS $this->assertSame(textlib::strtoupper($str, 'SHIFT-JIS'), $str); $str = pack("H*", "bcf2cce5d6d0cec4"); //GB2312 $this->assertSame(textlib::strtoupper($str, 'GB2312'), $str); $str = pack("H*", "bcf2cce5d6d0cec4"); //GB18030 $this->assertSame(textlib::strtoupper($str, 'GB18030'), $str); }
case 'term': $params['hook2'] = $hook; $printpivot = 0; $sqlfrom .= " LEFT JOIN {glossary_alias} ga on ge.id = ga.entryid"; $where = "AND (ge.concept = :hook OR ga.alias = :hook2) "; break; case 'entry': $printpivot = 0; $where = "AND ge.id = :hook"; break; case 'letter': if ($hook != 'ALL' and $hook != 'SPECIAL') { $params['hookup'] = textlib::strtoupper($hook); $where = "AND " . $DB->sql_substr("upper(concept)", 1, textlib::strlen($hook)) . " = :hookup"; } if ($hook == 'SPECIAL') { //Create appropiate IN contents $alphabet = explode(",", get_string('alphabet', 'langconfig')); list($nia, $aparams) = $DB->get_in_or_equal($alphabet, SQL_PARAMS_NAMED, $start='a', false); $params = array_merge($params, $aparams); $where = "AND " . $DB->sql_substr("upper(concept)", 1, 1) . " $nia"; } break; } $sqlwhere = "WHERE (ge.glossaryid = :gid1 or ge.sourceglossaryid = :gid2) AND (ge.approved <> 0 $userid) $where";
$entriesshown = 0; $currentpivot = ''; $site = $DB->get_record("course", array("id"=>1)); echo '<p style="text-align:right"><span style="font-size:0.75em">' . userdate(time()) . '</span></p>'; echo get_string("site") . ': <strong>' . format_string($site->fullname) . '</strong><br />'; echo get_string("course") . ': <strong>' . format_string($course->fullname) . ' ('. format_string($course->shortname) . ')</strong><br />'; echo get_string("modulename","glossary") . ': <strong>' . format_string($glossary->name, true) . '</strong>'; if ( $allentries ) { foreach ($allentries as $entry) { // Setting the pivot for the current entry $pivot = $entry->glossarypivot; $upperpivot = textlib::strtoupper($pivot); $pivottoshow = textlib::strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { $upperpivot = textlib::substr($upperpivot, 0, 1); $pivottoshow = textlib::substr($pivottoshow, 0, 1); } // If there's group break if ( $currentpivot != $upperpivot ) { // print the group break if apply if ( $printpivot ) { $currentpivot = $upperpivot; if ( isset($entry->userispivot) ) { // printing the user icon if defined (only when browsing authors)
function game_strtoupper($str) { if (game_get_moodle_version() >= '02.08') { return core_text::strtoupper($str); } if (game_get_moodle_version() >= '02.04') { return textlib::strtoupper($str); } else { if (game_get_moodle_version() >= '02.01') { return textlib_get_instance()->strtoupper($str); } else { return textlib_get_instance()->qstrtoupper($str); } } }
/** * Strtoupper multibyte wrapper function with HTML entities handling. * * @param string $str Text to convert * @return string Converted text */ private function _strtoupper($str) { $str = html_entity_decode($str, ENT_COMPAT, RCMAIL_CHARSET); if (class_exists('textlib')) { $str = textlib::strtoupper($str); } else { if (function_exists('mb_strtoupper')) { $str = mb_strtoupper($str); } else { $str = strtoupper($str); } } $str = htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET); return $str; }
/** * Internal callback function. */ function process_template_callback($block) { global $template_globals; $textlib = textlib::get_instance(); $repl = $block[0]; switch ($block[3]) { case 'u': $repl = $template_globals->username; break; case 'f': $repl = $template_globals->firstname; break; case 'l': $repl = $template_globals->lastname; break; } switch ($block[1]) { case '+': $repl = textlib::strtoupper($repl); break; case '-': $repl = textlib::strtolower($repl); break; case '~': $repl = textlib::strtotitle($repl); break; } if (!empty($block[2])) { $repl = textlib::substr($repl, 0, $block[2]); } return $repl; }