Code Monkey home page Code Monkey logo

dokuwiki-plugin-odtplus2dw's Introduction

odtplus2dw Plugin

Create a dokuwiki page from a file.

Description

odtplus2dw is a plugin for dokuwiki (forked from odt2dw to add doc/docx support). This plugin lets you import a document into Dokuwiki. It supports (at least) .odt, .doc, .docx formats. It should also work with any other document format that pandoc supports, but it has not been tested yet.

Usage

From a Dokuwiki page, click on the "Import file" button in the Page Tools. Select a File and click upload.

Installation

External requirements: This plugin requires the following additional components that must be installed separately:

  • php xsltProcessor class (ex : php-xml, php5-xsl)
  • php zipArchive class
  • pandoc
  • soffice (ex: libreoffice-writer)

If you run the Dokuwiki server on Debian, you can accomplish this requirements following this directions:

  • Install some packages needed:

sudo apt-get install wget default-jre php5-xsl libreoffice-writer

  • If you wish, you can execute the script installLatestPandoc.sh (included with this plugin) to install the latest version of pandoc. Or you can install pandoc any other way (check that version installed is not very outdated, or the conversion can fail).

soffice conversion (.doc support)

PHP code (at least in my system) is executed by the user daemon. I had problems running a Java application with this user (it seems soffice is a Java application) so I decided to run the soffice conversion using sudo. To make it work, I had to add a line to the file /etc/sudoers. You can do the same executing:

sudo echo "daemon ALL=(root)NOPASSWD:/usr/bin/soffice" >> /etc/sudoers

I'm not a security expert, but I think that this should not be a problem for anybody. If you do not use the soffice conversion (.doc support), you don't need to do this.

If PHP code is executed by any other user on your system, you only have to change it in the previous command.

Configuration and Settings

They are almost self-explanatory.

Change Log

v0.12 beta

  • Fixed: #8

v0.11 beta

  • Now the names of uploaded files can contain spaces.
  • Added French translation (thank you jmgfr!).

v0.10 beta

  • Changed name to odtplus2dw.
  • Added doc/docx support.
  • Added spanish translation.
  • Removed some translations (I can't update them, so I had to remove).

v0.09 beta

  • Adjust method signatures to match parent.
  • Add import button.

v0.08 beta

  • Fixed : bug #9.
  • Fixed : bug #14.

v0.07 beta

  • Fixed : parserPostDisplay now works with choice edit or preview.
  • Fixed : better class existence control.

v0.06 beta

  • Fixed : some small fixes to the english messages.
  • Add : message translation in Dutch (By mprins).
  • Fixed : check for mime type was too specific : It could be set in config panel.
  • Fixed : submit button was not translated and stay in french : His value depend of the dokuwiki lang file now.

v0.05 beta

  • Fixed : display an error if the parserUploadDir directory doesn't exists. Now it will be create if needed.

dokuwiki-plugin-odtplus2dw's People

Contributors

garlik-gag avatar georgesk avatar jmgfr avatar mprins avatar qky666 avatar rotdrop avatar splitbrain avatar thschrad avatar

Watchers

 avatar  avatar

dokuwiki-plugin-odtplus2dw's Issues

odtplus2dw/action.php(438) E_WARNING: Undefined variable $ID

Hello again, @qky666
Thanks for quick fix at #8 !

I've found one more problem and fix for it:

2024-02-19 08:03:56     /opt/www/wiki/lib/plugins/odtplus2dw/action.php(438) E_WARNING: Undefined variable $ID
  #0 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(438): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined varia...', '/opt/www/wiki.c...', 438)
  #1 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(255): action_plugin_odtplus2dw->_apply_result()
  #2 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(126): action_plugin_odtplus2dw->_odtplus2dw()
  #3 /opt/www/wiki/inc/Extension/EventHandler.php(80): action_plugin_odtplus2dw->_parser(Object(dokuwiki\Extension\Event), Array)
  #4 /opt/www/wiki/inc/Extension/Event.php(75): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'BEFORE')
  #5 /opt/www/wiki/inc/ActionRouter.php(83): dokuwiki\Extension\Event->advise_before()
  #6 /opt/www/wiki/inc/ActionRouter.php(49): dokuwiki\ActionRouter->setupAction('odtplus2dw')
  #7 /opt/www/wiki/inc/ActionRouter.php(62): dokuwiki\ActionRouter->__construct()
  #8 /opt/www/wiki/inc/actions.php(19): dokuwiki\ActionRouter::getInstance(true)
  #9 /opt/www/wiki/doku.php(131): act_dispatch()
  #10 {main}

https://github.com/qky666/dokuwiki-plugin-odtplus2dw/blob/master/action.php#L428-L458:

$ID is missing in this part. Only superusers can upload images due to this.
Simple addition , $ID to global $INFO; at https://github.com/qky666/dokuwiki-plugin-odtplus2dw/blob/master/action.php#L433 fixes this problem.

We've added debug messages and tested:

  • msg( 'odtplus2dw_TEST: auth_check:'.auth_quickaclcheck($ID).' id:'.serialize($ID).' upload:'.AUTH_UPLOAD);

Before:

  • odtplus2dw_TEST: auth_check:0 id: upload:8

After:

  • odtplus2dw_TEST: auth_check:16 id:s:16:"playground:test3"; upload:8

And one more little problem:

2024-02-19 13:33:15     /opt/www/wiki/lib/plugins/odtplus2dw/action.php(479) E_WARNING: Undefined array key 4
  #0 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(479): dokuwiki\ErrorHandler::errorHandler(2, 'Undefined array...', '/opt/www/wiki.c...', 479)
  #1 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(254): action_plugin_odtplus2dw->_parse_image()
  #2 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(126): action_plugin_odtplus2dw->_odtplus2dw()
  #3 /opt/www/wiki/inc/Extension/EventHandler.php(80): action_plugin_odtplus2dw->_parser(Object(dokuwiki\Extension\Event), Array)
  #4 /opt/www/wiki/inc/Extension/Event.php(75): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'BEFORE')
  #5 /opt/www/wiki/inc/ActionRouter.php(83): dokuwiki\Extension\Event->advise_before()
  #6 /opt/www/wiki/inc/ActionRouter.php(49): dokuwiki\ActionRouter->setupAction('odtplus2dw')
  #7 /opt/www/wiki/inc/ActionRouter.php(62): dokuwiki\ActionRouter->__construct()
  #8 /opt/www/wiki/inc/actions.php(19): dokuwiki\ActionRouter::getInstance(true)
  #9 /opt/www/wiki/doku.php(131): act_dispatch()
  #10 {main}

Looks like most of the time $value[4] is undefined at https://github.com/qky666/dokuwiki-plugin-odtplus2dw/blob/master/action.php#L476

Maybe something like https://www.php.net/manual/en/function.array-key-exists.php should be added?
Like if (array_key_exists(4, $value)) {$other = $value[4];} else {$other='';}

MaxFileSize settings not working

Hi everyone.

DokuWiki is installed on a docker container (with nginx+php7).

Note : The max file size for nginx and php7 has been increased to 10M. BTW it works. I can upload photos largers than the originally 1M size (tried 5M and it works like a charm).

Now, what happen if i change the maxfilesize settings to 4097152-(4Mo) in the plugin settings.
When i try to upload files < 2MB it works.
When i try to upload files > 2 MB it fails, like before.

I have to say that the parameters is indeed changed (the form with hidden "name="MAX_FILE_SIZE" is showing me the "4097152" number not the default one.)

Thanks for your help.

Great Plugin btw.

Error: Undefined constant "XSLTProcessor"

Hello @qky666 , I understand that plugin development have stopped years ago, but it was working fine for me.

But after update to php 8+ I got this error:
image

2024-02-14 10:19:01     /opt/www/wiki.cspfmba.ru/lib/plugins/odtplus2dw/action.php(214) Error: Undefined constant "XSLTProcessor"                    
  #0 /opt/www/wiki/lib/plugins/odtplus2dw/action.php(126): action_plugin_odtplus2dw->_odtplus2dw()                                        
  #1 /opt/www/wiki/inc/Extension/EventHandler.php(80): action_plugin_odtplus2dw->_parser(Object(dokuwiki\Extension\Event), Array)         
  #2 /opt/www/wiki/inc/Extension/Event.php(75): dokuwiki\Extension\EventHandler->process_event(Object(dokuwiki\Extension\Event), 'BEFORE')
  #3 /opt/www/wiki/inc/ActionRouter.php(83): dokuwiki\Extension\Event->advise_before()                                                    
  #4 /opt/www/wiki/inc/ActionRouter.php(49): dokuwiki\ActionRouter->setupAction('odtplus2dw')                                             
  #5 /opt/www/wiki/inc/ActionRouter.php(62): dokuwiki\ActionRouter->__construct()                                                         
  #6 /opt/www/wiki/inc/actions.php(19): dokuwiki\ActionRouter::getInstance(true)                                                          
  #7 /opt/www/wiki/doku.php(131): act_dispatch()                                                                                          
  #8 {main}          

According to code https://github.com/qky666/dokuwiki-plugin-odtplus2dw/blob/master/action.php#L214-L216:

    // Class Control
    if ( ! class_exists( XSLTProcessor ) ) return $this->_msg('er_class_xsltProcessor');
    if ( ! class_exists( ZipArchive ) ) return $this->_msg('er_class_zipArchive');
    if ( ! class_exists( DOMDocument ) ) return $this->_msg('er_class_domDocument');
    // Create instance of needed class
    $this->XSLT = new XSLTProcessor;
    $this->ZIP  = new ZipArchive;
    $this->XSL  = new DOMDocument;
    $this->XML  = new DOMDocument;

and my tests - small edition - adding quotes to XSLTProcessor, ZipArchive and DOMDocument in class_exists statement fixes the problem.

Can you add this fix? Without it, I have to manually patch our file.

Permission problem with doc file on fresh install

I have installed DokuWiki on my Ubuntu machine with Apache
DokuWiki - Release 2018-04-22a "Greebo"
odtplus2dw - v0.10 from 2018-06-28

I even enabbled logging in the plugin settings, but I see this:

odtplus2dw : er_logFile : Unable to write in the logFile
odtplus2dw : er_file_upload : Something went wrong with the file's upload : 2
odtplus2dw : er_checkUploadResult : Something is wrong with the uploaded file
odtplus2dw : er_pg_dir : Unable to remove the temporary directory : /

I can create pages, so no permission problem for DokuWiki itself.
PHPInfo attached below.

What do I miss?
Thanks.

phpinfo.zip

odt files with embedded images

Since manually uploading images and manually embedding them in DW pages is one of the most laborious jobs, my main interest would be to upload odt files with embedded images and have it all handled in one import step, with the images handled automatically. As a novice, it isn't clear to me if this (or some other?) plug-in handles odt filed with images in them, or if it only translates formatted text. Please let me know about this and any special considerations or suggestion to upload odt files with embedded images. Thanks! Baxter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.