function sp_compile_forums($forums, $parent = 0, $level = 0, $valueURL = false) { $out = ''; $indent = ' → '; foreach ($forums as $forum) { if ($forum->parent == $parent && $forum->forum_id != $parent) { if ($valueURL) { $out .= '<option value="' . $forum->forum_permalink . '">'; } else { $out .= '<option value="' . $forum->forum_id . '">'; } $out .= str_repeat($indent, $level) . sp_create_name_extract($forum->forum_name) . "</option>\n"; if (!empty($forum->children)) { $out .= sp_compile_forums($forums, $forum->forum_id, $level + 1, $valueURL); } } } return $out; }
function sp_QuickLinksTopicMobile($args = '', $label = '') { global $spThisUser; $defs = array('tagIdControl' => 'spQuickLinksTopicMobile', 'tagClass' => 'spControl', 'tagIdList' => 'spQuickLinksMobileList', 'listClass' => 'spQuickLinksList', 'listDataClass' => 'spQuickLinksGroup', 'openIcon' => 'sp_GroupOpen.png', 'closeIcon' => 'sp_GroupClose.png', 'length' => 40, 'show' => 20, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_QuickLinksTopicMobile_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagIdControl = esc_attr($tagIdControl); $tagClass = esc_attr($tagClass); $tagIdList = esc_attr($tagIdList); $listClass = esc_attr($listClass); $listDataClass = esc_attr($listDataClass); $openIcon = sp_find_icon(SPTHEMEICONSURL, sanitize_file_name($openIcon)); $closeIcon = sp_find_icon(SPTHEMEICONSURL, sanitize_file_name($closeIcon)); $length = (int) $length; $show = (int) $show; $echo = (int) $echo; $out = ''; if (!empty($spThisUser->newposts['topics'])) { $spList = new spTopicList(array_slice($spThisUser->newposts['topics'], 0, $show, true), $show, true); } else { $spList = new spTopicList('', $show, true); } if (!empty($spList->listData)) { $out .= "<div class='{$tagClass}' id='{$tagIdControl}'>\n"; $out .= "<p id='spQLTitle' onclick='spjOpenQL(\"{$tagIdList}\", \"spQLOpener\", \"{$openIcon}\", \"{$closeIcon}\");'>{$label}<span id='spQLOpener'><img src='{$openIcon}' /></span></p>\n"; $out .= "</div>"; $out .= sp_InsertBreak('echo=false'); $out .= "<div id='{$tagIdList}' class='{$listClass}' style='display:none'>\n"; $thisForum = 0; $group = false; foreach ($spList->listData as $spPost) { if ($spPost->forum_id != $thisForum) { if ($group) { $out .= '</div>'; } $out .= "<div class='{$listDataClass}'><p>" . sp_create_name_extract($spPost->forum_name, $length) . "</p>\n"; $thisForum = $spPost->forum_id; $group = true; } $class = 'spPostRead'; $image = "<img src='" . sp_find_icon(SPTHEMEICONSURL, "sp_QLBalloonNone.png") . "' alt='' />"; if ($spPost->post_status != 0) { $class = 'spPostMod'; $image = "<img src='" . sp_find_icon(SPTHEMEICONSURL, "sp_QLBalloonRed.png") . "' alt='' />"; } elseif (sp_is_in_users_newposts($spPost->topic_id)) { $class = 'spPostNew'; $image = "<img src='" . sp_find_icon(SPTHEMEICONSURL, "sp_QLBalloonBlue.png") . "' alt='' />"; } $out .= "<p><a class='{$class}' href='{$spPost->post_permalink}'>{$image} " . sp_create_name_extract($spPost->topic_name, $length) . "</a></p>\n"; } $out .= "</div></div>\n"; } $out = apply_filters('sph_QuickLinksTopicMobile', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_ForumDropdownTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spForumDropdownTag', 'tagClass' => 'spLinkTag', 'selectClass' => 'spSelectTag', 'forumList' => 0, 'label' => __("Select forum", 'sp-ttags'), 'length' => 30, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumDropdownTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $selectClass = esc_attr($selectClass); $forumList = esc_attr($forumList); $label = sp_filter_title_display($label); $length = (int) $length; $echo = (int) $echo; global $spThisUser; sp_forum_api_support(); $forum_ids = array(); if ($forumList == 0) { $forum_ids = sp_get_forum_memberships($spThisUser->ID); } else { $allforums = explode(',', $forumList); foreach ($allforums as $thisforum) { if (sp_can_view($thisforum, 'forum-title')) { $forum_ids[] = $thisforum; } } } if (empty($forum_ids)) { return; } # create where clause based on forums that current user can view $where = "forum_id IN (" . implode(",", $forum_ids) . ")"; $spdb = new spdbComplex(); $spdb->table = SFFORUMS; $spdb->fields = 'forum_slug, forum_name'; $spdb->join = array(SFGROUPS . ' ON ' . SFFORUMS . '.group_id = ' . SFGROUPS . '.group_id'); $spdb->where = $where; $spdb->orderby = 'group_seq, forum_seq'; $forums = $spdb->select(); $out = "<div id='{$tagId}' class='{$tagClass}'>"; $out .= '<select name="forumselect" class="' . $selectClass . '" onChange="javascript:spjChangeForumURL(this)">' . "\n"; $out .= '<option>' . $label . '</option>' . "\n"; foreach ($forums as $forum) { $out .= '<option value="' . sp_build_url($forum->forum_slug, '', 0, 0) . '"> ' . sp_create_name_extract(sp_filter_title_display($forum->forum_name), $length) . '</option>' . "\n"; } $out .= '</select>' . "\n"; $out .= '</div>'; $out .= '<script type="text/javascript">'; $out .= 'function spjChangeForumURL(menuObj) {'; $out .= 'var i = menuObj.selectedIndex;'; $out .= 'if(i > 0) {'; $out .= 'if(menuObj.options[i].value != "#") {'; $out .= 'window.location = menuObj.options[i].value;'; $out .= '}}}'; $out .= '</script>'; $out = apply_filters('sph_ForumDropdownTag', $out); if ($echo) { echo $out; } else { return $out; } }