PHP-UWA Widget Library
Geschrieben von skaldrom am 26. November 2007 / 
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.
UWA Standard
A widged, coded with UWA is basically a XML-Dokument. It contains metadata, settings and the active part, written in Javascript. Especially the Preferences are of interest, because they are dynamic and allow widgetspecific settings. There are also some convenience-functions in the UWA-library.
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.
Widget Repository
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).
Implementations
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.
A minimal example is included in the download-package and can also be checked online.
Displaying a widget should be straight forward:
require_once('uwawidget.php');
$uwawidget=new uwawidget('http://www.netvibes.com/api/uwa/examples/digg.xhtml');
echo $uwawidget->getWidgetHTML();
?>
There are two classmembers which can give more information about the widget:
- getMetaData()
- Metadaten like author, keywörds, description, … See the docu.
- getAdditionalData()
- Additional info like icons, stylesheets, …
Basically, there are the following sections for settings:
- general
- The widgets URL.
- configuration
- Displayparameters, which described in the docs.
- preferences
- 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() - getSettingsFormData($section)
- Returns the settings in a friendly array, from which a form can be generated. $section can be "general", "configuration" or "preferences"
- getSettingsHTML($section)
- 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: |
||
Uh, almost…
…I was almost faster than the german computer magazine c’t which has a short bit good introduction into UWA-Widgets.












2008-01-25 um 12.11 am
Uwa-widget not run in my moodle 1.9 , i like tha application , but not run, help me ?
Incompatibility?
Bug?
thanks
2008-01-25 um 10.33 am
I am very sorry, I have no Moodle 1.9 at hand at the moment. I promise you, I
will have a look at it as soon as we do our test-updates.
Are you using PHP5?
2008-01-28 um 3.32 pm
Hi,
Excellent work for this library !
I’m wondering if you believe it’s possible to change widget parameter “on the fly”, I.E : if i call the javascript method “BW.setPreferencesValues”, will the widget reload itself ?
Thank you
2008-01-30 um 12.42 pm
Moodle 1.9: I did an upgrade. It works now on my local 1.9 installation (Beta 4)
Sébastien: Yes, it looks like it does a reload in http://www.netvibes.com/js/UWA/load.js.php?env=BlogWidget . But it depends on the widget, it only works if it is coded correctly. Do you have a specific widget you want to use like this?
2008-08-15 um 8.07 am
Does it work the other way round? For instance wrapping moodle quizes with UWA so that they can be included in your Netvibes page?
2008-08-17 um 8.47 pm
@Carsten
Unfortunately not yet, but this is a great idea! I have added it to my ToDos…