function ad_block in Advertisement 5.2
Same name and namespace in other branches
- 5 ad.module \ad_block()
- 6 ad.module \ad_block()
- 6.2 ad.module \ad_block()
Drupal _block hook.
File
- ./
ad.module, line 1236 - An advertising system for Drupal powered websites.
Code
function ad_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks = array();
$groups = ad_groups_list();
foreach ($groups as $tid => $name) {
$blocks[$tid]['info'] = t('ad group: @name', array(
'@name' => $name,
));
}
return $blocks;
case 'configure':
$form["ad_block_quantity_{$delta}"] = array(
'#type' => 'select',
'#title' => t('Number of ads'),
'#default_value' => variable_get("ad_block_quantity_{$delta}", 1),
'#options' => drupal_map_assoc(array(
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
)),
'#description' => t('Select the maximum number of unique ads that should be displayed together in this block. If you specify a number larger than the maximum number of ads in this ad group, all ads will be displayed once.'),
);
return $form;
case 'save':
variable_set("ad_block_quantity_{$delta}", $edit["ad_block_quantity_{$delta}"]);
break;
case 'view':
$groups = ad_groups_list();
$block['content'] = ad($delta, variable_get("ad_block_quantity_{$delta}", 1));
return $block;
}
}