123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?php
- function hook_block_info() {
-
- $blocks['syndicate'] = array(
- 'info' => t('Syndicate'),
- 'cache' => DRUPAL_NO_CACHE
- );
- $blocks['recent'] = array(
- 'info' => t('Recent content'),
-
- );
- return $blocks;
- }
- function hook_block_info_alter(&$blocks, $theme, $code_blocks) {
-
- $blocks['user']['login']['status'] = 0;
- }
- function hook_block_configure($delta = '') {
-
- $form = array();
- if ($delta == 'recent') {
- $form['node_recent_block_count'] = array(
- '#type' => 'select',
- '#title' => t('Number of recent content items to display'),
- '#default_value' => variable_get('node_recent_block_count', 10),
- '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
- );
- }
- return $form;
- }
- function hook_block_save($delta = '', $edit = array()) {
-
- if ($delta == 'recent') {
- variable_set('node_recent_block_count', $edit['node_recent_block_count']);
- }
- }
- function hook_block_view($delta = '') {
-
- $block = array();
- switch ($delta) {
- case 'syndicate':
- $block['subject'] = t('Syndicate');
- $block['content'] = array(
- '#theme' => 'feed_icon',
- '#url' => 'rss.xml',
- '#title' => t('Syndicate'),
- );
- break;
- case 'recent':
- if (user_access('access content')) {
- $block['subject'] = t('Recent content');
- if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
- $block['content'] = array(
- '#theme' => 'node_recent_block',
- '#nodes' => $nodes,
- );
- } else {
- $block['content'] = t('No content available.');
- }
- }
- break;
- }
- return $block;
- }
- function hook_block_view_alter(&$data, $block) {
-
- if (is_array($data['content']) && isset($data['content']['#contextual_links'])) {
- unset($data['content']['#contextual_links']);
- }
-
-
- if (is_array($data['content']) && $block->module == 'somemodule') {
- $data['content']['#theme_wrappers'][] = 'mymodule_special_block';
- }
- }
- function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
-
-
-
-
-
- $data['subject'] = t('New title of the block');
- }
- function hook_block_list_alter(&$blocks) {
- global $language, $theme_key;
-
-
- $result = db_query('SELECT module, delta, language FROM {my_table}');
- $block_languages = array();
- foreach ($result as $record) {
- $block_languages[$record->module][$record->delta][$record->language] = TRUE;
- }
- foreach ($blocks as $key => $block) {
-
-
- if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
-
- continue;
- }
- if (!isset($block_languages[$block->module][$block->delta])) {
-
- continue;
- }
- if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
-
-
- unset($blocks[$key]);
- }
- }
- }
- function hook_block_cid_parts_alter(&$cid_parts, $block) {
- global $user;
-
- $cid_parts[] = $user->timezone;
- }
|