public function getStructure(\databox $databox) { $statusStructure = new StatusStructure($databox); $xmlPref = $databox->get_structure(); $sxe = simplexml_load_string($xmlPref); if ($sxe === false) { throw new \Exception('Failed to load database XML structure'); } foreach ($sxe->statbits->bit as $sb) { $bit = (int) $sb['n']; if ($bit < 4 && $bit > 31) { continue; } $status = []; $status['bit'] = $bit; $status['labeloff'] = (string) $sb['labelOff']; $status['labelon'] = (string) $sb['labelOn']; foreach ($this->locales as $code => $language) { $status['labels_on'][$code] = null; $status['labels_off'][$code] = null; } foreach ($sb->label as $label) { $status['labels_' . $label['switch']][(string) $label['code']] = (string) $label; } foreach ($this->locales as $code => $language) { $status['labels_on_i18n'][$code] = '' !== trim($status['labels_on'][$code]) ? $status['labels_on'][$code] : $status['labelon']; $status['labels_off_i18n'][$code] = '' !== trim($status['labels_off'][$code]) ? $status['labels_off'][$code] : $status['labeloff']; } $status['img_off'] = null; $status['img_on'] = null; if (is_file($statusStructure->getPath() . '-stat_' . $bit . '_0.gif')) { $status['img_off'] = $statusStructure->getUrl() . '-stat_' . $bit . '_0.gif?etag=' . md5_file($statusStructure->getPath() . '-stat_' . $bit . '_0.gif'); $status['path_off'] = $statusStructure->getPath() . '-stat_' . $bit . '_0.gif'; } if (is_file($statusStructure->getPath() . '-stat_' . $bit . '_1.gif')) { $status['img_on'] = $statusStructure->getUrl() . '-stat_' . $bit . '_1.gif?etag=' . md5_file($statusStructure->getPath() . '-stat_' . $bit . '_1.gif'); $status['path_on'] = $statusStructure->getPath() . '-stat_' . $bit . '_1.gif'; } $status['searchable'] = isset($sb['searchable']) ? (int) $sb['searchable'] : 0; $status['printable'] = isset($sb['printable']) ? (int) $sb['printable'] : 0; $statusStructure->setStatus($bit, $status); } return $statusStructure; }