You are here

function patterns_api_add_info_section in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/api/api.inc \patterns_api_add_info_section()

Adds / Replaces the 'info' section in a pattern

Adds automatically the standard values to the missing properties

Parameters

array $info (optional): An associative array of properties for the info section.

array $pattern (optional): An array representing a pattern file.

Bool $ow (optional): If TRUE, overwrites existing Info sections.

3 calls to patterns_api_add_info_section()
patterns_forms_get_info_section in includes/forms/forms.inc
patterns_lab_submit in includes/forms/lab.inc
Exports selected patterns either in a file or as a zip-archive
_patterns_export_merge_exported_patterns in patterns_export/finalize.inc
Merges modules info and sections in one pattern

File

includes/api/api.inc, line 123
API for writing pattern files.

Code

function patterns_api_add_info_section($info = array(), &$pattern = array(), $ow = FALSE) {
  if (isset($pattern[PATTERNS_SECTION_INFO]) && !$ow) {
    return FALSE;
  }
  global $user;
  global $base_root;
  $pattern[PATTERNS_SECTION_INFO] = array();
  $pattern[PATTERNS_SECTION_INFO]['title'] = isset($info['title']) ? $info['title'] : 'Untitled Pattern';
  $pattern[PATTERNS_SECTION_INFO]['category'] = isset($info['category']) ? $info['category'] : 'General';
  $pattern[PATTERNS_SECTION_INFO]['description'] = isset($info['description']) ? $info['description'] : 'No description';
  $pattern[PATTERNS_SECTION_INFO]['version'] = isset($info['version']) ? $info['version'] : '1.0';
  $pattern[PATTERNS_SECTION_INFO]['core'] = isset($info['core']) ? $info['core'] : 'x.y';
  $pattern[PATTERNS_SECTION_INFO]['author'] = isset($info['author']) ? $info['author'] : $user->name;
  $pattern[PATTERNS_SECTION_INFO]['author_email'] = isset($info['author_email']) ? $info['author_email'] : $user->mail;
  $pattern[PATTERNS_SECTION_INFO]['author_website'] = isset($info['author_website']) ? $info['author_website'] : $base_root;
  return $pattern;
}