getFilename(); global $lang; if (\strpos($filename, $lang)) { $key = $lang; } else { $key = DEFAULT_LOCALE; } $sections = $this->getFromCache($key); if (is_null($sections)) { if (!($data = @file_get_contents($filename))) { throw new \ErrorException(self::ERROR_READING_FILE); } /** * Let's replace some of the docbook tags and wrap some HTML-entities * inside CDATA containers. */ $pattern = array( '/(.+)<\/ulink>/isU', '/(.+)<\/itemizedlist>/isU', '/(.+)<\/simpara><\/listitem>/isU', '/(.+)<\/simpara>/isU', '/(.+)<\/emphasis>/isU', '/(.+)<\/envar>/isU', '/]+)?>(.+)<\/command>/isU', '/
(.+)<\/blockquote>/isU', '/]+)?>(.+)<\/programlisting>/isU', '/(.+)<\/quote>/isU', '//isU', '/(&(?:lt|gt|quot);)/is', ); $replace = array( '\\2', '\\1', '\\1', '\\1', '\\1', // emphasis '\\1', '\\1', // command '\\1', '\\1', // programlisting '“\\1”', '', '', ); $data = preg_replace($pattern, $replace, $data); /* Remove this weird character as it displays as À in Firefox. */ $data = str_replace(chr(194), '', $data); /* Now parse the data. */ $parser = new XMLParser(); $parsedData = $parser->parseByData($data); $sections = array(); /** * Build a map of the defined hrefs so we can give the xrefs the correct * text. */ $xref = array(); $count = 1; foreach (array_values($parsedData['faq']['section']) as $data) { $sections[] = new FaqSection($data, $count++, $xref); } $this->saveToCache($sections, $key); } return $sections; } }