本文整理汇总了PHP中highlight函数的典型用法代码示例。如果您正苦于以下问题:PHP highlight函数的具体用法?PHP highlight怎么用?PHP highlight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了highlight函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: do_fac
function do_fac($theFac, $theWidth, $search = FALSE, $dist = TRUE)
{
$print = "<TABLE BORDER='0'ID='left' width='" . $theWidth . "'>\n";
//
$print .= "<TR CLASS='even'><TD CLASS='td_data' COLSPAN=2 ALIGN='center'><B>Facility: <I>" . highlight($search, $theFac['fac_name']) . "</B></TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Description:</TD>\t<TD>" . highlight($search, nl2br($theFac['fac_descr'])) . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Capability:</TD>\t<TD>" . highlight($search, nl2br($theFac['capab'])) . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Status:</TD>\t<TD>" . $theFac['status_val'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Opening Hours:</TD>\t<TD>" . $theFac['opening_hours'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Access Rules:</TD>\t<TD>" . $theFac['access_rules'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Sec Reqs:</TD>\t<TD>" . $theFac['security_reqs'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Cont name:</TD>\t<TD>" . $theFac['contact_name'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Cont email:</TD>\t<TD>" . $theFac['contact_email'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Cont phone:</TD>\t<TD>" . $theFac['contact_phone'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Sec contact:</TD>\t<TD>" . $theFac['security_contact'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Sec email:</TD>\t<TD>" . $theFac['security_email'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Sec phone:</TD>\t<TD>" . $theFac['security_phone'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' VALIGN='top'><TD>Prim pager:</TD>\t<TD>" . $theFac['pager_p'] . "</TD></TR>\n";
$print .= "<TR CLASS='even' VALIGN='top'><TD>Sec pager:</TD>\t<TD>" . $theFac['pager_s'] . "</TD></TR>\n";
$print .= "<TR CLASS='odd' ><TD>Updated:</TD>\t\t<TD>" . format_date($theFac['updated']) . "</TD></TR>\n";
// $print .= "<TR CLASS='even'><TD>Status:</TD> <TD>" . $theFac['status_id'] . "</TD></TR>\n";
$print .= "<TR STYLE = 'display:none;'><TD colspan=2><SPAN ID='oldlat'>" . $theFac['lat'] . "</SPAN><SPAN ID='oldlng'>" . $theFac['lng'] . "</SPAN></TD></TR>";
$print .= "</TABLE>\n";
return $print;
}
开发者ID:sharedgeo,项目名称:TicketsCAD-SharedGeo-Dev,代码行数:25,代码来源:fac_routes_nm.php
示例2: fetchResults
function fetchResults(&$record_count)
{
global $AppUI;
$results = $this->_searchResults();
if ($results && getPermission($this->table_module, 'access')) {
$record_count += count($results);
$outstring = '<tr><th><b>' . $AppUI->_($this->table_title) . ' (' . count($results) . ')' . '</b></th></tr>' . "\n";
foreach ($results as $records) {
if (getPermission($this->table_module, 'access', $records[$this->table_key])) {
$ii = 0;
$display_val = '';
foreach ($this->display_fields as $fld) {
$ii++;
if (!($this->search_options['display_all_flds'] == 'on') && $ii > 2) {
break;
}
$display_val .= ($display_val ? ' ' : '') . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $fld)];
}
$tmplink = "";
if (isset($this->table_link) && isset($this->table_key)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)];
}
if (isset($this->table_link2) && isset($this->table_key2)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)] . $this->table_link2 . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key2)];
}
$outstring .= '<tr><td>' . "\n" . '<a href="' . $tmplink . '">' . highlight($display_val, $this->keywords) . '</a>' . "\n" . '</td></tr>' . "\n";
}
}
} else {
if ($this->search_options['show_empty'] == 'on') {
$outstring = '<tr><th><b>' . $AppUI->_($this->table_title) . ' (' . count($results) . ')' . '</b></th></tr>' . "\n" . '<tr><td>' . $AppUI->_('Empty') . '</td></tr>' . "\n";
}
}
return $outstring;
}
开发者ID:klr2003,项目名称:sourceread,代码行数:35,代码来源:smartsearch.class.php
示例3: find
function find($r, $len, $extra)
{
// $words = file_get_contents("/usr/share/dict/words");
$words = file_get_contents("dict.txt");
if (!$words) {
return "";
}
// echo($r);
preg_match_all("/\\b" . $r . "\\b/", $words, $keys);
$ret = "";
$fwords = $keys[0];
if ($len > 0) {
foreach ($fwords as $w) {
if (strlen($w) == $len) {
$ret .= highlight($w, $extra) . "<br>";
}
}
} else {
foreach ($fwords as $w) {
$ret .= highlight($w, $extra) . "<br>";
}
}
if (strlen($ret) > 0) {
echo $ret;
} else {
echo "No matches";
}
}
开发者ID:jamesthoughton,项目名称:web,代码行数:28,代码来源:scrabble.php
示例4: generate_documentation
/**
* Generate the documentation. The "main loop", so to speak.
*
* @param string $file (the filename)
* @return void
*/
function generate_documentation($file)
{
$code = file_get_contents($file);
$sections = parse($file, $code);
$sections = highlight($file, $sections);
generate_html($file, $sections);
}
开发者ID:rileydutton,项目名称:phocco,代码行数:13,代码来源:phocco.php
示例5: strhighlight
function strhighlight($needle, $haystack)
{
$ind = stripos($haystack, $needle);
$len = strlen($needle);
if ($ind !== false) {
return substr($haystack, 0, $ind) . "<strong>" . substr($haystack, $ind, $len) . "</strong>" . highlight($needle, substr($haystack, $ind + $len));
} else {
return $haystack;
}
}
开发者ID:vinerz,项目名称:yogo,代码行数:10,代码来源:stringmanager.php
示例6: test_highlight
function test_highlight() {
$this->assertEqual(highlight('good', 'This is good'), 'This is <span class="highlight">good</span>');
$this->assertEqual(highlight('SpaN', 'span'), '<span class="highlight">span</span>');
$this->assertEqual(highlight('span', 'SpaN'), '<span class="highlight">SpaN</span>');
$this->assertEqual(highlight('span', '<span>span</span>'), '<span><span class="highlight">span</span></span>');
$this->assertEqual(highlight('good is', 'He is good'), 'He <span class="highlight">is</span> <span class="highlight">good</span>');
$this->assertEqual(highlight('+good', 'This is good'), 'This is <span class="highlight">good</span>');
$this->assertEqual(highlight('-good', 'This is good'), 'This is good');
$this->assertEqual(highlight('+good', 'This is goodness'), 'This is goodness');
$this->assertEqual(highlight('good', 'This is goodness'), 'This is <span class="highlight">good</span>ness');
}
开发者ID:nfreear,项目名称:moodle,代码行数:11,代码来源:testweblib.php
示例7: highlight
static function highlight($array, $highlight)
{
$n = array();
foreach ($array as $key => $value) {
if (!in_array($key, array("photo", "ID"))) {
if (is_array($value)) {
$n[$key] = self::highlight($value, $highlight);
} else {
$n[$key] = highlight($highlight, $value);
}
} else {
$n[$key] = $value;
}
}
return $n;
}
开发者ID:WilliamStam,项目名称:Directory,代码行数:16,代码来源:_.php
示例8: fetchResults
public function fetchResults(&$permissions, &$record_count)
{
global $AppUI;
$outstring = '';
$q = $this->_buildQuery();
$results = null;
if ($q) {
$results = $q->loadList();
}
if ($results) {
$outstring = '';
$subrecord_count = 0;
foreach ($results as $records) {
if ($permissions->checkModuleItem($this->table_module, 'view', $records[$this->table_key])) {
//Don't count records for which the user does not have permission
$record_count += 1;
$subrecord_count += 1;
// --MSy-
$ii = 0;
$display_val = '';
foreach ($this->display_fields as $fld) {
$ii++;
if (!($this->search_options['display_all_flds'] == 'on') && $ii > 2) {
break;
}
$display_val = $display_val . ' ' . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $fld)];
}
//--MSy-
$tmplink = '';
if (isset($this->table_link) && isset($this->table_key)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)];
}
if (isset($this->table_link2) && isset($this->table_key2)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)] . $this->table_link2 . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key2)];
}
//--MSy--
$outstring .= '<tr><td><a href = "' . $tmplink . '">' . highlight($display_val, $this->keywords) . '</a></td></tr>';
}
}
$outstring = '<tr><th><b>' . $AppUI->_($this->table_title) . ' (' . $subrecord_count . ')' . '</b></th></tr> ' . "\n" . $outstring;
} else {
if ($this->search_options['show_empty'] == 'on') {
$outstring = '<tr><th><b>' . $AppUI->_($this->table_title) . ' (0)' . '</b></th></tr><tr><td>' . $AppUI->_('Empty') . '</td></tr>';
}
}
return $outstring;
}
开发者ID:viniciusbudines,项目名称:sisnuss,代码行数:47,代码来源:smartsearch.class.php
示例9: fetchResults
function fetchResults(&$permissions, &$record_count)
{
global $AppUI;
$sql = $this->_buildQuery();
$results = db_loadList($sql);
if ($results) {
$record_count += count($results);
$outstring = "<tr><th><b>" . $AppUI->_($this->table_title) . ' (' . count($results) . ')' . "</b></th></tr> \n";
foreach ($results as $records) {
if ($permissions->checkModuleItem($this->table_module, "view", $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)])) {
// --MSy-
$ii = 0;
$display_val = "";
foreach ($this->display_fields as $fld) {
$ii++;
if (!($this->search_options['display_all_flds'] == "on") && $ii > 2) {
break;
}
$display_val = $display_val . " " . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $fld)];
}
//--MSy-
$tmplink = "";
if (isset($this->table_link) && isset($this->table_key)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)];
}
if (isset($this->table_link2) && isset($this->table_key2)) {
$tmplink = $this->table_link . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key)] . $this->table_link2 . $records[preg_replace('/^.*\\.([^\\.]+)$/', '$1', $this->table_key2)];
}
//--MSy--
$outstring .= "<tr>";
$outstring .= "<td>";
$outstring .= "<a href = \" " . $tmplink . "\">" . highlight($display_val, $this->keywords) . "</a>\n";
$outstring .= "</td>\n";
$outstring .= "</tr>";
}
}
} else {
if ($this->search_options['show_empty'] == "on") {
$outstring = "<tr><th><b>" . $AppUI->_($this->table_title) . ' (' . count($results) . ')' . "</b></th></tr> \n";
$outstring .= "<tr>" . "<td>" . $AppUI->_('Empty') . "</td>" . "</tr>";
}
}
return $outstring;
}
开发者ID:n2i,项目名称:xvnkb,代码行数:44,代码来源:smartsearch.class.php
示例10: bat_highlight
function bat_highlight($message, $words, $color = '#ff0000')
{
if (!empty($words)) {
$highlightarray = explode(' ', $words);
$sppos = strrpos($message, chr(0) . chr(0) . chr(0));
if ($sppos !== FALSE) {
$specialextra = substr($message, $sppos + 3);
$message = substr($message, 0, $sppos);
}
$message = preg_replace_callback("/(^|>)([^<]+)(?=<|\$)/siU", function ($matches) use($highlightarray) {
return highlight($matches[2], $highlightarray, $matches[1]);
}, $message);
$message = preg_replace("/<highlight>(.*)<\\/highlight>/siU", "<strong><font color=\"{$color}\">\\1</font></strong>", $message);
if ($sppos !== FALSE) {
$message = $message . chr(0) . chr(0) . chr(0) . $specialextra;
}
}
return $message;
}
开发者ID:KKRainbow,项目名称:discuz-x32-php7,代码行数:19,代码来源:function_search.php
示例11: smartHighlight
function smartHighlight($code)
{
// find all php stuff
preg_match_all('!\\<\\?.*?\\?\\>!i', $code, $array);
$result = '';
$php = array();
// replace php within html with placeholders
foreach ($array[0] as $key => $found) {
$key = '____' . $key . '____';
$php[$key] = highlight($found, 'php');
$code = str_replace($found, $key, $code);
}
// now highlight the plain html
$code = highlight($code, 'html');
// put the highlighted php back in
foreach ($php as $key => $p) {
$code = str_replace($key, $p, $code);
}
return $code;
}
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:20,代码来源:highlight.php
示例12: code
static function code($code)
{
$code = @$code[1];
$lines = explode("\n", $code);
$first = trim(array_shift($lines));
$code = implode("\n", $lines);
$code = trim($code);
if (function_exists('highlight')) {
$result = '<pre class="highlight ' . $first . '">';
$result .= '<code>';
$result .= highlight($code, empty($first) ? 'php-html' : $first);
$result .= '</code>';
$result .= '</pre>';
} else {
$result = '<pre class="' . $first . '">';
$result .= '<code>';
$result .= htmlspecialchars($code);
$result .= '</code>';
$result .= '</pre>';
}
return $result;
}
开发者ID:robeam,项目名称:kirbycms,代码行数:22,代码来源:kirbytext.php
示例13: data_print_template
/**
* takes a list of records, the current data, a search string,
* and mode to display prints the translated template
*
* @global object
* @global object
* @param string $template
* @param array $records
* @param object $data
* @param string $search
* @param int $page
* @param bool $return
* @return mixed
*/
function data_print_template($template, $records, $data, $search='', $page=0, $return=false) {
global $CFG, $DB, $OUTPUT;
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
static $fields = NULL;
static $isteacher;
static $dataid = NULL;
if (empty($dataid)) {
$dataid = $data->id;
} else if ($dataid != $data->id) {
$fields = NULL;
}
if (empty($fields)) {
$fieldrecords = $DB->get_records('data_fields', array('dataid'=>$data->id));
foreach ($fieldrecords as $fieldrecord) {
$fields[]= data_get_field($fieldrecord, $data);
}
$isteacher = has_capability('mod/data:managetemplates', $context);
}
if (empty($records)) {
return;
}
foreach ($records as $record) { // Might be just one for the single template
// Replacing tags
$patterns = array();
$replacement = array();
// Then we generate strings to replace for normal tags
foreach ($fields as $field) {
$patterns[]='[['.$field->field->name.']]';
$replacement[] = highlight($search, $field->display_browse_field($record->id, $template));
}
// Replacing special tags (##Edit##, ##Delete##, ##More##)
$patterns[]='##edit##';
$patterns[]='##delete##';
if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) {
$replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/edit.php?d='
.$data->id.'&rid='.$record->id.'&sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="'.get_string('edit').'" title="'.get_string('edit').'" /></a>';
$replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='
.$data->id.'&delete='.$record->id.'&sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="'.get_string('delete').'" title="'.get_string('delete').'" /></a>';
} else {
$replacement[] = '';
$replacement[] = '';
}
$moreurl = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&rid=' . $record->id;
if ($search) {
$moreurl .= '&filter=1';
}
$patterns[]='##more##';
$replacement[] = '<a href="' . $moreurl . '"><img src="' . $OUTPUT->pix_url('i/search') . '" class="iconsmall" alt="' . get_string('more', 'data') . '" title="' . get_string('more', 'data') . '" /></a>';
$patterns[]='##moreurl##';
$replacement[] = $moreurl;
$patterns[]='##user##';
$replacement[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$record->userid.
'&course='.$data->course.'">'.fullname($record).'</a>';
$patterns[]='##export##';
if (!empty($CFG->enableportfolios) && ($template == 'singletemplate' || $template == 'listtemplate')
&& ((has_capability('mod/data:exportentry', $context)
|| (data_isowner($record->id) && has_capability('mod/data:exportownentry', $context))))) {
require_once($CFG->libdir . '/portfoliolib.php');
$button = new portfolio_add_button();
$button->set_callback_options('data_portfolio_caller', array('id' => $cm->id, 'recordid' => $record->id), '/mod/data/locallib.php');
list($formats, $files) = data_portfolio_caller::formats($fields, $record);
$button->set_formats($formats);
$replacement[] = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
} else {
$replacement[] = '';
}
$patterns[] = '##timeadded##';
$replacement[] = userdate($record->timecreated);
$patterns[] = '##timemodified##';
$replacement [] = userdate($record->timemodified);
//.........这里部分代码省略.........
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:lib.php
示例14: trackTable
//.........这里部分代码省略.........
// Did they want to see lyrics links?
if ($show_lyrics_links == "true") {
if ($metaData['lyrics'] != "") {
$urlArr = array();
$urlArr['jz_path'] = $child->getPath("String");
$urlArr['action'] = "popup";
$urlArr['ptype'] = "viewlyricsfortrack";
echo '<a href="' . urlize($urlArr) . '" onclick="openPopup(this, 450, 450); return false;"> - ' . word("Lyrics") . '</a>';
}
}
// Now let's show the description if there is one
if ($short_desc = $child->getShortDescription() and $hide_id3_comments == "false") {
echo "<br>" . $short_desc;
}
if ($description = $child->getDescription()) {
echo "<br>" . $description;
}
// Do they want ratings?
/*if ($enable_ratings == "true"){
//$rating = $display->displayRating($child,true);
if ($rating){
//echo "<br>". $rating;
}
//unset($rating);
}*/
?>
</td>
<?php
$lyricsSearch = false;
if (isset($_POST['search_type'])) {
if ($_POST['search_type'] == "lyrics") {
$lyricsSearch = $_POST['search_query'];
}
}
if (isset($_GET['search_type'])) {
if ($_GET['search_type'] == "lyrics") {
$lyricsSearch = $_GET['search_query'];
}
}
if ($lyricsSearch) {
// Now let's get the lyrics back
$lyrics = $child->getLyrics();
// Now let's parse it out
$lyrics = str_replace("Lyrics Provided by: Leo's Lyrics\nhttp://www.leoslyrics.com", "", $lyrics);
$start = strpos(strtolower($lyrics), strtolower($lyricsSearch)) - 20;
if ($start < 0) {
$start = 0;
}
$lyrics = " (..." . substr($lyrics, $start, strlen($lyricsSearch) + 40) . "...)";
$lyrics = highlight($lyrics, $lyricsSearch);
echo '<td width="6%" align="center" valign="top" class="jz_track_table_songs_td" nowrap>';
echo $lyrics;
echo '</td>';
}
?>
<?php
if ($showAlbumNames) {
echo '<td width="1%" class="jz_track_table_songs_td" nowrap>';
$display->link($album, returnItemShortName($album->getName(), 20), $album->getName(), "jz_track_table_songs_href");
echo '</td>';
}
?>
<?php
if ($showPlayCount) {
echo '<td width="1%" align="center" valign="top" class="jz_track_table_songs_td" nowrap>';
if ($child->getPlayCount() != 0) {
echo $child->getPlayCount() . " " . word("Plays");
} else {
echo " - ";
}
echo '</td>';
}
?>
<td width="6%" align="center" valign="top" class="jz_track_table_songs_td" nowrap>
<?php
echo convertSecMins($metaData['length']);
?>
</td>
</tr>
<?php
$i = 1 - $i;
unset($gParent);
unset($album);
}
// Now let's set a field with the number of checkboxes that were here
echo "</table>";
// Now let's show the playlist bar if we should
if ($showCheck) {
$this->blockSpacer();
$this->playlistBar();
echo "</form>";
}
}
开发者ID:seanfbrown,项目名称:jinzora,代码行数:101,代码来源:blocks.php
示例15: print_course
/**
* Print a description of a course, suitable for browsing in a list.
*
* @param object $course the course object.
* @param string $highlightterms (optional) some search terms that should be highlighted in the display.
*/
function print_course($course, $highlightterms = '')
{
global $CFG, $USER, $DB, $OUTPUT;
$context = get_context_instance(CONTEXT_COURSE, $course->id);
// Rewrite file URLs so that they are correct
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
echo html_writer::start_tag('div', array('class' => 'coursebox clearfix'));
echo html_writer::start_tag('div', array('class' => 'info'));
echo html_writer::start_tag('h3', array('class' => 'name'));
$linkhref = new moodle_url('/course/view.php', array('id' => $course->id));
$coursename = get_course_display_name_for_list($course);
$linktext = highlight($highlightterms, format_string($coursename));
$linkparams = array('title' => get_string('entercourse'));
if (empty($course->visible)) {
$linkparams['class'] = 'dimmed';
}
echo html_writer::link($linkhref, $linktext, $linkparams);
echo html_writer::end_tag('h3');
/// first find all roles that are supposed to be displayed
if (!empty($CFG->coursecontact)) {
$managerroles = explode(',', $CFG->coursecontact);
$namesarray = array();
$rusers = array();
if (!isset($course->managers)) {
$rusers = get_role_users($managerroles, $context, true, 'ra.id AS raid, u.id, u.username, u.firstname, u.lastname,
r.name AS rolename, r.sortorder, r.id AS roleid', 'r.sortorder ASC, u.lastname ASC');
} else {
// use the managers array if we have it for perf reasosn
// populate the datastructure like output of get_role_users();
foreach ($course->managers as $manager) {
$u = new stdClass();
$u = $manager->user;
$u->roleid = $manager->roleid;
$u->rolename = $manager->rolename;
$rusers[] = $u;
}
}
/// Rename some of the role names if needed
if (isset($context)) {
$aliasnames = $DB->get_records('role_names', array('contextid' => $context->id), '', 'roleid,contextid,name');
}
$namesarray = array();
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($rusers as $ra) {
if (isset($namesarray[$ra->id])) {
// only display a user once with the higest sortorder role
continue;
}
if (isset($aliasnames[$ra->roleid])) {
$ra->rolename = $aliasnames[$ra->roleid]->name;
}
$fullname = fullname($ra, $canviewfullnames);
$namesarray[$ra->id] = format_string($ra->rolename) . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $ra->id, 'course' => SITEID)), $fullname);
}
if (!empty($namesarray)) {
echo html_writer::start_tag('ul', array('class' => 'teachers'));
foreach ($namesarray as $name) {
echo html_writer::tag('li', $name);
}
echo html_writer::end_tag('ul');
}
}
echo html_writer::end_tag('div');
// End of info div
echo html_writer::start_tag('div', array('class' => 'summary'));
$options = new stdClass();
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
if (!isset($course->summaryformat)) {
$course->summaryformat = FORMAT_MOODLE;
}
echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
if ($icons = enrol_get_course_info_icons($course)) {
echo html_writer::start_tag('div', array('class' => 'enrolmenticons'));
foreach ($icons as $icon) {
echo $OUTPUT->render($icon);
}
echo html_writer::end_tag('div');
// End of enrolmenticons div
}
echo html_writer::end_tag('div');
// End of summary div
echo html_writer::end_tag('div');
// End of coursebox div
}
开发者ID:numbas,项目名称:moodle,代码行数:92,代码来源:lib.php
示例16: test_highlight
public function test_highlight()
{
$this->assertSame('This is <span class="highlight">good</span>', highlight('good', 'This is good'));
$this->assertSame('<span class="highlight">span</span>', highlight('SpaN', 'span'));
$this->assertSame('<span class="highlight">SpaN</span>', highlight('span', 'SpaN'));
$this->assertSame('<span><span class="highlight">span</span></span>', highlight('span', '<span>span</span>'));
$this->assertSame('He <span class="highlight">is</span> <span class="highlight">good</span>', highlight('good is', 'He is good'));
$this->assertSame('This is <span class="highlight">good</span>', highlight('+good', 'This is good'));
$this->assertSame('This is good', highlight('-good', 'This is good'));
$this->assertSame('This is goodness', highlight('+good', 'This is goodness'));
$this->assertSame('This is <span class="highlight">good</span>ness', highlight('good', 'This is goodness'));
$this->assertSame('<p><b>test</b> <b>1</b></p><p><b>1</b></p>', highlight('test 1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
$this->assertSame('<p><b>test</b> <b>1</b></p><p><b>1</b></p>', highlight('test +1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
$this->assertSame('<p><b>test</b> 1</p><p>1</p>', highlight('test -1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:weblib_test.php
示例17: forum_print_post
/**
* Print a forum post
*
* @global object
* @global object
* @uses FORUM_MODE_THREADED
* @uses PORTFOLIO_FORMAT_PLAINHTML
* @uses PORTFOLIO_FORMAT_FILE
* @uses PORTFOLIO_FORMAT_RICHHTML
* @uses PORTFOLIO_ADD_TEXT_LINK
* @uses CONTEXT_MODULE
* @param object $post The post to print.
* @param object $discussion
* @param object $forum
* @param object $cm
* @param object $course
* @param boolean $ownpost Whether this post belongs to the current user.
* @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
* @param boolean $link Just print a shortened version of the post as a link to the full post.
* @param string $footer Extra stuff to print after the message.
* @param string $highlight Space-separated list of terms to highlight.
* @param int $post_read true, false or -99. If we already know whether this user
* has read this post, pass that in, otherwise, pass in -99, and this
* function will work it out.
* @param boolean $dummyifcantsee When forum_user_can_see_post says that
* the current user can't see this post, if this argument is true
* (the default) then print a dummy 'you can't see this post' post.
* If false, don't output anything at all.
* @param bool|null $istracked
* @return void
*/
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost = false, $reply = false, $link = false, $footer = "", $highlight = "", $postisread = null, $dummyifcantsee = true, $istracked = null, $return = false)
{
global $USER, $CFG, $OUTPUT;
require_once $CFG->libdir . '/filelib.php';
// String cache
static $str;
// This is an extremely hacky way to ensure we only print the 'unread' anchor
// the first time we encounter an unread post on a page. Ideally this would
// be moved into the caller somehow, and be better testable. But at the time
// of dealing with this bug, this static workaround was the most surgical and
// it fits together with only printing th unread anchor id once on a given page.
static $firstunreadanchorprinted = false;
$modcontext = context_module::instance($cm->id);
$post->course = $course->id;
$post->forum = $forum->id;
$post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
if (!empty($CFG->enableplagiarism)) {
require_once $CFG->libdir . '/plagiarismlib.php';
$post->message .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum));
}
// caching
if (!isset($cm->cache)) {
$cm->cache = new stdClass();
}
if (!isset($cm->cache->caps)) {
$cm->cache->caps = array();
$cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext);
$cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext);
$cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext);
$cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext);
$cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext);
$cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext);
$cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext);
$cm->cache->caps['mod/forum:exportpost'] = has_capability('mod/forum:exportpost', $modcontext);
$cm->cache->caps['mod/forum:exportownpost'] = has_capability('mod/forum:exportownpost', $modcontext);
}
if (!isset($cm->uservisible)) {
$cm->uservisible = \core_availability\info_module::is_user_visible($cm, 0, false);
}
if ($istracked && is_null($postisread)) {
$postisread = forum_tp_is_post_read($USER->id, $post);
}
if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
$output = '';
if (!$dummyifcantsee) {
if ($return) {
return $output;
}
echo $output;
return;
}
$output .= html_writer::tag('a', '', array('id' => 'p' . $post->id));
$output .= html_writer::start_tag('div', array('class' => 'forumpost clearfix', 'role' => 'region', 'aria-label' => get_string('hiddenforumpost', 'forum')));
$output .= html_writer::start_tag('div', array('class' => 'row header'));
$output .= html_writer::tag('div', '', array('class' => 'left picture'));
// Picture
if ($post->parent) {
$output .= html_writer::start_tag('div', array('class' => 'topic'));
} else {
$output .= html_writer::start_tag('div', array('class' => 'topic starter'));
}
$output .= html_writer::tag('div', get_string('forumsubjecthidden', 'forum'), array('class' => 'subject', 'role' => 'header'));
// Subject.
$output .= html_writer::tag('div', get_string('forumauthorhidden', 'forum'), array('class' => 'author', 'role' => 'header'));
// Author.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
// row
$output .= html_writer::start_tag('div', array('class' => 'row'));
//.........这里部分代码省略.........
开发者ID:rezaies,项目名称:moodle,代码行数:101,代码来源:lib.php
示例18: text_clean
private function text_clean($text, $for = 'www_body')
{
// this is real crap.
global $settings, $session;
// clean only for www. rss uses the CDATA structure which does not require escaping
if ($for == 'www_body' || $for == 'www_comment') {
$text = htmlspecialchars($text);
}
// mark the search criterium
if ($session->search && ($for == 'www_body' || $for == 'www_comment')) {
$text = highlight($text, $session->search);
}
// clean special chars from copypasting from irc
$text = preg_replace('/[\\x00-\\x09\\x0b-\\x1F\\x7F]/', '', $text);
// delete timestamps
$text = preg_replace('/^[\\(\\[]?\\d+:\\d+(:\\d+)?[\\)\\]]?\\s/m', '', $text);
if ($for == 'www_body' || $for == 'rss_body' || $for == 'rss_title' || $for == 'excerpt') {
// add * to mark actions, joins, parts etc
$text = preg_replace('/^([a-z0-9\\[\\]\\{\\}_])/smi', '* $1', $text);
// :D
}
// hack for this db. old quotes came this way. so remove this once it's fixed or remove it if you start with a db from scratch.
$text = preg_replace("/^\n/", '', $text);
if ($for == 'www_body') {
// nicks for the website
$text = preg_replace_callback('/^<[@\\+\\s]?([a-z0-9\\-\\[\\]\\{\\}_`~\\|]+)>/mi', array($this, 'nick_colour'), $text);
}
if ($for == 'rss_body' || $for == 'rss_title') {
// escape the cdata structure (avoid injections) + nicks for rss
// nicks for rss never use < or < because they DON'T WORK for rss readers
// < works for some, < for some... so we use ()
$text = str_replace(']]>', ']]]]><![CDATA[>', $text);
// http://en.wikipedia.org/wiki/CDATA#Nesting
$text = preg_replace('/<[@\\+\\s]?([a-z0-9\\-\\[\\]\\{\\}_`~\\|]+)>/msi', '($1)', $text);
}
if ($for == 'excerpt') {
$text = preg_replace
|
请发表评论