You are here

function service_links_admin_services in Service links 6.2

Same name and namespace in other branches
  1. 7.2 service_links.admin.inc \service_links_admin_services()

Menu callback administration settings for services links list.

3 string references to 'service_links_admin_services'
service_links_displays_form_alter in plugins/service_links_displays.module
Implementation of hook_form_alter().
service_links_menu in ./service_links.module
Implementation of hook_menu().
service_links_sprites_form_alter in plugins/service_links_sprites.module
Implementation of hook_form_alter().

File

./service_links.admin.inc, line 398
Administrative page callbacks for Service Links module.

Code

function service_links_admin_services() {
  $settings = array();
  $services = service_links_get_links(NULL, TRUE);
  $settings['show'] = variable_get('service_links_show', NULL);
  $settings['weight'] = variable_get('service_links_weight', NULL);
  $form['service_links'] = array(
    '#theme' => 'service_links_drag_table',
  );
  $form['service_links']['service_links_show'] = array(
    '#tree' => TRUE,
  );
  $form['service_links']['service_links_weight'] = array(
    '#tree' => TRUE,
  );
  foreach ($services as $service_id => $service) {
    $icon = isset($service['icon']) ? service_links_expand_path($service['icon'], 'preset') : service_links_expand_path("{$service_id}.png", 'preset');
    $weight = isset($settings['weight'][$service_id]) ? $settings['weight'][$service_id] : 0;
    $form['service_links']['service_links_show'][$service_id] = array(
      '#service' => ucwords(str_replace('_', ' ', $service['module'])),
      '#weight' => $weight,
      '#type' => 'checkbox',
      '#title' => theme('image', $icon) . " " . t('Show %name link', array(
        '%name' => $service['name'],
      )),
      '#return_value' => 1,
      '#default_value' => isset($settings['show'][$service_id]) ? $settings['show'][$service_id] : 0,
    );
    $form['service_links']['service_links_weight'][$service_id] = array(
      '#type' => 'weight',
      '#delta' => 100,
      '#default_value' => $weight,
    );
  }
  if (empty($services)) {
    drupal_set_message(t('You need to load at least one of XXX Services module, please enable them in <a href="@url">admin > modules</a> page', array(
      '@url' => url('admin/build/modules'),
    )), 'warning');
  }
  return system_settings_form($form);
}