You are here

function _magic_build_info_file in Magic 7.2

Same name and namespace in other branches
  1. 7 magic.module \_magic_build_info_file()

Helper function to build the contents of the .info file.

This function will take the current theme information, and create the export based upon the current info file and settings saved within the database.

Parameters

array $array: An array of all the current theme settings to be parsed.

string $prefix: (Optional)

Return value

string The full, prettified .info file.

1 call to _magic_build_info_file()
magic_export_settings in includes/magic.export.inc
Exports theme settings.

File

includes/magic.export.inc, line 86
Form and utility functions for exporting theme settings.

Code

function _magic_build_info_file($array, $prefix = '') {
  $regions = array(
    'stylesheets' => 'Stylesheets',
    'regions' => 'Regions',
    'settings' => 'Settings',
    'scripts' => 'Scripts',
    'modernizr' => 'Modernizr',
  );
  $info = '';
  foreach ($array as $key => $value) {
    if (isset($regions[$key])) {
      $info .= "\n";
      $info .= "; ========================================\n";
      $info .= "; {$regions[$key]}\n";
      $info .= "; ========================================\n";
      $info .= "\n";
    }
    if (is_array($value)) {
      $info .= _magic_build_info_file($value, empty($prefix) ? $key : "{$prefix}[{$key}]");
    }
    else {
      $info .= $prefix ? "{$prefix}[{$key}]" : $key;
      $info .= " = " . str_replace("'", "\\'", $value) . "\n";
    }
  }
  return $info;
}