public function TMGMTFileFormatHTML::import in Translation Management Tool 7
Converts an exported file content back to the translated data.
Parameters
string $imported_file: Path to a file or an XML string to import.
bool $is_file: (optional) Whether $imported_file is the path to a file or not.
Return value
Translated data array.
Overrides TMGMTFileFormatInterface::import
File
- translators/
file/ tmgmt_file.format.html.inc, line 47
Class
- TMGMTFileFormatHTML
- Export into HTML.
Code
public function import($imported_file, $is_file = TRUE) {
$dom = new DOMDocument();
$dom
->loadHTMLFile($imported_file);
$xml = simplexml_import_dom($dom);
$data = array();
foreach ($xml
->xpath("//div[@class='atom']") as $atom) {
// Assets are our strings (eq fields in nodes).
$key = $this
->decodeIdSafeBase64((string) $atom['id']);
$data[$key]['#text'] = (string) $atom;
}
return tmgmt_unflatten_data($data);
}