Gadget Objects

These are data gathering, and data rendering components. They can support a variety of output formats.

Examples

Thru the years many of these objects have become polluted with database calls in the render() operations, etc.. Recently revised Gadgets which operate correctly can be found in. Please use these as examples:

  • FrontGadget
  • WelcomeGadget
  • AWRiverGadget
  • SchedGadget

You can easily create a alternate rendering of Gadget data by following the examples in:

  • ~/code/wh2o/gadgets/rss/FrontGadget.inc
  • ~/code/wh2o/gadgets/mapxml/AWRiver.inc
  • ~/code/wh2o/gadgets/wap/River.inc

These are called using the content dispatcher. An example of an HTML rivers list is:

http://host/content/AWRiver/view/state/NC

the same list as XML is

http://host/content/AWRiver/!mapxml/view/state/NC

Most Important Functions

These are the most interesting of the Framework objects, they organize and output data. An example is found in AWArticle.inc. Notice two methods in these objects.

  • The render() function outputs HTML, XML, or some other form of output. It should not be used to gather data. Use it like you would a template.
  • The act() function gathers and formats information. It stuffs the internal members of the Gadget with the information they need to complete output. It is also useful in object state transition.
  • The static function gadGetStates() (see example) returns meta information about the Gadget. This includes information about required parameters, and information about how to manage state.

Interactions with the Page

The page object offers several important functions to the Gadget. It handles resolving references to output format specific resources (e.g. getting the XML version of a RiverGadget). It serves as the source for parameters and also serves as the dispatcher to other objects. See how AWArticle gets its parameters and interacts with the page. To get the gadget's page issue:

$this->getPage()

To get a reference to an object, say the configuration of the site issue:

$c = $this->getPage()->getObjectRef("ConfigInfo");

State & State Maintence

Gadgets progress through state, a gadget may display a form in one state and process information in another. State is maintained through the intervention of the page. Paremeters are everything else, such as the form submission data.

Join AW and support river stewardship nationwide!