You are here

function _modernizr_current_build in Modernizr 7.3

Same name and namespace in other branches
  1. 8 modernizr.module \_modernizr_current_build()

Helper function to pulls all tests from the current modernizr.js

3 calls to _modernizr_current_build()
modernizr_generate_url in ./modernizr.admin.inc
Generates new Modernizr URL for admin interface Callback for 'admin/config/development/modernizr'.
modernizr_requirements in ./modernizr.install
Implements hook_requirements().
_modernizr_info_missing_tests in ./modernizr.module
Private function to look for missing Modernizr tests.

File

./modernizr.module, line 636
Main module file for Modernizr

Code

function _modernizr_current_build() {
  $tests =& drupal_static(__FUNCTION__);
  if (!isset($tests)) {
    $path = modernizr_get_path();
    $path_parts = explode('/', $path);
    $file = $path ? file_get_contents($path) : NULL;
    $filename = $path_parts[count($path_parts) - 1];
    $tests = array();

    // $matches holds two items:
    // - [0] the full URL
    // - [1] a string containing the args captured in the parens  vvvv
    $build_url = preg_match('/https?:\\/\\/modernizr.com\\/download\\/[#?]-(.*) /', $file, $matches);

    // Turn URL args into test entries for Drupal module
    if (isset($matches[1])) {
      $args_and_prefix = explode(':', $matches[1]);
      $build_args = explode('-', $args_and_prefix[0]);
      foreach ($build_args as $arg) {
        $tests[] = $arg;
      }
    }
    else {

      // Modernizr must not be downloaded, return null.
      return NULL;
    }
  }
  return $tests;
}