You are here

function freelinking_page_form in Freelinking 6

Same name and namespace in other branches
  1. 5 freelinking.module \freelinking_page_form()
  2. 6.2 freelinking.module \freelinking_page_form()
1 string reference to 'freelinking_page_form'
freelinking_page in ./freelinking.module

File

./freelinking.module, line 58

Code

function freelinking_page_form() {
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
    '#access' => user_access('administer freelinking'),
  );
  $options = array(
    'delete' => t('Delete'),
    'delete-all' => t('Delete All'),
  );
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'delete',
    '#access' => user_access('administer freelinking'),
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#access' => user_access('administer freelinking'),
  );
  $header = array(
    array(
      'data' => theme('table_select_header_cell'),
      '#access' => user_access('administer freelinking'),
    ),
    array(
      'data' => t('Phrase'),
      'field' => 'phrase',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Target'),
      'field' => 'phrase',
    ),
  );
  $query = 'SELECT hash, phrase, path FROM {freelinking}' . tablesort_sql($header);
  $result = pager_query($query, 50);
  while ($freelink = db_fetch_object($result)) {

    // looping through pairs
    $hash = $freelink->hash;
    $links[$hash] = '';
    $form['phrase'][$hash] = array(
      '#value' => urldecode($freelink->phrase),
    );
    $fltargetnid = _freelinking_exists($freelink->phrase);
    $freelink = _freelinking_make_link($freelink->phrase);
    if ($fltargetnid) {

      // node exists
      $link = l(t('see this content'), drupal_get_path_alias('node/' . $fltargetnid));
    }
    else {

      // no content found, show create link
      $link = l(t('create this content'), $freelink['path'], array(
        'attributes' => array(
          'class' => 'freelinking fl-create',
        ),
      ));
    }
    $form['target'][$hash] = array(
      '#value' => $link,
    );
  }

  // endwhile looping through links
  $form['links'] = array(
    '#type' => 'checkboxes',
    '#options' => $links,
    '#access' => user_access('administer freelinking'),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}