############################################################## 
## MOD Title: Collapsible Categories
## MOD Author: Brf < b.fermanich@insightbb.com  > (Brad Fermanich) http://castledoom.com/ 
## MOD Description: This MOD allows each user to collapse categories on index and viewforum
##		    and stores those settings for later page views.
## MOD Version: 0.0.0
## 
## Installation Level: Easy 
## Installation Time: 5 Minutes 
## Files To Edit: includes/functions_display.php
##		  styles/prosilver/templates/forumlist_body.html
##		  styles/prosilver/theme/content.css
## Included Files: ajax_update_collapse.php
##		   styles/prosilver/theme/images/cc_up.gif
##		   styles/prosilver/theme/images/cc_down.gif
##		   styles/prosilver/template/ccat.js
##
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
############################################################## 
## For security purposes, please check: http://www.phpbb.com/mods/ 
## for the latest version of this MOD. Although MODs are checked 
## before being allowed in the MODs Database there is no guarantee 
## that there are no security problems within the MOD. No support 
## will be given for MODs not found within the MODs Database which 
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes: 
## Note: If you are editing your stylesheet in the ACP on the Styles/Themes/prosilver/Edit page, you should do
## these edits in the ACP rather than in the file itself.
## If you edit the file itself, you will need to click Styles/Themes/prosilver/Refresh after the edit
##
############################################################## 
## MOD History: 
##
##   2008-3-31 - Version 0.3.0a
##	- Bugfix
##
##   2008-3-30 - Version 0.3.0
##	- Move javascript into its own file
##	- Move styles into stylesheet
##	- Adjust header ul-li-dd widths 
##	
##   2008-1-23 - Version 0.2.1
##	- One more bug with missing table row 
##	
##   2008-1-23 - Version 0.2.0a
##	- Blank value
##
##   2008-1-23 - Version 0.2.0
##	- Use image button.
##
##   2008-1-19 - Version 0.1.2
##	- Correct bug with missing profile field tablerow.
##
##   2008-1-18 - Version 0.1.1
##	- Specify Default Value for custom field
##
##   2008-1-16 - Version 0.1.0
##	- subsilver2 template
##
##   2008-1-16 - Version 0.0.0
##	- Initial Release
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ COPY ]------------------------------------------ 
#
copy root/ajax_update_collapse.php to ajax_update_collapse.php
copy root/styles/prosilver/theme/images/cc_open.gif to styles/prosilver/theme/images/cc_open.gif
copy root/styles/prosilver/theme/images/cc_close.gif to styles/prosilver/theme/images/cc_close.gif
copy root/styles/prosilver/template/ccat.js to styles/prosilver/template/ccat.js

# 
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_display.php

# 
#-----[ FIND ]------------------------------------------ 
#
	// Used to tell whatever we have to create a dummy category or not.

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
#
	$collapse_data=get_user_collapse();

# 
#-----[ FIND ]------------------------------------------ 
# 
			$template->assign_block_vars('forumrow', array(
				'S_IS_CAT'				=> true,

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
			$collapse_this = in_array($row['forum_id'],$collapse_data);
			$template->assign_block_vars('forumrow', array(
				'S_COLLAPSE'			=> ($collapse_this) ? 'style="display:none"':'',
				'COLLAPSE_SIGN'			=> ($collapse_this) ? '+':'-',
				'COLLAPSE_CLASS'		=> ($collapse_this) ? 'ccopen':'ccclose',
				'S_IS_CAT'				=> true,

#
#-----[ FIND ]------------------------------------------------
#
		$template->assign_block_vars('forumrow', array(
			'S_IS_CAT'			=> false,

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
	    	$collapse_this = in_array($row['forum_id'],$collapse_data);
		$template->assign_block_vars('forumrow', array(
			'S_COLLAPSE'			=> ($collapse_this) ? 'style="display:none"':'',
			'COLLAPSE_SIGN'			=> ($collapse_this) ? '+':'-',
			'COLLAPSE_CLASS'		=> ($collapse_this) ? 'ccopen':'ccclose',
			'S_IS_CAT'			=> false,

#
#-----[ FIND ]------------------------------------------------
#
		'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $root_data['forum_id'] . '&amp;mark=forums') : '',

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
		'S_AJAX_COLLAPSE_ACTION' => append_sid("{$phpbb_root_path}ajax_update_collapse.$phpEx","dummy=1",false),

#
#-----[ FIND ]------------------------------------------------
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
function get_user_collapse()
{
	global $user;
	if (!($user->data['is_registered']))
	{
		return(array());
	}
	else
	{
		$user->get_profile_fields( $user->data['user_id'] );
		$user_fields = $user->profile_fields;
		$collapse_list = (isset( $user_fields['pf_fcol'] )) ? $user_fields['pf_fcol'] : '';
		$collapse_array = explode(',', $collapse_list);
		if (is_array( $collapse_array ))
		{
			return( $collapse_array );
		}
		else
		{
			return( array() );
		}
	}
}

# 
#-----[ OPEN ]------------------------------------------ 
#
styles/prosilver/template/forumlist_body.html
# 
#-----[ FIND ]------------------------------------------ 
#
<!-- BEGIN forumrow -->

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
<script type="text/javascript">
// <![CDATA[
var myurl = "{S_AJAX_COLLAPSE_ACTION}";
// ]]>
</script> 
<script type="text/javascript" src="{T_TEMPLATE_PATH}/ccat.js"></script>

# 
#-----[ FIND ]------------------------------------------ 
#
						<dd class="lastpost"><span>{L_LAST_POST}</span></dd>

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
						<dd class="lastposthdr">{L_LAST_POST}</dd>
						<dd class="cchdr"><span><input type="button" class="{forumrow.COLLAPSE_CLASS}" value=" " onclick="flipf(this,'{forumrow.FORUM_ID}');" /></span></dd>

# 
#-----[ FIND ]------------------------------------------ 
#
				<ul class="topiclist forums">

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
				<ul class="topiclist forums" id="flist{forumrow.FORUM_ID}" {forumrow.S_COLLAPSE}>

# 
#-----[ OPEN ]------------------------------------------ 
#
#
# Note: If you are editing your stylesheet in the ACP on the Styles/Themes/prosilver/Edit page, you should do
# these edits in the ACP rather than in the file itself.
# If you edit the file itself, you will need to click Styles/Themes/prosilver/Refresh after the edit
# 
styles/prosilver/theme/content.css

# 
#-----[ FIND ]------------------------------------------ 
#
dd.lastpost {
	width: 25%;
	font-size: 1.1em;
}

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

dd.lastposthdr {
	width: 18%;
	font-size: 1.1em;
}

dd.cchdr {
	width: 7%;
	float: right !important;
	font-size: 1.1em;
}

.ccopen{
	background: #888888 url("{T_THEME_PATH}/images/cc_down.gif") no-repeat center center;
	width: 25px;
	height:25px;
	border: thin solid #666666 
}

.ccclose{
	background: #888888 url("{T_THEME_PATH}/images/cc_up.gif") no-repeat center center;
	width: 25px;
	height:25px;
	border: thin solid #666666
}

# 
#-----[ DIY INSTRUCTIONS ]------------------------------------------ 
# 

Browse to ACP / Users & Groups / Users / Custom profile fields
Type "fcol" (without the quotes) into the Add box
Select Textarea in the dropdown
Click Create new field
Select "No" for Display profile field
Select "Hide profile field" for Visibility Option
Type "Forum Collapse Data" (without quotes) for Field name/title
Type "Comma-delimited list of categories to collapse" (without quotes) for Field description.
Set Default value to 0 (zero).
Click Save.
Leave profile specific options at default values.
Click Save. 
---------------
If you have edited the file content.css:
Navigate to ACP / Styles / Themes and click "Refresh" next to prosilver.

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 