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


PHP highlight函数代码示例

本文整理汇总了PHP中highlight函数的典型用法代码示例。如果您正苦于以下问题:PHP highlight函数的具体用法?PHP highlight怎么用?PHP highlight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了highlight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.'&amp;rid='.$record->id.'&amp;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.'&amp;delete='.$record->id.'&amp;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 . '&amp;rid=' . $record->id;
        if ($search) {
            $moreurl .= '&amp;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.
                               '&amp;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 = "&nbsp; &nbsp; &nbsp; &nbsp;(..." . 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>
		   &nbsp; <?php 
            echo convertSecMins($metaData['length']);
            ?>
 &nbsp;
		   </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


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