function popup_announcement_list in Pop-up announcement 7
Display list of all blocks with announcements
Admin page
1 string reference to 'popup_announcement_list'
- popup_announcement_menu in ./
popup_announcement.module - Implements hook_menu().
File
- ./
popup_announcement.admin.inc, line 8
Code
function popup_announcement_list() {
// table header
$header = array(
array(
'data' => t('#'),
),
array(
'data' => t('Block name'),
),
array(
'data' => t('Status'),
),
// is this block active or not (associated with theme region)
array(
'data' => t('Size'),
),
array(
'data' => t('Number visit'),
),
array(
'data' => t('Delay'),
),
array(
'data' => t('Visibility Settings'),
),
array(
'data' => t('Pages'),
),
array(
'data' => t('Edit'),
),
array(
'data' => t('Created'),
),
array(
'data' => t('Delete'),
),
);
// visibility types
$visibility = array(
BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'),
);
// collect data about blocks with announcements
$rows = array();
$pa = new Popup_announcement_block();
$bs = $pa
->get_blocks();
$i = 1;
foreach ($bs as $bid => $b) {
$block = block_load('popup_announcement', 'popup_announcement_' . $bid);
$destination = drupal_get_destination();
// todo what this?
$rows[] = array(
'#' => $i,
'name' => $b['name'] == FALSE ? t('Pop-up announcement ' . $bid) : $b['name'],
'status' => $block->status == 1 ? 'enabled' : 'disabled',
'size' => $b['width'] . 'px / ' . $b['height'] . 'px',
'number_visit' => $b['number_visit'],
'delay' => $b['delay'],
'visibility_settings' => $visibility[$block->visibility],
'pages' => check_plain($block->pages),
'action' => l('edit', 'admin/structure/block/manage/popup_announcement/popup_announcement_' . $bid . '/configure'),
'created' => format_date($b['created']),
'delete' => l('delete', 'admin/config/popup_announcement/' . $bid . '/delete'),
);
$i++;
}
$build['popup_announcement_list'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
// add button "add new announcement"
$build['popup_announcement_create_button'] = drupal_get_form('popup_announcement_create_button');
return $build;
}