<?php } ?> <?php $letter = ""; foreach ($this->rows as $glossary) { $thisletter = strtolower(substr($glossary->word, 0, 1)); if ($thisletter != $letter) { $letter = $thisletter; echo "<a name='letter_{$letter}' ></a>"; } ?> <div class="fsf_glossary_div"> <div class="fsf_glossary_title"><a name='<?php echo FSF_Glossary::MakeAnchor($glossary->word); ?> '></a><?php echo $glossary->word; ?> </div> <div class="fsf_glossary_text"><?php echo $glossary->description; echo $glossary->longdesc; ?> </div> <div class="fsf_clear"></div> </div> <?php }
static function ReplaceGlossary($text) { FSF_Glossary::GetGlossary(); if (count(FSF_Glossary::$fsf_glossary) == 0) { return $text; } // build a rough list of terms in the document in question. This means less stuff for the preg to check later on FSF_Glossary::$inuse = array(); foreach (FSF_Glossary::$fsf_glossary as $word => $tip) { if (stripos($text, $word) !== FALSE) { // build an object containing the data about the word we have possibly in the doc $o = new stdClass(); $word = strtolower($word); $o->word = $word; $o->regex = "/\\b({$word})\\b/i"; $o->href = "#"; $anc = FSF_Glossary::MakeAnchor($word); if (FSF_Settings::get('glossary_link')) { $o->href = FSFRoute::_('index.php?option=com_fsf&view=glossary&letter=' . strtolower(substr($word, 0, 1)) . '#' . $anc); } $o->class = "fsj_tip fsf_glossary_word"; FSF_Glossary::$inuse[] = $o; } } // setup empty dom object libxml_use_internal_errors(TRUE); $dom = new DOMDocument('1.0', 'UTF-8'); FSF_Glossary::$cdom =& $dom; $dom->substituteEntities = false; $dom->recover = true; $dom->strictErrorChecking = false; $dom->resolveExternals = false; //$text = str_replace("&","&", $text); // load the xml file. Add padding tags as the dom adds crap to the start of the output $dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?><meta http-equiv="content-type" content="text/html; charset=utf-8"><xxxglossaryxxx>' . $text . "</xxxglossaryxxx>"); // get list of html tags to ignore $tag_ignore = FSF_Settings::get('glossary_exclude'); $tag_ignore = explode(",", $tag_ignore); $tags = array(); $tags[] = "a"; foreach ($tag_ignore as $tag) { $tag = trim($tag); if (!$tag) { continue; } $tags[] = $tag; } // replace all glossary terms FSF_Glossary::preg_replace_dom($dom->documentElement, $tags); // get resultant html $result = $dom->saveHTML(); //$result = str_replace("&","&", $result); // use padding added earlier to remove appended content $pos1 = strpos($result, "<xxxglossaryxxx>") + 16; $pos2 = strrpos($result, "</xxxglossaryxxx>"); $result = substr($result, $pos1, $pos2 - $pos1); return $result; }