{#
/**
 * WebsiteBaker CMS AdminTool: addonMonitor
 *
 * Template for the display of templates 
 * 
 * 
 * @platform    CMS WebsiteBaker 2.8.x
 * @package     addonMonitor
 * @author      Christian M. Stefan (Stefek)
 * @copyright   Christian M. Stefan
 * @license     http://www.gnu.org/licenses/gpl-2.0.html
 */
#}
{#
{{ dump() }}
#}
<table style="width:100%;" cellpadding="3" cellspacing="0"  class="select_types">
	<tr>
		<td colspan="2">
			<div>	
				<label class="tool_module" for="include_themes"><input id="include_themes" type="checkbox" checked="checked" /><span title="Templates used for Admin Control Panel (Backend)">ACP Themes</span><sup>({{ count_acpthemes }})</sup></label>
                                <label class="page_module" for="include_templates"><input id="include_templates" type="checkbox" checked="checked" /><span>Page-Templates</span><sup>({{ count_pagetemplates }})</sup></label>
			</div>
		</td>
	<tr>
		<td>
			<fieldset>
				<legend>Filter by Addon Name</legend>
				<input class="filterinput" name="filter" id="filter_titles" value="" maxlength="30" size="30" type="text">
				<input class="clearbtn" id="clear_titles" type="submit" value="clear"/>
			</fieldset>
		</td>		
		<td>
			<fieldset>
				<legend>Filter by Author</legend>
				<input class="filterinput" name="filter" id="filter_authors" value="" maxlength="30" size="30" type="text">
				<input class="clearbtn" id="clear_authors" type="submit" value="clear"/>
			</fieldset>
		</td>
	</tr>
</table>
<table style="width:100%" border="0" cellpadding="3" cellspacing="0" id="htmlgrid" class="amDashboard">	
	<thead>	
		<tr>
			<th title="AddonType" class="sort"><span>Type</span></th>
			<th class="sort"><span>Addon Name</span></th>
			<th>Version</th>
			<th>Description</th>
			<th>Author</th>
			<th class="sort"><span>active</span></th>
		</tr>
	</thead>
	<tbody>
	{%for addon in addons %}			
		{% set function = (addon.function == 'template' ? 'Page Template' : 'ACP Theme') %}
		{% set row_class = (addon.function == 'template' ? 'page' : 'tool') %}
		
		<tr id="addons_{{ addon.addon_id }}" class="row_{{ row_class }}" rel="{{ addon.function }}">
			<td class="addon_icon">
				<div>
					{% if addon.icon %}
						<img src="{{ addon.icon }}" alt="{{ function }}" title="{{ function }}" width="144" />	
					{% else %}
						<small>{{function}}</small>
					{% endif %}
					<br />
					{{function}}
				</div>
			</td>
			<td class="addon_name">
				{{ addon.name }}<br />
				<small><i>{{ addon.directory }}</i></small>
			</td>
			<td class="addon_version">{{ addon.version }}</td>
			<td class="addon_description">
				{% if addon.description %}	
					{{ addon.description }}
				{% else %}
					<i>~ no description available ~</i>
				{% endif %}				
			</td>
			<td class="addon_author">
				<ul class="authors">
				{% for author in addon.author|split(', ') %}
					<li>{{ author }}</li>
				{% endfor %}
				</ul>
			</td>
			<td class="addon_active">
				<span style="display:none;">{# display none, we need it for sorting only #}
					{% if (addon.active == 'Y' or (addon.directory == constant('DEFAULT_TEMPLATE')) or (addon.directory == constant('DEFAULT_THEME'))) %}1{% else %}0{% endif %}
				</span>
				{% if addon.function == 'template' %}
					{% if (addon.active_pages|length > 0) or (addon.directory == constant('DEFAULT_TEMPLATE')) %}						
						<ul class="using_sections">							
						{% if addon.directory == constant('DEFAULT_TEMPLATE') %}	
							<li>Default Template</li>
						{% else %}
							<li title="this language is in use on {{ addon.active_pages|length }} Pages">{{ addon.active_pages|length }}x</li>
							{% for pID in addon.active_pages %}					
								<li title="PageID: {{ pID }}"><a href="{{ constant('WB_URL') }}/{{ constant('ADMIN_DIRECTORY') }}/pages/settings.php?page_id={{ pID }}" target="_blank">{{ pID }}</a></li>
							{% endfor %}
						{% endif %}	
						</ul>
					{% else %}
						<ul class="using_sections_null">
							<li title="this language is not used on any page">0x</li>
						</ul>
					{% endif %}
				{% else %}
					{% if addon.directory == constant('DEFAULT_THEME') %}
						<ul class="using_sections">								
							<li>Default ACP Theme</li>						
						</ul>
					{% else %}	
						<ul class="using_sections_null">
							<li>ACP Theme not in use</li>
						</ul>
					{% endif %}				
				{% endif %}				
			</td>			
		</tr>
	{% endfor %}
	</tbody>
	<tfoot>
		<tr>
			<td colspan="6">
				<b>Installed Templates:</b> {{ addons|length }}  <br/>
				<span class="page_module">{{ count_pagetemplates }} x <b>Page-Templates</b></span><br/>
				<span class="tool_module">{{ count_acpthemes }} x <b>ACP Themes</b></span>
			</td>
		</tr>
	</tfoot>
</table>