You are here

function mail_edit_overview in Mail Editor 5

Menu callback; administrative mail editing overview.

1 string reference to 'mail_edit_overview'
mail_edit_menu in ./mail_edit.module

File

./mail_edit.module, line 88

Code

function mail_edit_overview($mailkey = '') {
  $keys = array();
  if ($cache = cache_get('mail_edit_overview')) {
    $keys = unserialize($cache->data);
  }
  else {
    foreach (module_list() as $module) {
      $file = file_get_contents(drupal_get_path('module', $module) . "/{$module}.module");
      preg_match_all('/drupal_mail\\((.)(.+)\\1,/U', $file, $matches);
      $keys = array_merge($keys, $matches[2]);
    }
    $keys = array_merge($keys, module_invoke_all('mailkeys'));
    cache_set('mail_edit_overview', 'cache', serialize($keys));
  }
  if ($mailkey && array_search($mailkey, $keys) !== FALSE) {
    return drupal_get_form('mail_edit_form', $mailkey);
  }
  sort($keys);
  $header = array(
    t('Key'),
    t('Description'),
  );
  $rows = array();
  foreach ($keys as $key) {
    $rows[$key] = array(
      l($key, 'admin/build/mail_edit/' . $key),
      t('<em>No description has been set.</em>'),
    );
  }
  $result = db_query('SELECT mailkey, description FROM {mail_edit}');
  while ($d = db_fetch_object($result)) {
    $rows[$d->mailkey][1] = $d->description;
  }
  $output = theme('table', $header, $rows, array(
    'style' => 'width:98%;',
  ));
  return $output;
}