function widgets_set_load in Widgets 7
Load a set by set name or ID. May be used as a loader for menu items.
Parameters
$name: The name of the set.
$wsid: Optional. The numeric id of a set if the name is not known.
$include: If set, this loader will restrict to a specific type of widget set, may be one of the defined widget set storage constants.
Return value
An widget set array containing the following keys:
- "wsid": The unique widget set ID.
- "name": The unique widget set name.
- "elements": An array of widget elements within this widget set.
If the widget set name or ID is not valid, an empty array is returned.
See also
9 calls to widgets_set_load()
- widgets_block_view in ./
widgets.module - Implements hook_block_view().
- widgets_element_definition_load in ./
widgets.module - Load the definition for an widget.
- widgets_element_delete in ./
widgets.module - Delete an widget element.
- widgets_element_load in ./
widgets.module - Load a single widget.
- widgets_element_save in ./
widgets.module - Save an widget element.
File
- ./
widgets.module, line 470 - Exposes global functionality for creating widget sets.
Code
function widgets_set_load($name = NULL, $wsid = NULL, $include = NULL) {
$sets = widgets_sets();
// If retrieving by name.
if (isset($name) && isset($sets[$name])) {
$set = $sets[$name];
}
// If retrieving by widget set id.
if (!isset($name) && isset($wsid)) {
foreach ($sets as $name => $database_set) {
if (isset($database_set['wsid']) && $database_set['wsid'] == $wsid) {
$set = $database_set;
break;
}
}
}
// Restrict to the specific type of flag. This bitwise operation basically
// states "if the storage is X, then allow".
if (isset($set) && (!isset($include) || $set['storage'] & (int) $include)) {
if (arg(0) != 'admin') {
drupal_alter('widgets_set_view', $set);
}
return $set;
}
// Otherwise the set was not found.
return FALSE;
}