function prev_next_admin in Previous/Next API 6
Same name and namespace in other branches
- 7.2 prev_next.admin.inc \prev_next_admin()
- 7 prev_next.module \prev_next_admin()
Menu callback argument. Creates the prev_next administration form.
1 string reference to 'prev_next_admin'
- prev_next_menu in ./
prev_next.module - Implementation of hook_menu().
File
- ./
prev_next.module, line 42
Code
function prev_next_admin() {
$form['status'] = array(
'#type' => 'fieldset',
'#title' => t('Indexing status'),
);
$max_nid = variable_get('prev_next_index_nid', 0);
$cond = _prev_next_node_types_sql();
$total = db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE status = 1 {$cond}"));
$completed = db_result(db_query("SELECT COUNT(nid) FROM {prev_next_node}"));
$remaining = max(0, $total - $completed);
$percentage = (int) min(100, 100 * ($total - $remaining) / max(1, $total)) . '%';
$status = t('<p>%percentage of nodes have been indexed. There are %remaining items left to index, out of a total of %total.</p>', array(
'%percentage' => $percentage,
'%remaining' => $remaining,
'%total' => $total,
));
$status .= $max_nid ? t('<p>Max node ID for indexing on the next cron run: @max.</p>', array(
'@max' => $max_nid,
)) : t('<p>Existing nodes have finished prev/next indexing.</p>');
$form['status']['status'] = array(
'#value' => $status,
);
$form['status']['reindex'] = array(
'#type' => 'submit',
'#value' => t('Re-index'),
);
$form['prev_next_batch_size'] = array(
'#title' => t('Batch size'),
'#description' => t('Number of nodes to index during each cron run.'),
'#type' => 'textfield',
'#size' => 6,
'#maxlength' => 7,
'#default_value' => variable_get('prev_next_batch_size', PREV_NEXT_BATCH_SIZE_DEFAULT),
'#required' => TRUE,
);
$form['prev_next_num_blocks'] = array(
'#title' => t('Blocks'),
'#description' => t('Number of blocks available.'),
'#type' => 'textfield',
'#size' => 2,
'#maxlength' => 3,
'#default_value' => variable_get('prev_next_num_blocks', PREV_NEXT_NUM_BLOCKS_DEFAULT),
'#required' => TRUE,
);
$form['node_types'] = array(
'#type' => 'fieldset',
'#title' => t('Content types'),
'#description' => t('Define settings for each content type. If none of them is included, then all of them will be.'),
);
foreach (node_get_types() as $type => $name) {
$form['node_types'][$type] = array(
'#type' => 'fieldset',
'#description' => t('Note: changing one of these values will reset the entire Prev/Next index.'),
'#title' => node_get_types('name', $type),
'#collapsible' => TRUE,
'#collapsed' => !variable_get(PREV_NEXT_NODE_TYPE . $type, 0),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type] = array(
'#type' => 'checkbox',
'#title' => t('Include'),
'#default_value' => variable_get(PREV_NEXT_NODE_TYPE . $type, 0),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type . '_current'] = array(
'#type' => 'hidden',
'#default_value' => variable_get(PREV_NEXT_NODE_TYPE . $type, 0),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type . '_indexing_criteria'] = array(
'#title' => t('Indexing criteria'),
'#type' => 'select',
'#options' => array(
'nid' => t('Node ID'),
'created' => t('Post date'),
'changed' => t('Updated date'),
'title' => t('Title'),
),
'#default_value' => variable_get(PREV_NEXT_NODE_TYPE . $type . '_indexing_criteria', PREV_NEXT_INDEXING_CRITERIA_DEFAULT),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type . '_indexing_criteria_current'] = array(
'#type' => 'hidden',
'#value' => variable_get(PREV_NEXT_NODE_TYPE . $type . '_indexing_criteria', PREV_NEXT_INDEXING_CRITERIA_DEFAULT),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type . '_same_type'] = array(
'#type' => 'checkbox',
'#title' => t('Only nodes with same content type'),
'#default_value' => variable_get(PREV_NEXT_NODE_TYPE . $type . '_same_type', 0),
);
$form['node_types'][$type][PREV_NEXT_NODE_TYPE . $type . '_same_type_current'] = array(
'#type' => 'hidden',
'#default_value' => variable_get(PREV_NEXT_NODE_TYPE . $type . '_same_type', 0),
);
}
$form['#submit'][] = 'prev_next_admin_submit';
return system_settings_form($form);
}