[comment]
ui_component: category_vert_toggle
ui_component_type: vertical
ui_component_group: Navigation
ui_component_label: Collapsable Vertical Category List

page_class:
	label: Page class
	type: select
	lookup: which_page
	db: area
	help: Defines which sets of items should be displayed
	advanced: 1

set_selector:
	label: Page area selector
	type: select
	db: area
	lookup: sel
	help: Defines which sets of items should be displayed
	advanced: 1

timed:
	label: Use timed build
	type: select
	help: Makes more efficient for large/busy catalogs
	options: 0=No, 5=5 minutes, 10=10 minutes, 20=20 minutes, 60=60 minutes, 1440=Daily
	advanced: 1
	code: timed

toggleswitchon:
	label: Toggle Open Switch
	type:  text
	help: Image to use for opening a category, leave blank to leave default +
	advanced: 1

toggleswitchoff:
	label: Toggle Closed Switch
	widget:  text
	help: Image to use for closing a category, leave blank to leave default -
	advanced: 1

imagedirpath:
	label: Override default image directory path
	type:  text
	help: Image directory path defaults to '__DOCROOT__/__IMAGE_DIR__'
	advanced: 1

imagedirurl:
	label: Override default image directory URL
	type:  text
	help: Image directory URL defaults to '' (include trailing '/')
	advanced: 1
[/comment]

<tr><td align="left" class="categorybar">
  <table width="90%" align="center">

<!-- BEGIN COMPONENT [control component category_vert_toggle] -->

[comment] Set default expand & contract graphics here [/comment]
[set toggleswitchon]plus.gif[/set]
[set toggleswitchoff]minus.gif[/set]
[set imagedirurl][/set]
[set imagedirpath]__DOCROOT__/__IMAGE_DIR__[/set]

[seti showtoggleon][if type=file term="[control imagedirpath]/[control toggleswitchon]"]
		<img border=0 src="[control imagedirurl][control toggleswitchon]">
	[else]
		<font class="categorybar"><font size="+1">+</font></font>
	[/else]
	[/if][/seti]
[seti showtoggleoff][if type=file term="[control imagedirpath]/[control toggleswitchoff]"]
		<img border=0 src="[control imagedirurl][control toggleswitchoff]">
	[else]
		<font class="categorybar"><font size="+1">-</font></font>
	[/else]
	[/if][/seti]

[timed-build auto=1 if="[control timed 0]" minutes="[control timed 0]"]
[perl]
	if ($CGI->{expand}) {
		$area = $CGI->{expand};
		$Scratch->{expandarea}{$area} = 1;
	}
	if ($CGI->{collapse}) {
		$area = $CGI->{collapse};
		undef $Scratch->{expandarea}{$area};
	}
	unless($Tag->control('toggleswitchon')) {
		$Tag->control('toggleswitchon',undef, { set => 1 });
	}
	unless($Tag->control('toggleswitchoff')) {
		$Tag->control('toggleswitchoff',undef, { set => 1 });
	}
	unless($Tag->control('imagedirpath')) {
		$Tag->control('imagedirpath',undef, { set => 1 });
	}
	unless($Tag->control('imagedirurl')) {
		$Tag->control('imagedirurl',undef, { set => 1 });
	}

	return('');
[/perl]

<tr>
    <td valign="top" align="right" colspan=3>
	<a href="[history-scan form="expandall=1"]">
	[scratch showtoggleon]
	<font class="categorybar"><b>[L]Show All Subcategories[/L]</b></a>
</tr>
<tr>
    <td valign="top" align="right" colspan=3>
	<a href="[history-scan form="collapseall=1"]">
	[scratch showtoggleoff]
	<font class="categorybar">
	<b>[L]Collapse All Categories[/L]</b></a>
    </td>
</tr>

[set found_cat][/set]
[loop 
        prefix=box
        search="
                fi=area
                st=db
                tf=sort
                ac=0
                ac=0
                co=yes

                sf=sel
                op=eq 
                se=[control set_selector left]
                
                sf=which_page
                op=rm  
                se=[control page_class all|@@MV_PAGE@@]
"]
  [set found_cat]1[/set]
  [perl]
    $Scratch->{expandarea}{"[box-code]"} = 1 if ($CGI->{expandall});
    undef $Scratch->{expandarea}{"[box-code]"} if ($CGI->{collapseall});
    return('');
  [/perl]
  <tr>
    <td>
	[if explicit]
	    [condition] 
		return($Scratch->{expandarea}{"[box-code]"});
	    [/condition] 
		<a href="[history-scan form="collapse=[box-code]"]">[scratch showtoggleoff]</a>
    	[else]
		<a href="[history-scan form="expand=[box-code]"]">[scratch showtoggleon]</a>
	[/else]
	[/if]
    </td>
    <td class="categorybar" colspan=2>
    	<b>&nbsp;&nbsp;[box-exec bar_link]area <A HREF="$URL$$EXPAND$" class=barlink>$ANCHOR$</A>[/box-exec]</b>
    </td>
  </tr>
[if explicit]
    [condition] 
	return($Scratch->{expandarea}{"[box-code]"});
    [/condition] 
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;&nbsp;&nbsp;</td>
    <td class="categorybar">

    [loop prefix=cat
	search="
		fi=cat
		st=db
		co=yes
		tf=sort
		tf=name
		rf=code,name
		sf=sel
		se=[box-code]
	"]
	[cat-exec bar_link]cat[/cat-exec]<br>
    [/loop]
    </td>
  </tr>
[/if]
[/loop]

<tr>
  <td>&nbsp;</td>
</tr>

[if !scratch found_cat]
[loop
    search="
        ra=yes
        tf=description
    "]
  <tr>   
    <td class="categorybar">
      	<b>[page [loop-code]]<font class="categorybar">[loop-field description]</font>[/page]</b>
    </td>
  </tr>
[/loop]
[/if]
[/timed-build]

  </table>
  <br>
</td></tr>

<!-- END COMPONENT [control component category_vert_toggle] -->

