Widgets¶
In wordpress so called widgets are small applications which come along with the plugin and can be placed/configured via the wordpress admin interface via “Design > Widgets”. We’ve added several to provide the latest or most important information on the website.
Webcam Widget¶
webcams.php extens the wordpress WP_Widget class. The widget is loading the webcams from the *wetterturnier_webcams database table if there are any for the current cityObject using the corresponding webcamObject objects.
Each webcam is attached to one specific city via it’s cityID
and is
defined via three attributes: url to the webcam image (has to be a static url),
a source url, and a short description. The latter two will be used to set the
source link below the live image.
Uses:
- wetterturnier_cityObject: current city.
- wetterturnier_webcamObject: defined webcams if there are any.
-
class
WP_wetterturnier_widget_webcams
¶ This is the webcams plugin for wp-wetterturnier. Small widget which displays the latest webcam image - if there are any defined.
@file webcams.php @author Reto Stauffer @date december 2017
-
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget
@param array $args
@param array $instance
-
show_webcams
()¶ The ‘core function’ of this widget: loads the defined @ref wetterturnier_webcamObjects via current city (@ref wetterturnier_cityObject) and displays them if there are any. If there are no images a short string will be shown.
-
Leaderboard Widget¶
leading.php
extens the wordpress WP_Widget
class. The widget is loading the players with the highest
points given a certain time and active city. Uses the data from the
*wetterturnier_betstat database table.
Todo
Currently uses the method userclass::show_leading
.
Should be decoupled and rather use the new (not yet scripted)
rankingclass and procude the output directly within
WP_wetterturnier_widget_leading::show_leading
.
Makes use of the avatar image and bbpress profile link when displaying the data.
Uses:
- wetterturnier_cityObject: current city.
-
class
WP_wetterturnier_widget_leading
¶ This is the leading widget for wp-wetterturnier. The leading widget shows the best players of the tournament given the active city.
@file leading.php @author Reto Stauffer @date Somewhen back in 2015
-
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget
@param array $args
@param array $instance
-
show_leading
()¶ The function which creates the frontend output. It basically only creates a html div element with a specific class. The jQuery plugin js/wetterturnier.rankingtable.js is looking for these elements and fills them with data.
-
Lightning Activity¶
blitzortung.php
also extends the wordpress WP_Widget
class.
The widget does two things: see if new data are available (data-stream not dead)
and if data are available check wether there was is lightning activity in the surrounding
of the city. If so, a small image will be displayed.
Todo
Provide some brief information about the data set and where these routines are running and/or can be found on the wetterturnier server (cross-ref style).
Uses:
- wetterturnier_cityObject: current city.
-
class
WP_wetterturnier_widget_blitzortung
¶ -
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget
@param array $args
@param array $instance
-
show_blitzortung
()¶ The ‘core function’ of this widget: reading a file called ‘lastrun’ located in /var/www/html/Rimages/blitzortung/ to see whether there are new data (output will be ignored if incoming data stream would break down) Displays a small image and a time stamp if there is lightning activity in the area. Data from ACINN, see class header description.
-
Latest Observations¶
latestobs.php
also extends the wordpress WP_Widget
class.
The widget does two things: see if new data are available (data-stream not dead)
and if data are available check wether there was is lightning activity in the surrounding
of the city. If so, a small image will be displayed.
Todo
Provide some brief information about the data set and where these routines are running and/or can be found on the wetterturnier server (cross-ref style).
Uses:
- wetterturnier_cityObject: current city.
- wetterturnier_stationObject: stations for city.
- wetterturnier_latestobsObject: fetching latest observations from obs database.
-
class
WP_wetterturnier_widget_latestobs
¶ This is the widget displaying the latest observations for all stations attached to a specific city (the active city). Note that this plugin uses the @ref wetterturnier_latestobsClass which itself makes use of the ‘obs’ database (proper read-permissions have to be set). If there are no data at all or the latest observations are too old they will not be displayed.
@file latestobs.php @author Reto Stauffer @date Somewhen back in 2015
-
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget
@param array $args
@param array $instance
-
show_latestobs
()¶ The ‘core function’ of this widget: loads latest observations from database. if the data are too old (older than $nhours) they won’t be displayed, e.g., if the data stream breaks down.
-
Tournament Calendar¶
tournaments.php
also extends the wordpress WP_Widget
class.
Displays the tournament calendar with the upcoming tourmanet dates.
In addition, the bet-counts (submitted partial/full forecasts for the upcoming
tournament) are shown.
Todo
Check whether it would make sense to move the data request into the new and not yet coded rankingclass.
-
class
WP_wetterturnier_widget_tournaments
¶ Widget to display the tournament calendar. The tournament calendar shows our users whether there will be a tournament or not, the data on which the calendar is based on is also used to open/start a tournament. In addition to the calendar the bet-counts are shown. They show the number of players which already have submitted a partial or full forecast for the upcoming tournament.
@file tournaments.php @author Reto Stauffer @date 2014
-
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget, shows calendar and triggers the @ref show_bet_counts function.
@param array $args
@param array $instance
-
show_bet_counts
()¶ One of the two core functions: displays the bet counts.
@todo Freaky sql statement, maybe outsource and put a method into the new not yet coded rankingclass?
-
Private Messages¶
bbpmessages.php
also extends the wordpress WP_Widget
class.
Requires an active installation of the bbpmessages
plugin. If the plugin is
not installed or at least ont active this widget will print out a message telling
you that you might not have installed the dpeendency. Else the plugin is checking
if there are new unread privat messages in the in-box and displays either a number
or a message that there are no new messages.
Note the widget is only visible when the user is logged in (as only logged in users are able to retrieve and/or send messages).
Todo
Check whether it would make sense to move the data request into the new and not yet coded rankingclass.
-
class
WP_wetterturnier_widget_bbpmessages
¶ Custom plugin to display private message inbox count based on the bbpmessages plugin. Output either shows that there are no new messages or a number with themessage count. If the user is not logged in this widget is invisible. Shows a message if the bbpmessages plugin is not active or not installed such that the system admin knows what’s going on.
@file bbpmessages.php @author Reto Stauffer @date 2014
-
__construct
()¶ Setting up the widget name and the control options
-
form
($instance)¶ Creates the admin-widget box (drag-and-drop widget with attributes/settings)
@param array $instance The widget options
-
update
($new_instance, $old_instance)¶ Processing widget options on save
@param array $new_instance The new options
@param array $old_instance The previous options
@return array $instance (updated)
-
widget
($args, $instance)¶ Outputs the content of the widget
@param array $args
@param array $instance
-
show_bbpmessages
()¶ The ‘core function’ of this widget: if bbpmessages plugin is active the message box is checked. The user is getting informed if he/she has new messages or not.
-