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.
Eingeordnet in Learninmanagement Systeme (lms), Web | 6 Komentare »











Auf vielfachen Schülerwunsch hin habe ich einen Block für unser Learning Management System 
Ich möchte für die Website 
), da er ansonsten die Klickpositionen ein Bisschen durcheinander bringt. Dieses Blog beispielsweise ist Fixed left and right menus, liquid content.