Skip to content
Snippets Groups Projects
Commit 6ce8e179 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Delete unl_blocks module, these blocks are now set in unl_profile.install as per #7633

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@225 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent cc36578a
Branches
Tags
No related merge requests found
; $Id$
name = UNL blocks
description = Adds blocks needed by the UNL WDN template.
core = 7.x
dependencies[] = unl
files[] = unl_blocks.module
<?php
// $Id$
/**
* @file
* Adds blocks for editable regions of the UNL template.
*/
/**
* Implements hook_block_info().
*
* This hook declares to Drupal what blocks are provided by the module.
*/
function unl_blocks_block_info() {
// This hook returns an array, each component of which is an array of block
// information. The array keys are the 'delta' values used in other block
// hooks.
// The required block information is a block description, which is shown
// to the site administrator in the list of possible blocks. You can also
// provide initial settings for block weight, status, etc.
$blocks['leftcollinks'] = array(
'info' => t('Related Links'),
'status' => TRUE,
'region' => 'leftcollinks',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_CACHE_GLOBAL,
);
$blocks['contactinfo'] = array(
'info' => t('Contact Info'),
'status' => TRUE,
'region' => 'contactinfo',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_CACHE_GLOBAL,
);
$blocks['optionalfooter'] = array(
'info' => t('Optional Footer'),
'status' => TRUE,
'region' => 'optionalfooter',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_CACHE_GLOBAL,
);
$blocks['footercontent'] = array(
'info' => t('Footer Content'),
'status' => TRUE,
'region' => 'footercontent',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_CACHE_GLOBAL,
);
return $blocks;
}
/**
* Implements hook_block_configure().
*
* This hook declares configuration options for blocks provided by this module.
*/
function unl_blocks_block_configure($delta = '') {
// The $delta parameter tells us which block is being configured.
// In this example, we'll allow the administrator to customize
// the text of the 'configurable text string' block defined in this module.
$form = array();
if ($delta == 'leftcollinks') {
// All we need to provide is the specific configuration options for our
// block. Drupal will take care of the standard block configuration options
// (block title, page visibility, etc.) and the save button.
$form['unl_blocks_leftcollinks'] = array(
'#type' => 'text_format',
'#title' => t('Block contents'),
'#size' => 60,
'#description' => t('For more info see http://www1.unl.edu/wdn/wiki/Related_Links'),
'#default_value' => variable_get('unl_blocks_leftcollinks', t('<ul><li><a href="http://wdn.unl.edu/">Web Developer Network</a></li></ul>')),
);
}
if ($delta == 'contactinfo') {
$form['unl_blocks_contactinfo'] = array(
'#type' => 'text_format',
'#title' => t('Block contents'),
'#size' => 60,
'#description' => t('For more info see http://www1.unl.edu/wdn/wiki/Contact_Info'),
'#default_value' => variable_get('unl_blocks_contactinfo'),
);
}
if ($delta == 'optionalfooter') {
$form['unl_blocks_optionalfooter'] = array(
'#type' => 'text_format',
'#title' => t('Block contents'),
'#size' => 60,
'#description' => t('Not currently used'),
'#default_value' => variable_get('unl_blocks_optionalfooter'),
);
}
if ($delta == 'footercontent') {
$form['unl_blocks_footercontent'] = array(
'#type' => 'text_format',
'#title' => t('Block contents'),
'#size' => 60,
'#description' => t('Leave this blank to get the standard/default UNL copyright line. For more info see http://www1.unl.edu/wdn/wiki/Base_Footer'),
'#default_value' => variable_get('unl_blocks_footercontent'),
);
}
return $form;
}
/**
* Implements hook_block_save().
*
* This hook declares how the configured options for a block
* provided by this module are saved.
*/
function unl_blocks_block_save($delta = '', $edit = array()) {
// We need to save settings from the configuration form.
// We need to check $delta to make sure we are saving the right block.
if ($delta == 'leftcollinks') {
// Have Drupal save the string to the database.
variable_set('unl_blocks_leftcollinks', $edit['unl_blocks_leftcollinks']);
}
if ($delta == 'contactinfo') {
variable_set('unl_blocks_contactinfo', $edit['unl_blocks_contactinfo']);
}
if ($delta == 'optionalfooter') {
variable_set('unl_blocks_optionalfooter', $edit['unl_blocks_optionalfooter']);
}
if ($delta == 'footercontent') {
variable_set('unl_blocks_footercontent', $edit['unl_blocks_footercontent']);
}
return;
}
/**
* Implements hook_block_view().
*
* This hook generates the contents of the blocks themselves.
*/
function unl_blocks_block_view($delta = '') {
$block = array();
//The $delta parameter tells us which block is being requested.
switch ($delta) {
case 'leftcollinks':
// The subject is displayed at the top of the block. Note that it
// should be passed through t() for translation. The title configured
// for the block using Drupal UI superseeds this one.
$block['subject'] = t('Related Links');
// The content of the block is typically generated by calling a custom
// function.
$block['content'] = unl_blocks_contents($delta);
break;
case 'contactinfo':
$block['subject'] = t('Contacting Us');
$block['content'] = unl_blocks_contents($delta);
break;
case 'optionalfooter':
$block['content'] = unl_blocks_contents($delta);
break;
case 'footercontent':
$block['content'] = unl_blocks_contents($delta);
break;
}
return $block;
}
/**
* A module-defined block content function.
*/
function unl_blocks_contents($which_block) {
switch ($which_block) {
case 'leftcollinks':
// Modules would typically perform some database queries to fetch the
// content for their blocks. Here, we'll just use the variable set in the
// block configuration or, if none has set, a default value.
return variable_get('unl_blocks_leftcollinks');
case 'contactinfo':
return variable_get('unl_blocks_contactinfo');
case 'optionalfooter':
return variable_get('unl_blocks_optionalfooter');
case 'footercontent':
return variable_get('unl_blocks_footercontent');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment