You are here

function widgets_elements in Widgets 7

Load all widget elements from the database.

Return value

An array of all widget elements.

See also

widgets_element_load()

1 call to widgets_elements()
widgets_set_elements in ./widgets.module
Load all the widgets for a wdiget set.
2 string references to 'widgets_elements'
widgets_element_save in ./widgets.module
Save an widget element.
widgets_set_flush in ./widgets.module
Flush cached media for a set.

File

./widgets.module, line 889
Exposes global functionality for creating widget sets.

Code

function widgets_elements() {
  $elements =& drupal_static(__FUNCTION__);
  if (!isset($elements)) {
    $elements = array();

    // Add database widget elements.
    $result = db_select('widgets_elements', NULL, array(
      'fetch' => PDO::FETCH_ASSOC,
    ))
      ->fields('widgets_elements')
      ->orderBy('widgets_elements.weight', 'ASC')
      ->execute();
    foreach ($result as $element) {
      $element['data'] = unserialize($element['data']);
      $definition = widgets_element_definition_load($element['name']);

      // Do not load widget elements whose definition cannot be found.
      if ($definition) {
        $element = array_merge($definition, $element);
        $elements[$element['weid']] = $element;
      }
    }
  }
  return $elements;
}