Ejemplo n.º 1
0
function tag_draw_optgroup($pid = 0, $origindent = 0, $depth = 0, $indent = 0, $offset = 0)
{
    global $context, $settings;
    if ($depth > 0) {
        $offset += 2;
    } else {
        if ($depth == 0) {
            $indent = $origindent;
        }
    }
    foreach ($context['tags']['by_parent'][$pid] as $branch) {
        list($id, $tag, $approved1, $taggable, $tagged, $approved2, $quantity) = $branch;
        $has_children = array_key_exists($id, $context['tags']['by_parent']);
        echo str_repeat("\t", $indent) . '<option value="' . $id . '">' . str_repeat("&nbsp;", $offset) . $tag . '</option>' . "\n";
        if ($has_children) {
            tag_draw_optgroup($id, $origindent, $depth + 1, $indent, $offset);
        }
    }
}
Ejemplo n.º 2
0
function template_main()
{
    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">';
    if (isset($context['poptags'])) {
        echo $context['poptags'];
    }
    echo '
					</td>
				</tr>
			</table>';
    // check we have the variables set
    if (isset($context['tags_newtagged'])) {
        echo '
			<br />
			<div align="center"><large><a href="', $scripturl, '?action=tags;sa=viewall">', $txt['smftags_viewall'], '</a>', $txt['smftags_viewall2'], '</large></div>
			<br />
			<form name="pendingtags" action="', $scripturl, '?action=tags" method="post" accept-charset="', $context['character_set'], '">
			<table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor">
				<tr>
					<td align="center" class="catbg">', $txt['smftags_manage_tags'], '</td>
				</tr>
				<tr>
					<td align="center" class="windowbg2">
						<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
							<tr>
								<td class="catbg3">', $txt['smftags_tag'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_parents'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_taggable'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_select'], '</td>
							</tr>';
        foreach ($context['tags_newtags'] as $i => $newtag) {
            echo '
							<tr>
								<td class="windowbg2"><a href="' . $scripturl . '?action=tags;id=' . $newtag['ID_TAG'] . '">' . $newtag['tag'] . '</a></td>
								<td class="windowbg2">';
            if (!empty($newtag['parent_id'])) {
                $output = array();
                $parent = $newtag['parent_id'];
                while (isset($newtag['parent_array'][$parent])) {
                    $output[] = $newtag['parent_array'][$parent]['tag'];
                    $parent = $newtag['parent_array'][$parent]['parent_id'];
                }
                echo implode(' &rArr; ', $output);
            }
            echo '</td>
								<td class="windowbg2">', $newtag['taggable'] ? strtolower($txt['smftags_taggable']) : strtolower($txt['smftags_untaggable']), '</td>
								<td class="windowbg"><input type="checkbox" name="a' . $newtag['ID_TAG'] . '" value="1"></td>
							</tr>';
        }
        echo '
						</table>
					</td>
				</tr>
				<tr class="catbg">
					<td align="right"> 
						<select name="todo">
							<option>-------</option>
							<option value="approve">', $txt['smftags_act_approve'], '</option>
							<option value="delete">', $txt['smftags_act_delete'], '</option>
						</select>
						<input type="submit" name="pendingtags" value="', $txt['smftags_act_go'], '">
						<input type="reset" value="', $txt['smftags_act_reset'], '">
					</td>
				</tr>
			</table>
			</form>

			<br />';
        if (allowedTo('smftags_create')) {
            echo '
		<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
		function addCreateTag() {
			var oldtr = document.getElementById(\'newCreateTag\');
			var newtr = document.createElement(\'tr\');
			var table = document.getElementById(\'newCreateTagtable\');
			var rows = table.getElementsByTagName("TR").length;
			newtr.innerHTML = oldtr.innerHTML;
			document.getElementById(\'tag1\').setAttribute(\'name\',\'tag\' + rows);
			document.getElementById(\'parent1\').setAttribute(\'name\',\'parent\' + rows);
			document.getElementById(\'taggable1\').setAttribute(\'name\',\'taggable\' + rows);
			document.getElementById(\'approved1\').setAttribute(\'name\',\'approved\' + rows);
			document.getElementById(\'tag1\').setAttribute(\'id\',\'tag\' + rows);
			document.getElementById(\'parent1\').setAttribute(\'id\',\'parent\' + rows);
			document.getElementById(\'taggable1\').setAttribute(\'id\',\'taggable\' + rows);
			document.getElementById(\'approved1\').setAttribute(\'id\',\'approved\' + rows);
			newtr.setAttribute(\'id\',\'newCreateTag\');
			oldtr.removeAttribute(\'id\');
			table.appendChild(newtr);
		}
	// ]]></script>
			<form name="create" action="', $scripturl, '?action=tags" method="post" accept-charset="', $context['character_set'], '">
			<table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor">
				<tr>
					<td align="center" class="catbg">', $txt['smftags_create'], '</td>
				</tr>
				<tr>
					<td align="center" class="windowbg2">
						<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor" id="newCreateTagtable">
							<tr>
								<td class="catbg3">', $txt['smftags_tag'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_parent'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_taggable'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_approved'], '</td>
							</tr>
							<tr id="newCreateTag">
								<td class="windowbg"><input type="text" name="tag1" id="tag1" size="50" max="256"></td>
								<td class="windowbg">
									<select name="parent1" id="parent1">
										<option value="0">- ', $txt['smftags_noparent'], ' -</option>
';
            if (include_once $settings['default_theme_dir'] . '/Tags.tree.inc.php') {
                tag_draw_optgroup(0, 10);
            }
            echo '
									</select>
								<td class="windowbg"><input type="checkbox" name="taggable1" id="taggable1" value="1"></td>
								<td class="windowbg2"><input type="checkbox" name="approved1" id="approved1" value="1"></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr class="catbg">
					<td colspan="3" align="right">
						<input type="button" value="Add more" onClick="addCreateTag()">
						<input type="submit" value="', $txt['smftags_act_create'], '" name="create">
						<input type="reset" value="', $txt['smftags_act_reset'], '">
					</td>
				</tr>
			</table>
			</form>';
        }
        if (isset($context['tags_newtagged']) && !empty($context['tags_newtagged'])) {
            echo '
			<br />
			<table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor">
				<tr>
					<td align="center" class="catbg">', $txt['smftags_manage_topictags'], '</td>
				</tr>
				<tr>
					<td align="center" class="windowbg2">
					<form name="tagusertopic" action="', $scripturl, '?action=tags" method="post" accept-charset="', $context['character_set'], '">
						<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
							<tr>
								<td class="catbg3">', $txt['smftags_tag'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_postedby'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_suggestedby'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_tagssuggested'], '</td>
								<td class="catbg3" align="center">', $txt['smftags_select'], '</td>
							</tr>';
            // draw header row for each unique topic/suggested by pair
            foreach ($context['tags_newtagged'] as $i => $newtagged) {
                $rowspan_suggestedby = empty($context['tags_expand']) ? '' : ' rowspan="' . count($newtagged['tags']) . '"';
                echo '
							<tr>
								<td class="windowbg2"' . $rowspan_suggestedby . '><a href="' . $scripturl . '?topic=' . $newtagged['ID_TOPIC'] . '.0"' . $rowspan_suggestedby . '>' . $newtagged['subject'] . '</a></td>
								<td class="windowbg"' . $rowspan_suggestedby . '><a href="' . $scripturl . '?action=profile;u=' . $newtagged['posterID'] . '">' . $newtagged['posterName'] . '</a></td>
								<td class="windowbg2"' . $rowspan_suggestedby . '><a href="' . $scripturl . '?action=profile;u=' . $newtagged['ID_MEMBER'] . '">' . $newtagged['memberName'] . '</a></td>';
                $tl = array();
                // now look at each individual tag suggested for this pair
                if (!empty($context['tags_expand'])) {
                    foreach ($newtagged['tags'] as $j => $t) {
                        if ($j != 0) {
                            echo '
							<tr>';
                        }
                        echo '
								<td class="windowbg">', ($t['approved'] ? '<i>' : '') . '<a href="' . $scripturl . '?action=tags;id=' . $t['ID_TAG'] . '">' . $t['tag'] . '</a>' . ($t['approved'] ? '</i>' : ''), '</td><td class="windowbg2">', $t['approved'] ? '' : '<input type="checkbox" name="i' . $t['ID'] . '" value="1">', '</td>
							</tr>';
                    }
                } else {
                    foreach ($newtagged['tags'] as $j => $t) {
                        $tl[] = ($t['approved'] ? '<i>' : '') . '<a href="' . $scripturl . '?action=tags;id=' . $t['ID_TAG'] . '">' . $t['tag'] . '</a>' . ($t['approved'] ? '</i>' : '');
                    }
                    echo '
								<td class="windowbg">' . implode(' · ', $tl) . '</td>
								<td class="windowbg2"><input type="checkbox" name="' . $newtagged['ID_TOPIC'] . 'x' . $newtagged['ID_MEMBER'] . '" value="1"></td>';
                }
            }
            echo '
							</tr>
							<tr class="catbg">
								<td colspan="3" align="left">', !empty($context['tags_index']) ? '<b>' . $txt[139] . ':</b> ' . $context['tags_index'] : '', '</td>
								<td colspan="2" align="right"> 
									<select name="todo">
										<option>-------</option>
										<option value="approveusertopic">', $txt['smftags_act_approve'], ' </option>', $context['tags_expand'] ? '' : '
										<option value="expandusertopic">' . $txt['smftags_act_expand'] . '</option>', '
										<option value="deleteusertopic">', $txt['smftags_act_delete'], '</option>
									</select>
									<input type="submit" name="tagusertopic" value="', $txt['smftags_act_go'], '">
									<input type="reset" value="', $txt['smftags_act_reset'], '">
								</td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
			</table>
			<br /> ';
        }
    }
    echo '
			<br />
			<table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor">
				<tr>
					<td align="center" class="catbg">', $txt['smftags_latest'], '</td>
				</tr>
				<tr>
					<td align="center" class="windowbg2">
						<table border="0" width="100%" align="center" cellspacing="1" cellpadding="4" class="bordercolor">
							<tr>
								<td class="catbg3">', $txt['smftags_subject'], '</td>
								<td class="catbg3" width="11%">', $txt['smftags_startedby'], '</td>
								<td class="catbg3" width="4%" align="center">', $txt['smftags_replies'], '</td>
								<td class="catbg3" width="4%" align="center">', $txt['smftags_views'], '</td>
							</tr>';
    if (!isset($context['tags_topics'])) {
        $context['tags_topics'] = array();
    }
    foreach ($context['tags_topics'] as $i => $topic) {
        echo '
							<tr>
								<td class="windowbg2"><a href="' . $scripturl . '?topic=' . $topic['ID_TOPIC'] . '.0">' . $topic['subject'] . '</a></td>
								<td class="windowbg"><a href="' . $scripturl . '?action=profile;u=' . $topic['ID_MEMBER'] . '">' . $topic['posterName'] . '</a></td>
								<td class="windowbg2">' . $topic['numReplies'] . '</td>
								<td class="windowbg2">' . $topic['numViews'] . '</td>
							</tr>';
    }
    echo '
						</table>
					</td>
				</tr>
			</table>
			<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>';
}