Skip to content

Commit

Permalink
mod-glossary MDL-23026 Fixed regressions in conversion to OUTPUT for …
Browse files Browse the repository at this point in the history
…glossary auto-linking filter
  • Loading branch information
Sam Hemelryk committed Jul 20, 2010
1 parent d9eb626 commit 4843f0d
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions mod/glossary/filter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php

/**
*
* @global moodle_database $DB
* @global core_renderer $OUTPUT
* @param int $courseid
* @param string $text
* @return string
*/
function glossary_filter($courseid, $text) {
global $CFG, $DB, $OUTPUT;
global $CFG, $DB, $OUTPUT, $GLOSSARY_EXCLUDECONCEPTS;

// Trivial-cache - keyed on $cachedcourseid
static $nothingtodo;
Expand Down Expand Up @@ -114,7 +122,6 @@ function glossary_filter($courseid, $text) {
foreach ($concepts as $concept) {

$glossaryname = $glossaries[$concept->glossaryid];

if ($concept->category) { // Link to a category
$title = strip_tags($glossaryname.': '.$strcategory.' '.$concept->concept);
$href_tag_begin = '<a class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
Expand All @@ -128,26 +135,23 @@ function glossary_filter($courseid, $text) {
$encodedconcept = urlencode($concept->concept);
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
}
$randid = html_writer::random_id($title);
$href_tag_begin = '<a id="'.$randid.'" class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
'href="'.$CFG->wwwroot.'/mod/glossary/showentry.php?courseid='.$courseid.
'&amp;concept='.$encodedconcept.'" >';

//attach the onclick event
$link = '/mod/glossary/showentry.php?courseid='.$courseid.'\&amp;concept='.$encodedconcept;
$action = new popup_action('click', $link.'&popup=1', 'entry', array('height'=>600,'width'=>450));
$OUTPUT->add_action_handler($action, $randid);
$randid = html_writer::random_id('glossary');
$link = new moodle_url('/mod/glossary/showentry.php', array('courseid'=>$courseid, 'concept'=>$encodedconcept));
$href_tag_begin = html_writer::start_tag('a', array(
'href'=>$link,
'id'=>$randid,
'title'=>$title,
'class'=>'glossary autolink glossaryid'.$concept->glossaryid));
//attach the onclick events
$OUTPUT->add_action_handler(new popup_action('click', new moodle_url($link, array('popup'=>'1')), 'entry', array('height'=>600,'width'=>450)), $randid);
}


$conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>',
$concept->casesensitive, $concept->fullmatch);
}

$conceptlist = filter_remove_duplicates($conceptlist);
}

global $GLOSSARY_EXCLUDECONCEPTS;
if(!empty($GLOSSARY_EXCLUDECONCEPTS)) {
$reducedconceptlist=array();
foreach($conceptlist as $concept) {
Expand Down

0 comments on commit 4843f0d

Please sign in to comment.