Add RSSGenerator, hooked up to index.xhtml
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / Acronymizer.php
blob66a1449edce132f9f13a1abb36c25f98706897c1
1 <?php
3 /**
4 * Based on a list of known acronyms, populates of the title attribute
5 * of acronym elements in documents.
6 */
7 class XHTMLCompiler_DOMFilter_Acronymizer extends XHTMLCompiler_DOMFilter
10 protected $name = 'Acronymizer';
12 /**
13 * Array of recognized acronyms.
14 * @todo Make a public API for this, allow multiple acronym sets
15 * and different precedences for them.
17 protected $acronyms = array(
18 // markup languages and related technologies
19 'SGML' => 'Standard Generalized Markup Language',
20 'HTML' => 'HyperText Markup Language',
21 'XHTML' => 'Extensible HyperText Markup Language',
22 'XML' => 'Extensible Markup Language',
23 'RSS' => 'Really Simple Syndication',
24 'DTD' => 'Document Type Definition',
25 'CSS' => 'Cascading Style Sheets',
26 // programming/apis
27 'PHP' => 'PHP: HyperText Preprocessor',
28 'CMS' => 'Content Management System',
29 'API' => 'Application Programming Interface',
30 'DOM' => 'Document Object Module',
31 'SAX' => 'Simple API for XML',
32 // web-app security
33 'XSS' => 'Cross-Site Scripting',
34 // organizations/groups
35 'W3C' => 'World Wide Web Consortium',
36 'RFC' => 'Request for Comment',
37 'PEAR' => 'PHP Extension and Application Repository',
38 'PECL' => 'PHP Extension Community Library',
39 // paradigms
40 'WYSIWYG' => 'What You See Is What You Get',
41 'WYSIWYM' => 'What You See Is What You Mean',
42 // character encodings
43 'UTF-8' => '8-bit Unicode Transformation Format',
44 'ASCII' => 'American Standard Code for Information Interchange',
45 // other
46 'INI' => 'Initialization',
47 'UI' => 'User Interface',
48 'SHA-1' => 'Secure Hash Algorithm 1',
49 'CPU' => 'Central Processing Unit',
50 'LGPL' => 'Lesser GNU Public License',
51 'URI' => 'Uniform Resource Identifier',
54 public function process(DOMDocument $dom, $page) {
55 $nodes = $this->query("//html:acronym[not(@title)]");
56 foreach ($nodes as $node) {
57 $acronym = $node->textContent;
58 if (!isset($this->acronyms[$acronym])) {
59 trigger_error(htmlspecialchars($acronym) . ' is not a recognized acronym (missing title attribute)');
60 continue;
62 $node->setAttribute('title', $this->acronyms[$acronym]);