function nodesinblock_queue in Nodes In Block 6
Same name and namespace in other branches
- 7 nodesinblock.admin.inc \nodesinblock_queue()
Menu callback to look at the queue for nodes in block.
Parameters
integer $block The delta of the block.:
integer $show_block_links Whether to render the blocklinks or not.:
integer $show_create_links Whether to render the create node links or not.:
2 string references to 'nodesinblock_queue'
- nodesinblock_menu in ./
nodesinblock.module - Implementation of hook_menu().
- nodesinblock_nodequeue in ./
nodesinblock.module - Nodes in block queue tab.
File
- ./
nodesinblock.admin.inc, line 205 - Administration page for nodes in block.
Code
function nodesinblock_queue($form_state, $block = NULL, $show_block_links = TRUE, $show_create_links = TRUE) {
$form = array();
$form['nodes'] = array(
'#tree' => TRUE,
);
$number_of_blocks = variable_get('nodesinblock_nrofblocks', 1);
if ($block == NULL) {
$block = 0;
}
// Blocklinks.
if ($show_block_links == TRUE) {
$blocklinks = array();
for ($i = 0, $a = 1; $i < $number_of_blocks; $i++, $a++) {
$title = check_plain(variable_get('nodesinblock_friendlyname_' . $i, t('Nodes in block ' . $a)));
$delta = $i != '0' ? '/' . $i : '';
$blocklinks[] = array(
'title' => $title,
'href' => 'admin/settings/nodesinblock/queue' . $delta,
);
}
$form['blocklinks'] = array(
'#type' => 'item',
'#value' => theme('links', $blocklinks),
);
}
// Content create links.
if ($show_create_links == TRUE) {
$createlinks = array();
$saved_delta = $block + 1;
$saved_types = variable_get('nodesinblock_contenttypes', array());
foreach ($saved_types as $type) {
$deltas = variable_get('nodesinblock_' . $type . '_block', array());
if (isset($deltas[$saved_delta]) && $deltas[$saved_delta] != 0) {
$createlinks[] = array(
'title' => t('Create new @type', array(
'@type' => $type,
)),
'href' => 'node/add/' . $type,
);
}
}
$form['createlinks'] = array(
'#type' => 'item',
'#value' => theme('links', $createlinks),
);
}
// Get nodes and store them in #nodes key.
$query = "SELECT n.nid, n.title, n.status as node_status,\n \t\t\t\t\tnib.weight, nib.visibility FROM {nodesinblock} nib INNER JOIN {node} n\n \t\t\t\t\ton n.nid = nib.nid WHERE nib.delta = %d ORDER BY weight ASC";
$nodes = db_query($query, $block);
while ($row = db_fetch_object($nodes)) {
$form['nodes'][$row->nid]['nid'] = array(
'#type' => 'value',
'#value' => $row->nid,
);
$form['nodes'][$row->nid]['title'] = array(
'#type' => 'item',
'#value' => check_plain($row->title),
);
$form['nodes'][$row->nid]['node_status'] = array(
'#type' => 'item',
'#value' => $row->node_status == 1 ? t('published') : t('unpublished'),
);
$form['nodes'][$row->nid]['visibility'] = array(
'#type' => 'item',
'#value' => htmlentities($row->visibility),
);
$form['nodes'][$row->nid]['weight'] = array(
'#type' => 'weight',
'#default_value' => $row->weight,
'#delta' => 30,
);
}
// Block delta
$form['delta'] = array(
'#type' => 'value',
'#value' => $block,
);
// Save button.
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}