OCA\Richdocuments\Controller\DocumentController::prepareDocuments PHP Method

prepareDocuments() private method

Prepare document(s) structure
private prepareDocuments ( $rawDocuments )
    private function prepareDocuments($rawDocuments)
    {
        $discovery_parsed = null;
        try {
            $discovery = $this->getDiscovery();
            $loadEntities = libxml_disable_entity_loader(true);
            $discovery_parsed = simplexml_load_string($discovery);
            libxml_disable_entity_loader($loadEntities);
            if ($discovery_parsed === false) {
                $this->cache->remove('discovery.xml');
                $wopiRemote = $this->appConfig->getAppValue('wopi_url');
                return array('status' => 'error', 'message' => $this->l10n->t('Collabora Online: discovery.xml from "%s" is not a well-formed XML string.', array($wopiRemote)), 'hint' => $this->l10n->t('Please contact the "%s" administrator.', array($wopiRemote)));
            }
        } catch (ResponseException $e) {
            return array('status' => 'error', 'message' => $e->getMessage(), 'hint' => $e->getHint());
        }
        $fileIds = array();
        $documents = array();
        $lolang = strtolower(str_replace('_', '-', $this->settings->getUserValue($this->uid, 'core', 'lang', 'en')));
        foreach ($rawDocuments as $key => $document) {
            if (is_object($document)) {
                $documents[] = $document->getData();
            } else {
                $documents[$key] = $document;
            }
            $documents[$key]['icon'] = preg_replace('/\\.png$/', '.svg', \OCP\Template::mimetype_icon($document['mimetype']));
            $documents[$key]['hasPreview'] = \OC::$server->getPreviewManager()->isMimeSupported($document['mimetype']);
            $ret = $this->getWopiSrcUrl($discovery_parsed, $document['mimetype']);
            $documents[$key]['urlsrc'] = $ret['urlsrc'];
            $documents[$key]['action'] = $ret['action'];
            $documents[$key]['lolang'] = $lolang;
            $fileIds[] = $document['fileid'];
        }
        usort($documents, function ($a, $b) {
            return @$b['mtime'] - @$a['mtime'];
        });
        $session = new Db\Session();
        $sessions = $session->getCollectionBy('file_id', $fileIds);
        $members = array();
        $member = new Db\Member();
        foreach ($sessions as $session) {
            $members[$session['es_id']] = $member->getActiveCollection($session['es_id']);
        }
        return array('status' => 'success', 'documents' => $documents, 'sessions' => $sessions, 'members' => $members);
    }