function responsive_preview_install in Responsive Theme Preview 7
Implements hook_install().
File
Code
function responsive_preview_install() {
/* References:
* - http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
* - http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/
* - http://pieroxy.net/blog/2012/10/18/media_features_of_the_most_common_devices.html
*/
$devices = _responsive_preview_get_devices();
// Insert the preconfigured devices into the database.
$query = db_insert('responsive_preview');
$query
->fields(array(
'name',
'label',
'width',
'height',
'dppx',
'orientation',
'weight',
'status',
'langcode',
));
foreach ($devices as $device) {
$query
->values($device);
}
$transaction = db_transaction();
try {
$query
->execute();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('responsive_preview', $e);
throw $e;
}
}