profile_admin_overview

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/profile/profile.admin.inc, строка 14

Версии
5 – 6
profile_admin_overview()

Form builder to display a listing of all editable profile fields.

See also

profile_admin_overview_submit()

Связанные темы

Код

<?php
function profile_admin_overview() {
  $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight');

  $form = array();
  $categories = array();
  while ($field = db_fetch_object($result)) {
    // Collect all category information
    $categories[] = $field->category;

    // Save all field information
    $form[$field->fid]['name'] = array('#value' => check_plain($field->name));
    $form[$field->fid]['title'] = array('#value' => check_plain($field->title));
    $form[$field->fid]['type'] = array('#value' => $field->type);
    $form[$field->fid]['category'] = array('#type' => 'select', '#default_value' => $field->category, '#options' => array());
    $form[$field->fid]['weight'] = array('#type' => 'weight', '#default_value' => $field->weight);
    $form[$field->fid]['edit'] = array('#value' => l(t('edit'), "admin/user/profile/edit/$field->fid"));
    $form[$field->fid]['delete'] = array('#value' => l(t('delete'), "admin/user/profile/delete/$field->fid"));
  }

  // Add the cateogory combo boxes
  $categories = array_unique($categories);
  foreach ($form as $fid => $field) {
    foreach ($categories as $cat => $category) {
      $form[$fid]['category']['#options'][$category] = $category;
    }
  }

  // Display the submit button only when there's more than one field
  if (count($form) > 1) {
    $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
  }
  else {
    // Disable combo boxes when there isn't a submit button
    foreach ($form as $fid => $field) {
      unset($form[$fid]['weight']);
      $form[$fid]['category']['#type'] = 'value';
    }
  }
  $form['#tree'] = TRUE;

  $addnewfields = '<h2>'. t('Add new field') .'</h2>';
  $addnewfields .= '<ul>';
  foreach (_profile_field_types() as $key => $value) {
    $addnewfields .= '<li>'. l($value, "admin/user/profile/add/$key") .'</li>';
  }
  $addnewfields .= '</ul>';
  $form['addnewfields'] = array('#value' => $addnewfields);

  return $form;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему