diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
index 9e83ed256..53a78c9c6 100644
--- a/phpdotnet/phd/Package/PHP/XHTML.php
+++ b/phpdotnet/phd/Package/PHP/XHTML.php
@@ -336,31 +336,30 @@ public static function generateAcronymInfo($filename) {
if ($info) {
return $info;
}
+
if (!is_file($filename)) {
trigger_error(vsprintf("Can't find acronym file (%s), skipping", [$filename]), E_USER_WARNING);
return array();
}
- $r = new \XMLReader;
- if (!$r->open($filename)) {
- throw new \Error(vsprintf('Could not open file for accessing acronym information (%s)', [$filename]));
+ $useInternalErrors = libxml_use_internal_errors(true);
+ $entities = simplexml_load_file($filename);
+ libxml_clear_errors();
+ libxml_use_internal_errors($useInternalErrors);
+ if ($entities === false) {
+ trigger_error(vsprintf("Can't parse acronym file (%s), skipping", [$filename]), E_USER_WARNING);
+ return [];
}
- $acronyms = array();
- $k = "";
- while ($r->read()) {
- if ($r->nodeType != \XMLReader::ELEMENT) {
- continue;
- }
- if ($r->name == "term") {
- $r->read();
- $k = $r->value;
- $acronyms[$k] = "";
- } else if ($r->name == "simpara") {
- $r->read();
- $acronyms[$k] = $r->value;
+ $acronyms = [];
+ foreach ($entities as $entity) {
+ $name = (string) $entity["name"];
+ if (str_starts_with($name, "acronym.expansion.")) {
+ $acronyms[substr($name, strlen("acronym.expansion."))] = trim(preg_replace('/\s+/', ' ', (string) $entity));
}
}
+
+ ksort($acronyms);
$info = $acronyms;
return $acronyms;
}
diff --git a/render.php b/render.php
index 94c9e0967..15f8c7b87 100644
--- a/render.php
+++ b/render.php
@@ -61,12 +61,21 @@
// This needs to be moved. Preferably into the PHP package.
if (!$conf) {
+ // Acronym expansions come from the translatable entity file in the
+ // language checkout (e.g. en/, it/), languages without a
+ // translated copy fall back to the English one.
+ $acronymFilename = dirname($config->xmlRoot) . DIRECTORY_SEPARATOR . $config->language
+ . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'entities.acronyms.ent';
+ if (!is_file($acronymFilename)) {
+ $acronymFilename = dirname($config->xmlRoot) . DIRECTORY_SEPARATOR . 'en'
+ . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'entities.acronyms.ent';
+ }
$config->init(array(
"langDir" => __INSTALLDIR__ . DIRECTORY_SEPARATOR . "phpdotnet" . DIRECTORY_SEPARATOR
. "phd" . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR
. "langs" . DIRECTORY_SEPARATOR,
"phpwebVersionFilename" => $config->xmlRoot . DIRECTORY_SEPARATOR . 'version.xml',
- "phpwebAcronymFilename" => $config->xmlRoot . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'acronyms.xml',
+ "phpwebAcronymFilename" => $acronymFilename,
"phpwebSourcesFilename" => $config->xmlRoot . DIRECTORY_SEPARATOR . 'sources.xml',
"phpwebHistoryFilename" => $config->xmlRoot . DIRECTORY_SEPARATOR . 'fileModHistory.php',
));
@@ -108,7 +117,7 @@
$outputHandler->v("Indexing...", VERBOSE_INDEXING);
// Create indexer
$format = new Index($config->indexCache, $config, $outputHandler);
-
+
$render->attach($format);
$outputHandler->v("Running full build", VERBOSE_RENDER_STYLE);
diff --git a/tests/package/php/acronym_info_001.phpt b/tests/package/php/acronym_info_001.phpt
new file mode 100644
index 000000000..b015243d2
--- /dev/null
+++ b/tests/package/php/acronym_info_001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Acronym info 001 - Acronyms are read from acronym.expansion.* entity elements
+--FILE--
+
+--EXPECT--
+array(4) {
+ ["API"]=>
+ string(33) "Application Programming Interface"
+ ["CSPRNG"]=>
+ string(54) "Cryptographically Secure PseudoRandom Number Generator"
+ ["PHP"]=>
+ string(27) "PHP: Hypertext Preprocessor"
+ ["cURL"]=>
+ string(18) "Client URL Library"
+}
diff --git a/tests/package/php/data/acronyms.xml b/tests/package/php/data/acronyms.xml
deleted file mode 100644
index 0120d0892..000000000
--- a/tests/package/php/data/acronyms.xml
+++ /dev/null
@@ -1,368 +0,0 @@
-
-
-
-
-
- Acronyms
-
-
- API
-
- Application Programming Interface
-
-
-
- ASCII
-
- American Standard Code for Information Interchange
-
-
-
- BMP
-
- Bitmap
-
-
-
- CGI
-
- Common Gateway Interface
-
-
-
- CLI
-
- Command Line Interpreter/Interface
-
-
-
- CSS
-
- Cascading Style Sheets
-
-
-
- CSV
-
- Comma Separated Value
-
-
-
- CVS
-
- Concurrent Versions System
-
-
-
- DLL
-
- Dynamic Link Library
-
-
-
- DSSSL
-
- Document Style Semantics and Specification Language
-
-
-
- EXIF
-
- Exchangeable Image File
-
-
-
- EOF
-
- End Of File
-
-
-
- FAQ
-
- Frequently Asked Questions
-
-
-
- FTP
-
- File Transfer Protocol
-
-
-
- GD
-
- Graphics Draw
-
-
-
- GIF
-
- Graphic Interchange Format
-
-
-
- GMP
-
- GNU Multiple Precision
-
-
-
- HIS
-
- Hyperwave Information Server
-
-
-
- HTML
-
- Hyper Text Markup Language
-
-
-
- HTTP
-
- Hypertext Transfer Protocol
-
-
-
- IDE
-
- Integrated Development Environment
-
-
-
- IFD
-
- Image File Directory
-
-
-
- IFF
-
- Interchange File Format
-
-
-
- IMAP
-
- Internet Message Access Protocol
-
-
-
- JB2
-
- Joint Bilevel Image Experts Group
-
-
-
- JP2
-
- JPEG-2000
-
-
-
- JPC
-
- Japan Picture
-
-
-
- JPEG
-
- Joint Photographic Experts Group
-
-
-
- MIME
-
- Multipurpose Internet Mail Extensions
-
-
-
- MP
-
- Multiple Precision
-
-
-
- MSDN
-
- Microsoft Developer Network
-
-
-
- NNTP
-
- Network News Transfer Protocol
-
-
-
- PDF
-
- Portable Document Format
-
-
-
- PECL
-
- PHP Extension and Application Repository
-
-
-
- PHP
-
- PHP: Hypertext Preprocessor
-
-
-
- PNG
-
- Portable Network Graphics
-
-
-
- POP3
-
- Post Office Protocol version 3
-
-
-
- POSIX
-
- Portable Operating System Interface
-
-
-
- PSD
-
- Photoshop Document
-
-
-
- RGB
-
- Red-Green-Blue
-
-
-
- SAPI
-
- Server Application Programming Interface
-
-
-
- SASL
-
- Simple Authentication and Security Layer
-
-
-
- SWF
-
- Shockwave Flash
-
-
-
- TCP
-
- Transmission Control Protocol
-
-
-
- TIFF
-
- Tagged Image File Format
-
-
-
- TNS
-
- Transparent Network Substrate
-
-
-
- UDF
-
- User Defined Functions
-
-
-
- Unicode
-
- Unique, Universal, and Uniform character enCoding
-
-
-
- URI
-
- Uniform Resource Identifier
-
-
-
- URL
-
- Uniform Resource Locator
-
-
-
- WBMP
-
- Wireless Bitmap
-
-
-
- XBM
-
- X Bitmap
-
-
-
- XML
-
- eXtensible Markup Language
-
-
-
- XPath
-
- XML Path Language
-
-
-
- XSLT
-
- eXtensible Stylesheet Language Transformations
-
-
-
-
-
-
-
diff --git a/tests/package/php/data/entities.acronyms.ent b/tests/package/php/data/entities.acronyms.ent
new file mode 100644
index 000000000..a657a3cff
--- /dev/null
+++ b/tests/package/php/data/entities.acronyms.ent
@@ -0,0 +1,23 @@
+
+
+
+
+
+Some other, non acronym, entity
+
+PHP
+
+Application Programming Interface
+
+
+ Cryptographically Secure
+ PseudoRandom Number Generator
+
+
+PHP: Hypertext Preprocessor
+
+Client URL Library
+
+