You are here

function ctools_get_keyword in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/context-admin.inc \ctools_get_keyword()
1 call to ctools_get_keyword()
ctools_context_get_defaults in includes/context-admin.inc
Get the defaults for a new instance of a context plugin.

File

includes/context-admin.inc, line 831
includes/common-context.inc Provide API for adding contexts for modules that embed displays.

Code

function ctools_get_keyword($page, $word) {

  // Create a complete set of keywords
  $keywords = array();
  foreach (array(
    'arguments',
    'relationships',
    'contexts',
    'requiredcontexts',
  ) as $type) {
    if (!empty($page->{$type}) && is_array($page->{$type})) {
      foreach ($page->{$type} as $info) {
        $keywords[$info['keyword']] = TRUE;
      }
    }
  }
  $keyword = $word;
  $count = 1;
  while (!empty($keywords[$keyword])) {
    $keyword = $word . '_' . ++$count;
  }
  return $keyword;
}