Collapse Categories  1.2.0  Invision Power Board 1.3
Mod Beschreibung Zeigt oder verbirgt Kategorien
Mod Kompatibilität Invision Power Board 1.3
Mod Kategorie Minor Mod
Mod Autor Peter
Mod Emailadresse des Autors Peter@ibforen.de
Dokumentationspfad sources/mods/collapse/mod_collapse_howto.htm
Mod Version 1.2.0
Hinweis Weitergabe ohne Zustimmung ist untersagt. Download von ibforen.de
Alle Änderungen sind am mod_token zu erkennen

Dieses html-howto wurde erstellt mit The ModInstaller 1.3.2 von
Peter@ibforen.de, released on 29th January, 2007
Erstellungsdatum: 2009-03-20

Es darf ohne ausdrückliche Genehmigung nicht weiterverwendet werden.

Hinweis
  • Dieser Mod ist keine Freeware.
  • Eine Weitergabe dieser Anleitung oder einer der Mod-Dateien ist untersagt. Die Distribution des Mods und seiner Dateien ist nur mit meiner ausdrücklichen Genehmigung gestattet.
  • Die Anpassung des Mods an die Skins des eigenen Boards ist ausdrücklich gewünscht. Dabei darf jedoch nicht mein Copyright verletzt werden und abgewandelte Codeteile weitervertrieben werden.
  • Eine Verletzung dieser Regelung führt letztendlich dazu, dass ich künftig keine frei verfügbaren Modifikationen mehr produziere. In diesem Sinne bitte ich darum, die schöpferische Leistung aller Programmierer zu respektieren und die Urheberschaften zu beachten.
Mod Token mod_collapse

 Inhalt

1 History und Change Logs
2 Veränderungen
3 Kopieren
4 Kodieren
5 Anpassen
6 Kommentar
7 Ältere History und Change Logs

 1.  History und Change Logs

1.2.0


1.1.4


1.1.3


1.1.2


1.1.2


1.1


1.0


 2.  Veränderungen
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.  Kopieren

Kopiere alle Dateien im Ordner upload des Archivs in das Root-Verzeichnis deines Boards und behalte dabei die Struktur bei.


 4.  Kodieren


Schritt  1:  Öffne sources/Boards.php

  A. Suche in function Boards(..)

        $stats_html = "";

     Füge darunter ein den blauen Code

        $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. Suche in function Boards(..)

        if ($stats_html != "")
        {

     Füge darüber ein den blauen Code



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


        if ($stats_html != "")
        {

  C. Suche in function Boards(..)

        if ($stats_html != "")
        {

     Füge darunter ein den blauen Code

        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. Suche in function Boards(..)

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

     Füge darunter ein den blauen Code

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



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


  E. Suche in function process_all_cats(..)

    function process_all_cats() {

        global $std, $DB, $ibforums;

     Füge darunter ein den blauen Code

    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. Suche in function process_all_cats(..)

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

     Füge darunter ein den blauen Code

            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. Suche in function process_all_cats(..)

            if ($temp_html != "")
            {

     Füge darunter ein den blauen Code

            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. Suche in function process_all_cats(..)

            unset($temp_html);
        }

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

     Füge darüber ein den blauen Code



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


            unset($temp_html);
        }

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


Schritt  2:  Öffne sources/Forums.php

  A. Suche in function show_subforums(..)

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

     Füge darunter ein den blauen Code

        $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. Suche in function show_subforums(..)

        if ($temp_html != "")
        {

     Füge darunter ein den blauen Code

        if ($temp_html != "")
        {



/*-- mod_collapse exclude begin


  C. Suche in function show_subforums(..)

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

     Füge darunter ein den blauen Code

            $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. Suche in function show_subforums(..)

        unset($temp_html);

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

     Füge darüber ein den blauen Code



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


        unset($temp_html);

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


Schritt  3:  Öffne sources/functions.php

  Suche in function load_skin(..)

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

     Füge darunter ein den blauen Code

            $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.  Anpassen

Cookies

Die Modifikation basiert auf den Gebrauch von Cookies. Falls Cookies vom Browser abgewiesen werden, kann die Modifikation nicht funktionieren.

Ob Cookies zugelassen und akzeptiert werden, kann man an der Url im Adressfeld des Browsers erkennen:
Zitat


Falls dort die session_id s=... angehängt ist, so werden Cookies abgewiesen.


Anpassen des Skins

Im Ordner Addons/Skin/s1 befindet sich die Datei mod_collapse_skin.php. Hier ist ein Ersatz der Originalfunction CatHeader_Expanded(...). Die neue Funktion fügt eine kleine Grafik zum Header jeder Kategorie hinzu, so dass die Kategorie durch Anklicken verborgen werden kann.

Diese Datei kann angepasst und in den Skinordner ./Skin/sx kopiert werden . Nicht vergessen, ein Resynchronize via ACP durchzuführen.

 6.  Kommentar



 7.  Ältere History und Change Logs