You are here

function service_links_service_links_content_type_edit_form in Service links 7.2

The form to add or edit a service_links as content.

1 string reference to 'service_links_service_links_content_type_edit_form'
service_links.inc in plugins/content_types/service_links.inc
Content type enables user to place the selected service links

File

plugins/content_types/service_links.inc, line 128
Content type enables user to place the selected service links

Code

function service_links_service_links_content_type_edit_form($form, &$form_state) {
  ctools_include('plugins');
  $conf = $form_state['conf'];
  $form['service_links_style'] = array(
    '#type' => 'select',
    '#title' => t('Service link icon style'),
    '#options' => array(
      'service_links' => t('Normal service links display'),
      'service_links_fisheye' => t('Service links with FishEye effect'),
    ),
    '#default_value' => isset($conf['service_links_style']) ? $conf['service_links_style'] : TRUE,
  );
  $form['service_links_block_style'] = array(
    '#type' => 'select',
    '#title' => t('Service link display'),
    '#options' => array(
      1 => t('Only text'),
      2 => t('Only icon'),
      3 => t('Icon and text'),
      4 => t('Empty'),
    ),
    '#default_value' => isset($conf['service_links_block_style']) ? $conf['service_links_block_style'] : TRUE,
    '#states' => array(
      'invisible' => array(
        ':input[name="service_links_style"]' => array(
          'value' => 'service_links_fisheye',
        ),
      ),
    ),
  );
  $settings = _service_links_load_settings();
  $services = service_links_get_links($settings['link_show']);
  $form['panel_service_links'] = array(
    '#theme' => 'service_links_drag_table',
  );
  $form['panel_service_links']['panel_service_links_show'] = array(
    '#tree' => TRUE,
  );
  $form['panel_service_links']['panel_service_links_weight'] = array(
    '#tree' => TRUE,
  );
  foreach ($services as $service_id => $service) {
    $icon = array(
      'path' => isset($service['icon']) ? service_links_expand_path($service['icon'], 'preset') : service_links_expand_path("{$service_id}.png", +'preset'),
    );
    $form[$service_id] = array(
      '#service' => ucwords(str_replace('_', ' ', $service['module'])),
      '#type' => 'checkbox',
      '#title' => theme('image', $icon) . " " . t('Show %name link', array(
        '%name' => $service['name'],
      )),
      '#return_value' => 1,
      '#default_value' => isset($conf[$service_id]) ? $conf[$service_id] : 0,
    );
  }
  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/modules'),
    )), 'warning');
  }
  return $form;
}