function freelinking_page_form in Freelinking 6.2
Same name and namespace in other branches
- 5 freelinking.module \freelinking_page_form()
- 6 freelinking.module \freelinking_page_form()
1 string reference to 'freelinking_page_form'
File
- ./
freelinking.module, line 58
Code
function freelinking_page_form($admin = TRUE) {
if ($admin) {
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array(
'delete' => t('Delete'),
'delete-all' => t('Delete All'),
);
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'delete',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$header = array(
array(
'data' => theme('table_select_header_cell'),
),
array(
'data' => t('Phrase'),
'field' => 'phrase',
'sort' => 'asc',
),
array(
'data' => t('Target'),
'field' => 'phrase',
),
);
}
else {
$header = array(
array(
'data' => t('Phrase'),
'field' => 'phrase',
'sort' => 'asc',
),
array(
'data' => t('Target'),
'field' => 'phrase',
),
);
}
// endifelse not $admin
$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 = '<a href="' . url($freelink['path'], array()) . '">' . t('create this content') . '</a>';
}
$form['target'][$hash] = array(
'#value' => $link,
);
}
// endwhile looping through links
if ($admin) {
$form['links'] = array(
'#type' => 'checkboxes',
'#options' => $links,
);
}
// endif admin
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
return $form;
}