[COMMENT] /* +-------------------------------------------------------------------------- | Invision Board v1.3 | ======================================== | > mod_collapse function library | > Module written by Peter(Pit) | > Peter member at ibforen.de, Pit member at invisionize.com | > email: Peter@ibforen.de | +-------------------------------------------------------------------------- | > mod_collapse Module Version Number: 1.1.3 (2006-08-08) | > 2005 - 2006 by Peter +-------------------------------------------------------------------------- */ [COMMENT_END] [INTERFACE] 'title' => 'Collapse Categories', 'sub_title' => 'Réduire/agrandir les catégories', 'category' => 'Minor Mod', 'compatible' => 'Invision Power Board 1.3', 'version' => '1.2.0', 'author' => 'Peter', 'email' => 'Peter@ibforen.de', 'mod_token' => 'mod_collapse', [INTERFACE_END] [HISTORY] [b]1.2.0[/b] [list][*]Bugfix for cookie problem with sub domains Complete installation process is necessary. Replace all mod files (html/mod_collapse.js, skin file etc.). [/list] [b]1.1.4[/b] [list][*]Bugfix for cookie problem under Mozilla/Firefox Complete installation process is necessary. Replace all mod files. [/list] [b]1.1.3[/b] [list][*]Bugfix for subcats (Step 2, Part C) [/list] [b]1.1.2[/b] [list][*]No sql queries if statistics area is hidden [/list] [b]1.1[/b] [list][*]Statistics section is collapsable [*]Collapse a category is not any longer reloading the entire page but uses the visibility attribut [/list] [b]1.0[/b] [list][*]Enables collapsing of categories and subforums [*]Settings are stored in cookies [*]Collapsed categories are not loaded to save bandwidth [/list] [HISTORY_END] [SQL] [SQL_END] [CODE] [MOD_TOKEN] mod_collapse [FNAME] sources/Boards.php [STEP] [SEARCH] $stats_html = ""; [INSERT] //-- mod_collapse begin if ($std->my_getcookie("fstats_block") == "none" && !isset($ibforums->input['collapse_stats_s'])) { $stats_html = 1; } else { //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] if ($stats_html != "") { [INSERT] //-- mod_collapse begin } //-- mod_collapse end [MODE] insert_above [STEP] [SEARCH] if ($stats_html != "") { [INSERT] //-- mod_collapse begin global $HTTP_COOKIE_VARS; if (!$this->use_skin && file_exists(ROOT_PATH."Skin/{$ibforums->skin_id}/mod_collapse_skin.php")) { $this->collapse_html = $std->load_template('mod_collapse_skin'); $this->use_skin = true; } if (isset($ibforums->input['collapse_stats_s'])) { $std->my_setcookie("fstats_block", "", 1); $_COOKIE[$ibforums->vars['cookie_id'].'fstats_block'] = "block"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id'].'fstats_block'] = "block"; } if (isset($ibforums->input['collapse_stats_h'])) { $std->my_setcookie("fstats_block", "none", 1); $_COOKIE[$ibforums->vars['cookie_id'].'fstats_block'] = "none"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id'].'fstats_block'] = "none"; } $url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext']."?".$_SERVER['QUERY_STRING']; $url = preg_replace("`\&collapse_stats_.=\d*`", "", $url); if (($std->my_getcookie("fstats_block") == "none" || isset($ibforums->input['collapse_stats_h'])) && !isset($ibforums->input['collapse_stats_s'])) { $url .= "&collapse_stats_s=1"; if ($this->use_skin) { $this->output .= $this->collapse_html->stats_header_hide($url); $this->output .= $this->collapse_html->stats_footer(); } else { $html = $this->html->stats_header(); $col = "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n
{$ibforums->lang['board_stats']}
\n"; $html = str_replace($ibforums->lang['board_stats'], $col, $html); $html = preg_replace("`(^.*)(\\2", $html); $this->output .= $html; $this->output .= preg_replace("`(^.*?)`is", "\\1\n", $this->html->stats_footer()); } } else if (TRUE) { $url .= "&collapse_stats_h=1"; if ($this->use_skin) { $this->output .= $this->collapse_html->stats_header_show($url); $this->output .= $stats_html; $this->output .= $this->collapse_html->stats_footer(); } else { $html = $this->html->stats_header(); $col = "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n"; $col .= "\n
{$ibforums->lang['board_stats']}
\n"; $html = str_replace($ibforums->lang['board_stats'], $col, $html); $html = preg_replace("`(^.*)(\\2", $html); $this->output .= $html; $this->output .= $stats_html; $this->output .= preg_replace("`(^.*?)`is", "\\1", $this->html->stats_footer()); } } else { //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] $this->output .= $this->html->stats_footer(); [INSERT] //-- mod_collapse begin } //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] function process_all_cats() { global $std, $DB, $ibforums; [INSERT] //-- mod_collapse begin global $HTTP_COOKIE_VARS; if (file_exists(ROOT_PATH."Skin/{$ibforums->skin_id}/mod_collapse_skin.php")) { $this->collapse_html = $std->load_template('mod_collapse_skin'); $this->use_skin = true; } if (isset($ibforums->input['collapse_s'])) { $std->my_setcookie("fc".$ibforums->input['collapse_s']."_block", "", 1); $_COOKIE[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_s']."_block"] = "block"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_s']."_block"] = "block"; } if (isset($ibforums->input['collapse_h'])) { $std->my_setcookie("fc".$ibforums->input['collapse_h']."_block", "none", 1); $_COOKIE[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_h']."_block"] = "none"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_h']."_block"] = "none"; } $url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext']."?".$_SERVER['QUERY_STRING']; $url = preg_replace("`\&collapse_.=\d*`", "", $url); $url = preg_replace("`\#col\d*$`", "", $url); //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] if ( $cat_data['state'] != 1 ) { continue; } [INSERT] //-- mod_collapse begin $hide_this_cat = $std->my_getcookie("fc{$cat_id}_block") == "none" && $ibforums->input['collapse_s'] != $cat_id; $this->output .= ""; $cat_data['collapse_url'] = $url."&collapse_s=".$cat_id."#col".$cat_id; if ($hide_this_cat) { if ($this->use_skin) { $this->output .= $this->collapse_html->CatHeader_Expanded_Hide($cat_data); } else { $html = $this->html->CatHeader_Expanded($cat_data); $html = preg_replace("`(.*"; $col_1 = "\n"; $col_1 .= "\n"; $col_1 .= "\n\n"; $col_2 .= "\n"; $col_2 .= "\n
"; $col_2 = "$pic
\n"; $match = "`(<\{CAT_IMG\}>.*?{$cat_data['name']}.*?<\/a>)`is"; if (!preg_match($match, $html)) $match = "`({$cat_data['name']}.*?<\/a>)`is"; $html = preg_replace($match, "$col_1\\1$col_2", $html); $this->output .= $html; } $this->output .= $this->html->end_this_cat(); } else { //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] if ($temp_html != "") { [INSERT] //-- mod_collapse begin $cat_data['collapse_url'] = $url."&collapse_h=".$cat_id."#col".$cat_id; if ($this->use_skin) { $this->output .= $this->collapse_html->CatHeader_Expanded_Show($cat_data); } else if (TRUE) { $html = $this->html->CatHeader_Expanded($cat_data); $html = preg_replace("`(.*"; $col_1 = "\n"; $col_1 .= "\n"; $col_1 .= "\n\n"; $col_2 .= "\n"; $col_2 .= "\n
"; $col_2 = "$pic
\n"; $match = "`(<\{CAT_IMG\}>.*?{$cat_data['name']}.*?<\/a>)`is"; if (!preg_match($match, $html)) $match = "`({$cat_data['name']}.*?<\/a>)`is"; $html = preg_replace($match, "$col_1\\1$col_2", $html); $this->output .= $html; } else //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] unset($temp_html); } $this->output .= $this->html->end_all_cats(); [INSERT] //-- mod_collapse begin } //-- mod_collapse end [MODE] insert_above [FNAME_END] [MOD_TOKEN] mod_collapse [FNAME] sources/Forums.php [STEP] [SEARCH] $fid = $ibforums->input['f']; [INSERT] //-- mod_collapse begin global $HTTP_COOKIE_VARS; if (file_exists(ROOT_PATH."Skin/{$ibforums->skin_id}/mod_collapse_skin.php")) { $this->collapse_html = $std->load_template('mod_collapse_skin'); $this->use_skin = true; } if (isset($ibforums->input['collapse_s'])) { $std->my_setcookie("fc".$ibforums->input['collapse_s']."_block", "", 1); $_COOKIE[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_s']."_block"] = "block"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_s']."_block"] = "block"; } if (isset($ibforums->input['collapse_h'])) { $std->my_setcookie("fc".$ibforums->input['collapse_h']."_block", "none", 1); $_COOKIE[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_h']."_block"] = "none"; $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id']."fc".$ibforums->input['collapse_h']."_block"] = "none"; } $url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext']."?".$_SERVER['QUERY_STRING']; $url = preg_replace("`\&collapse_.=f\d*`", "", $url); $hide_this_cat = $std->my_getcookie("fcf{$fid}_block") == "none" && $ibforums->input['collapse_s'] != "f".$fid; $this->sub_output .= ""; $cat_data['collapse_url'] = $url."&collapse_s=f".$fid."#col".$fid; $cat_data['id'] = "f".$fid; if ($hide_this_cat) { if ($this->use_skin) { $cat_data['collapse_name'] = $ibforums->lang['forums']; $this->sub_output .= $this->collapse_html->CatHeader_Expanded_Hide($cat_data); } else { $html = $this->board_html->CatHeader_Expanded($cat_data); $html = preg_replace("`(.*"; $col_1 = "\n"; $col_1 .= "\n"; $col_1 .= "\n\n"; $col_2 .= "\n"; $col_2 .= "\n
"; $col_2 = "$pic
\n"; $match = "`(<\{CAT_IMG\}>.*?{$cat_data['name']}.*?<\/a>)`is"; if (!preg_match($match, $html)) $match = "`({$cat_data['name']}.*?<\/a>)`is"; $html = preg_replace($match, "$col_1\\1{$ibforums->lang['forums']}$col_2", $html); if (preg_match("`(.*?\s*\s*`is", $html)) { $html = preg_replace("`(.*?\s*\s*`is", "\\1", $html); } else { $html = preg_replace("`(.*)`is", "\\1", $html); } $this->sub_output .= $html; } $this->sub_output .= $this->board_html->end_this_cat(); } else { //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] if ($temp_html != "") { [INSERT] /*-- mod_collapse exclude begin [MODE] insert_below [STEP] [SEARCH] $this->sub_output .= $this->board_html->subheader(); [INSERT] -- mod_collapse exclude end */ //-- mod_collapse begin $this->sub_output .= ""; $cat_data['collapse_url'] = $url."&collapse_h=f".$fid."#col".$fid; if ($this->use_skin) { $cat_data['collapse_name'] = $ibforums->lang['forums']; $this->sub_output .= $this->collapse_html->CatHeader_Expanded_Show($cat_data); } else { $html = $this->board_html->CatHeader_Expanded($cat_data); $html = preg_replace("`(.*"; $col_1 = "\n"; $col_1 .= "\n"; $col_1 .= "\n\n"; $col_2 .= "\n"; $col_2 .= "\n
"; $col_2 = "{$ibforums->lang['forums']}$pic
\n"; $match = "`(<\{CAT_IMG\}>.*?{$cat_data['name']}.*?<\/a>)`is"; if (!preg_match($match, $html)) $match = "`({$cat_data['name']}.*?<\/a>)`is"; $html = preg_replace($match, "$col_1\\1$col_2", $html); $this->sub_output .= $html; } //-- mod_collapse end [MODE] insert_below [STEP] [SEARCH] unset($temp_html); $this->sub_output .= $this->board_html->end_all_cats(); [INSERT] //-- mod_collapse begin } //-- mod_collapse end [MODE] insert_above [FNAME_END] [MOD_TOKEN] mod_collapse [FNAME] sources/functions.php [STEP] [SEARCH] $ibforums->member['skin'] = $row['sid']; } [INSERT] //-- mod_collapse begin $col_js = "\n\n"; $col_js .= "\n\n"; $row['template'] = str_replace( "<% JAVASCRIPT %>", "<% JAVASCRIPT %>".$col_js, $row['template']); //-- mod_collapse end [MODE] insert_below [FNAME_END] [CODE_END] [COPY] L'archive de la mod est préstructurée. Merci de copier le répertoire [b]upload[/b] de l'archive décompressée entièrement dans le répertoire racine de votre forum. [LIST][*]Si le répertoire lang de cette archive contient plus que la langue francaise dans lang/fr, you devrez copier les autres fichiers langues dans leurs répertoires respectifs. Exemple: Le fichier langue allemend se trouve dans lang/de. Si votre répertoires allemand se trouve dans lang/2, vous devez copier lang/de vers lang/2 [/LIST] [COPY_END] [CUSTOMIZE] [size=4]Cookies[/size] This modifikation is based upon the use of cookies. If cookies are not allowed or if cookies are refused, then this modifikation will have no effect. The use of cookies can be recognized by viewing the url in the browser's address field: [quote] If you can identify a session_id [b]s=...[/b], then cookies are refused. [/quote] [size=4]Customize the skin[/size] I have added a skin file Addons/Skin/s1/mod_collapse_skin.php. There you will find a replacement of original [b]function CatHeader_Expanded(...)[/b]. The new function adds the little image to the header of each category, so we can collapse the category by clicking on it. You can modify this file and copy it into the skin folder ./Skin/sx. Do not forget to run a Resynchronize via ACP. By default the little image is positioned left of the category name and the functions are reversed: A click on the image opens the category, a click on the name toggles between Show and Hide. [CUSTOMIZE_END] [COMMENT_MOD] [COMMENT_MOD_END] [HISTORY_OLD] [HISTORY_OLD_END]