NULL, 'FlickrSecret' => NULL, 'DieOnError' => false, 'EnableCache' => false, 'CacheType' => 'fs', 'CachePath' => $_SERVER['DOCUMENT_ROOT'] . '/cache', 'HTMLWrapper'=> array('
', '
'), # $FlickrGallery['HTML'] options: # {{URL_*}} returns a flickr URL of a particular size: square, medium, etc. # {{*}} returns a flickr API response argument value for a . # {{S_*}} returns "sanitized" html code of above for safe use in lightbox. # {{D_*}} passes a directive argument directly into the HTML template. # {{E_*}} executes php code, but is very tricky to use. 'HTML' => ' {{S_title}} ', 'HTMLErrorWrapper' => array('

- ', ' -

'), )); SDVA($FlickrAPI, array( 'Method' => 'flickr.photos.getRecent', )); ##### Initialize ##### FlickrGalleryInit(); ##### Functions ##### function FlickrGalleryInit () { Markup('FlickrGallery', 'directives', '/\\(:flickrgallery\\s*(.*?):\\)/e', "FlickrGallery(PSS('$1'))"); } function FlickrGallery($inpt=NULL) { global $FarmD, $FlickrGallery, $FlickrAPI; include_once("$FarmD/cookbook/phpFlickr/phpFlickr.php"); $fg = $FlickrGallery; $fa = $FlickrAPI; $args = ParseArgs($inpt); if (!empty($args[''][0])) { $fa['Method'] = $args[''][0]; } elseif (!empty($args['Method'])) { $fa['Method'] = $args['Method']; } elseif (!empty($args['method'])) { $fa['Method'] = $args['method']; } $fa_call = str_replace('flickr.', '', $fa['Method']); unset($fa['Method']); $args_keys = array_keys($args); foreach ($args_keys as $k) { $fa[$k] = $args[$k]; } $f = new phpFlickr($fg['FlickrAPI'], $fg['FlickrSecret'], $fg['DieOnError']); if ($fg['EnableCache'] == true) { $f->enableCache($fg['CacheType'], $fg['CachePath']); } $photos = $f->call('flickr.' . $fa_call, $fa); if (@$photos['photos']['total'] != 0) { $g = 'photos'; } elseif (@$photos['photoset']['total'] != 0) { $g = 'photoset'; } else { return FlickrGalleryError($f, 'no Flickr images available for display'); } foreach ($photos[$g]['photo'] as $photo) { $html_build = preg_replace('/{{URL_(.*?)}}/ei', '$f->buildPhotoURL($photo, "$1")', $fg['HTML']); $html_build = preg_replace('/{{S_(.*?)}}/ei', 'htmlspecialchars(@$photo[$1])', $html_build); $html_build = preg_replace('/{{D_(.*?)}}/ei', 'htmlspecialchars(@$args[$1])', $html_build); $html_build = preg_replace('/{{E_(.*?)}}/emi', '$1', $html_build); $html_build = preg_replace('/{{(.*?)}}/ei', '@$photo[$1]', $html_build); @$html_out .= $html_build; } return Keep($fg['HTMLWrapper'][0] . $html_out . $fg['HTMLWrapper'][1]); } function FlickrGalleryError($f, $m) { global $FlickrGallery; if ($f->getErrorCode()) { $m = 'flickr API error ' . $f->getErrorCode() . ': ' . $f->getErrorMsg(); } return Keep($FlickrGallery['HTMLErrorWrapper'][0] . $m . $FlickrGallery['HTMLErrorWrapper'][1]); }