You are here

function _magic_build_info_file in Magic 7

Same name and namespace in other branches
  1. 7.2 includes/magic.export.inc \_magic_build_info_file()

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

This function will take the current theme infomation, 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: The prefix of something @fubhy made.

Return value

string The full info file all prettified.

1 call to _magic_build_info_file()
magic_export_settings in ./magic.module
Exports theme settings.

File

./magic.module, line 162
Keep Frontend DRY; sprinkle it with MAGIC!

Code

function _magic_build_info_file($array, $prefix = '') {
  $info = '';
  $info_regions = array(
    'stylesheets',
    'regions',
    'settings',
    'scripts',
    'modernizr',
  );
  foreach ($array as $key => $value) {
    foreach ($info_regions as $region) {
      if ($key === $region) {
        $info .= "\n; ========================================";
        $info .= "\n" . '; ' . ucfirst($key) . "\n";
        $info .= "; ========================================\n\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;
}