You are here

function mostpopular_services_form in Drupal Most Popular 6

1 string reference to 'mostpopular_services_form'
mostpopular_menu in ./mostpopular.module
Implements hook_menu().

File

./mostpopular.admin.inc, line 353
Defines all the administration forms for the Most Popular module.

Code

function mostpopular_services_form() {
  $services = MostPopularService::fetchSorted();
  $form = array(
    '#tree' => TRUE,
    '#theme' => 'mostpopular_config_services_form',
    'services' => array(),
  );
  foreach ($services as $key => $service) {
    $form['services'][$key] = array(
      'enabled' => array(
        '#type' => 'checkbox',
        '#default_value' => $service->enabled,
      ),
      'status' => array(
        '#type' => 'item',
        '#value' => theme('mostpopular_service_status', $service->status),
      ),
      'name' => array(
        '#markup' => $service->name,
      ),
      'title' => array(
        '#type' => 'textfield',
        '#size' => 32,
        '#default_value' => $service->title,
      ),
      'weight' => array(
        '#type' => 'weight',
        '#delta' => MostPopularService::numServices(),
        '#default_value' => $service->weight,
      ),
      'config' => array(
        '#markup' => l(t('Configure'), "admin/settings/mostpopular/services/{$service->sid}"),
      ),
      'service' => array(
        '#type' => 'value',
        '#value' => serialize($service),
      ),
    );
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save Configuration'),
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset Titles'),
  );

  // Add a reset button
  $form['clear'] = array(
    '#type' => 'submit',
    '#attributes' => array(
      'onclick' => 'javascript:return confirm("' . t("Each service will be reset and the most popular items will be cleared.\nYou should refresh the stats after clearing the caches. Are you sure you want to do this?") . '");',
    ),
    '#value' => t('Clear all cached values'),
  );
  return $form;
}