function tagadmin_draw_branch($pid = 0, $origindent = 0, $depth = 0, $bg = "", $indent = 0, $type = 'checkbox', $offset = 0) { // depth = -1 will stop recursion, = -2 will force drawing of a root element // type can be 'checkbox' or 'radio' only global $context, $settings, $txt, $scripturl; $row = 0; if ($depth > 0) { // add offset $offset += 2; } else { if ($depth < 0) { // no recursion $bg = 2; echo str_repeat("\t", $indent) . '<tr>' . "\n"; echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '" colspan="3">', str_repeat(" ", $offset), '<a href="', $scripturl, '?action=tags;id=0"><i>[', $txt['smftags_roottag'], ']</i></a></td>', "\n"; if ($type == "checkbox") { echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', '<input type="checkbox" name="tag[0]" value="1"></td>', "\n"; } else { if ($type == "radio") { echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', '<input type="radio" name="master" value="tag[0]"</td>', "\n"; } } } else { // set root indent $indent = $origindent; } } foreach ($context['tags']['by_parent'][$pid] as $branch) { $bg = empty($bg) ? 2 : ""; list($id, $tag, $approved1, $taggable, $tagged, $approved2, $quantity) = $branch; $has_children = array_key_exists($id, $context['tags']['by_parent']); echo str_repeat("\t", $indent) . '<tr>' . "\n"; echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', str_repeat(" ", $offset), '<a href="', $scripturl, '?action=tags;id=', $id, '">', $tag, '</a></td>', "\n"; echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', $quantity, '</td>', "\n"; echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', $taggable ? strtolower($txt['smftags_taggable']) : strtolower($txt['smftags_untaggable']), '</td>', "\n"; if ($type == "checkbox") { echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', '<input type="checkbox" name="tag[', $id, ']" value="1"></td>', "\n"; } else { if ($type == "radio") { echo str_repeat("\t", $indent + 1), '<td class="windowbg', $bg, '">', '<input type="radio" name="master" value="tag[', $id, ']"</td>', "\n"; } } echo str_repeat("\t", $indent) . '</tr>' . "\n"; if ($has_children && $depth >= 0) { tagadmin_draw_branch($id, $origindent, $depth + 1, $bg, $indent, $type, $offset); } } }
function template_viewall2() { global $txt, $context, $scripturl, $settings; echo ' <div class="tborder"> <table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor"> <tr> <td align="center" class="catbg">', $txt['smftags_popular'], '</td> </tr> <tr> <td align="center" class="windowbg2">'; $ids = array(); if (isset($context['poptags'])) { echo $context['poptags']; } echo '</td> </tr> </table> <form method="POST" name="', strtolower($_REQUEST['todo']), '" action="', $scripturl, '?action=tags;sa=viewall">'; if ($_REQUEST['todo'] == "merge") { echo ' <div align="center">', $txt['smftags_merge2'], '</div> <table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor"> <tr> <td class="catbg3">', $txt['smftags_tag'], '</td> <td class="catbg3">', $txt['smftags_count'], '</td> <td class="catbg3">', $txt['smftags_taggable'], '</td> <td class="catbg3">', $txt['smftags_select'], '</td> </tr>'; foreach ($context['tags']['by_parent'] as $parent => $children) { foreach ($children as $child) { list($id, $tag, $approved1, $taggable, $tagged, $approved2, $quantity) = $child; $bg = empty($bg) ? 2 : ""; echo ' <tr> <td class="windowbg', $bg, '"><a href="', $scripturl, '?action=tags;id=', $id, '">', $tag, '</a></td> <td class="windowbg', $bg, '">', $quantity, '</td> <td class="windowbg', $bg, '">', $taggable, '</td> <td class="windowbg', $bg, '"><input type="radio" name="master" value="tag[', $id, ']"></td> </tr>'; $ids[] = $id; } } echo ' <tr class="catbg"> <td colspan="4" align="right"> <input type="submit" name="merge" value="', $txt['smftags_act_merge'], '"> <input type="reset" value="', $txt['smftags_act_reset'], '"> </td> </tr> </table> <input type="hidden" name="slaves" value="', implode(',', $ids), '">'; } else { if ($_REQUEST['todo'] == "move") { echo ' <div align="center">', $txt['smftags_move2'], '</div> <table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor"> <tr> <td class="catbg3">Tag</td> <td class="catbg3">Count</td> <td class="catbg3">Taggable</td> <td class="catbg3">Select</td> </tr>'; if (@(include_once $settings['default_theme_dir'] . '/Tags.tree.inc.php')) { // using depth = -2 to include the root element and stop recursion, as moving to a child tag would create orphans tagadmin_draw_branch(0, 4, -2, "", 0, "radio"); } foreach ($context['tags']['by_parent'] as $parent => $children) { foreach ($children as $child) { $ids[] = $child[0]; } } echo ' <input type="hidden" name="slaves" value="', implode(',', $ids), '"> <tr class="catbg"> <td colspan="4" align="right"> <input type="submit" name="move" value="', $txt['smftags_act_move'], '"> <input type="reset" value="', $txt['smftags_act_reset'], '"> </td> </tr> </table> </form>'; } else { fatal_error($txt['smftags_err_nodirect']); } } echo ' <br /> </div>'; //The Copyright is required to remain or contact me to purchase link removal. echo ' <br /> <div align="center"><a href="http://www.smfhacks.com" target="blank">SMF Tags</a></div>'; }