function faq_block in Frequently Asked Questions 5
Same name and namespace in other branches
- 5.2 faq.module \faq_block()
- 6 faq.module \faq_block()
File
- ./
faq.module, line 1593
Code
function faq_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('FAQ Categories');
$blocks[1]['info'] = t('Recent FAQs');
$blocks[2]['info'] = t('Random FAQs');
return $blocks;
case 'view':
switch ($delta) {
case 0:
// FAQ Categories
if (module_exists("taxonomy")) {
$terms = array();
foreach (taxonomy_get_vocabularies('faq') as $vocab) {
foreach (taxonomy_get_tree($vocab->vid) as $term) {
$terms[$term->name] = $term->tid;
}
}
if (sizeof($terms) > 0) {
$block['subject'] = t('FAQ Categories');
$items = array();
foreach ($terms as $name => $tid) {
$items[] = l($name, 'faq/' . $tid);
}
$list_style = variable_get('faq_category_listing', 'ul');
$block['content'] = theme('item_list', $items, NULL, $list_style);
}
}
break;
case 1:
// Recent FAQs
$block['subject'] = t('Recent FAQs');
$block['content'] = theme('faq_highlights', variable_get('faq_block_recent_faq_count', 5));
break;
case 2:
// Random FAQs
$block['subject'] = t('Random FAQs');
$block['content'] = theme('faq_random_highlights', variable_get('faq_block_random_faq_count', 5));
break;
}
// end switch($delta)
return $block;
case 'configure':
switch ($delta) {
case 0:
break;
case 1:
// Recent FAQs
$form['faq_block_recent_faq_count'] = array(
'#type' => 'textfield',
'#title' => t('Number of FAQs to show'),
'#description' => t("This controls the number of FAQs that appear in the 'Recent FAQs' block"),
'#default_value' => variable_get('faq_block_recent_faq_count', 5),
);
break;
case 2:
// Random FAQs
$form['faq_block_random_faq_count'] = array(
'#type' => 'textfield',
'#title' => t('Number of FAQs to show'),
'#description' => t("This controls the number of FAQs that appear in the 'Random FAQs' block"),
'#default_value' => variable_get('faq_block_random_faq_count', 5),
);
break;
}
// end switch($delta)
return $form;
case 'save':
switch ($delta) {
case 0:
break;
case 1:
variable_set('faq_block_recent_faq_count', $edit['faq_block_recent_faq_count']);
break;
case 2:
variable_set('faq_block_random_faq_count', $edit['faq_block_random_faq_count']);
break;
}
// end switch($delta)
return;
}
// end switch($op)
}