mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
New lightspeed wiki filter (using the static and nothingtodo technologies now)
This commit is contained in:
parent
d79a0c4cab
commit
26ccd11c60
@ -10,32 +10,37 @@
|
||||
|
||||
global $CFG;
|
||||
|
||||
static $nothingtodo;
|
||||
static $wikipagelist;
|
||||
|
||||
if (!empty($nothingtodo)) { // We've been here in this page already
|
||||
return $text;
|
||||
}
|
||||
|
||||
if (empty($courseid)) {
|
||||
if ($site = get_site()) {
|
||||
$courseid = $site->id;
|
||||
}
|
||||
$courseid = SITEID;
|
||||
}
|
||||
|
||||
if (!($course = get_record('course', 'id', $courseid))) {
|
||||
/// Create a list of all the wikis to search for. It may be cached already.
|
||||
|
||||
if (empty($wikipagelist)) {
|
||||
|
||||
/// Get all wikis for this course.
|
||||
if (!$wikis = wiki_get_course_wikis($courseid)) {
|
||||
$nothingtodo = true;
|
||||
return $text;
|
||||
}
|
||||
|
||||
$linkarray = array();
|
||||
$wikipagelist = array();
|
||||
|
||||
// Get all wikis for this course.
|
||||
$wikis = wiki_get_course_wikis($courseid);
|
||||
if (empty($wikis)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
// Walk through each wiki, and get entries.
|
||||
/// Walk through each wiki, and get entries.
|
||||
foreach ($wikis as $wiki) {
|
||||
if ($wiki_entries = wiki_get_entries($wiki)) {
|
||||
|
||||
// Walk through each entry and get the pages.
|
||||
/// Walk through each entry and get the pages.
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id, 'pagename, version DESC')) {
|
||||
// Walk through each page and filter.
|
||||
/// Walk through each page and filter.
|
||||
$wikientries = array();
|
||||
foreach ($wiki_pages as $wiki_page) {
|
||||
if (!in_array($wiki_page->pagename, $wikientries)) {
|
||||
@ -44,7 +49,7 @@
|
||||
.'&userid='.$wiki_entry->userid
|
||||
.'&groupid='.$wiki_entry->groupid
|
||||
.'&page='.$wiki_page->pagename.'">';
|
||||
$linkarray[] = new filterobject($wiki_page->pagename, $startlink, '</a>', false, true);
|
||||
$wikipagelist[] = new filterobject($wiki_page->pagename, $startlink, '</a>', false, true);
|
||||
$wikientries[] = $wiki_page->pagename;
|
||||
}
|
||||
}
|
||||
@ -52,8 +57,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filter_phrases($text, $linkarray);
|
||||
return filter_phrases($text, $wikipagelist);
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user