You are here

function addtohomescreen_page_build in Add to homescreen 7

Implements hook_page_build().

File

./addtohomescreen.module, line 75
Integrates the 'Add to homescreen' library with Drupal.

Code

function addtohomescreen_page_build(&$page) {
  if (($library = libraries_detect('addtohomescreen')) && !empty($library['installed'])) {
    $attached =& $page['page_bottom']['addtohomescreen']['#attached'];
    $settings = array(
      'debug' => variable_get('addtohomescreen_debug', FALSE),
      'modal' => variable_get('addtohomescreen_modal', FALSE),
      'mandatory' => variable_get('addtohomescreen_mandatory', FALSE),
      'skipFirstVisit' => variable_get('addtohomescreen_skipfirstvisit', TRUE),
      'autostart' => variable_get('addtohomescreen_autostart', TRUE),
      'icon' => variable_get('addtohomescreen_icon', TRUE),
      'startDelay' => (int) variable_get('addtohomescreen_startdelay', 1),
      'lifespan' => (int) variable_get('addtohomescreen_lifespan', 15),
      'displayPace' => (int) variable_get('addtohomescreen_displaypace', 1440),
      'maxDisplayCount' => (int) variable_get('addtohomescreen_maxdisplaycount', 1),
    );
    if (variable_get('addtohomescreen_use_custom_message', FALSE)) {
      $settings['message'] = [
        'android' => variable_get('addtohomescreen_message_android', ''),
        'ios' => variable_get('addtohomescreen_message_ios', ''),
      ];
    }
    $variant = variable_get('addtohomescreen_compression_type', 'minified');
    $attached['libraries_load'][] = array(
      'addtohomescreen',
      $variant,
    );
    $attached['js'][] = array(
      'data' => array(
        'addtohomescreen' => $settings,
      ),
      'type' => 'setting',
    );
  }
}