NP_AttachFile

A few weeks ago (or was it months Embarassed ) I told that i was working on a plugin called NP_AttachFile. Today i put a first working version onine to test.

With this plugin you can 'attach' files to an item. But first things first: this plugin doesn't care about uploading files. It just gives you the possibility to enter a path or url to a file you want to link to. Also you can enter a description, contenttype and size.

Using the plugin you can by example:

  • attach some files to an item and let them show up under the item in a nice looking table (use the skinvar <%AttachFile%> for this)
  • add the attachments as enclosures in your rss-feed, by example to create podcasts (use the skinvar <%AttachFile(rss)%> for this)

IMPORTANT: This plugin is far from 'feature-complete' and may have security issues (i still have to check input etc), so I advise you only to test it on a development machine, or localhost.
I'm also not sure if the plugin will function on PHP4, still have to try this.

Features i still need to add/do:

  • Autodetection of the contenttype and size (currently do not choose 'autodetect' for contenttype since this might generate errors)
  • Admin area for the files (currently only available for filetypes)
  • More predefined contenttypes
  • a very big refactoring ("extract class" file & filetype)

Now you might be wondering why such a rather stupid plugin takes so much time?
The answer is rather simple: i'm trying to create a plugin with an ultimate layered design Laughing. If you dive into the code you'll see i:

  • Did a lot of refactorings named "extract method" which results in *very* readable code
  • tried to split 'business'-logic from presentation. This resulted in an admin area which almost only contains html code + a 'code behind'-file which contains 'glue'-code to connect to the business-layer which is in the plugin-file itself. (inspired by asp.net...)
  • use a basic form of exceptions: PHP4's error handling sucks (sorry for saying it), so i added my own kind of exceptions. I'll write an article on the NUDN about this.
  • Provide UnitTests. This will certainly be the first plugin with UnitTests Smile It makes developing just so much easier Smile I'll also write an article about this on the NUDN Wink
  • If you want to run the UnitTests, download The SimpleTest framework from http://www.lastcraft.com/simple_test.php and extract it in 'nucleus/libs/simpletest'. Then you can run the tests by opening http://localhost/your/nucleus/installation/nucleus/plugins/attachfile/UnitTests.php . This will run all available UnitTests, currently 31. If everything goes well you'll see a green bar at the bottom with the text: "2/2 test cases complete: 31 passes, 0 fails and 0 exceptions.", if not, there is a problem Smile

    You can download the latest development release from http://dev.budts.be/releases/attachfile/ or from CVS: http://sourceforge.net/cvs/?group_id=80225. Bugs can be reported in my BugTracker

    This item was copied from my post a the forum

    Comments

    There are no comments.

    Comment Atom Feed