Collapse Categories  1.2.0  Invision Power Board 1.3
Description de la Mod Réduire/agrandir les catégories
Compatibilité de la Mod Invision Power Board 1.3
Catégorie de la Mod Minor Mod
Auteur de la Mod Peter
Adresse e-mail de l'auteur de la mod Peter@ibforen.de
Info Fichier sources/mods/collapse/mod_collapse_howto.htm
Version de la Mod 1.2.0
Commentaires Distribution interdite. Téléchargement autorisé depuis ibforen.de.
Tous les changements peuvent être reconnus avec le mod_token

Cette page html-howto a été créée par The ModInstaller 1.3.2 de
Peter@ibforen.de, sorti le 2007-01-08
Date de création 2009-03-20

Ce n'est pas pour un usage public.

Attention
  • Cette Mod n'est pas libre.
  • La redistribution de ce howto ou d'un des fichiers de la mod est interdite. La redistribution de la mod ou de ses fichiers seulement est soumise à mon autorisation.
  • La personnalisation de la Mod, afin d'adapter le skin de votr forum, est la bienvenue. Partager vos expériences avec la communauté également. Mais n'enfreignez pas mon copyright en distribuant des portions de code dérivées de cette mod.
  • La violation de ces règles m'ammèneraient à stopper toute production de modifications ou programmes libres. SVP, respectez le travail créatif des codeurs et le salut de leurs copyrights.
Mod Token mod_collapse

 Contenu

1 Nouveautés et changements
2 Fichier(s) modifié(s) par la mod
3 Copie
4 Code
5 Personnalisation
6 Commentaires
7 Historiques des changements

 1.  Nouveautés et changements

1.2.0


1.1.4


1.1.3


1.1.2


1.1


1.0


 2.  Fichier(s) modifié(s) par la mod
Changed file Changed function
sources/Boards.php Boards(..)
sources/Boards.php process_all_cats(..)
sources/Forums.php show_subforums(..)
sources/functions.php load_skin(..)

 3.  Copie

L'archive de la mod est préstructurée. Merci de copier le répertoire upload de l'archive décompressée entièrement dans le répertoire racine de votre forum.



 4.  Code


Étape  1:  Ouvrir sources/Boards.php

  A. Trouver dans function Boards(..)

        $stats_html = "";

     Ajouter en-dessous le code en bleu

        $stats_html = "";



//-- mod_collapse begin
        if ($std->my_getcookie("fstats_block") == "none" && !isset($ibforums->input['collapse_stats_s'])) {
            $stats_html = 1;
        }
        else {
//-- mod_collapse end


  B. Trouver dans function Boards(..)

        if ($stats_html != "")
        {

     Ajouter au-dessus le code en bleu



//-- mod_collapse begin
        }
//-- mod_collapse end


        if ($stats_html != "")
        {

  C. Trouver dans function Boards(..)

        if ($stats_html != "")
        {

     Ajouter en-dessous le code en bleu

        if ($stats_html != "")
        {



//-- 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<table width='100%'>";
                    $col .= "\n<tr>";
                    $col .= "\n<td align='left'>{$ibforums->lang['board_stats']}</td>";
                    $col .= "\n<td align='right'><a href='$url' onclick=\"show('fstats');return true;\"><img src='{$ibforums->vars['img_url']}/plus.gif' border='0' /></a></td>";
                    $col .= "\n</tr>";
                    $col .= "\n</table>\n";
                    $html = str_replace($ibforums->lang['board_stats'], $col, $html);
                    $html = preg_replace("`(^.*)(<table.*$)`is", "\\1<div id='fstats_block' style='display:block;'>\\2", $html);
                    $this->output .= $html;
                    $this->output .= preg_replace("`(^.*?</table>)`is", "\\1\n</div>", $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<table width='100%'>";
                    $col .= "\n<tr>";
                    $col .= "\n<td align='left'>{$ibforums->lang['board_stats']}</td>";
                    $col .= "\n<td align='right'><a href='javascript:show('fstats');' ><img src='{$ibforums->vars['img_url']}/minus.gif' style='vertical-align:middle;border:0px;' id='fstats_collapse' /></a></td>";
                    $col .= "\n</tr>";
                    $col .= "\n</table>\n";
                    $html = str_replace($ibforums->lang['board_stats'], $col, $html);
                    $html = preg_replace("`(^.*)(<table.*$)`is", "\\1<div id='fstats_block' style='display:block;'>\\2", $html);
                    $this->output .= $html;
                    $this->output .= $stats_html;
                    $this->output .= preg_replace("`(^.*?</table>)`is", "\\1</div>", $this->html->stats_footer());
                }
            }
            else {
//-- mod_collapse end


  D. Trouver dans function Boards(..)

            $this->output .= $this->html->stats_footer();

     Ajouter en-dessous le code en bleu

            $this->output .= $this->html->stats_footer();



//-- mod_collapse begin
            }
//-- mod_collapse end


  E. Trouver dans function process_all_cats(..)

    function process_all_cats() {

        global $std, $DB, $ibforums;

     Ajouter en-dessous le code en bleu

    function process_all_cats() {

        global $std, $DB, $ibforums;



//-- 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


  F. Trouver dans function process_all_cats(..)

            if ( $cat_data['state'] != 1 )
            {
                continue;
            }

     Ajouter en-dessous le code en bleu

            if ( $cat_data['state'] != 1 )
            {
                continue;
            }



//-- mod_collapse begin
            $hide_this_cat = $std->my_getcookie("fc{$cat_id}_block") == "none" && $ibforums->input['collapse_s'] != $cat_id;
            $this->output .= "<a href='' name='col".$cat_id."'></a>";
            $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("`(.*<table)`is", "\\1 id=\"fc{$cat_id}_block\" style=\"display:none;\"", $html);
                    $pic = "<a href=\"{$cat_data['collapse_url']}\" onclick=\"show('fc{$cat_id}');return true;\"><img style='border:0px;vertical-align:middle;text-align:right;cursor:pointer; cursor:hand;' src='{$ibforums->vars['img_url']}/plus.gif' /></a>";
                    $col_1  = "\n<table width='100%'>";
                    $col_1 .= "\n<tr>";
                    $col_1 .= "\n<td align='left'>";
                    $col_2  = "</td>\n<td align='right'>$pic</td>";
                    $col_2 .= "\n</tr>";
                    $col_2 .= "\n</table>\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


  G. Trouver dans function process_all_cats(..)

            if ($temp_html != "")
            {

     Ajouter en-dessous le code en bleu

            if ($temp_html != "")
            {



//-- 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("`(.*<table)`is", "\\1 id=\"fc{$cat_id}_block\" style=\"display:block;\"", $html);
                        $pic = "<a href=\"javascript:show('fc{$cat_id}')\" ><img style='border:0px;vertical-align:middle;text-align:right;cursor:pointer; cursor:hand;' src='{$ibforums->vars['img_url']}/minus.gif' id='fc{$cat_id}_collapse' /></a>";
                        $col_1  = "\n<table width='100%'>";
                        $col_1 .= "\n<tr>";
                        $col_1 .= "\n<td align='left'>";
                        $col_2  = "</td>\n<td align='right'>$pic</td>";
                        $col_2 .= "\n</tr>";
                        $col_2 .= "\n</table>\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


  H. Trouver dans function process_all_cats(..)

            unset($temp_html);
        }

        $this->output .= $this->html->end_all_cats();

     Ajouter au-dessus le code en bleu



//-- mod_collapse begin
            }
//-- mod_collapse end


            unset($temp_html);
        }

        $this->output .= $this->html->end_all_cats();


Étape  2:  Ouvrir sources/Forums.php

  A. Trouver dans function show_subforums(..)

        $fid = $ibforums->input['f'];

     Ajouter en-dessous le code en bleu

        $fid = $ibforums->input['f'];



//-- 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 .= "<a href='' name='col".$fid."'></a>";
        $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("`(.*<table)`is", "\\1 id=\"fc{$cat_id}_block\" style=\"display:none;\"", $html);
                $pic = "<a href=\"javascript:show('fcf{$fid}')\" ><img style='border:0px;vertical-align:middle;text-align:right;cursor:pointer; cursor:hand;' src='{$ibforums->vars['img_url']}/plus.gif' /></a>";
                $col_1  = "\n<table width='100%'>";
                $col_1 .= "\n<tr>";
                $col_1 .= "\n<td align='left'>";
                $col_2  = "</td>\n<td align='right'>$pic</td>";
                $col_2 .= "\n</tr>";
                $col_2 .= "\n</table>\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("`(.*?<table.*)<table.*?>\s*<tr.*/tr>\s*</table>`is", $html)) {
                    $html = preg_replace("`(.*?<table.*)<table.*?>\s*<tr.*/tr>\s*</table>`is", "\\1", $html);
                }
                else {
                    $html = preg_replace("`(.*)<tr.*?/tr>`is", "\\1", $html);
                }
                $this->sub_output .= $html;
            }
            $this->sub_output .= $this->board_html->end_this_cat();
        }
        else {
//-- mod_collapse end


  B. Trouver dans function show_subforums(..)

        if ($temp_html != "")
        {

     Ajouter en-dessous le code en bleu

        if ($temp_html != "")
        {



/*-- mod_collapse exclude begin


  C. Trouver dans function show_subforums(..)

            $this->sub_output .= $this->board_html->subheader();

     Ajouter en-dessous le code en bleu

            $this->sub_output .= $this->board_html->subheader();



-- mod_collapse exclude end */

//-- mod_collapse begin
            $this->sub_output .= "<a href='' name='col".$fid."'></a>";
            $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("`(.*<table)`is", "\\1 id=\"fcf{$fid}_block\" style=\"display:block;\"", $html);
                $pic = "<a href=\"javascript:show('fcf{$fid}')\" ><img style='border:0px;vertical-align:middle;text-align:right;cursor:pointer; cursor:hand;' src='{$ibforums->vars['img_url']}/minus.gif' id='fcf{$fid}_collapse' /></a>";
                $col_1  = "\n<table width='100%'>";
                $col_1 .= "\n<tr>";
                $col_1 .= "\n<td align='left'>";
                $col_2  = "{$ibforums->lang['forums']}</td>\n<td align='right'>$pic</td>";
                $col_2 .= "\n</tr>";
                $col_2 .= "\n</table>\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


  D. Trouver dans function show_subforums(..)

        unset($temp_html);

        $this->sub_output .= $this->board_html->end_all_cats();

     Ajouter au-dessus le code en bleu



//-- mod_collapse begin
        }
//-- mod_collapse end


        unset($temp_html);

        $this->sub_output .= $this->board_html->end_all_cats();


Étape  3:  Ouvrir sources/functions.php

  Trouver dans function load_skin(..)

            $ibforums->member['skin'] = $row['sid'];
        }

     Ajouter en-dessous le code en bleu

            $ibforums->member['skin'] = $row['sid'];
        }



//-- mod_collapse begin
        $col_js  = "\n<script type='text/javascript' language='javascript'>\n";
        $col_js .= "var __COOKIE_DOMAIN__ = '{$ibforums->vars['cookie_domain']}';\n";
        $col_js .= "var __COOKIE_PATH__ = '{$ibforums->vars['cookie_path']}';\n";
        $col_js .= "var __COOKIE_PREFIX__ = '{$ibforums->vars['cookie_id']}';\n";
        $col_js .= "\n</script>\n";
        $col_js .= "\n<script type='text/javascript' language='javascript' src='html/mod_collapse.js'></script>\n";
        $row['template'] = str_replace( "<% JAVASCRIPT %>", "<% JAVASCRIPT %>".$col_js, $row['template']);
//-- mod_collapse end


 5.  Personnalisation

Cookies

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:
Zitat


If you can identify a session_id s=..., then cookies are refused.


Customize the skin

I have added a skin file Addons/Skin/s1/mod_collapse_skin.php. There you will find a replacement of original function CatHeader_Expanded(...). 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.

 6.  Commentaires



 7.  Historiques des changements