Description
The Docx module in conjunction with the Docx node module (which is packaged with the docx module) allows users to download node content as Word documents. The point is to enable people to have the content in the form of a docx document which they can then easily further edit (or whatever they want to do with it) with Word. This is an alternative to simply copying and pasting a web page into Word - which can lead to results which are hard to work with and that are not necessarily particularly attractive. This is not designed to reproduce complex layout in a Word document, but rather create a document which is easy and familiar for end users to use.
This module was created for the Commtap project. Example page with link to Word document - click on the Word icon on the top right of the content area. The Commtap project is a collaborative project which allows users to share ideas for supporting work with people with communication disabilities. A number of users were not comfortable with using web forms for adding and editing content, so instead they can download this content as a Word document - which they are more comfortable and familiar with - and upload the changed document back to the site - which the sites editors can then deal with.
The project depends on an external project (HTML to docx converter) which I have also written.
More detailed information
This project is currently two modules:
- The Docx module - which manages the included libraries and has generic functions for creating a docx download;
- The Docx node module - this adds content from a node object into the Word document.
The project is structured like this to allow for the possibility of creating further modules for processing other types of non-node content.
The module uses the Drupal theme system to provide a default way of styling the resulting Word document, and allow developers to customise how the Word document looks. Theme functions can be defined per content type, or for all content types. Content can be inserted into the Word document by either using direct PHPWord methods or using HTML to docx converter functions to insert HTML. When using the HTML to docx converter functions, a style function can be configured to allow HTML elements to be styled in a defined way in the Word document according to their name or CSS class.
Git
Git repository see: 6.x.1.x branch. Clone with:
git clone --recursive --branch 6.x.1.x git.drupal.org:sandbox/neilt17/1694708.git docx.
Drupal version
This is for Drupal 6. It shouldn't be much work for me to create a Drupal 7 version.
Comments
Comment #0.0
neilt17 commentedClarified information on what the Commtap project is for.
Comment #0.1
neilt17 commentedCorrected Git instructions.
Comment #1
Milena commentedAutomated review
It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Manual review
docx.info file
In your .info file you have ; $Id$
Please, remove it. It is old CVS tag.
docx.install file
Consider using get_t() function instead of st(). It is meant for .install files which can be run after Drupal core installation.
docx.module file
hook_menu()
You have description telling 'description' => 'Download pages in the docx format.',
I believe this is wrong description because element provides settings form, not download page.
On the beginning you have some code not placed in functions:
// Load the converter files if it looks like they have been obtained:
You have 2 hooks for that:
hook_init() which is cached.
hook_book() which is not cached, but not all modules functions will be loaded when hook_boot() is called.
You do not use any module functions, so consider using one of the hooks mentioned before.
docx.admin.inc file
docx_settings()
Remove any commented code.
docx_admin_form()
I do not see $nodetype_options defined in your module, yet you use it in your function. I have found that you use it in docxnode module, but I can enable docx without docxnode.
docxnode module
It's basically the same as docx module.
Remove CVS tag, remove commented code
You should also avoid obvious comment. This makes readability worse. Some examples below:
Summary
I wrote my last module for 6.x really long time ago, so my review might not be as accurate as it should be.
But while you are waiting for other reviews you can work with these issues.
I have not enabled your module (I admit) due to lack of drupal 6 instance at the moment, but your application was in the issue queue for so long without an answer I believe even my review could be helpful a little.
What's more, I believe you should consider participating in Review bonus to get your application reviewed sooner.
Comment #2
joelrosen commentedComment #3
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
Comment #4
one_hoopy_frood commentedHi there Neil. Congrats on a nice little module. It does nearly exactly what I need to accomplish.
NOTE:
I am -not- a drupal coder ... but am basically familiar with php and trying to get there. I have a project due in 2 weeks and most of the docx module is serving what I need. Though, to be honest, my template function is a complete rewrite and doesn't use the simplehtmldom at all, just straight calls to PHPword to write out a custom, templatted document.
Anyhow, the important small issue:
Per-content type, allow only certain roles to download it:
I just want to make a little top-right link "Download Docx" to show for only a certain role on enabled nodes. Was thinking of somehow making a section on the EDIT CONTENT TYPE menu that said something like "ALLOW THE FOLLOWING ROLES TO RECEIVE A DOCX DOWNLOAD LINK"
[then, select radio button roles]
I have been working on looking at how the PRINT module does this, but it's rather complex, and I'm getting lost.
Security hangup?:
i also notice that an anonymous user is served a docx file if they know to prefix with docx in the url:
If an anonymous user goes to :
mysite.com/docx/node/207
even though they don't have permission to access that node type, the theme function will run and offer them a docx download containing only the 'public' field content (of which there is none, so they get a blank document with only the "TITLE" field in it). That's not a huge issue, but I'd like them to just get a page not found error rather than being served anything at all.
Thoughts?
Comment #5
neilt17 commentedComment #6
neilt17 commentedThank you for posting this here one_hoopy_frood.
I have added a node access check to the module - line 108 of docxnode.module - so users who don't have access to the node should now get an access denied message if they and try and download it as a docx document. Thank you for pointing that one out - could you check if that works OK for you?
To determine whether or not to display a download link for the node currently being viewed, use the docx_access_check() function:
For example, put something like this in your template.php file:
Then include this in your template file, e.g.
<div><?php print $my_docx_download_link ?></div>Comment #7
one_hoopy_frood commentedAnonymous user fix:
Verrrrruh naaaaaaace.
Tried a couple of different ways and anonymous users now receive an 'access denied' error when attempting to guess the url via:
mysite/docx/node/399
Floating Link:
I'll try to implement the link and see what happens. ;)
Thanks a bundle!
Comment #8
one_hoopy_frood commentedOkay, so I
-placed the 'if then' code you wrote in my template.php file.
-placed the
print $my_docx_download_linkcode in my node.tpl.php
No joy.
Troubleshoot #1:
I hard-coded the following into the node.tpl.php :
where the link should go, and it DOES print that in the right place.
Troubleshoot #2:
I put that back to the 'print the variable form' :
<div><?php print $my_docx_download_link ?></div>Then, I changed the code in template.php to this:
$vars['my_docx_download_link'] = 'ignore this text';Does not print.
Troubleshoot #3:
I then changed the code in template.php thusly and got:
$my_docx_download_link = 'ignore this text';But that doesn't print either.
What do I not get? It seems like the variable does not pass between the two ... or the template.php page is parsed afterward or something.
Thoughts? I appreciate your time on this matter.
Chris
Comment #9
neilt17 commentedIf you are putting that code in the
phptemplate_preprocess_page(&$vars)function, then that variable should appear in your page.tpl.php file, or in node.tpl.php if you put it inphptemplate_preprocess_node(&$vars)- is that what you are doing?Comment #10
one_hoopy_frood commentedAh yes. Now I feel totally lost. ;)
Actually, I don't know what I am to make of this:
phptemplate_preprocess_node(&$vars)Where does that go?
Much obliged for help.
Chris
Comment #11
neilt17 commentedProbably a bit too much to go into here. A really good book that explains how this works is "Pro Drupal 7 Development" or "Pro Drupal Development 2nd edition" (for Drupal 6). You can find it here: http://www.drupalbook.com/
Comment #12
one_hoopy_frood commentedWill read it, thanks again. =)
Comment #12.0
one_hoopy_frood commentedFurther correction to Git instructions.