*/ class ImageBlockCallbacks { /** */ function callback($params, &$smarty, $callback, $userId=null) { GalleryCoreApi::requireOnce('modules/imageblock/classes/ImageBlockHelper.class'); switch($callback) { case 'LoadImageBlock': /* Pick up our overrides */ if (!$params['useDefaults']) { /* * If we're overriding the defaults, then overlay our changes on top of the * defaults and pass in a complete 'show' parameter. */ list ($ret, $moduleParams) = GalleryCoreApi::fetchAllPluginParameters('module', 'imageblock'); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } $showMap = array_flip(explode('|', $moduleParams['show'])); foreach (array('showHeading' => 'heading', 'showTitle' => 'title', 'showViews' => 'views', 'showOwner' => 'owner', 'showDate' => 'date') as $blockVarName => $showMapName) { if (empty($params[$blockVarName])) { unset($showMap[$showMapName]); } else { $showMap[$showMapName] = 1; } } $params['show'] = implode('|', array_keys($showMap)); } $vars =& $smarty->_tpl_vars; if (isset($vars['theme']['actingUserId'])) { /* Support guest-preview mode */ $params['userId'] = $vars['theme']['actingUserId']; } /* * ImageBlockHelper expects a GalleryTemplate, but Smarty callbacks don't provide * one, so create a temporary wrapper. */ $template = new GalleryTemplate(dirname(__FILE__), false); $template->_smarty =& $smarty; /* Remove null parameters */ foreach (array_keys($params) as $key) { if (!isset($params[$key])) { unset($params[$key]); } } $ret = ImageBlockHelper::loadImageBlocks($template, $params); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } return null; } return GalleryCoreApi::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__); } } ?>