Skip to content

Commit

Permalink
NEW phpoffice/phpword support
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 20, 2023
1 parent d7b5507 commit 4ce580f
Show file tree
Hide file tree
Showing 24 changed files with 166 additions and 6,905 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/update-js.yml

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Overview

The module adds functionality to import OpenOffice-compatible files (doc, docx, etc) into Silverstripe pages and content.
The module adds functionality to import .docx files into Silverstripe pages and content.

## Installation

Expand All @@ -15,12 +15,35 @@ composer require silverstripe/documentconverter

## Configuration

You will need to set the following three environment variables:
### PHPOffice/PHPWord

By default this project will use the [PHPOffice/PHPWord](https://github.com/PHPOffice/PHPWord) library to convert uploaded word documents.

### docvert

**Note:** Using of of [docvert](https://github.com/holloway/docvert) to convert uploaded word documents was primarily designed for Common Web Platform (CWP) clients. It is no longer recommended to use docvert.

docvert support is deprecated and will be removed in the next major version

If you wish to use docvert instead of PHPOffice/PHPWord, then add the following configuration to your project:

```yaml
SilverStripe\DocumentConverter\ImportField:
importer_class: SilverStripe\DocumentConverter\ServiceConnector
```
If you are using docver then you will need to set the following three environment variables:
- `DOCVERT_USERNAME`
- `DOCVERT_PASSWORD`
- `DOCVERT_URL`

**Note:** This module is primarily designed for Common Web Platform (CWP) clients. There will be additional setup required to use this module as intended, if you are not using the CWP government edition.
If do not have the cwp/cwp-core module installed then enable docvert with the following configuration - note will be automatically applied if you also have the cwp/cwp-core module installed and the `DOCVERT_USERNAME` environment variable set.

```yaml
Page:
extensions:
- SilverStripe\DocumentConverter\PageExtension
```

## User Guide

Expand Down
8 changes: 8 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
Name: documentconverter
Only:
classexists: Page
---
Page:
extensions:
- SilverStripe\DocumentConverter\PageExtension
6 changes: 0 additions & 6 deletions babel.config.json

This file was deleted.

1 change: 0 additions & 1 deletion client/dist/js/DocumentConversionField.js

This file was deleted.

44 changes: 0 additions & 44 deletions client/src/js/DocumentConversionField.js

This file was deleted.

1 change: 0 additions & 1 deletion codecov.yml

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"require": {
"php": "^8.1",
"silverstripe/cms": "^5",
"silverstripe/asset-admin": "^2"
"silverstripe/asset-admin": "^2",
"phpoffice/phpword": "^1.1"
},
"require-dev": {
"ext-curl": "*",
Expand Down
Binary file modified docs/en/userguide/_images/interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions docs/en/userguide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,3 @@ If you upload the document straight away the simplest scenario will be executed:
* The original document will be removed afterwards
* The page will remain in draft mode for you to preview the output
* All images that came with the document will be stored in the top level directory of the assets

The interface will allow you to fine tune your import options. Import will start as soon as you choose the file to import, so set up the options beforehand. The options are, from top to bottom:

* *Split document into pages*: scans the document looking for level 1 or level 2 headings and
puts each subsection into separate child page. It will cause the conversion process to
replace the existing children pages completely. The initial part of the document until the
first header occurrence will be added to the main page instead.
* *Keep the original document*: prevents the removal of the uploaded document. The document will become
available in the *Files* section of the CMS. Also, if the TOC has been enabled, the link will be
automatically added to the main page.
* *Choose a folder to save this file*: asset directory to be used for storing the original document and the
image files that came along with the document.
* *Replace this page with a Table of Contents*: will generate the Table of Contents and replace the main page
content with it. Caution: this can remove some of the document content that would otherwise be added here
(see the *Split document into pages* option above).
* *Publish modified pages*: in addition to performing all other actions it will publish the pages. Reviewing
the conversion outcome is advised before publishing, so avoid this option unless you are sure what will
be produced.

## Contributing

### Translations

Translations of the natural language strings are managed through a third party translation interface, transifex.com. Newly added strings will be periodically uploaded there for translation, and any new translations will be merged back to the project source code.

Please use [https://www.transifex.com/projects/p/silverstripe-documentconverter](https://www.transifex.com/projects/p/silverstripe-documentconverter) to contribute translations, rather than sending pull requests with YAML files.
1 change: 1 addition & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ en:
EachH1: 'for each heading 1'
EachH2: 'for each heading 2'
FileWarningHeader: 'Warning: import will remove all content and subpages of this page.'
DoNoSaveWarning: 'Note: Only .docx files are supported.<br><br>Warning: Page content will be updated as soon as you select a file.<br><br>Do not click the Save or Publish buttons as this will revert the uploaded content.'
ImportedFromFile: 'Import content from a word document'
IncludeTOC: 'Replace this page with a Table of Contents.'
KeepSource: 'Keep the original document. Adds a link to it on TOC, if enabled.'
Expand Down
27 changes: 0 additions & 27 deletions package.json

This file was deleted.

Loading

0 comments on commit 4ce580f

Please sign in to comment.