Pressbooks\Modules\Import\Ooxml\Docx::import PHP Метод

import() публичный Метод

public import ( array $current_import ) : boolean
$current_import array
Результат boolean
    function import(array $current_import)
    {
        try {
            $this->isValidZip($current_import['file']);
        } catch (\Exception $e) {
            return false;
        }
        // get the paths to content
        $doc_path = $this->getTargetPath(self::DOCUMENT_SCHEMA);
        $meta_path = $this->getTargetPath(self::METADATA_SCHEMA);
        // get the content
        $xml = $this->getZipContent($doc_path);
        $meta = $this->getZipContent($meta_path);
        // get all Footnote IDs from document
        $fn_ids = $this->getIDs($xml);
        // get all Endnote IDs from document
        $en_ids = $this->getIDs($xml, 'endnoteReference');
        // get all Hyperlink IDs from the document
        $ln_ids = $this->getIDs($xml, 'hyperlink', 'r:id');
        // process the footnote ids
        if ($fn_ids) {
            // pass the IDs and get the content
            $this->fn = $this->getRelationshipPart($fn_ids);
        }
        // process the endnote ids
        if ($en_ids) {
            $this->en = $this->getRelationshipPart($en_ids, 'endnotes');
        }
        // process the hyperlink ids
        if ($ln_ids) {
            $this->ln = $this->getRelationshipPart($ln_ids, 'hyperlink');
        }
        // introduce a stylesheet
        $proc = new \XSLTProcessor();
        $xsl = new \DOMDocument();
        $xsl->load(__DIR__ . '/xsl/docx2html.xsl');
        $proc->importStylesheet($xsl);
        // throw it back into the DOM
        $dom_doc = $proc->transformToDoc($xml);
        $this->parseMetaData($meta);
        $chapter_parent = $this->getChapterParent();
        foreach ($current_import['chapters'] as $id => $chapter_title) {
            // do nothing it has been omitted
            if (!$this->flaggedForImport($id)) {
                continue;
            }
            $html = $this->parseContent($dom_doc, $chapter_title);
            $this->kneadAndInsert($html, $chapter_title, $this->determinePostType($id), $chapter_parent);
        }
        // Done
        return $this->revokeCurrentImport();
    }