/** * Implementation of hook_block(). * * three 'recent flickr photoset' blocks: * 'flickr recent sets' Displays the most recent photosets, titles, and descriptions in a block. * 'flickr recent titles' displays the most recent photoset titles in a block. * 'flickr recent thumbs' displays the most recent photoset thumbnails in a block. * * all three are css styleable * recent sets class is '{$flickr_class}_recent' * recent sets class is '{$flickr_class}_titles' * recent sets class is '{$flickr_class}_thumbs' * * i would suggest something like: * * .flickr, .flickr_recent { * padding: 4px; * margin: 6px; * border-top:1px solid #222; * border-bottom:1px solid #222; * } * .flickr_title { * font-weight: bold; * } * .flickr_thumbs { * display: block; * float: left; * height: 100px; * width: 100px; * margin: 4px; * text-align: center; * } * * * the number of photosets to display is configurable (per block) in the block config */ function flickr_block($op='list', $delta=0, $edit = array()) { switch($delta) { case 0: // full flickr photosets $block_type = 'flickr_recent'; $count_var = 'flickr_recent_count'; break; case 1: // flickr photoset titles $block_type = 'flickr_titles'; $count_var = 'flickr_titles_count'; break; case 2: // flickr photosets thumbs $block_type = 'flickr_thumbs'; $count_var = 'flickr_thumbs_count'; break; } if ($op == "list") { $block[0]["info"] = t('Flickr recent sets'); $block[1]["info"] = t('Flickr recent titles'); $block[2]["info"] = t('Flickr recent thumbs'); return $block; } else if ($op == 'configure') { $form = array(); $form[$count_var] = array( '#type' => 'textfield', '#title' => t('Max photosets'), '#size' => 4, '#description' => t('This is the maximum number of photosets to display.'), '#default_value' => variable_get($count_var, '5') ); return $form; } else if ($op == 'save') { variable_set($count_var, $edit[$count_var]); } else if ($op == 'view') { global $user; if (user_access('access content')) { $flickr_api_key = variable_get('flickr_apik','bd4441fc9cef3745a18955ffdf91c732'); $flickr_uid = variable_get('flickr_uid','35034355182@N01'); $count = variable_get($count_var, 5); $url = "http://www.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=$flickr_api_key&user_id=$flickr_uid"; $resp = flickr_get_cached_file_contents($url, 'r', 600, variable_get('flickr_cache','/tmp')); $settree = flickr_make_xmltree($resp); if (!empty($top_level_tree['rsp']['err']) || empty($settree)) { $output = "
". format_plural($album['photos'], '1 photo', '%count photos') ." in this album
(".l(t('view locally'), "flickr/setimages/$album_id")." - view on Flickr).
$album_description