Geschrieben von skaldrom am 26. November 2007 /
Update Jan 2011: The PHP-Update library has been completely rewritten and does now support the current IFrame-Method. The principles are still the same, but the API has changed quite a bit: Projekt auf oncode.info.
Widgets and Web 2.0
Widgets are little miniapplications which show data in a clearly arranged way or perform a more or less simple task for the user. Widgets are present on Windows Vista, Mac, iPhone and also in a webbased form for iGoogle, Yahoo!, Netvibes and many other portals. To give a boost to widget development, Netvibes presented a new framework which shall facilate the coding of widgets. The child is called Universal Widget Architecture. Widgets coded with the help of this framework should work on all the mentioned plattforms.
The UWA specification has its own homepage and is very well documented. There are examples, a code-skeleton with explanations, a step-by-step tutorial, a forum and even a cheat-sheet. The start is very easy with such a lot of documentation.
Finished and released widgets can be made available for the public and published in the Widget Repository (Ecosystem). Widgets ion this website can be added to the different platforms with a single (or double) click). There are some widgets in the repository which are coded in the deprecated Mini-API standard, but these will dissappear soon (hopefully).
That sounded fascinating and must have a use somewhere… I will implement some widgets later, I needed to make these widgets usable in our own projects first. So I wrote a little PHP-class which I called pretentious PHP-UWA Widget Library.Handling widged should be easy, using this class. A little bit more ambitious is the handling of widget dependend preferences.
Displaying a widget should be straight forward:
There are two classmembers which can give more information about the widget:
- Metadaten like author, keywörds, description, … See the docu.
- Additional info like icons, stylesheets, …
Basically, there are the following sections for settings:
- The widgets URL.
- Displayparameters, which described in the docs.
- Widget dependent preferences, also mentioned in the docs
For all these settings, there are the following classmembers:
- Setters and Getters
- setModuleUrl(), setConfiguration(), setPreferences()
getModuleUrl(), getConfiguration(), getPreferences()
- Returns the settings in a friendly array, from which a form can be generated. $section can be "general", "configuration" or "preferences"
- Returns the settings in an array with the format "Label" => "HTML". $section can be "general", "configuration" or "preferences"
For a test, I coded a Moodle block, which allows to use UWA Widgets inside the LMS. Heyo, WordPress, Xoops, etc-Coderz, how about an integration of the Widgets in your system???
Examples from the Moodle block:
|The configuration in Moodle:|
…I was almost faster than the german computer magazine c’t which has a short bit good introduction into UWA-Widgets.