function freelinking_block in Freelinking 5
Same name and namespace in other branches
- 6 freelinking.module \freelinking_block()
- 6.2 freelinking.module \freelinking_block()
File
- ./
freelinking.module, line 210
Code
function freelinking_block($op = 'list', $delta = 0) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Freelink targets that need to be created');
return $blocks;
break;
case 'configure':
$form['freelinking_block_options'] = array(
'#type' => 'fieldset',
'#title' => t('Freelinking Block Options'),
);
$form['freelinking_block_options']['freelinking_blocktitle'] = array(
'#title' => t('Title of freelinks block'),
'#type' => 'textfield',
'#default_value' => variable_get('freelinking_blocktitle', t('Create This Content')),
'#size' => 30,
'#maxlength' => 60,
'#description' => t('Title of the block that shows freelinked phrases without content.'),
);
for ($i = 5; $i <= 30; $i = $i + 5) {
$options[$i] = $i;
}
$form['freelinking_block_options']['freelinking_blocknum'] = array(
'#title' => t('Number of non-existing link phrases to show'),
'#type' => 'select',
'#options' => $options,
'#default_value' => variable_get('freelinking_blocknum', '10'),
'#description' => t('Number of phrases to show in the block.'),
);
return $form;
break;
case 'view':
switch ($delta) {
case 0:
$query = 'SELECT * FROM {freelinking} WHERE path LIKE "%node/add%" ORDER BY RAND()';
$query .= ' LIMIT ' . variable_get('freelinking_blocknum', 10);
$result = db_query($query);
$content = '';
while ($freelink = db_fetch_object($result)) {
$items[] = l(urldecode($freelink->phrase), 'freelinking/' . $freelink->phrase);
}
// endwhile looping through flpairs
$block['subject'] = variable_get('freelinking_blocktitle', 'Create This Content');
$block['content'] = theme('item_list', $items);
return $block;
default:
break;
}
// endswitch $delta
default:
break;
}
// endswitch $op
}