'Auto Glossary',
'pi_version' => '1.2',
'pi_author' => 'Sadhana Ganapathiraju',
'pi_author_url' => 'http://www.nikhedonia.com/',
'pi_description' => 'Creates a glossary of abbreviations and acronyms',
'pi_usage' => AutoGlossary::usage()
);
class AutoGlossary
{
var $return_data = '';
var $terms = array();
var $dl = '';
function make_termdfn($dt, $dd)
{
$dt = "\t
$dt\n";
$dd = "\t\t$dd\n\n";
return $dt . $dd;
}
function scan()
{
global $TMPL;
$data = str_replace('/', '/', $TMPL->tagdata);
$regex = '/\<(abbr|acronym)\s*?title="(.*?)"\s*?\>(.*?)\<\/(abbr|acronym)\>/';
preg_match_all($regex, $data, $matches, PREG_SET_ORDER);
foreach($matches as $match)
{
// It's possible that two terms have different
// meanings, but it's highly unlikely that the
// same meaning has two different terms.
$this->terms[$match[2]] = $match[3];
}
array_unique($this->terms);
}
function make_dl()
{
global $TMPL;
$dlClassName = $TMPL->fetch_param("class");
if ($dlClassName !== "")
{
$this->dl = "\n";
}
else
{
$this->dl = "\n";
}
foreach($this->terms as $dd => $dt)
{
$this->dl .= $this->make_termdfn($dt, $dd);
}
$this->dl .= "
\n\n";
}
function show()
{
$this->scan();
$this->make_dl();
$this->return_data = str_replace("{glossary}", $this->dl, $this->return_data);
}
function AutoGlossary()
{
global $TMPL;
$this->return_data = $TMPL->tagdata;
$this->show();
}
function usage()
{
ob_start();
?>
Creates a glossary of abbreviations and acronyms. Surround the text you
want parsed with the tags:
{exp:autoglossary class="dl-glossary"}
Text to be passed here...
{glossary{}}
{/exp:autoglossary}
The plugin looks at all the s and s in the text and replaces
all instances of {glossary} with the terms and their definitions.