function smarty_block_mtmultiblog($args, $content, &$ctx, &$repeat) { # Set default mode for backwards compatibility $mode = $args['mode']; $mode or $mode = 'loop'; if (!isset($content)) { # Check for nested MTMultiBlog tags if ($ctx->stash('multiblog_context')) { $repeat = false; return ''; } # If MTMultiBlog was called with no arguments, we check the # blog-level settings for the default includes/excludes. if (!($args['blog_ids'] or $args['include_blogs'] or $args['exclude_blogs'])) { $id = $ctx->stash('blog_id'); global $multiblog_blog_config; if (!$multiblog_blog_config) { $multiblog_blog_config = array(); } if (!isset($multiblog_blog_config[$id])) { $multiblog_blog_config[$id] = $ctx->mt->db->fetch_plugin_data("MultiBlog", "configuration:blog:{$id}"); } if (!isset($multiblog_blog_config[$id])) { $multiblog_blog_config[$id] = array(); } $is_include = $multiblog_blog_config[$id]['default_mtmultiblog_action']; if ($multiblog_blog_config[$id]['default_mtmulitblog_blogs']) { $blogs = $multiblog_blog_config[$id]['default_mtmulitblog_blogs']; } if ($blogs && isset($is_include)) { $args[$is_include ? 'include_blogs' : 'exclude_blogs'] = $blogs; } else { $mode = 'context'; # Override 'loop' mode } } # Filter MultiBlog args through access controls if (!multiblog_filter_blogs_from_args($ctx, $args)) { if ($mode == 'loop') { $repeat = false; return ''; } } else { if ($mode != 'loop' && $mode != 'context') { # Throw error if mode is unknown $repeat = false; return ''; } } } # Run MultiBlog in specified mode if ($mode == 'loop') { $content = multiblog_loop($args, $content, $ctx, $repeat); } elseif ($mode == 'context') { $content = multiblog_context($args, $content, $ctx, $repeat); } return $content; }
function multiblog_block_wrapper($args, $content, &$ctx, &$repeat) { $tag = $ctx->this_tag(); $localvars = array('local_blog_id'); if (!isset($content)) { $ctx->localize($localvars); # Filter blogs from multiblog tag attributes if any if (!multiblog_filter_blogs_from_args($ctx, $args)) { $repeat = false; $ctx->restore($localvars); return ''; # Set multiblog tag context if applicable } elseif ($mode = $ctx->stash('multiblog_context')) { $args[$mode] = $ctx->stash('multiblog_blog_ids'); } } # Fix for MTMultiBlogIfLocalBlog which should never return # true with MTTags block because tags are cross-blog if ($ctx->this_tag() == 'mttags') { $ctx->stash('local_blog_id', 0); } # Call original tag handler with new multiblog args global $multiblog_orig_handlers; $fn = $multiblog_orig_handlers[$tag]; $result = $fn($args, $content, $ctx, $repeat); # Restore localized variables if last loop if (!$repeat) { $ctx->restore($localvars); } return $result; }