============================================================================================================================
Modification Name: Category Theme Preview

Version: 1.0

Modification Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Based on: Theme Preview by FunForum.
                Category Theme Preview by Adam Clarke

Description:
This modification will give your members the option to 'preview' Themes and set them as their theme by clicking a link.
After you uploaded some screenshots the themes will be displayed in their own table using the colors of that theme.
This modification also allows you to organize your themes within categories and view them by category or all at once.
Do Not Use This Modificatioin If You Have The Regular Theme Preview Modification Installed!

Supported Version: XMB 1.9.5 SP1

Notes: This modification is released under the GPL v3. A copy is provided with this software package.

Please backup your files before installing this modification.
Neither XMBGarage nor the author can be held responsible if your board stops functioning properly due to you installing this modification.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================
===================================
Paste The Following Code And Submit Changes:
===================================

ALTER TABLE $table_settings ADD themepreviewext SET('jpg','gif','png','bmp') NOT NULL default 'jpg';
ALTER TABLE $table_settings ADD themepreviewguests VARCHAR(3) NOT NULL default 'on';
ALTER TABLE $table_settings ADD themespp INT(3) NOT NULL default '20';
ALTER TABLE $table_settings ADD themecats TEXT NOT NULL;
ALTER TABLE $table_themes ADD category INT(3) NOT NULL default '1';

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
========================
Add To End Of File Above ?>
========================

// Category Theme Preview Mod Begin
$lang['themepreview1'] = 'Theme Preview';
$lang['themepreview2'] = 'Theme IDs';
$lang['themepreview3'] = 'Theme Preview Extention:';
$lang['themepreview4'] = 'Guests view Theme Preview:';
$lang['themepreview5'] = 'Set the number of themes per page';
$lang['themepreview6'] = 'Set this as my theme';
$lang['themepreview7'] = 'Viewing Themes';
$lang['themepreview8'] = 'Default Theme:';
$lang['themepreview9'] = 'This page shows the proper names for your thumbnail images:';
$lang['themepreview10'] = 'Theme Name';
$lang['themepreview11'] = 'Theme ID';
$lang['themepreview12'] = 'Image URL';
$lang['themepreview13'] = '$lang["themepreview14"] = "This theme is in use by $tusersnum users.";';
$lang['themepreview15'] = 'Theme Categories:<br /><small><em>(Separate with commas)</em></small>';
$lang['themepreview16'] = 'Theme Category:';
$lang['themepreview17'] = 'All Themes';
$lang['themepreview18'] = 'Show Themes from Category:';
// Category Theme Preview Mod End

============================================================================================================================
=======
Step 3:
=======
==============
Edit File: cp.php
==============
==========
Find Code:
==========

        $resetSigOn = $resetSigOff = '';
        if($SETTINGS['resetsigs'] == 'on') {
            $resetSigOn = $selHTML;
        } else {
            $resetSigOff = $selHTML;
        }
        
===============
Add Code Below:
===============

        // Category Theme Preview Mod Begin
        $tpextjpg = $tpextgif = $tpextpng = $tpextbmp = false;
        switch($SETTINGS['themepreviewext']) {
            case 'jpg':
                $tpextjpg = true;
                break;
            
            case 'gif':
                $tpextgif = true;
                break;
            
            case 'png':
                $tpextpng = true;
                break;
            
            case 'bmp':
                $tpextbmp = true;
                break;
        }
    
        $tpguestson = $tpguestsoff = '';
        if ($SETTINGS['themepreviewguests'] == 'on') {
            $tpguestson = $selHTML;
        } else {
            $tpguestsoff = $selHTML;
        }
        // Category Theme Preview Mod End
        
==========
Find Code:
==========

        $checked = array($sel_serverload, $sel_queries, $sel_phpsql, $sel_loadtimes);

===============
Add Code Below:
===============

        // Category Theme Preview Mod Begin
        $themescat = array();
        $themecats = unserialize($SETTINGS['themecats']);
        foreach($themecats as $tcid=>$catname) {
            $themescat[] = $catname;
        }
        $themecats = implode(', ', $themescat);
        unset($themescat, $tcid, $catname);
        // Category Theme Preview Mod End

==========
Find Code:
==========

        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);
        ?>
        
================
Replace Code With:
================
    
        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);
        // Category Theme Preview Mod Begin
        printsetting3($lang['themepreview3'], 'tpextnew', array('JPG', 'GIF', 'PNG', 'BMP'), array('jpg', 'gif', 'png', 'bmp'), array($tpextjpg, $tpextgif, $tpextpng, $tpextbmp), false);
        printsetting1($lang['themepreview4'], 'tpguestsnew', $tpguestson, $tpguestsoff);
        printsetting2($lang['themepreview5'], 'themesppnew', $SETTINGS['themespp'], 4);
        // Category Theme Preview Mod End
        ?>
        <!-- Category Theme Preview Mod Begin -->
        <tr>
        <td class="tablerow" bgcolor="<?php echo $altbg1?>"><?php echo $lang['themepreview15']?></td>
        <td class="tablerow" bgcolor="<?php echo $altbg2?>"><textarea rows="5" name="themecatsnew" cols="50"><?php echo $themecats?></textarea></td>
        </tr>
        <!-- Category Theme Preview Mod End -->

==========
Find Code:
==========

        $tickercontentsnew = addslashes($tickercontentsnew);

===============
Add Code Below:
===============

        // Category Theme Preview Mod Begin
        $tcid = 1;
        $themecats = explode(',', $themecatsnew);
        $newthemecats = array();
        foreach($themecats as $themecat) {
            $newthemecats[$tcid] = trim($themecat);
            $tcid++;
        }
        $themecatsnew = serialize($newthemecats);
        unset($newthemecats, $themecats);
        // Category Theme Preview Mod End

==========
Find Code:
==========

        $resetSigNew = ($resetSigNew == 'on') ? 'on' : 'off';

===============
Add  Code Below:
===============

        // Category Theme Preview Mod Begin
        $tpguestsnew = ($tpguestsnew == 'on') ? 'on' : 'off';
        // Category Theme Preview Mod End

=====
Find Code:
=====

        $db->query("UPDATE $table_settings SET
        
============================
Add Code To End Of Line Before "); :
============================

, themepreviewext='$tpextnew', themepreviewguests='$tpguestsnew', themespp='$themesppnew', themecats='$themecatsnew'

============================================================================================================================
=======
Step 4:
=======
================
Edit File: header.php
================
==========
Find Code:
==========

$links = implode(' &nbsp; ', $links);
    
==========
Add Above:
==========

// Category Theme Preview-link
$links[] = "<img src=\"$imgdir/themes.gif\" alt=\"$lang[themepreview1]\" title=\"$lang[themepreview1]\" /> <a href=\"./catthemes.php\"><font class=\"navtd\">$lang[themepreview1]</font></a>";

============================================================================================================================
=======
Step 5:
=======
===============
Edit File: misc.php
===============
==========
Find Code:
==========

    } elseif (false !== strpos($url, "/index.php")) {
        $location = $lang['onlineindex'];
        
==========
Add Below:
==========

    // Category Theme Preview Mod Begin
    } elseif (false !== strpos($url, "/catthemes.php")) {
        $location = $lang['themepreview7'];
    // Category Theme Preview Mod End
        
============================================================================================================================
=======
Step 6:
=======
===============
Edit File: cp2.php
===============
==========
Find Code:
==========

        $themestuff = $db->fetch_array($query);
        
===============
Add Code Below:
===============

        // Category Theme Preview Mod Begin
        $themecatbox = array();
        $themecatbox[] = "<select name=\"themecatnew\">";
        $themecats = unserialize($SETTINGS['themecats']);
        asort($themecats);
        foreach($themecats as $tcid => $catname) {
            $selected = ($tcid == $themestuff['category']) ? 'selected="selected"' : '';
            $themecatbox[] = "<option value=\"$tcid\" $selected>$catname</option>";
        }
        $themecatbox[] = "</select>";
        $themecatbox = implode("\n", $themecatbox);
        // Category Theme Preview Mod End
        
==========
Find Code:
==========

        <tr bgcolor="<?php echo $altbg2?>" class="tablerow">
        <td><?php echo $lang['texthemename']?></td>
        <td colspan="2"><input type="text" name="namenew" value="<?php echo $themestuff['name']?>" /></td>
        </tr>
        
===============
Add Code Below:
===============

        <!-- Category Theme Preview Mod Begin -->
        <tr bgcolor="<?php echo $altbg2?>" class="tablerow">
        <td><?php echo $lang['themepreview16']?></td>
        <td colspan="2"><?php echo $themecatbox?></td>
        </tr>
        <!-- Category Theme Preview Mod End -->
        
==========
Find Code:
==========

    } elseif (isset($single) && $single == "anewtheme1") {
    
===============
Add Code Below:
===============

        // Category Theme Preview Mod Begin
        $themecatbox = array();
        $themecatbox[] = "<select name=\"themecatnew\">";
        $themecats = unserialize($SETTINGS['themecats']);
        sort($themecats);
        foreach($themecats as $tcid => $catname) {
            $themecatbox[] = "<option value=\"$tcid\">$catname</option>";
        }
        $themecatbox[] = "</select>";
        $themecatbox = implode("\n", $themecatbox);
        // Category Theme Preview Mod End

==========
Find Code:
==========

        <tr bgcolor="<?php echo $altbg2?>" class="tablerow">
        <td><?php echo $lang['texthemename']?></td>
        <td><input type="text" name="namenew" /></td>
        </tr>

===============
Add Code Below:
===============

        <!-- Category Theme Preview Mod Begin -->
        <tr bgcolor="<?php echo $altbg2?>" class="tablerow">
        <td><?php echo $lang['themepreview16']?></td>
        <td><?php echo $themecatbox?></td>
        </tr>
        <!-- Category Theme Preview Mod End -->

==========
Find Code:
==========

        $db->query("UPDATE $table_themes SET name='$namenew',
        
========================================
Add To End Of Line Before WHERE themeid='$orig'");
========================================

, category='$themecatnew'

==========
Find Code:
==========

        $db->query("INSERT INTO $table_themes (themeid,
        
==========================
Add To Line Before  ) VALUES (
==========================

, category

========================
Add To End Of Line Before  "); 
========================

, '$themecatnew'

============================================================================================================================
=======
Step 7:
=======
==========================
Go To Admin Panel --> Templates
==========================
=============================
Create New Template: theme_preview
=============================
=============================
Add Code Below and Submit Changes
=============================

<table cellspacing="0" cellpadding="0" border="0" width="$THEME[tablewidth]" align="center" bgcolor="$THEME[bordercolor]">
<tr>
<td>
<table border="0" cellspacing="$THEME[borderwidth]" cellpadding="$THEME[tablespace]" width="100%">
<tr>
<td class="category" colspan="3"><font color="$THEME[cattext]"><strong>$lang[themepreview1]</strong></font></td>
</tr>
<tr class="tablerow">
<td colspan="3" bgcolor="$altbg1">$lang[themepreview18] $themecatbox</td>
</tr>
<tr class="tablerow">
<td colspan="3" bgcolor="$altbg2">$themes</td>
</tr>
$multi
</table></td>
</tr>
</table>

============================================================================================================================
=======
Step 8:
=======
==========================
Go To Admin Panel --> Templates
==========================
================================
Create New Template: theme_preview_row
================================
=============================
Add Code Below and Submit Changes
=============================

<table cellspacing="0" cellpadding="0" border="0" width="$THEME[tablewidth]" align="center" bgcolor="$THEME[bordercolor]">
<tr>
<td>
<table border="0" cellspacing="$THEME[borderwidth]" cellpadding="$THEME[tablespace]" width="100%">
<tr>
<td $tcatcode><font color="$THEME[cattext]"><strong>$themename</strong></font></td>
</tr>
<tr class="tablerow">
<td bgcolor="$THEME[altbg2]" align="center">$themeimg</td>
</tr>
<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" align="center">$lang[themepreview14]<br />$themelink</td>
</tr>
</table></td>
</tr>
</table>
<br />

============================================================================================================================
=======
Step 9:
=======
==========================
Go To Admin Panel --> Templates
==========================
===============================
Create New Template: theme_preview_ids
===============================
=============================
Add Code Below and Submit Changes
=============================

<table cellspacing="0" cellpadding="0" border="0" width="$THEME[tablewidth]" align="center" bgcolor="$THEME[bordercolo]">
<tr>
<td>
<table border="0" cellspacing="$THEME[borderwidth]" cellpadding="$THEME[tablespace]" width="100%">
<tr>
<td class="category"><font color="$THEME[cattext]"><strong>$lang[themepreview2]</strong></font></td>
</tr>
<tr class="tablerow">
<td bgcolor="$THEME[altbg2]">$lang[themepreview9]<br />
<table border="1">
<tr>
<th>$lang[themepreview10]</th>
<th>$lang[themepreview11]</th>
<th>$lang[themepreview12]</th>
</tr>
$themes
</table></td>
</tr>
</table></td>
</tr>
</table>

============================================================================================================================
========
Step 10:
========
==========================
Go To Admin Panel --> Templates
==========================
===================================
Create New Template: theme_preview_ids_row
===================================
=============================
Add Code Below and Submit Changes
=============================

<tr>
<td>$THEME[name]</td>
<td>$THEME[themeid]</td>
<td>$filename</td>
</tr>

============================================================================================================================
========
Step 11:
========
==========================
Go To Admin Panel --> Templates
==========================
====================================
Create New Template: theme_preview_multipage
====================================
=============================
Add Code Below and Submit Changes
=============================

<tr bgcolor="$THEME[altbg2]">
<td class="smalltxt" align="left" width="50%">$multipage</td>
<td class="smalltxt" align="right" width="50%">$adminlink</td>
</tr>

============================================================================================================================

Upload provided catthemes.php from the 'Contents' folder to your forum directory.

!!IMPORTANT!! Point your browser to http://www.yoursite.ext/catthemes.php before assigning categories or you may get warning errors!

Create a directory called 'catthemes' in your 'images' directory.

Upload screenshots of your themes in the format that you choose within Settings. The screenshots should be named
in the format X_thumb.ext where X is the ID number of the theme, and ext is the extension you've chosen.

For more instructions on the proper names for your theme screenshots, point your browser to http://www.yoursite.ext/catthemes.php?action=themeids

============================================================================================================================
Enjoy!