/** * Add appropriate form elements to the criteria form * * @param stdClass $data details of overall criterion */ public function config_form_criteria($data) { global $OUTPUT; $prefix = 'criteria-' . $this->id; if (count($data->criteria) > 2) { echo $OUTPUT->box_start(); if (!empty($this->description)) { $badge = new badge($this->badgeid); echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } echo $OUTPUT->heading($this->get_title(), 2); $agg = $data->get_aggregation_methods(); if (!$data->is_locked() && !$data->is_active()) { $editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id)); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action')); echo $OUTPUT->box($editaction, array('criteria-header')); $url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey())); echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null, null, array('aria-describedby' => 'overall')); echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall')); } else { echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix'); } echo $OUTPUT->box_end(); } }
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' => core_text::strtoupper($DB->get_prefix() . $xmldb_table->getName()), 'column_name' => core_text::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); }
/** * Add appropriate form elements to the criteria form * * @param stdClass $data details of overall criterion */ public function config_form_criteria($data) { global $OUTPUT; $prefix = 'criteria-' . $this->id; if (count($data->criteria) > 2) { echo $OUTPUT->box_start(); echo $OUTPUT->heading($this->get_title(), 2); $agg = $data->get_aggregation_methods(); if (!$data->is_locked() && !$data->is_active()) { $url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey())); $table = new html_table(); $table->attributes = array('class' => 'clearfix'); $table->colclasses = array('', 'activatebadge'); $table->data[] = array($OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null), get_string('overallcrit', 'badges')); echo html_writer::table($table); } else { echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix'); } echo $OUTPUT->box_end(); } }
/** * Strtoupper multibyte wrapper function with HTML entities handling. * * @param string $str Text to convert * @return string Converted text */ protected function strtoupper($str) { return core_text::strtoupper($str); }
/** * Draws the personalized header in a PDF * * @param unknown $pdf * @param unknown $stinfo * @param unknown $examname * @param unknown $pagenumber * @param unknown $fileimgpath * @param unknown $logofilepath * @param unknown $course * @param string $totalpages * @param string $bottomqr * @param string $isanswersheet * @param number $attemptid */ function emarking_draw_header($pdf, $stinfo, $examname, $pagenumber, $fileimgpath, $logofilepath, $course, $totalpages = null, $bottomqr = true, $isanswersheet = false, $attemptid = 0) { global $CFG; $pdf->SetAutoPageBreak(false); // If we have a log, it is drawn on the top left part if ($CFG->emarking_includelogo && $logofilepath) { $pdf->Image($logofilepath, 2, 8, 30); } // Exam name $left = 58; $top = 8; $pdf->SetFont('Helvetica', '', 12); $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper($examname)); // Student name $pdf->SetFont('Helvetica', '', 9); $top += 5; $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper(get_string('name') . ": " . $stinfo->name)); $top += 4; // Student idnumber if ($stinfo->idnumber && strlen($stinfo->idnumber) > 0) { $pdf->SetXY($left, $top); $pdf->Write(1, get_string('idnumber', 'mod_emarking') . ": " . $stinfo->idnumber); $top += 4; } // Course name $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper(get_string('course') . ": " . $course->fullname)); $top += 4; if (file_exists($stinfo->picture)) { $pdf->Image($stinfo->picture, 35, 8, 15, 15, "PNG", null, "T", true); } // Page number and total pages if ($totalpages) { $totals = new stdClass(); $totals->identified = $pagenumber; $totals->total = $totalpages; $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper(get_string('page') . ": " . get_string('aofb', 'mod_emarking', $totals))); } // Generate the QR images $qrstring = "{$stinfo->id}-{$course->id}-{$pagenumber}"; // If the page is an answer sheets (has bubbles), add the attemptid if ($isanswersheet && $attemptid > 0) { $qrstring .= '-' . $attemptid . '-BB'; } list($img, $imgrotated) = emarking_create_qr_image($fileimgpath, $qrstring, $stinfo, $pagenumber); $pdf->Image($img, 176, 3, 34); if ($bottomqr) { $pdf->Image($imgrotated, 0, $pdf->getPageHeight() - 35, 34); } // Delete QR images unlink($img); unlink($imgrotated); }
/** * Returns an object containing the details from 'pages' and 'versions' * tables for the specified version of the specified (named) page, or false * if page/version does not exist. * * @param object $subwiki Current subwiki object * @param string $pagename Name of desired page or null for start * @return object $pageversion Version object */ function ouwiki_get_page_version($subwiki, $pagename, $versionid) { global $DB; $userfields = user_picture::fields('u', null, 'userid'); $sql = "SELECT p.id AS pageid, p.subwikiid, p.title, p.currentversionid,\n v.id AS versionid, v.xhtml, v.timecreated, v.userid, v.xhtmlformat,\n v.deletedat, {$userfields},\n v.wordcount\n FROM {ouwiki_pages} p, {ouwiki_versions} v\n LEFT JOIN {user} u ON v.userid = u.id\n WHERE p.subwikiid = ? AND v.id = ? AND UPPER(p.title) = ?"; $pagename = core_text::strtoupper($pagename); $pageversion = $DB->get_record_sql($sql, array($subwiki->id, $versionid, $pagename)); $pageversion->recentversions = false; return $pageversion; }
public function print_badge_criteria(badge $badge, $short = '') { $output = ""; $agg = $badge->get_aggregation_methods(); if (empty($badge->criteria)) { return get_string('nocriteria', 'badges'); } else { if (count($badge->criteria) == 2) { if (!$short) { $output .= get_string('criteria_descr', 'badges'); } } else { $output .= get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method()])); } } $items = array(); unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); foreach ($badge->criteria as $type => $c) { if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short); } else { $items[] = get_string('criteria_descr_' . $short . $type, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short); } } $output .= html_writer::alist($items, array(), 'ul'); return $output; }
/** * Returns information about badge criteria in a list form. * * @param badge $badge Badge objects * @param string $short Indicates whether to print full info about this badge * @return string $output HTML string to output */ public function print_badge_criteria(badge $badge, $short = '') { $agg = $badge->get_aggregation_methods(); if (empty($badge->criteria)) { return get_string('nocriteria', 'badges'); } $overalldescr = ''; $overall = $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]; if (!$short && !empty($overall->description)) { $overalldescr = $this->output->box(format_text($overall->description, $overall->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } // Get the condition string. if (count($badge->criteria) == 2) { $condition = ''; if (!$short) { $condition = get_string('criteria_descr', 'badges'); } } else { $condition = get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method()])); } unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); $items = array(); // If only one criterion left, make sure its description goe to the top. if (count($badge->criteria) == 1) { $c = reset($badge->criteria); if (!$short && !empty($c->description)) { $overalldescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $c->criteriatype, 'badges') . $c->get_details($short); } else { $items[] = get_string('criteria_descr_' . $short . $c->criteriatype, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($c->criteriatype)])) . $c->get_details($short); } } else { foreach ($badge->criteria as $type => $c) { $criteriadescr = ''; if (!$short && !empty($c->description)) { $criteriadescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short) . $criteriadescr; } else { $items[] = get_string('criteria_descr_' . $short . $type, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short) . $criteriadescr; } } } return $overalldescr . $condition . html_writer::alist($items, array(), 'ul'); }
$ratingoptions->items = $allentries; $ratingoptions->aggregate = $glossary->assessed; //the aggregation method $ratingoptions->scaleid = $glossary->scale; $ratingoptions->userid = $USER->id; $ratingoptions->returnurl = $CFG->wwwroot . '/mod/glossary/view.php?id=' . $cm->id; $ratingoptions->assesstimestart = $glossary->assesstimestart; $ratingoptions->assesstimefinish = $glossary->assesstimefinish; $rm = new rating_manager(); $allentries = $rm->get_ratings($ratingoptions); } foreach ($allentries as $entry) { // Setting the pivot for the current entry $pivot = $entry->glossarypivot; $upperpivot = core_text::strtoupper($pivot); $pivottoshow = core_text::strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if (!$fullpivot) { $upperpivot = core_text::substr($upperpivot, 0, 1); $pivottoshow = core_text::substr($pivottoshow, 0, 1); } // if there's a group break if ($currentpivot != $upperpivot) { // print the group break if apply if ($printpivot) { $currentpivot = $upperpivot; echo '<div>'; echo '<table cellspacing="0" class="glossarycategoryheader">'; echo '<tr>'; if (isset($entry->userispivot)) { // printing the user icon if defined (only when browsing authors)
$where = "AND ({$searchcond})"; } break; 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' and $hookstrlen = core_text::strlen($hook)) { $params['hookup'] = core_text::strtoupper($hook); $where = "AND " . $DB->sql_substr("upper(concept)", 1, $hookstrlen) . " = :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\n (ge.approved <> 0 {$userid})\n {$where}"; switch ($tab) { case GLOSSARY_DATE_VIEW: $sqlorderby = "ORDER BY {$sqlsortkey} {$sqlsortorder}";
/** * * @param string The string being uppercased * @param string $encoding The encoding parameter is the character encoding. * If it is omitted, the internal character encoding * value will be used. * * @return string The string with all alphabetic characters converted to uppercase. */ function mb_strtoupper($str, $encoding = null) { if ($encoding === null) { $encoding = mb_internal_encoding(); } return \core_text::strtoupper($str, $encoding); }
/** * Dispatch criteria rendering to an appropriate place. * * Dispatch to a theme renderer method to output the details if one * exists -- that way we can make changes to the output. */ protected function print_badge_criteria_single($badge, $aggregationmethods, $type, $criteria, $short = '') { switch ($type) { case BADGE_CRITERIA_TYPE_ACTIVITY: $details = $this->print_badge_criteria_activity($criteria, $short); break; case BADGE_CRITERIA_TYPE_COURSE: $details = $this->print_badge_criteria_course($criteria, $short); break; case BADGE_CRITERIA_TYPE_COURSESET: $details = $this->print_badge_criteria_courseset($criteria, $short); break; default: $details = $criteria->get_details(); } if (count($criteria->params) === 1) { $stringname = 'criteria_descr_single_' . $short . $type; $title = static::string($stringname); } else { $stringname = 'criteria_descr_' . $short . $type; $count = core_text::strtoupper($aggregationmethods[$badge->get_aggregation_method($type)]); $title = static::string($stringname, $count); } return $title . $details; }
/** * Convenience method to transform a field into SQL statement. * * @param string $field The field, or *. * @param string $table The table name, without the prefix 'glossary_'. * @return string SQL statement. */ protected static function resolve_field($field, $table) { $prefix = constant(__CLASS__ . '::ALIAS_' . core_text::strtoupper($table)); return sprintf('%s.%s', $prefix, $field); }
/** * Internal callback function. */ function cc_process_template_callback($name, $description, $idnumber, $block) { switch ($block[3]) { case 's': $repl = $name; break; case 'd': $repl = $description; break; case 'i': $repl = $idnumber; break; default: return $block[0]; } switch ($block[1]) { case '+': $repl = core_text::strtoupper($repl); break; case '-': $repl = core_text::strtolower($repl); break; case '~': $repl = core_text::strtotitle($repl); break; } if (!empty($block[2])) { $repl = core_text::substr($repl, 0, $block[2]); } return $repl; }
/** * Callback used when generating a shortname based on a template. * * @param string $fullname full name. * @param string $idnumber ID number. * @param array $block result from preg_replace_callback. * @return string */ public static function generate_shortname_callback($fullname, $idnumber, $block) { switch ($block[3]) { case 'f': $repl = $fullname; break; case 'i': $repl = $idnumber; break; default: return $block[0]; } switch ($block[1]) { case '+': $repl = core_text::strtoupper($repl); break; case '-': $repl = core_text::strtolower($repl); break; case '~': $repl = core_text::strtotitle($repl); break; } if (!empty($block[2])) { $repl = core_text::substr($repl, 0, $block[2]); } return $repl; }
/** * 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 = core_text::strtoupper($repl); break; case '-': $repl = core_text::strtolower($repl); break; case '~': $repl = core_text::strtotitle($repl); break; } if (!empty($block[2])) { $repl = core_text::substr($repl, 0, $block[2]); } return $repl; }
public function test_timezones() { global $CFG, $USER; // The timezones used in this test are chosen because they do not use DST - that would break the test. $currenttimezonephp = date_default_timezone_get(); $currenttimezonecfg = null; if (!empty($CFG->timezone)) { $currenttimezonecfg = $CFG->timezone; } $userstimezone = null; if (!empty($USER->timezone)) { $userstimezone = $USER->timezone; } // We are testing a difference between $CFG->timezone and the php.ini timezone. // GMT+8. date_default_timezone_set('Australia/Perth'); // GMT-04:30. $CFG->timezone = 'America/Caracas'; $testclass = new \core\task\scheduled_test_task(); // Scheduled tasks should always use servertime - so this is 03:30 GMT. $testclass->set_hour('1'); $testclass->set_minute('0'); // Next valid time should be 1am of the next day. $nexttime = $testclass->get_next_scheduled_time(); // GMT+05:45. $USER->timezone = 'Asia/Kathmandu'; $userdate = userdate($nexttime); // Should be displayed in user timezone. // I used http://www.timeanddate.com/worldclock/fixedtime.html?msg=Moodle+Test&iso=20140314T01&p1=58 // to verify this time. $this->assertContains('11:15 AM', core_text::strtoupper($userdate)); $CFG->timezone = $currenttimezonecfg; date_default_timezone_set($currenttimezonephp); }
function emarking_draw_header($pdf, $stinfo, $examname, $pagenumber, $fileimgpath, $logofilepath, $course, $totalpages = null, $bottomqr = true, $isanswersheet = false, $attemptid = 0) { global $CFG; $pdf->SetAutoPageBreak(false); // For the QR string and get the images $qrstring = "{$stinfo->id}-{$course->id}-{$pagenumber}"; if ($isanswersheet && $attemptid > 0) { $qrstring .= '-' . $attemptid . '-BB'; } list($img, $imgrotated) = emarking_create_qr_image($fileimgpath, $qrstring, $stinfo, $pagenumber); if ($CFG->emarking_includelogo && $logofilepath) { $pdf->Image($logofilepath, 2, 8, 30); } $left = 38; $top = 8; $pdf->SetFont('times', '', 12); $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper($examname)); $pdf->SetFont('times', '', 9); $top += 5; $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper($stinfo->name)); $top += 4; if ($stinfo->idnumber && strlen($stinfo->idnumber) > 0) { $pdf->SetXY($left, $top); $pdf->Write(1, get_string('idnumber', 'mod_emarking') . ": " . $stinfo->idnumber); $top += 4; } $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper($stinfo->group)); $top += 4; $pdf->SetXY($left, $top); $pdf->Write(1, core_text::strtoupper($course->fullname)); $pdf->Image($img, 176, 3, 34); // y antes era -2 if ($bottomqr) { $pdf->Image($imgrotated, 0, $pdf->getPageHeight() - 35, 34); } unlink($img); unlink($imgrotated); }
/** * Tests the static strtoupper. */ public function test_strtoupper() { $str = "Žluťoučký koníček"; $up = 'ŽLUŤOUČKÝ KONÍČEK'; $this->assertSame($up, core_text::strtoupper($str)); $iso2 = pack("H*", "ae6c75bb6f75e86bfd206b6f6eede8656b"); $this->assertSame(core_text::convert($up, 'utf-8', 'iso-8859-2'), core_text::strtoupper($iso2, 'iso-8859-2')); $win = pack("H*", "8e6c759d6f75e86bfd206b6f6eede8656b"); $this->assertSame(core_text::convert($up, 'utf-8', 'cp1250'), core_text::strtoupper($win, 'cp1250')); $str = '言語設定'; $this->assertSame($str, core_text::strtoupper($str)); $str = '简体中文'; $this->assertSame($str, core_text::strtoupper($str)); $str = pack("H*", "1b24423840386c405f446a1b2842"); // ISO-2022-JP $this->assertSame($str, core_text::strtoupper($str, 'ISO-2022-JP')); $str = pack("H*", "8cbe8cea90dd92e8"); // SHIFT-JIS $this->assertSame($str, core_text::strtoupper($str, 'SHIFT-JIS')); $str = pack("H*", "bcf2cce5d6d0cec4"); // GB2312 $this->assertSame($str, core_text::strtoupper($str, 'GB2312')); $str = pack("H*", "bcf2cce5d6d0cec4"); // GB18030 $this->assertSame($str, core_text::strtoupper($str, 'GB18030')); }
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); } } }
/** * Browse a glossary entries using the search. * * @param int $id The glossary ID. * @param string $query The search query. * @param bool $fullsearch Whether or not full search is required. * @param string $order The way to order the results. * @param string $sort The direction of the order. * @param int $from Start returning records from here. * @param int $limit Number of records to return. * @param array $options Array of options. * @return array Containing count, entries and warnings. * @since Moodle 3.1 * @throws moodle_exception * @throws invalid_parameter_exception */ public static function get_entries_by_search($id, $query, $fullsearch, $order, $sort, $from, $limit, $options) { $params = self::validate_parameters(self::get_entries_by_search_parameters(), array('id' => $id, 'query' => $query, 'fullsearch' => $fullsearch, 'order' => core_text::strtoupper($order), 'sort' => core_text::strtoupper($sort), 'from' => $from, 'limit' => $limit, 'options' => $options)); $id = $params['id']; $query = $params['query']; $fullsearch = $params['fullsearch']; $order = $params['order']; $sort = $params['sort']; $from = $params['from']; $limit = $params['limit']; $options = $params['options']; $warnings = array(); if (!in_array($order, array('CONCEPT', 'CREATION', 'UPDATE'))) { throw new invalid_parameter_exception('invalidorder'); } else { if (!in_array($sort, array('ASC', 'DESC'))) { throw new invalid_parameter_exception('invalidsort'); } } // Get and validate the glossary. list($glossary, $context) = self::validate_glossary($id); // Fetching the entries. $entries = array(); list($records, $count) = glossary_get_entries_by_search($glossary, $context, $query, $fullsearch, $order, $sort, $from, $limit, $options); foreach ($records as $key => $record) { self::fill_entry_details($record, $context); $entries[] = $record; } return array('count' => $count, 'entries' => $entries, 'warnings' => $warnings); }
/** * Add appropriate criteria elements * * @param stdClass $data details of various criteria */ public function config_form_criteria($data) { global $OUTPUT; $agg = $data->get_aggregation_methods(); $editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id)); $deleteurl = new moodle_url('/badges/criteria_action.php', array('badgeid' => $this->badgeid, 'delete' => true, 'type' => $this->criteriatype)); $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action')); $deleteaction = $OUTPUT->action_icon($deleteurl, new pix_icon('t/delete', get_string('delete')), null, array('class' => 'criteria-action')); echo $OUTPUT->box_start(); if (!$data->is_locked() && !$data->is_active()) { echo $OUTPUT->box($deleteaction . $editaction, array('criteria-header')); } echo $OUTPUT->heading($this->get_title() . $OUTPUT->help_icon('criteria_' . $this->criteriatype, 'badges'), 3, 'main help'); if (!empty($this->description)) { $badge = new badge($this->badgeid); echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } if (!empty($this->params)) { if (count($this->params) > 1) { echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method($this->criteriatype)])), array('clearfix')); } else { echo $OUTPUT->box(get_string('criteria_descr_single_' . $this->criteriatype, 'badges'), array('clearfix')); } echo $OUTPUT->box($this->get_details(), array('clearfix')); } echo $OUTPUT->box_end(); }
/** * 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('core_text')) { $str = core_text::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; }
public function test_timezones() { global $CFG, $USER; // The timezones used in this test are chosen because they do not use DST - that would break the test. $this->resetAfterTest(); $this->setTimezone('Asia/Kabul'); $testclass = new \core\task\scheduled_test_task(); // Scheduled tasks should always use servertime - so this is 03:30 GMT. $testclass->set_hour('1'); $testclass->set_minute('0'); // Next valid time should be 1am of the next day. $nexttime = $testclass->get_next_scheduled_time(); // GMT+05:45. $USER->timezone = 'Asia/Kathmandu'; $userdate = userdate($nexttime); // Should be displayed in user timezone. // I used http://www.timeanddate.com/worldclock/fixedtime.html?msg=Moodle+Test&iso=20160502T01&p1=113 // setting my location to Kathmandu to verify this time. $this->assertContains('2:15 AM', core_text::strtoupper($userdate)); }
/** * 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 = core_text::substr($letter, 0, 1); if (preg_match('/^[a-zA-Z]$/', $letter)) { $letter = core_text::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); }
function emarking_create_printform($context, $exam, $userrequests, $useraccepts, $category, $totalpages, $course) { global $CFG; require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php"; require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi.php"; $cantsheets = $totalpages / ($exam->totalstudents + $exam->extraexams); $totalextraexams = $exam->totalstudents + $exam->extraexams; $canttotalpages = $cantsheets * $totalextraexams; $pdf = new FPDI(); $cp = $pdf->setSourceFile($CFG->dirroot . "/mod/emarking/img/printformtemplate.pdf"); for ($i = 1; $i <= $cp; $i++) { $pdf->AddPage(); // Agrega una nueva página if ($i <= $cp) { $tplIdx = $pdf->importPage($i); // Se importan las páginas del documento pdf. $pdf->useTemplate($tplIdx, 0, 0, 0, 0, $adjustPageSize = true); // se inserta como template el archivo pdf subido // Copia/Impresión/Plotteo $pdf->SetXY(32, 48.5); $pdf->Write(1, "x"); // Fecha día $pdf->SetXY(153, 56); $pdf->Write(1, core_text::strtoupper(date('d'))); // Fecha mes $pdf->SetXY(163, 56); $pdf->Write(1, core_text::strtoupper(date('m'))); // Fecha año $pdf->SetXY(173, 56); $pdf->Write(1, core_text::strtoupper(date('Y'))); // Solicitante $pdf->SetXY(95, 69); $pdf->Write(1, core_text::strtoupper($useraccepts->firstname . " " . $useraccepts->lastname)); // Centro de Costo $pdf->SetXY(95, 75.5); $pdf->Write(1, core_text::strtoupper($category->idnumber)); // Campus UAI $pdf->SetXY(95, 80.8); $pdf->Write(1, core_text::strtoupper("")); // Número originales $pdf->SetXY(35, 106.5); $pdf->Write(1, core_text::strtoupper($cantsheets)); // Número copias $pdf->SetXY(60, 106.5); $pdf->Write(1, core_text::strtoupper("--")); // Número impresiones $pdf->SetXY(84, 106.5); $pdf->Write(1, core_text::strtoupper($totalextraexams)); // BN $pdf->SetXY(106, 106.5); $pdf->Write(1, "x"); // Páginas totales $pdf->SetXY(135, 106.5); $pdf->Write(1, core_text::strtoupper($canttotalpages)); // Número impresiones Total $pdf->SetXY(84, 133.8); $pdf->Write(1, core_text::strtoupper("")); // Páginas totales Total $pdf->SetXY(135, 133.8); $pdf->Write(1, core_text::strtoupper("")); // Páginas totales Total $pdf->SetXY(43, 146); $pdf->Write(1, core_text::strtoupper($course->fullname . " , " . $exam->name)); // Recepcionado por Nombre $pdf->SetXY(30, 164.5); $pdf->Write(1, core_text::strtoupper("")); // Recepcionado por RUT $pdf->SetXY(127, 164.5); $pdf->Write(1, core_text::strtoupper("")); } } $pdf->Output("PrintForm" . $exam->id . ".pdf", "I"); // se genera el nuevo pdf }