You are here

function responsive_preview_get_device_definition in Responsive Theme Preview 7

Retrieves all or a specific device record.

Parameters

$name: (Optional) A string that identifies a device by its unique name.

Return value

An associative array that represents a list of device definitions.

5 calls to responsive_preview_get_device_definition()
responsive_preview_admin_form in ./responsive_preview.admin.inc
Form callback: builds the page for administering devices.
responsive_preview_device_delete_form in ./responsive_preview.admin.inc
Form constructor for the device deletion form.
responsive_preview_device_delete_form_submit in ./responsive_preview.admin.inc
Form submission handler for responsive_preview_device_delete_form().
responsive_preview_device_edit_form in ./responsive_preview.admin.inc
Form builder for the device editing form.
responsive_preview_title_callback in ./responsive_preview.admin.inc
Constructs a title for the device edit form.
1 string reference to 'responsive_preview_get_device_definition'
responsive_preview_device_configuration_form in ./responsive_preview.admin.inc
Builds a form that represents a device definition.

File

./responsive_preview.admin.inc, line 323
Administrative page callbacks for the responsive_preview module.

Code

function responsive_preview_get_device_definition($name = '') {
  if (empty($name) && ($cache = cache_get('responsive_preview_devices'))) {
    return $cache->data;
  }
  $results = array();
  try {
    $query = db_select('responsive_preview', 'rp')
      ->fields('rp')
      ->orderBy('weight', 'ASC');
    if (!empty($name)) {
      $query
        ->condition('name', $name);
    }
    $results = $query
      ->execute()
      ->fetchAllAssoc('name', PDO::FETCH_ASSOC);
  } catch (Exception $e) {
    watchdog_exception('responsive_preview', $e);
    throw $e;
  }
  if (empty($name)) {
    cache_set('responsive_preview_devices', $results, 'cache');
  }
  return $results;
}