function nodesinblock_queue in Nodes In Block 7
Same name and namespace in other branches
- 6 nodesinblock.admin.inc \nodesinblock_queue()
Menu callback to look at the queue for nodes in block.
Parameters
$block: The delta of the block.
$show_block_links: Whether to render the blocklinks or not.
$show_create_links: Whether to render the create node links or not.
2 string references to 'nodesinblock_queue'
- nodesinblock_menu in ./
nodesinblock.module - Implements hook_menu().
- nodesinblock_nodequeue in ./
nodesinblock.module - Nodes in block queue tab.
File
- ./
nodesinblock.admin.inc, line 202 - Administration page for nodes in block.
Code
function nodesinblock_queue($form, &$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/config/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 = db_select('nodesinblock', 'nib');
$query
->join('node', 'n', 'nib.nid = n.nid');
$query
->fields('nib', array(
'nid',
'visibility',
'render',
'weight',
));
$query
->fields('n', array(
'title',
'status',
))
->condition('delta', $block)
->orderBy('weight', 'ASC');
$results = $query
->execute()
->fetchAll();
foreach ($results as $row) {
$form['nodes'][$row->nid]['nid'] = array(
'#type' => 'value',
'#value' => $row->nid,
);
$form['nodes'][$row->nid]['title'] = array(
'#markup' => check_plain($row->title),
);
$form['nodes'][$row->nid]['node_status'] = array(
'#markup' => $row->status == 1 ? t('published') : t('unpublished'),
);
$form['nodes'][$row->nid]['visibility'] = array(
'#markup' => 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;
}