| 1 |
<?php |
<?php |
| 2 |
// $Id: flickr_block.module,v 1.15 2008/11/21 10:19:37 paulbooker Exp $ |
// $Id: flickr_block.module,v 1.15.2.1 2009/01/30 10:39:01 paulbooker Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_block(). |
* Implementation of hook_block(). |
| 16 |
$blocks[3]['info'] = t('Flickr recent photos'); |
$blocks[3]['info'] = t('Flickr recent photos'); |
| 17 |
$blocks[4]['info'] = t('Flickr recent photosets'); |
$blocks[4]['info'] = t('Flickr recent photosets'); |
| 18 |
$blocks[5]['info'] = t('Flickr random photos'); |
$blocks[5]['info'] = t('Flickr random photos'); |
| 19 |
|
$blocks[6]['info'] = t('Flickr group photos'); |
| 20 |
|
|
| 21 |
// Photoset blocks |
// Photoset blocks |
| 22 |
$blocks[6]['info'] = t('Flickr random photo from photoset'); |
$blocks[7]['info'] = t('Flickr random photo from photoset'); |
| 23 |
|
|
| 24 |
return $blocks; |
return $blocks; |
| 25 |
|
|
| 79 |
break; |
break; |
| 80 |
case 5: // sitewide, random |
case 5: // sitewide, random |
| 81 |
break; |
break; |
| 82 |
case 6: // sitewide, random |
case 6: // sitewide, group |
| 83 |
|
$form["flickr_block_{$delta}_user_id"]['#title'] = t('Show photos from this group id'); |
| 84 |
|
$form["flickr_block_{$delta}_user_id"]['#description'] = t('Will select photos from this group pool'); |
| 85 |
|
break; |
| 86 |
|
case 7: // sitewide, random |
| 87 |
$form["flickr_block_{$delta}_photoset"] = array( |
$form["flickr_block_{$delta}_photoset"] = array( |
| 88 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 89 |
'#title' => t('Flickr Photoset Id'), |
'#title' => t('Flickr Photoset Id'), |
| 110 |
case 3: |
case 3: |
| 111 |
case 4: |
case 4: |
| 112 |
case 5: |
case 5: |
| 113 |
|
case 6: |
| 114 |
variable_set('flickr_block_'. $delta, array( |
variable_set('flickr_block_'. $delta, array( |
| 115 |
'user_id' => $edit["flickr_block_{$delta}_user_id"], |
'user_id' => $edit["flickr_block_{$delta}_user_id"], |
| 116 |
'show_n' => (int) $edit["flickr_block_{$delta}_show_n"], |
'show_n' => (int) $edit["flickr_block_{$delta}_show_n"], |
| 117 |
'size' => $edit["flickr_block_{$delta}_size"], |
'size' => $edit["flickr_block_{$delta}_size"], |
| 118 |
)); |
)); |
| 119 |
break; |
break; |
| 120 |
case 6: |
case 7: |
| 121 |
variable_set('flickr_block_'. $delta, array( |
variable_set('flickr_block_'. $delta, array( |
| 122 |
'user_id' => $edit["flickr_block_{$delta}_user_id"], |
'user_id' => $edit["flickr_block_{$delta}_user_id"], |
| 123 |
'show_n' => (int) $edit["flickr_block_{$delta}_show_n"], |
'show_n' => (int) $edit["flickr_block_{$delta}_show_n"], |
| 175 |
$block['subject'] = t('Flickr random photos'); |
$block['subject'] = t('Flickr random photos'); |
| 176 |
$block['content'] = _flickr_block_random($settings['user_id'], $settings['show_n'], $settings['size']); |
$block['content'] = _flickr_block_random($settings['user_id'], $settings['show_n'], $settings['size']); |
| 177 |
} |
} |
| 178 |
elseif ($delta == 6) { |
elseif ($delta == 6) { |
| 179 |
|
$block['subject'] = t('Flickr Group photos'); |
| 180 |
|
$block['content'] = _flickr_block_group_recent($settings['user_id'], $settings['show_n'], $settings['size']); |
| 181 |
|
} |
| 182 |
|
elseif ($delta == 7) { |
| 183 |
$block['subject'] = t('Flickr random photoset photos'); |
$block['subject'] = t('Flickr random photoset photos'); |
| 184 |
$block['content'] = _flickr_block_photoset_random($settings['user_id'], $settings['show_n'], $settings['size'], $settings['photoset_id']); |
$block['content'] = _flickr_block_photoset_random($settings['user_id'], $settings['show_n'], $settings['size'], $settings['photoset_id']); |
| 185 |
} |
} |
| 268 |
return $output; |
return $output; |
| 269 |
} |
} |
| 270 |
|
|
| 271 |
|
/* |
| 272 |
|
* This renders a block with photos from the selected groupid |
| 273 |
|
*/ |
| 274 |
|
function _flickr_block_group_recent($groupid, $show_n, $size) { |
| 275 |
|
$output = ''; |
| 276 |
|
if ($photos = flickr_get_group_photos($groupid, 1, array('per_page' => $show_n))) { |
| 277 |
|
foreach ($photos['photo'] as $photo) { |
| 278 |
|
$output .= theme('flickr_block_photo', $photo, $size); |
| 279 |
|
} |
| 280 |
|
} |
| 281 |
|
return $output; |
| 282 |
|
} |
| 283 |
|
|
| 284 |
/** |
/** |
| 285 |
* Implementation of hook_theme(). |
* Implementation of hook_theme(). |
| 286 |
*/ |
*/ |