function widgets_get_widgets in Widgets 6
Get all widgets.
Parameters
$regions: Restrict widgets to only this region.
Return value
List of widgets.
2 calls to widgets_get_widgets()
- widgets_form_alter in ./
widgets.module - Implementation of hook_form_alter().
- widgets_form_node_type_form_alter in ./
widgets.module - Implementation of hook_form_FORM_ID_alter().
File
- ./
widgets.inc, line 15 - Implementaion of custom functions for Widgets module.
Code
function widgets_get_widgets($region = NULL) {
$options = array();
// Get widget types.
$types = variable_get('widgets_types', NULL);
if (is_null($types)) {
return $options;
}
$enabled_types = array();
foreach ($types as $key => $value) {
if ($value != '0') {
$enabled_types[] = "'{$key}'";
}
}
$enabled_types = implode(',', $enabled_types);
if ($results = db_query("SELECT n.nid, n.title, w.weight FROM {node} n LEFT JOIN {widgets} w ON w.widget_nid = n.nid WHERE n.type IN (" . $enabled_types . ") AND n.status = 1 ORDER BY w.weight ASC")) {
while ($row = db_fetch_array($results)) {
$options[$row['nid']] = $row['title'];
}
}
return $options;
}