You are here

function entity_share_ui_share_action_form in Entity Share 7

Form generation.

Parameters

array $form: The form array.

array $form_state: The form state.

Return value

array Form render array.

1 string reference to 'entity_share_ui_share_action_form'
entity_share_ui_share_page in modules/entity_share_ui/modules/entity_share_ui_client/entity_share_ui_client.share.admin.inc
Page builder.

File

modules/entity_share_ui/modules/entity_share_ui_client/entity_share_ui_client.share.admin.inc, line 106
Entity Share UI Client Admin Share file.

Code

function entity_share_ui_share_action_form(array $form, array &$form_state) {
  if (isset($form_state['build_info']['args'][0])) {
    $nids = $form_state['build_info']['args'][0];
  }
  else {

    // Note: $form_state['values'] is not available there.
    $nids = !empty($form_state['input']['nids']) ? explode(',', $form_state['input']['nids']) : array();
  }
  $form = array();
  $form['#action'] = url('admin/content/entity_share');
  $form['endpoints'] = array(
    '#type' => 'fieldset',
    '#title' => t('Enpoints'),
  );
  $endpoints_options = array();
  $endpoints = EntityShareUiClientEndpoint::loadAll(NULL, TRUE);
  foreach ($endpoints as $endpoint) {
    $endpoints_options[$endpoint['eid']] = $endpoint['title'];
  }
  if (count($endpoints_options) == 0) {
    $endpoint_chkbx_title = t('No endpoint is available or enabled, create one or enable an existing endpoint.');
  }
  else {
    $endpoint_chkbx_title = t('Select the @endpoint that will be targeted for the sharing process', array(
      '@endpoint' => format_plural(count($endpoints_options), 'endpoint', 'endpoints'),
    ));
  }
  $form['endpoints']['endpoints'] = array(
    '#type' => 'checkboxes',
    '#title' => check_plain($endpoint_chkbx_title),
    '#options' => $endpoints_options,
  );

  // Hidden.
  $form['nids'] = array(
    '#type' => 'hidden',
    '#value' => implode(',', $nids),
  );

  // Actions.
  if (count($endpoints_options) > 0) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Share contents'),
      '#validate' => array(
        'entity_share_ui_share_action_form_validate',
      ),
      '#submit' => array(
        'entity_share_ui_share_action_form_submit',
      ),
    );
  }
  $form['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => url('admin/content', array(
      'absolute' => TRUE,
    )),
  );
  return $form;
}