Skip to content

Commit

Permalink
Merge cb89b16 into d4963a1
Browse files Browse the repository at this point in the history
  • Loading branch information
adpe committed Jul 8, 2021
2 parents d4963a1 + cb89b16 commit 4477676
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions classes/checkers/checker_links/checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ public function run($course) {

// For wiki, we have to check the pages too.
if ($modname === self::MOD_TYPE_WIKI) {
$this->check_wiki_pages($mod);
$subwikis = $this->get_subwikis($mod->id);

foreach ($subwikis as $subwiki) {
$this->check_wiki_pages($subwiki->id);
}
}

// Check modules properties.
Expand Down Expand Up @@ -205,18 +209,35 @@ protected function check_book_chapters($mod) {
}

/**
* @param $mod
* Returns the subwikis of a wiki.
*
* @param int $id The wiki id.
* @return array
* @throws \dml_exception
*/
protected function get_subwikis(int $id): array {
global $DB;

return $DB->get_records('wiki_subwikis', ['wikiid' => $id]);
}

/**
* Checks wiki pages links in content of a subwiki.
*
* @param int $id The subwiki id.
* @throws \dml_exception
* @throws moodle_exception
*/
protected function check_wiki_pages($mod) {
protected function check_wiki_pages(int $id) {
global $DB;

$pages = $DB->get_records('wiki_pages', array('subwikiid' => $mod->id), '', 'id,title,cachedcontent');
$pages = $DB->get_records('wiki_pages', ['subwikiid' => $id], '', 'id, title, cachedcontent');

foreach ($pages as $page) {
$target = get_string('checker_links_wiki_page', 'block_course_checker', (object) ["title" => $page->title]);
$target = get_string('checker_links_wiki_page', 'block_course_checker', (object) ['title' => $page->title]);
$resolutionlink = new moodle_url('/mod/wiki/edit.php', ['pageid' => $page->id]);

$this->check_urls_with_resolution_url($this->get_urls_from_text($page->cachedcontent), $resolutionlink, $target);
}
}
}
}

0 comments on commit 4477676

Please sign in to comment.