-function mkdru_block($op='list', $delta='sources', $edit=array()) {
- switch ($op) {
- case 'list':
- $blocks['mkdru_sources']['info'] = t('mkdru - source facets');
- $blocks['mkdru_sources']['cache'] = BLOCK_NO_CACHE;
- $blocks['mkdru_subjects']['info'] = t('mkdru - subject facets');
- $blocks['mkdru_subjects']['cache'] = BLOCK_NO_CACHE;
- $blocks['mkdru_authors']['info'] = t('mkdru - author facets');
- $blocks['mkdru_authors']['cache'] = BLOCK_NO_CACHE;
- return $blocks;
-
- case 'view':
- switch ($delta) {
- // TODO: make the facet themable, I have no clue why this won't work
-// case 'mkdru_sources':
-// $block['subject'] = t('Source');
-// $block['content'] = theme('mkdru_block_facet', 'mkdru-sources');
-// return $block;
-// case 'mkdru_subjects':
-// $block['subject'] = t('Subject');
-// $block['content'] = theme('mkdru_block_facet', 'mkdru-subjects');
-// return $block;
-// case 'mkdru_authors':
-// $block['subject'] = t('Author');
-// $block['content'] = theme('mkdru_block_facet', 'mkdru-authors');
-// return $block;
- case 'mkdru_sources':
- $block['subject'] = t('Source');
- $block['content'] = '<div id="mkdru-sources"> </div>';
- return $block;
- case 'mkdru_subjects':
- $block['subject'] = t('Subject');
- $block['content'] = '<div id="mkdru-subjects"> </div>';
- return $block;
- case 'mkdru_authors':
- $block['subject'] = t('Author');
- $block['content'] = '<div id="mkdru-authors"> </div>';
- return $block;
- }
+function mkdru_block_view($delta) {
+ if (substr($delta, 0, 12) == 'mkdru_facet_') {
+ $facet = substr($delta, 12);
+ $block['subject'] = t(ucwords($facet));
+ $block['content'] = theme('mkdru_block_facet',
+ array('class' => 'mkdru-facet-' . $facet));
+ return $block;
+ }
+ elseif (substr($delta, 0, 13) == 'mkdru_search_') {
+ $nid = substr($delta, 13);
+ $block['content'] = theme('mkdru_block_search',
+ array('nid' => $nid, 'path' => '/node/' . $nid));
+ return $block;