drupal_build_js_cache

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 drupal_build_js_cache($files, $filename)

Aggregate JS files, putting them in the files directory.

Übergabeparameter

$files An array of JS files to aggregate and compress into one file.

$filename The name of the aggregate JS file.

Rückgabewert

The name of the JS file.

▾ 1 function calls drupal_build_js_cache()

drupal_get_js in includes/common.inc
Returns a themed presentation of all JavaScript code for the current page.

Code

includes/common.inc, line 2455

<?php
function drupal_build_js_cache($files, $filename) {
  $contents = '';

  // Create the js/ within the files folder.
  $jspath = file_create_path('js');
  file_check_directory($jspath, FILE_CREATE_DIRECTORY);

  if (!file_exists($jspath . '/' . $filename)) {
    // Build aggregate JS file.
    foreach ($files as $path => $info) {
      if ($info['preprocess']) {
        // Append a ';' and a newline after each JS file to prevent them from running together.
        $contents .= file_get_contents($path) . ";\n";
      }
    }

    // Create the JS file.
    file_save_data($contents, $jspath . '/' . $filename, FILE_EXISTS_REPLACE);
  }

  return $jspath . '/' . $filename;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen