<?php
/**
 * <pre>
 * Invision Power Services
 * Templates skin file
 * Last Updated: $Date: 2010-03-19 11:58:54 -0400 (Fri, 19 Mar 2010) $
 * </pre>
 *
 * @author 		$Author: bfarber $
 * @copyright	(c) 2001 - 2009 Invision Power Services, Inc.
 * @license		http://www.invisionpower.com/community/board/license.html
 * @package		IP.Content
 * @link		http://www.invisionpower.com
 * @since		1st March 2009
 * @version		$Revision: 223 $
 */
 
class cp_skin_templates extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * Show category form
 *
 * @access	public
 * @param	string		Add or edit
 * @param	array 		Block data for edit
 * @return	string		HTML
 */
public function categoryForm( $type, $category=array() )
{
$IPBHTML = "";
//--starthtml--//

$title	= $type == 'add' ? $this->lang->words['add_template_cat__title'] : $this->lang->words['edit_template_cat__title'] . $category['container_name'];
$do 	= $type == 'add' ? 'doAddCategory' : 'doEditCategory';

$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$title}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;type={$this->request['type']}' title='{$this->lang->words['cancel_edit_alt']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/delete.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['button__cancel']}
			</a>
		</li>
	</ul>
</div>

<form action='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do={$do}&amp;type={$this->request['type']}' method='post' id='adform' name='adform'>
<input type='hidden' name='id' value='{$category['container_id']}' />
<div class='acp-box'>
	<h3>{$this->lang->words['specify_cat_details']}</h3>
	<ul class='acp-form alternate_rows'>
		<li>
			<label>{$this->lang->words['template_cat__title']}</label>
			<input type='text' class='text' name='category_title' />
		</li>
	</ul>

	<div class="acp-actionbar">
		<input type='submit' value=' {$this->lang->words['button__save']} ' class="button primary" />
	</div>
</div>	
</form>
HTML;

//--endhtml--//
return $IPBHTML;
}

/**
 * Confirm template deletion
 *
 * @access	public
 * @param	integer		Template id
 * @param	array		Template data
 * @param	integer		Pages still using template
 * @return	string		HTML
 */
public function confirmDelete( $id, $template, $count )
{
$IPBHTML = "";
//--starthtml--//

$stillUsing	= sprintf( $this->lang->words['template_still_used'], $count );

$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$this->lang->words['confirm_template_delete']}</h2>
</div>
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>

<form action='{$this->settings['base_url']}{$this->form_code}&amp;do=delete&amp;confirm=1&amp;type={$this->request['type']}' method='post'>
<input type='hidden' name='template' value='{$id}' />
<div class='acp-box page-template-form'>
	<h3>{$this->lang->words['confirm_to_continue_d']}</h3>
	<p>{$stillUsing}</p>
	<div class="acp-actionbar">
		<input type='submit' value=' {$this->lang->words['button__cd']} ' class="button primary" />
		<input type='button' value=' {$this->lang->words['button__canceld']} ' class="realbutton redbutton" onclick='return acp.redirect("{$this->settings['base_url']}{$this->form_code}&amp;section=pages&amp;type={$this->request['type']}");' />
	</div>
</div>	
</form>

HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the listing of page templates
 *
 * @access	public
 * @param	array		Current templates
 * @param	array 		Categories
 * @return	string		HTML
 */
public function listTemplatesPage( $templates=array(), $categories=array() )
{
$IPBHTML = "";
//--starthtml--//

$template['pages']	= $this->registry->class_localization->formatNumber( intval($template['pages']) );

$IPBHTML .= <<<HTML
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>
<script type='text/javascript'>
	ipb.templates['cat_empty_page']	= new Template("<li class='no-records' id='record_00#{category}'><em>{$this->lang->words['no_templates_yet']}</em></li>");
</script>
<div class='section_title'>
	<h2>{$this->lang->words['page_templates_title']}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;type={$this->request['type']}' title='{$this->lang->words['add_template_button']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['add_template_button']}
			</a>
		</li>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=addCategory&amp;type={$this->request['type']}' title='{$this->lang->words['add_block_category']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['add_block_category']}' />
				{$this->lang->words['add_block_category']}
			</a>
		</li>
	</ul>
</div>
<div id='category-containers-p'>
HTML;

//-----------------------------------------
// Now we loop over cats and put templates in,
// then put the rest in "Other templates"
//-----------------------------------------

$categories[]	= array( 'container_id' => 0, 'container_name' => $this->lang->words['current_templates_header'], 'noEdit' => true );

if( is_array($categories) AND count($categories) )
{
	$dragNDrop	= array();
	
	foreach( $categories as $category )
	{
		//-----------------------------------------
		// Don't show "other blocks" category if it's
		// empty, but we have blocks in other cats
		//-----------------------------------------
		
		if( $category['container_id'] == 0 AND !(is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ])) AND count($templates) )
		{
			continue;
		}

		$dragNDrop[]	= "sortable_handle_p_{$category['container_id']}";
		
		$IPBHTML .= <<<HTML
	<div id='container_p_{$category['container_id']}'>
		<div class='acp-box adv_controls'>
			<h3>
HTML;

			if( !$category['noEdit'] )
			{
				$IPBHTML .= <<<HTML
				<div class='category-manage'>
					<img class='ipbmenu' id="menu_catp{$category['container_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['block_options']}' />
					<ul class='acp-menu' id='menu_catp{$category['container_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=editCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_category']}</a></li>
						<li class='icon delete'><a href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=deleteCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template_category']}</a></li>
					</ul>
				</div>
HTML;
			}
			
			$IPBHTML .= <<<HTML
				 <div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div> {$category['container_name']}
			</h3>
			<ul id='sortable_handle_p_{$category['container_id']}' class='alternate_rows filemanager'>
HTML;

		if( is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ]) )
		{
			foreach( $templates[ $category['container_id'] ] as $template )
			{
				$pages_in_use	= sprintf( $this->lang->words['used_by_s_pages'], $template['pages'] );
				
				$IPBHTML .= <<<HTML
				<li class='record control_row' id='record_{$template['template_id']}'>
					<ul class='controls no_extra'>
						<li class='left'>
							<a class='edit' href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_link']}</a>
						</li>
						<li class='right'>
							<a class='delete' href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}{$this->form_code}&amp;do=delete&amp;template={$template['template_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template__link']}</a>
						</li>
					</ul>
					<div class="info">
						{$this->lang->words['last_modified_pre']} {$template['template_updated_formatted']}<br />
						{$pages_in_use}
					</div>
					<div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div>
					<div>
						<strong><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$template['template_name']}</a></strong>
						<div class='desctext'>{$template['template_desc']}</div>
					</div>
				</li>
HTML;
			}
		}
		else
		{
			$IPBHTML .= <<<HTML
			<li class='no-records' id='record_00{$category['container_id']}'>
				<em>{$this->lang->words['no_templates_yet']} <a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=add&amp;type={$this->request['type']}'>{$this->lang->words['create_pt_now']}</a></em>
			</li>
HTML;
		}
		
		$IPBHTML .= <<<HTML
			</ul>
		</div>
		<br />
	</div>
HTML;
	}
}

$_dragNDrop_Categories	= implode( "', '", $dragNDrop );

$IPBHTML .= <<<HTML
</div>
<script type='text/javascript'>
	acp.ccs.initTemplateCategorization( new Array('{$_dragNDrop_Categories}') );
</script>
HTML;
//--endhtml--//
return $IPBHTML;
}


/**
 * Show the listing of database templates
 *
 * @access	public
 * @param	array		Current templates
 * @param	array 		Categories
 * @return	string		HTML
 */
public function listTemplatesDatabase( $templates=array(), $categories=array() )
{
$IPBHTML = "";
//--starthtml--//

$template['pages']	= $this->registry->class_localization->formatNumber( intval($template['pages']) );

$IPBHTML .= <<<HTML
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>
<script type='text/javascript'>
	ipb.templates['cat_empty_db']	= new Template("<li class='no-records' id='record_000#{category}'><em>{$this->lang->words['no_templates_yet']}</em></li>");
</script>

<div class='section_title'>
	<h2>{$this->lang->words['page_templates_dbtitle']}</h2>
	<ul class='context_menu'>
		<li>
			<a class='ipbmenu' title='{$this->lang->words['add_template_button']}' id='addContent'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['add_template_button']}
			</a>
		</li>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=addCategory&amp;type={$this->request['type']}' title='{$this->lang->words['add_block_category']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['add_block_category']}' />
				{$this->lang->words['add_block_category']}
			</a>
		</li>
	</ul>
</div>
<ul class='acp-menu' id='addContent_menucontent'>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=1&amp;type={$this->request['type']}' title='{$this->lang->words['db_add_template_category']}'>{$this->lang->words['db_add_template_category']}</a></li>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=2&amp;type={$this->request['type']}' title='{$this->lang->words['db_add_template_listing']}'>{$this->lang->words['db_add_template_listing']}</a></li>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=3&amp;type={$this->request['type']}' title='{$this->lang->words['db_add_template_display']}'>{$this->lang->words['db_add_template_display']}</a></li>
</ul>
<div id='category-containers-d'>
HTML;

//print_r($categories);
//print_r($templates);
//-----------------------------------------
// Now we loop over cats and put templates in,
// then put the rest in "Other templates"
//-----------------------------------------

$categories[]	= array( 'container_id' => 00, 'container_name' => $this->lang->words['current_templates_header'], 'noEdit' => true );

if( is_array($categories) AND count($categories) )
{
	foreach( $categories as $category )
	{
		//-----------------------------------------
		// Don't show "other blocks" category if it's
		// empty, but we have blocks in other cats
		//-----------------------------------------
		
		if( $category['container_id'] == 0 AND !(is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ])) AND count($templates) )
		{
			continue;
		}

		$dragNDrop[]	= "sortable_handle_d_{$category['container_id']}";
		
		$IPBHTML .= <<<HTML
	<div id='container_d_{$category['container_id']}'>
		<div class='acp-box adv_controls'>
			<h3>
HTML;

			if( !$category['noEdit'] )
			{
				$IPBHTML .= <<<HTML
				<div class='category-manage'>
					<img class='ipbmenu' id="menu_catd{$category['container_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['block_options']}' />
					<ul class='acp-menu' id='menu_catd{$category['container_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=editCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_category']}</a></li>
						<li class='icon delete'><a href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=deleteCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template_category']}</a></li>
					</ul>
				</div>
HTML;
			}
			
			$IPBHTML .= <<<HTML
				 <div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div> {$category['container_name']}
			</h3>
			<ul id='sortable_handle_d_{$category['container_id']}' class='alternate_rows filemanager'>
HTML;

		if( is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ]) )
		{
			foreach( $templates[ $category['container_id'] ] as $template )
			{
				$pages_in_use	= sprintf( $this->lang->words['used_by_s_dbs'], $template['dbs'] );
				
				$IPBHTML .= <<<HTML
				<li class='record control_row' id='record_{$template['template_id']}'>
					<ul class='controls'>
						<li class='left'>
							<a class='edit' href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_link']}</a>
						</li>
						<li class='right ipbmenu' id='menu_folder{$template['template_id']}'>
							{$this->lang->words['folder_options_alt']}
						</li>
					</ul>
					<ul class='acp-menu' id='menu_folder{$template['template_id']}_menucontent'>
						<li class='icon delete'><a href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}{$this->form_code}&amp;do=delete&amp;template={$template['template_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template__link']}</a></li>
						<li class='icon view'><a href='#' onclick="return acp.ccs.viewCompare( '{$this->settings['base_url']}module=ajax&amp;section=compare&amp;id={$template['template_id']}' );">{$this->lang->words['template_diff_report']}</a></li>
					</ul>

					<div class="info">
						{$this->lang->words['last_modified_pre']} {$template['template_updated_formatted']}<br />
						{$pages_in_use}
					</div>
					<div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div>
					<div>
						<strong><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$template['template_name']}</a></strong>
						<div class='desctext'>{$template['template_desc']}</div>
					</div>
				</li>
HTML;
			}
		}
		else
		{
			$IPBHTML .= <<<HTML
			<li class='no-records' id='record_000{$category['container_id']}'>
				<em>{$this->lang->words['no_templates_yet']} <a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=add&amp;database=1&amp;type={$this->request['type']}'>{$this->lang->words['create_pt_dbcat_now']}</a></em>
			</li>
HTML;
		}
		
		$IPBHTML .= <<<HTML
			</ul>
		</div>
		<br />
	</div>
HTML;
	}
}

$_dragNDrop_Categories	= implode( "', '", $dragNDrop );

$IPBHTML .= <<<HTML
</div>
<script type='text/javascript'>
	acp.ccs.initTemplateCategorization( new Array('{$_dragNDrop_Categories}') );
</script>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the listing of article templates
 *
 * @access	public
 * @param	array		Current templates
 * @param	array 		Categories
 * @return	string		HTML
 */
public function listTemplatesArticles( $templates=array(), $categories=array() )
{
$IPBHTML = "";
//--starthtml--//

$template['pages']	= $this->registry->class_localization->formatNumber( intval($template['pages']) );

$IPBHTML .= <<<HTML
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>
<script type='text/javascript'>
	ipb.templates['cat_empty_db']	= new Template("<li class='no-records' id='record_000#{category}'><em>{$this->lang->words['no_templates_yet']}</em></li>");
</script>

<div class='section_title'>
	<h2>{$this->lang->words['art_templates_title']}</h2>
	<ul class='context_menu'>
		<li>
			<a class='ipbmenu' title='{$this->lang->words['add_template_button']}' id='addContent'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['icon']}' />
				{$this->lang->words['add_template_button']}
			</a>
		</li>
		<li>
			<a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=addCategory&amp;type={$this->request['type']}' title='{$this->lang->words['add_block_category']}'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='{$this->lang->words['add_block_category']}' />
				{$this->lang->words['add_block_category']}
			</a>
		</li>
	</ul>
</div>
<ul class='acp-menu' id='addContent_menucontent'>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=4&amp;type={$this->request['type']}' title='{$this->lang->words['art_add_template_frontpage']}'>{$this->lang->words['art_add_template_frontpage']}</a></li>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=5&amp;type={$this->request['type']}' title='{$this->lang->words['art_add_template_display']}'>{$this->lang->words['art_add_template_display']}</a></li>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=6&amp;type={$this->request['type']}' title='{$this->lang->words['art_add_template_archive']}'>{$this->lang->words['art_add_template_archive']}</a></li>
	<li class='icon add'><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=add&amp;database=7&amp;type={$this->request['type']}' title='{$this->lang->words['art_add_template_categories']}'>{$this->lang->words['art_add_template_categories']}</a></li>
</ul>
<div id='category-containers-d'>
HTML;

//print_r($categories);
//print_r($templates);
//-----------------------------------------
// Now we loop over cats and put templates in,
// then put the rest in "Other templates"
//-----------------------------------------

$categories[]	= array( 'container_id' => 00, 'container_name' => $this->lang->words['current_templates_header'], 'noEdit' => true );

if( is_array($categories) AND count($categories) )
{
	foreach( $categories as $category )
	{
		//-----------------------------------------
		// Don't show "other blocks" category if it's
		// empty, but we have blocks in other cats
		//-----------------------------------------
		
		if( $category['container_id'] == 0 AND !(is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ])) AND count($templates) )
		{
			continue;
		}

		$dragNDrop[]	= "sortable_handle_d_{$category['container_id']}";
		
		$IPBHTML .= <<<HTML
	<div id='container_d_{$category['container_id']}'>
		<div class='acp-box adv_controls'>
			<h3>
HTML;

			if( !$category['noEdit'] )
			{
				$IPBHTML .= <<<HTML
				<div class='category-manage'>
					<img class='ipbmenu' id="menu_catd{$category['container_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['block_options']}' />
					<ul class='acp-menu' id='menu_catd{$category['container_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=editCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_category']}</a></li>
						<li class='icon delete'><a href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=deleteCategory&amp;id={$category['container_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template_category']}</a></li>
					</ul>
				</div>
HTML;
			}
			
			$IPBHTML .= <<<HTML
				 <div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div> {$category['container_name']}
			</h3>
			<ul id='sortable_handle_d_{$category['container_id']}' class='alternate_rows filemanager'>
HTML;

		if( is_array($templates[ $category['container_id'] ]) AND count($templates[ $category['container_id'] ]) )
		{
			foreach( $templates[ $category['container_id'] ] as $template )
			{
				$IPBHTML .= <<<HTML
				<li class='record control_row' id='record_{$template['template_id']}'>
					<ul class='controls'>
						<li class='left'>
							<a class='edit' href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$this->lang->words['edit_template_link']}</a>
						</li>
						<li class='right ipbmenu' id='menu_folder{$template['template_id']}'>
							{$this->lang->words['folder_options_alt']}
						</li>
					</ul>
					<ul class='acp-menu' id='menu_folder{$template['template_id']}_menucontent'>
						<li class='icon delete'><a href='#' onclick="return acp.confirmDelete( '{$this->settings['base_url']}{$this->form_code}&amp;do=delete&amp;template={$template['template_id']}&amp;type={$this->request['type']}' );">{$this->lang->words['delete_template__link']}</a></li>
						<li class='icon view'><a href='#' onclick="return acp.ccs.viewCompare( '{$this->settings['base_url']}module=ajax&amp;section=compare&amp;id={$template['template_id']}' );">{$this->lang->words['template_diff_report']}</a></li>
					</ul>

					<div class="info">
						{$this->lang->words['last_modified_pre']} {$template['template_updated_formatted']}
					</div>
					<div class='draghandle'><img src='{$this->settings['skin_acp_url']}/_newimages/drag_icon.png' alt=''></div>
					<div>
						<strong><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=edit&amp;template={$template['template_id']}&amp;type={$this->request['type']}'>{$template['template_name']}</a></strong>
						<div class='desctext'>{$template['template_desc']}</div>
					</div>
				</li>
HTML;
			}
		}
		else
		{
			$IPBHTML .= <<<HTML
			<li class='no-records' id='record_000{$category['container_id']}'>
				<em>{$this->lang->words['no_templates_yet']} <a href='{$this->settings['base_url']}&amp;module=templates&amp;section=pages&amp;do=add&amp;database=4&amp;type={$this->request['type']}'>{$this->lang->words['create_pt_artcat_now']}</a></em>
			</li>
HTML;
		}
		
		$IPBHTML .= <<<HTML
			</ul>
		</div>
		<br />
	</div>
HTML;
	}
}

$_dragNDrop_Categories	= implode( "', '", $dragNDrop );

$IPBHTML .= <<<HTML
</div>
<script type='text/javascript'>
	acp.ccs.initTemplateCategorization( new Array('{$_dragNDrop_Categories}') );
</script>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the form to add or edit a template
 *
 * @access	public
 * @param	string		Type (add|edit)
 * @param	array		Current data
 * @param	array 		Form elements
 * @return	string		HTML
 */
public function templateForm( $type, $defaults, $form )
{
$IPBHTML = "";
//--starthtml--//

$title	= $type == 'add' ? $this->lang->words['adding_a_template'] : $this->lang->words['editing_a_template'];
$code	= $type == 'add' ? 'doAdd' : 'doEdit';

$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$title}</h2>
</div>
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>

<form action='{$this->settings['base_url']}{$this->form_code}&amp;do={$code}&amp;type={$this->request['type']}' method='post'>
<input type='hidden' name='template' value='{$defaults['template_id']}' />
<input type='hidden' name='template_database' value='{$defaults['template_database']}' />

<input type='hidden' name='step' value='3' />
<div class='acp-box page-template-form'>
	<h3>{$this->lang->words['template_form_header']}</h3>
	<table width='100%' cellpadding='0' cellspacing='0' class='form_table alternate_rows double_pad'>
		<tr>
			<td style='width: 40%'>
				<strong>{$this->lang->words['template_title']}</strong>
			</td>
			<td style='width: 60%'>
				{$form['name']}
			</td>
		</tr>
		<tr>
			<td>
				<strong>{$this->lang->words['template_key']}</strong><br /><span class='desctext'>{$this->lang->words['template_key_desc']}</span>
			</td>
			<td>
				{$form['key']}
			</td>
		</tr>
		<tr>
			<td>
				<strong>{$this->lang->words['template_description']}</strong><br /><span class='desctext'>{$this->lang->words['template_description_desc']}</span>
			</td>
			<td>
				{$form['description']}
			</td>
		</tr>
HTML;

if( $form['category'] )
{
	$IPBHTML .= <<<HTML
		<tr>
			<td>
				<strong>{$this->lang->words['select_category']}</strong>
			</td>
			<td>
				{$form['category']}
			</td>
		</tr>
HTML;
}

$_dbLink	= '';

if( $this->request['database'] OR $defaults['template_database'] )
{
	$_dbLink	= " &middot; <a href='#' id='inline-db-tags-link' rel='{$defaults['template_database']}'>{$this->lang->words['database_tag_help_link']}</a>";
	
	if( $defaults['template_id'] )
	{
		$_dbLink	.= " &middot; <a href='#' onclick=\"return acp.ccs.viewCompare( '{$this->settings['base_url']}module=ajax&amp;section=compare&amp;id={$defaults['template_id']}' );\">{$this->lang->words['template_diff_report']}</a>";
	}
}

$IPBHTML .= <<<HTML
		<tr>
			<td colspan='2'>
				<strong>{$this->lang->words['template_html']}</strong><br /><span class='desctext'><a href='#' id='inline-template-tags-link'>{$this->lang->words['template_tag_help_link']}</a>{$_dbLink}</span>
				<div class='clear' style='padding: 10px'><div id='content-label'>{$form['content']}</div></div>
			</td>
		</tr>
	</table>
	<div class="acp-actionbar">
		<input type='submit' value=' {$this->lang->words['button__save']} ' class="button primary" /> <input type='submit' name='save_and_reload' value=' {$this->lang->words['button__reload']} ' class="button primary" />
	</div>
</div>	
</form>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * View a database template difference report
 *
 * @access	public
 * @param	array 		Template data
 * @param	string		Diff output
 * @return	string		HTML
 */
public function viewDiffReport( $template, $output )
{
$IPBHTML = "";
//--starthtml--//

$_date	= $this->registry->class_localization->getDate( $template['template_updated'], 'SHORT' );

$IPBHTML .= <<<HTML
<h3>
	{$this->lang->words['template_diff_title']} {$template['template_name']}
	<div style='float:right;'><span class='desctext'>{$this->lang->words['row_modified']} {$_date}</span></div>
</h3>
<div style="padding:4px;line-height:125%;overflow:auto"><pre>{$output}</pre></div>
HTML;
//--endhtml--//
return $IPBHTML;
}


/**
 * Show the template tags
 *
 * @access	public
 * @param	array 		Categories
 * @param	array		Current template tags (blocks)
 * @param	array 		Databases
 * @return	string		HTML
 */
public function listTemplateTags( $categories, $blocks, $databases )
{
$IPBHTML = "";
//--starthtml--//

$IPBHTML .= <<<HTML
<div class='acp-box'>
	<h3>{$this->lang->words['template_tag_header']}</h3>
	<ul class='acp-form templateTagRows'>
HTML;

if( $this->request['do'] == 'showtags' )
{
	$IPBHTML .= <<<HTML
		<li class='template-tag-cat'>
			{$this->lang->words['special_tags_cat']}
		</li>
		<li>
			<label>{$this->lang->words['tag__page_content']} <span class='desctext'>{$this->lang->words['tag__page_content_desc']}</span></label>
			<div class='template-tag'>{ccs special_tag="page_content"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__page_title']} <span class='desctext'>{$this->lang->words['tag__page_title_desc']}</span></label>
			<div class='template-tag'>{ccs special_tag="page_title"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__meta_tags']} <span class='desctext'>{$this->lang->words['tag__meta_tags_desc']}</span></label>
			<div class='template-tag'>{ccs special_tag="meta_tags"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__navigation']} <span class='desctext'>{$this->lang->words['tag__nav_desc']}</span></label>
			<div class='template-tag'>{ccs special_tag="navigation"}</div>
		</li>
HTML;
}

$categories[]	= array( 'container_id' => 0, 'container_name' => $this->lang->words['current_blocks_header'] );

if( is_array($categories) AND count($categories) )
{
	foreach( $categories as $category )
	{
		$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$category['container_name']}
			</li>
HTML;
		if( is_array($blocks[ $category['container_id'] ]) AND count($blocks[ $category['container_id'] ]) )
		{
			foreach( $blocks[ $category['container_id'] ] as $block )
			{
				$tag	= '{parse block="' . $block['block_key'] . '"}';
				
				$IPBHTML .= <<<HTML
					<li>
						<label><a href='#' class='block-preview-link' id='{$block['block_id']}-blockPreview' title='{$this->lang->words['block_preview_alt']}'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/view.png' alt='{$this->lang->words['block_preview_alt']}' /></a> {$block['block_name']} <span class='desctext'>{$block['block_description']}</span></label>
						<div class='template-tag'>{$tag}</div>
					</li>
HTML;
			}
		}
	}
}

if( is_array($databases) AND count($databases) )
{
	$IPBHTML .= <<<HTML
		<li class='template-tag-cat'>
			{$this->lang->words['template_tag_dbs']}
		</li>
HTML;

	foreach( $databases as $database )
	{
		if( !$database['database_is_articles'] )
		{
			continue;
		}
		
		$tag	= '{parse articles}';
		
		$IPBHTML .= <<<HTML
			<li>
				<label>{$database['database_name']}</label>
				<div class='template-tag'>{$tag}</div>
			</li>
HTML;
	}

	foreach( $databases as $database )
	{
		if( $database['database_is_articles'] )
		{
			continue;
		}
		
		$tag	= '{parse database="' . $database['database_key'] . '"}';
		
		$IPBHTML .= <<<HTML
			<li>
				<label>{$database['database_name']}</label>
				<div class='template-tag'>{$tag}</div>
			</li>
HTML;
	}
}

$IPBHTML .= <<<HTML
	</ul>
</div>
<script type='text/javascript'>
	$$('.block-preview-link').each( function(elem){
		$(elem).observe('click', acp.ccs.showBlockPreview );
	});
</script>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the template tags inline
 *
 * @access	public
 * @param	array 		Categories
 * @param	array		Current template tags (blocks)
 * @param	array 		Databases
 * @return	string		HTML
 */
public function inlineTemplateTags( $categories, $blocks, $databases )
{
$IPBHTML = "";
//--starthtml--//

$IPBHTML .= <<<HTML
<div class='templateTags'>
	<h4>
		<div style='float:right'><img id='template-tags-link' style='cursor:pointer;' src='{$this->settings['skin_acp_url']}/_newimages/icons/help.png' alt='{$this->lang->words['template_tag_help_full']}' title='{$this->lang->words['template_tag_help_full']}' /> <img id='close-tags-link' style='cursor:pointer;' src='{$this->settings['skin_acp_url']}/_newimages/icons/cross.png' alt='{$this->lang->words['template_tag_help_close']}' title='{$this->lang->words['template_tag_help_close']}' /></div>
		{$this->lang->words['template_tag_header']}
	</h4>
	<ul>
HTML;

if( $this->request['do'] == 'showtags' )
{
	$IPBHTML .= <<<HTML
		<li class='template-tag-cat'>
			{$this->lang->words['special_tags_cat']}
		</li>
		<li>
			<label>{$this->lang->words['tag__page_content']}</label>
			<div>{ccs special_tag="page_content"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__page_title']}</label>
			<div>{ccs special_tag="page_title"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__meta_tags']}</label>
			<div>{ccs special_tag="meta_tags"}</div>
		</li>
		<li>
			<label>{$this->lang->words['tag__navigation']}</label>
			<div class='template-tag'>{ccs special_tag="navigation"}</div>
		</li>
HTML;
}

$categories[]	= array( 'container_id' => 0, 'container_name' => $this->lang->words['current_blocks_header'] );

if( is_array($categories) AND count($categories) )
{
	foreach( $categories as $category )
	{
		$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$category['container_name']}
			</li>
HTML;
		if( is_array($blocks[ $category['container_id'] ]) AND count($blocks[ $category['container_id'] ]) )
		{
			foreach( $blocks[ $category['container_id'] ] as $block )
			{
				$tag	= '{parse block="' . $block['block_key'] . '"}';
				
				$IPBHTML .= <<<HTML
					<li>
						<label><a href='#' class='block-preview-link' id='{$block['block_id']}-blockPreview' title='{$this->lang->words['block_preview_alt']}'><img src='{$this->settings['skin_acp_url']}/_newimages/icons/view.png' alt='{$this->lang->words['block_preview_alt']}' /></a> {$block['block_name']}</label>
						<div>{$tag}</div>
					</li>
HTML;
			}
		}
	}
}

if( is_array($databases) AND count($databases) )
{
	$IPBHTML .= <<<HTML
		<li class='template-tag-cat'>
			{$this->lang->words['template_tag_dbs']}
		</li>
HTML;

	foreach( $databases as $database )
	{
		if( !$database['database_is_articles'] )
		{
			continue;
		}
		
		$tag	= '{parse articles}';
		
		$IPBHTML .= <<<HTML
			<li>
				<label>{$database['database_name']}</label>
				<div>{$tag}</div>
			</li>
HTML;
	}

	foreach( $databases as $database )
	{
		if( $database['database_is_articles'] )
		{
			continue;
		}
		
		$tag	= '{parse database="' . $database['database_key'] . '"}';
		
		$IPBHTML .= <<<HTML
			<li>
				<label>{$database['database_name']}</label>
				<div>{$tag}</div>
			</li>
HTML;
	}
}

$IPBHTML .= <<<HTML
	</ul>
</div>
<script type='text/javascript'>
	if( $('template-tags-link') )
	{
HTML;

if( $this->request['do'] == 'showtags' )
{
	$IPBHTML .= <<<HTML
		$('template-tags-link').observe('click', acp.ccs.showTemplateTags );
HTML;
}
else
{
	$IPBHTML .= <<<HTML
		$('template-tags-link').observe('click', acp.ccs.showFullPageTags );
HTML;
}

$IPBHTML .= <<<HTML
	}
	
	if( $('close-tags-link') )
	{
		$('close-tags-link').observe('click', acp.ccs.closeInlineHelp );
	}
	
	$$('.block-preview-link').each( function(elem){
		$(elem).observe('click', acp.ccs.showBlockPreview );
	});
</script>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the databases for db tag help
 *
 * @access	public
 * @param	array 		Databases
 * @return	string		HTML
 */
public function listDatabases( $databases )
{
$IPBHTML = "";
//--starthtml--//

$IPBHTML .= <<<HTML
<style type='text/css'>
	@import url({$this->settings['skin_app_url']}css/ccs.css);
</style>
<div class='acp-box databaseTags'>
	<h3>{$this->lang->words['dbhelp_tag_header']}</h3>
	<ul class='acp-form'>
HTML;

if( is_array($databases) AND count($databases) )
{
	$IPBHTML .= <<<HTML
		<li class='template-tag-cat'>
			{$this->lang->words['taghelp_select_db']}
		</li>
HTML;

	foreach( $databases as $database )
	{
		$IPBHTML .= <<<HTML
			<li>
				<label><a href='{$this->settings['base_url']}{$this->form_code}&amp;do=tags&amp;id={$database['database_id']}&amp;type={$this->request['type']}'>{$database['database_name']}</a></label>
				<div>{$database['database_description']}</div>
			</li>
HTML;
	}
}

$IPBHTML .= <<<HTML
	</ul>
</div>
HTML;
//--endhtml--//
return $IPBHTML;
}

/**
 * Show the database tag help
 *
 * @access	public
 * @param	array 		Database
 * @param	array 		Fields
 * @return	string		HTML
 * @todo 	Update the help window here appropriately
 */
public function listDatabaseTags( $database, $fields )
{
$IPBHTML = "";
//--starthtml--//

//-----------------------------------------
// Databases and articles
//-----------------------------------------

$_catsHide		= ( $this->request['type'] != 1 AND $this->request['type'] != 7 ) ? "style='display: none;'" : '';
$_listHide		= ( $this->request['type'] != 2 AND $this->request['type'] != 6 ) ? "style='display: none;'" : '';
$_showHide		= ( $this->request['type'] != 3 AND $this->request['type'] != 5 ) ? "style='display: none;'" : '';

$_fpHide		= $this->request['type'] != 4 ? "style='display: none;'" : '';
//$_viewHide		= $this->request['type'] != 5 ? "style='display: none;'" : '';
//$_archHide		= $this->request['type'] != 6 ? "style='display: none;'" : '';
//$_catlHide		= $this->request['type'] != 7 ? "style='display: none;'" : '';

$IPBHTML .= <<<HTML
<style type='text/css'>
	@import url({$this->settings['skin_app_url']}css/ccs.css);
</style>
<script type='text/javascript' src='{$this->settings['js_app_url']}acp.ccs.js'></script>
<!--<div class='acp-box databaseTags'>
	<h3>{$this->lang->words['dbhelp1_tag_header']}</h3>
	<ul class='acp-form'>
		<li class='template-tag-cat'>
			{$this->lang->words['taghelp_select_template']}
		</li>
		<li>
			<label><span class='ipbmenu ttype' id='type-categories'>{$this->lang->words['taghelp__categories']}</span></label>
		</li>
		<li>
			<label><span class='ipbmenu ttype' id='type-listing'>{$this->lang->words['taghelp__listing']}</span></label>
		</li>
		<li>
			<label><span class='ipbmenu ttype' id='type-display'>{$this->lang->words['taghelp__display']}</span></label>
		</li>
	</ul>
-->	
	<div class='acp-box databaseTags' id='db-tags-categories' {$_catsHide}>
		<h3>{$this->lang->words['taghelp__h3_categories']}</h3>
		<ul class='acp-form'>
			<li class='template-tag-cat'>
				{$this->lang->words['taghelp__database_tags']}
			</li>
			<li>
				<label>&#36;data['database']['database_name']</label>
				<div>{$this->lang->words['tagh_db_dbname']}</div>
			</li>
			<li>
				<label>&#36;data['database']['base_link']</label>
				<div>{$this->lang->words['tagh_db_baselink']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_add']</label>
				<div>{$this->lang->words['tagh_db_canadd']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_rate']</label>
				<div>{$this->lang->words['tagh_db_canrate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_comment']</label>
				<div>{$this->lang->words['tagh_db_cancomment']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['moderate_edit']</label>
				<div>{$this->lang->words['tagh_db_modedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_delete']</label>
				<div>{$this->lang->words['tagh_db_moddel']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_deletec']</label>
				<div>{$this->lang->words['tagh_db_moddelc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_lock']</label>
				<div>{$this->lang->words['tagh_db_modlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_unlock']</label>
				<div>{$this->lang->words['tagh_db_modunlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_pin']</label>
				<div>{$this->lang->words['tagh_db_modpin']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approve']</label>
				<div>{$this->lang->words['tagh_db_modapp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approvec']</label>
				<div>{$this->lang->words['tagh_db_modappc']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['database_id']</label>
				<div>{$this->lang->words['tagh_db_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_key']</label>
				<div>{$this->lang->words['tagh_db_dbkey']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_database']</label>
				<div>{$this->lang->words['tagh_db_db']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_description']</label>
				<div>{$this->lang->words['tagh_db_desc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_count']</label>
				<div>{$this->lang->words['tagh_db_fields']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_record_count']</label>
				<div>{$this->lang->words['tagh_db_records']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_categories']</label>
				<div>{$this->lang->words['tagh_db_tplc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_listing']</label>
				<div>{$this->lang->words['tagh_db_tpll']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_display']</label>
				<div>{$this->lang->words['tagh_db_tpld']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_user_editable']</label>
				<div>{$this->lang->words['tagh_db_ue']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_all_editable']</label>
				<div>{$this->lang->words['tagh_db_wiki']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_open']</label>
				<div>{$this->lang->words['tagh_db_open']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comments']</label>
				<div>{$this->lang->words['tagh_db_comments']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_rate']</label>
				<div>{$this->lang->words['tagh_db_rate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_revisions']</label>
				<div>{$this->lang->words['tagh_db_revisions']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_title']</label>
				<div>{$this->lang->words['tagh_db_ft']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_sort']</label>
				<div>{$this->lang->words['tagh_db_fs']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_direction']</label>
				<div>{$this->lang->words['tagh_db_order']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_perpage']</label>
				<div>{$this->lang->words['tagh_db_pp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comment_approve']</label>
				<div>{$this->lang->words['tagh_db_comma']}</div>
			</li>
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_cats']} <div>{$this->lang->words['tagh__database_catsdesc']}</div>
			</li>
			<li>
				<label>&#36;category['category_id']</label>
				<div>{$this->lang->words['tagh_cat_cid']}</div>
			</li>
			<li>
				<label>&#36;category['category_database_id']</label>
				<div>{$this->lang->words['tagh_cat_dbid']}</div>
			</li>
			<li>
				<label>&#36;category['category_name']</label>
				<div>{$this->lang->words['tagh_cat_cname']}</div>
			</li>
			<li>
				<label>&#36;category['category_parent_id']</label>
				<div>{$this->lang->words['tagh_cat_parent']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_id']</label>
				<div>{$this->lang->words['tagh_cat_last']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_date']</label>
				<div>{$this->lang->words['tagh_cat_ldate']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_member']</label>
				<div>{$this->lang->words['tagh_cat_lmem']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_name']</label>
				<div>{$this->lang->words['tagh_cat_lmemname']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_seo_name']</label>
				<div>{$this->lang->words['tagh_cat_seoname']}</div>
			</li>
			<li>
				<label>&#36;category['category_description']</label>
				<div>{$this->lang->words['tagh_cat_desc']}</div>
			</li>
			<li>
				<label>&#36;category['category_position']</label>
				<div>{$this->lang->words['tagh_cat_pos']}</div>
			</li>
			<li>
				<label>&#36;category['category_records']</label>
				<div>{$this->lang->words['tagh_cat_records']}</div>
			</li>
			<li>
				<label>&#36;category['category_show_records']</label>
				<div>{$this->lang->words['tagh_cat_showr']}</div>
			</li>
			<li>
				<label>&#36;category['category_has_perms']</label>
				<div>{$this->lang->words['tagh_cat_perms']}</div>
			</li>
			<li>
				<label>&#36;category['image']</label>
				<div>{$this->lang->words['tagh_cat_image']}</div>
			</li>
		</ul>
	</div>
	
	<div class='acp-box databaseTags' id='db-tags-listing' {$_listHide}>
		<h3>{$this->lang->words['taghelp__h3_listing']}</h3>
		<ul class='acp-form'>
			<li class='template-tag-cat'>
				{$this->lang->words['taghelp__database_tags']}
			</li>
			<li>
				<label>&#36;data['database']['database_name']</label>
				<div>{$this->lang->words['tagh_db_dbname']}</div>
			</li>
			<li>
				<label>&#36;data['database']['base_link']</label>
				<div>{$this->lang->words['tagh_db_baselink']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_add']</label>
				<div>{$this->lang->words['tagh_db_canadd']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_edit']</label>
				<div>{$this->lang->words['tagh_db_canedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_rate']</label>
				<div>{$this->lang->words['tagh_db_canrate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_comment']</label>
				<div>{$this->lang->words['tagh_db_cancomment']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['moderate_edit']</label>
				<div>{$this->lang->words['tagh_db_modedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_delete']</label>
				<div>{$this->lang->words['tagh_db_moddel']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_deletec']</label>
				<div>{$this->lang->words['tagh_db_moddelc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_lock']</label>
				<div>{$this->lang->words['tagh_db_modlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_unlock']</label>
				<div>{$this->lang->words['tagh_db_modunlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_pin']</label>
				<div>{$this->lang->words['tagh_db_modpin']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approve']</label>
				<div>{$this->lang->words['tagh_db_modapp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approvec']</label>
				<div>{$this->lang->words['tagh_db_modappc']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['database_id']</label>
				<div>{$this->lang->words['tagh_db_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_key']</label>
				<div>{$this->lang->words['tagh_db_dbkey']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_database']</label>
				<div>{$this->lang->words['tagh_db_db']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_description']</label>
				<div>{$this->lang->words['tagh_db_desc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_count']</label>
				<div>{$this->lang->words['tagh_db_fields']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_record_count']</label>
				<div>{$this->lang->words['tagh_db_records']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_categories']</label>
				<div>{$this->lang->words['tagh_db_tplc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_listing']</label>
				<div>{$this->lang->words['tagh_db_tpll']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_display']</label>
				<div>{$this->lang->words['tagh_db_tpld']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_user_editable']</label>
				<div>{$this->lang->words['tagh_db_ue']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_all_editable']</label>
				<div>{$this->lang->words['tagh_db_wiki']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_open']</label>
				<div>{$this->lang->words['tagh_db_open']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comments']</label>
				<div>{$this->lang->words['tagh_db_comments']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_rate']</label>
				<div>{$this->lang->words['tagh_db_rate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_revisions']</label>
				<div>{$this->lang->words['tagh_db_revisions']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_title']</label>
				<div>{$this->lang->words['tagh_db_ft']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_sort']</label>
				<div>{$this->lang->words['tagh_db_fs']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_direction']</label>
				<div>{$this->lang->words['tagh_db_order']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_perpage']</label>
				<div>{$this->lang->words['tagh_db_pp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comment_approve']</label>
				<div>{$this->lang->words['tagh_db_comma']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_cats']} <div>{$this->lang->words['tagh__database_subcatsdesc']}</div>
			</li>
			<li>
				<label>&#36;category['category_id']</label>
				<div>{$this->lang->words['tagh_cat_cid']}</div>
			</li>
			<li>
				<label>&#36;category['category_database_id']</label>
				<div>{$this->lang->words['tagh_cat_dbid']}</div>
			</li>
			<li>
				<label>&#36;category['category_name']</label>
				<div>{$this->lang->words['tagh_cat_cname']}</div>
			</li>
			<li>
				<label>&#36;category['category_parent_id']</label>
				<div>{$this->lang->words['tagh_cat_parent']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_id']</label>
				<div>{$this->lang->words['tagh_cat_last']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_date']</label>
				<div>{$this->lang->words['tagh_cat_ldate']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_member']</label>
				<div>{$this->lang->words['tagh_cat_lmem']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_name']</label>
				<div>{$this->lang->words['tagh_cat_lmemname']}</div>
			</li>
			<li>
				<label>&#36;category['category_last_record_seo_name']</label>
				<div>{$this->lang->words['tagh_cat_seoname']}</div>
			</li>
			<li>
				<label>&#36;category['category_description']</label>
				<div>{$this->lang->words['tagh_cat_desc']}</div>
			</li>
			<li>
				<label>&#36;category['category_position']</label>
				<div>{$this->lang->words['tagh_cat_pos']}</div>
			</li>
			<li>
				<label>&#36;category['category_records']</label>
				<div>{$this->lang->words['tagh_cat_records']}</div>
			</li>
			<li>
				<label>&#36;category['category_show_records']</label>
				<div>{$this->lang->words['tagh_cat_showr']}</div>
			</li>
			<li>
				<label>&#36;category['category_has_perms']</label>
				<div>{$this->lang->words['tagh_cat_perms']}</div>
			</li>
			<li>
				<label>&#36;category['image']</label>
				<div>{$this->lang->words['tagh_cat_image']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_curcat']} <div>{$this->lang->words['tagh__database_curcat_desc']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_id']</label>
				<div>{$this->lang->words['tagh_cat_cid']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_database_id']</label>
				<div>{$this->lang->words['tagh_cat_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_name']</label>
				<div>{$this->lang->words['tagh_cat_cname']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_parent_id']</label>
				<div>{$this->lang->words['tagh_cat_parent']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_last_record_id']</label>
				<div>{$this->lang->words['tagh_cat_last']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_last_record_date']</label>
				<div>{$this->lang->words['tagh_cat_ldate']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_last_record_member']</label>
				<div>{$this->lang->words['tagh_cat_lmem']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_last_record_name']</label>
				<div>{$this->lang->words['tagh_cat_lmemname']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_last_record_seo_name']</label>
				<div>{$this->lang->words['tagh_cat_seoname']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_description']</label>
				<div>{$this->lang->words['tagh_cat_desc']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_position']</label>
				<div>{$this->lang->words['tagh_cat_pos']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_records']</label>
				<div>{$this->lang->words['tagh_cat_records']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_show_records']</label>
				<div>{$this->lang->words['tagh_cat_showr']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['category_has_perms']</label>
				<div>{$this->lang->words['tagh_cat_perms']}</div>
			</li>
			<li>
				<label>&#36;data['parent']['image']</label>
				<div>{$this->lang->words['tagh_cat_image']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_fields']} <div>{$this->lang->words['tagh__database_fields_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_id']</label>
				<div>{$this->lang->words['tagh_field_id']}</div>
			</li>
			<li>
				<label>&#36;field['field_database_id']</label>
				<div>{$this->lang->words['tagh_field_dbid']}</div>
			</li>
			<li>
				<label>&#36;field['field_name']</label>
				<div>{$this->lang->words['tagh_field_title']}</div>
			</li>
			<li>
				<label>&#36;field['field_description']</label>
				<div>{$this->lang->words['tagh_field_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_type']</label>
				<div>{$this->lang->words['tagh_field_type']}</div>
			</li>
			<li>
				<label>&#36;field['field_required']</label>
				<div>{$this->lang->words['tagh_field_req']}</div>
			</li>
			<li>
				<label>&#36;field['field_user_editable']</label>
				<div>{$this->lang->words['tagh_field_ue']}</div>
			</li>
			<li>
				<label>&#36;field['field_position']</label>
				<div>{$this->lang->words['tagh_field_pos']}</div>
			</li>
			<li>
				<label>&#36;field['field_max_length']</label>
				<div>{$this->lang->words['tagh_field_max']}</div>
			</li>
			<li>
				<label>&#36;field['field_extra']</label>
				<div>{$this->lang->words['tagh_field_ex']}</div>
			</li>
			<li>
				<label>&#36;field['field_html']</label>
				<div>{$this->lang->words['tagh_field_html']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_records']} <div>{$this->lang->words['tagh__database_records_desc']}</div>
			</li>
			<li>
				<label>&#36;record['primary_id_field']</label>
				<div>{$this->lang->words['tagh_rec_id']}</div>
			</li>
			<li>
				<label>&#36;record['member_id']</label>
				<div>{$this->lang->words['tagh_rec_mem']}</div>
			</li>
			<li>
				<label>&#36;record['record_saved']</label>
				<div>{$this->lang->words['tagh_rec_saved']}</div>
			</li>
			<li>
				<label>&#36;record['record_updated']</label>
				<div>{$this->lang->words['tagh_rec_updated']}</div>
			</li>
			<li>
				<label>&#36;record['post_key']</label>
				<div>{$this->lang->words['tagh_rec_pk']}</div>
			</li>
			<li>
				<label>&#36;record['rating_real']</label>
				<div>{$this->lang->words['tagh_rec_ratingreal']}</div>
			</li>
			<li>
				<label>&#36;record['rating_hits']</label>
				<div>{$this->lang->words['tagh_rec_ratinghits']}</div>
			</li>
			<li>
				<label>&#36;record['rating_value']</label>
				<div>{$this->lang->words['tagh_rec_ratingttl']}</div>
			</li>
			<li>
				<label>&#36;record['category_id']</label>
				<div>{$this->lang->words['tagh_rec_catid']}</div>
			</li>
			<li>
				<label>&#36;record['record_locked']</label>
				<div>{$this->lang->words['tagh_rec_locked']}</div>
			</li>
			<li>
				<label>&#36;record['record_comments']</label>
				<div>{$this->lang->words['tagh_rec_comments']}</div>
			</li>
			<li>
				<label>&#36;record['record_approved']</label>
				<div>{$this->lang->words['tagh_rec_visible']}</div>
			</li>
			<li>
				<label>&#36;record['record_pinned']</label>
				<div>{$this->lang->words['tagh_rec_pinned']}</div>
			</li>
			<li>
				<label>&#36;record['record_views']</label>
				<div>{$this->lang->words['tagh_rec_views']}</div>
			</li>
			<li>
				<label>&#36;record['_isRead']</label>
				<div>{$this->lang->words['tagh_rec_isread']}</div>
			</li>
HTML;

foreach( $fields as $field )
{
	$_field_field	= sprintf( $this->lang->words['tagh_rec_fieldf'], $field['field_name'] );
	$_field_value	= sprintf( $this->lang->words['tagh_rec_fieldv'], $field['field_name'] );
	
	$IPBHTML .= <<<HTML
			<li>
				<label>&#36;record['field_{$field['field_id']}']</label>
				<div>{$_field_field}</div>
			</li>
			<li>
				<label>&#36;record['field_{$field['field_id']}_value']</label>
				<div>{$_field_value}</div>
			</li>
HTML;
}

$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_misc']}
			</li>
			<li>
				<label>&#36;data['pages']</label>
				<div>{$this->lang->words['tagh_pagelinks']}</div>
			</li>
			<li>
				<label>&#36;data['show']</label>
				<div>{$this->lang->words['tagh_show_rec']}</div>
			</li>
HTML;

if( $this->request['type'] == 6 )
{
	$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$this->lang->words['tagh3_specialtags']} <div>{$this->lang->words['tagh3_specialtagsdesc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['title']</label>
				<div>{$this->lang->words['tagh_articletitle']}</div>
			</li>
			<li>
				<label>&#36;data['special']['content']</label>
				<div>{$this->lang->words['tagh_articlecontent']}</div>
			</li>
			<li>
				<label>&#36;data['special']['frontpage']</label>
				<div>{$this->lang->words['tagh_articlefp']}</div>
			</li>
			<li>
				<label>&#36;data['special']['date']</label>
				<div>{$this->lang->words['tagh_articledate']}</div>
			</li>
			<li>
				<label>&#36;data['special']['expiry']</label>
				<div>{$this->lang->words['tagh_articleexpiry']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_allowed']</label>
				<div>{$this->lang->words['tagh_articleca']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_cutoff']</label>
				<div>{$this->lang->words['tagh_articlecc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['image']</label>
				<div>{$this->lang->words['tagh_articleimage']}</div>
			</li>
HTML;
}

$IPBHTML .= <<<HTML
		</ul>
	</div>
	
	<div class='acp-box databaseTags' id='db-tags-display' {$_showHide}>
		<h3>{$this->lang->words['taghelp__h3_display']}</h3>
		<ul class='acp-form'>
			<li class='template-tag-cat'>
				{$this->lang->words['taghelp__database_tags']}
			</li>
			<li>
				<label>&#36;data['database']['database_name']</label>
				<div>{$this->lang->words['tagh_db_dbname']}</div>
			</li>
			<li>
				<label>&#36;data['database']['base_link']</label>
				<div>{$this->lang->words['tagh_db_baselink']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_add']</label>
				<div>{$this->lang->words['tagh_db_canadd']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_edit']</label>
				<div>{$this->lang->words['tagh_db_canedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_rate']</label>
				<div>{$this->lang->words['tagh_db_canrate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_comment']</label>
				<div>{$this->lang->words['tagh_db_cancomment']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['moderate_edit']</label>
				<div>{$this->lang->words['tagh_db_modedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_delete']</label>
				<div>{$this->lang->words['tagh_db_moddel']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_deletec']</label>
				<div>{$this->lang->words['tagh_db_moddelc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_lock']</label>
				<div>{$this->lang->words['tagh_db_modlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_unlock']</label>
				<div>{$this->lang->words['tagh_db_modunlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_pin']</label>
				<div>{$this->lang->words['tagh_db_modpin']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approve']</label>
				<div>{$this->lang->words['tagh_db_modapp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approvec']</label>
				<div>{$this->lang->words['tagh_db_modappc']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['database_id']</label>
				<div>{$this->lang->words['tagh_db_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_key']</label>
				<div>{$this->lang->words['tagh_db_dbkey']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_database']</label>
				<div>{$this->lang->words['tagh_db_db']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_description']</label>
				<div>{$this->lang->words['tagh_db_desc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_count']</label>
				<div>{$this->lang->words['tagh_db_fields']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_record_count']</label>
				<div>{$this->lang->words['tagh_db_records']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_categories']</label>
				<div>{$this->lang->words['tagh_db_tplc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_listing']</label>
				<div>{$this->lang->words['tagh_db_tpll']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_display']</label>
				<div>{$this->lang->words['tagh_db_tpld']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_user_editable']</label>
				<div>{$this->lang->words['tagh_db_ue']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_all_editable']</label>
				<div>{$this->lang->words['tagh_db_wiki']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_open']</label>
				<div>{$this->lang->words['tagh_db_open']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comments']</label>
				<div>{$this->lang->words['tagh_db_comments']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_rate']</label>
				<div>{$this->lang->words['tagh_db_rate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_revisions']</label>
				<div>{$this->lang->words['tagh_db_revisions']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_title']</label>
				<div>{$this->lang->words['tagh_db_ft']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_sort']</label>
				<div>{$this->lang->words['tagh_db_fs']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_direction']</label>
				<div>{$this->lang->words['tagh_db_order']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_perpage']</label>
				<div>{$this->lang->words['tagh_db_pp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comment_approve']</label>
				<div>{$this->lang->words['tagh_db_comma']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_fields']} <div>{$this->lang->words['tagh__database_fields_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_id']</label>
				<div>{$this->lang->words['tagh_field_id']}</div>
			</li>
			<li>
				<label>&#36;field['field_database_id']</label>
				<div>{$this->lang->words['tagh_field_dbid']}</div>
			</li>
			<li>
				<label>&#36;field['field_name']</label>
				<div>{$this->lang->words['tagh_field_title']}</div>
			</li>
			<li>
				<label>&#36;field['field_description']</label>
				<div>{$this->lang->words['tagh_field_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_type']</label>
				<div>{$this->lang->words['tagh_field_type']}</div>
			</li>
			<li>
				<label>&#36;field['field_required']</label>
				<div>{$this->lang->words['tagh_field_req']}</div>
			</li>
			<li>
				<label>&#36;field['field_user_editable']</label>
				<div>{$this->lang->words['tagh_field_ue']}</div>
			</li>
			<li>
				<label>&#36;field['field_position']</label>
				<div>{$this->lang->words['tagh_field_pos']}</div>
			</li>
			<li>
				<label>&#36;field['field_max_length']</label>
				<div>{$this->lang->words['tagh_field_max']}</div>
			</li>
			<li>
				<label>&#36;field['field_extra']</label>
				<div>{$this->lang->words['tagh_field_ex']}</div>
			</li>
			<li>
				<label>&#36;field['field_html']</label>
				<div>{$this->lang->words['tagh_field_html']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_records']} <div>{$this->lang->words['tagh__database_record_view']}</div>
			</li>
			<li>
				<label>&#36;data['record']['primary_id_field']</label>
				<div>{$this->lang->words['tagh_rec_id']}</div>
			</li>
			<li>
				<label>&#36;data['record']['member_id']</label>
				<div>{$this->lang->words['tagh_rec_mem']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_saved']</label>
				<div>{$this->lang->words['tagh_rec_saved']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_updated']</label>
				<div>{$this->lang->words['tagh_rec_updated']}</div>
			</li>
			<li>
				<label>&#36;data['record']['post_key']</label>
				<div>{$this->lang->words['tagh_rec_pk']}</div>
			</li>
			<li>
				<label>&#36;data['record']['rating_real']</label>
				<div>{$this->lang->words['tagh_rec_ratingreal']}</div>
			</li>
			<li>
				<label>&#36;data['record']['rating_hits']</label>
				<div>{$this->lang->words['tagh_rec_ratinghits']}</div>
			</li>
			<li>
				<label>&#36;data['record']['rating_value']</label>
				<div>{$this->lang->words['tagh_rec_ratingttl']}</div>
			</li>
			<li>
				<label>&#36;data['record']['category_id']</label>
				<div>{$this->lang->words['tagh_rec_catid']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_locked']</label>
				<div>{$this->lang->words['tagh_rec_locked']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_comments']</label>
				<div>{$this->lang->words['tagh_rec_comments']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_approved']</label>
				<div>{$this->lang->words['tagh_rec_visible']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_pinned']</label>
				<div>{$this->lang->words['tagh_rec_pinned']}</div>
			</li>
			<li>
				<label>&#36;data['record']['record_views']</label>
				<div>{$this->lang->words['tagh_rec_views']}</div>
			</li>
HTML;

foreach( $fields as $field )
{
	$_field_field	= sprintf( $this->lang->words['tagh_rec_fieldf'], $field['field_name'] );
	$_field_value	= sprintf( $this->lang->words['tagh_rec_fieldv'], $field['field_name'] );
	
	$IPBHTML .= <<<HTML
			<li>
				<label>&#36;data['record']['field_{$field['field_id']}']</label>
				<div>{$_field_field}</div>
			</li>
			<li>
				<label>&#36;data['record']['field_{$field['field_id']}_value']</label>
				<div>{$_field_value}</div>
			</li>
HTML;
}

$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_misc']}
			</li>
			<li>
				<label>&#36;data['comments']</label>
				<div>{$this->lang->words['tagh_comments']}</div>
			</li>
HTML;

if( $this->request['type'] == 5 )
{
	$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$this->lang->words['tagh3_specialtags']} <div>{$this->lang->words['tagh3_specialtagsdesc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['title']</label>
				<div>{$this->lang->words['tagh_articletitle']}</div>
			</li>
			<li>
				<label>&#36;data['special']['content']</label>
				<div>{$this->lang->words['tagh_articlecontent']}</div>
			</li>
			<li>
				<label>&#36;data['special']['frontpage']</label>
				<div>{$this->lang->words['tagh_articlefp']}</div>
			</li>
			<li>
				<label>&#36;data['special']['date']</label>
				<div>{$this->lang->words['tagh_articledate']}</div>
			</li>
			<li>
				<label>&#36;data['special']['expiry']</label>
				<div>{$this->lang->words['tagh_articleexpiry']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_allowed']</label>
				<div>{$this->lang->words['tagh_articleca']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_cutoff']</label>
				<div>{$this->lang->words['tagh_articlecc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['image']</label>
				<div>{$this->lang->words['tagh_articleimage']}</div>
			</li>
HTML;
}

$IPBHTML .= <<<HTML
		</ul>
	</div>
	
	<div class='acp-box databaseTags' id='db-tags-frontpage' {$_fpHide}>
		<h3>{$this->lang->words['taghelp__h3_listing']}</h3>
		<ul class='acp-form'>
			<li class='template-tag-cat'>
				{$this->lang->words['taghelp__database_tags']}
			</li>
			<li>
				<label>&#36;data['database']['database_name']</label>
				<div>{$this->lang->words['tagh_db_dbname']}</div>
			</li>
			<li>
				<label>&#36;data['database']['base_link']</label>
				<div>{$this->lang->words['tagh_db_baselink']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_add']</label>
				<div>{$this->lang->words['tagh_db_canadd']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_edit']</label>
				<div>{$this->lang->words['tagh_db_canedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_rate']</label>
				<div>{$this->lang->words['tagh_db_canrate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['_can_comment']</label>
				<div>{$this->lang->words['tagh_db_cancomment']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['moderate_edit']</label>
				<div>{$this->lang->words['tagh_db_modedit']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_delete']</label>
				<div>{$this->lang->words['tagh_db_moddel']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_deletec']</label>
				<div>{$this->lang->words['tagh_db_moddelc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_lock']</label>
				<div>{$this->lang->words['tagh_db_modlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_unlock']</label>
				<div>{$this->lang->words['tagh_db_modunlock']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_pin']</label>
				<div>{$this->lang->words['tagh_db_modpin']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approve']</label>
				<div>{$this->lang->words['tagh_db_modapp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['moderate_approvec']</label>
				<div>{$this->lang->words['tagh_db_modappc']}</div>
			</li>
			
			<li>
				<label>&#36;data['database']['database_id']</label>
				<div>{$this->lang->words['tagh_db_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_key']</label>
				<div>{$this->lang->words['tagh_db_dbkey']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_database']</label>
				<div>{$this->lang->words['tagh_db_db']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_description']</label>
				<div>{$this->lang->words['tagh_db_desc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_count']</label>
				<div>{$this->lang->words['tagh_db_fields']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_record_count']</label>
				<div>{$this->lang->words['tagh_db_records']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_categories']</label>
				<div>{$this->lang->words['tagh_db_tplc']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_listing']</label>
				<div>{$this->lang->words['tagh_db_tpll']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_template_display']</label>
				<div>{$this->lang->words['tagh_db_tpld']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_user_editable']</label>
				<div>{$this->lang->words['tagh_db_ue']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_all_editable']</label>
				<div>{$this->lang->words['tagh_db_wiki']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_open']</label>
				<div>{$this->lang->words['tagh_db_open']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comments']</label>
				<div>{$this->lang->words['tagh_db_comments']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_rate']</label>
				<div>{$this->lang->words['tagh_db_rate']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_revisions']</label>
				<div>{$this->lang->words['tagh_db_revisions']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_title']</label>
				<div>{$this->lang->words['tagh_db_ft']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_sort']</label>
				<div>{$this->lang->words['tagh_db_fs']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_direction']</label>
				<div>{$this->lang->words['tagh_db_order']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_field_perpage']</label>
				<div>{$this->lang->words['tagh_db_pp']}</div>
			</li>
			<li>
				<label>&#36;data['database']['database_comment_approve']</label>
				<div>{$this->lang->words['tagh_db_comma']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__categoriesfp']} <div>{$this->lang->words['tagh__categoriesfpdesc']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_id']</label>
				<div>{$this->lang->words['tagh_cat_cid']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_database_id']</label>
				<div>{$this->lang->words['tagh_cat_dbid']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_name']</label>
				<div>{$this->lang->words['tagh_cat_cname']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_parent_id']</label>
				<div>{$this->lang->words['tagh_cat_parent']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_last_record_id']</label>
				<div>{$this->lang->words['tagh_cat_last']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_last_record_date']</label>
				<div>{$this->lang->words['tagh_cat_ldate']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_last_record_member']</label>
				<div>{$this->lang->words['tagh_cat_lmem']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_last_record_name']</label>
				<div>{$this->lang->words['tagh_cat_lmemname']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_last_record_seo_name']</label>
				<div>{$this->lang->words['tagh_cat_seoname']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_description']</label>
				<div>{$this->lang->words['tagh_cat_desc']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_position']</label>
				<div>{$this->lang->words['tagh_cat_pos']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_records']</label>
				<div>{$this->lang->words['tagh_cat_records']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_show_records']</label>
				<div>{$this->lang->words['tagh_cat_showr']}</div>
			</li>
			<li>
				<label>&#36;data['category']['category_has_perms']</label>
				<div>{$this->lang->words['tagh_cat_perms']}</div>
			</li>
			<li>
				<label>&#36;data['category']['image']</label>
				<div>{$this->lang->words['tagh_cat_image']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_fields']} <div>{$this->lang->words['tagh__database_fields_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_id']</label>
				<div>{$this->lang->words['tagh_field_id']}</div>
			</li>
			<li>
				<label>&#36;field['field_database_id']</label>
				<div>{$this->lang->words['tagh_field_dbid']}</div>
			</li>
			<li>
				<label>&#36;field['field_name']</label>
				<div>{$this->lang->words['tagh_field_title']}</div>
			</li>
			<li>
				<label>&#36;field['field_description']</label>
				<div>{$this->lang->words['tagh_field_desc']}</div>
			</li>
			<li>
				<label>&#36;field['field_type']</label>
				<div>{$this->lang->words['tagh_field_type']}</div>
			</li>
			<li>
				<label>&#36;field['field_required']</label>
				<div>{$this->lang->words['tagh_field_req']}</div>
			</li>
			<li>
				<label>&#36;field['field_user_editable']</label>
				<div>{$this->lang->words['tagh_field_ue']}</div>
			</li>
			<li>
				<label>&#36;field['field_position']</label>
				<div>{$this->lang->words['tagh_field_pos']}</div>
			</li>
			<li>
				<label>&#36;field['field_max_length']</label>
				<div>{$this->lang->words['tagh_field_max']}</div>
			</li>
			<li>
				<label>&#36;field['field_extra']</label>
				<div>{$this->lang->words['tagh_field_ex']}</div>
			</li>
			<li>
				<label>&#36;field['field_html']</label>
				<div>{$this->lang->words['tagh_field_html']}</div>
			</li>
			
			<li class='template-tag-cat'>
				{$this->lang->words['tagh__database_records']} <div>{$this->lang->words['tagh__database_records_desc']}</div>
			</li>
			<li>
				<label>&#36;record['primary_id_field']</label>
				<div>{$this->lang->words['tagh_rec_id']}</div>
			</li>
			<li>
				<label>&#36;record['member_id']</label>
				<div>{$this->lang->words['tagh_rec_mem']}</div>
			</li>
			<li>
				<label>&#36;record['record_saved']</label>
				<div>{$this->lang->words['tagh_rec_saved']}</div>
			</li>
			<li>
				<label>&#36;record['record_updated']</label>
				<div>{$this->lang->words['tagh_rec_updated']}</div>
			</li>
			<li>
				<label>&#36;record['post_key']</label>
				<div>{$this->lang->words['tagh_rec_pk']}</div>
			</li>
			<li>
				<label>&#36;record['rating_real']</label>
				<div>{$this->lang->words['tagh_rec_ratingreal']}</div>
			</li>
			<li>
				<label>&#36;record['rating_hits']</label>
				<div>{$this->lang->words['tagh_rec_ratinghits']}</div>
			</li>
			<li>
				<label>&#36;record['rating_value']</label>
				<div>{$this->lang->words['tagh_rec_ratingttl']}</div>
			</li>
			<li>
				<label>&#36;record['category_id']</label>
				<div>{$this->lang->words['tagh_rec_catid']}</div>
			</li>
			<li>
				<label>&#36;record['record_locked']</label>
				<div>{$this->lang->words['tagh_rec_locked']}</div>
			</li>
			<li>
				<label>&#36;record['record_comments']</label>
				<div>{$this->lang->words['tagh_rec_comments']}</div>
			</li>
			<li>
				<label>&#36;record['record_approved']</label>
				<div>{$this->lang->words['tagh_rec_visible']}</div>
			</li>
			<li>
				<label>&#36;record['record_pinned']</label>
				<div>{$this->lang->words['tagh_rec_pinned']}</div>
			</li>
			<li>
				<label>&#36;record['record_views']</label>
				<div>{$this->lang->words['tagh_rec_views']}</div>
			</li>
			<li>
				<label>&#36;record['_isRead']</label>
				<div>{$this->lang->words['tagh_rec_isread']}</div>
			</li>
HTML;

foreach( $fields as $field )
{
	$_field_field	= sprintf( $this->lang->words['tagh_rec_fieldf'], $field['field_name'] );
	$_field_value	= sprintf( $this->lang->words['tagh_rec_fieldv'], $field['field_name'] );
	
	$IPBHTML .= <<<HTML
			<li>
				<label>&#36;record['field_{$field['field_id']}']</label>
				<div>{$_field_field}</div>
			</li>
			<li>
				<label>&#36;record['field_{$field['field_id']}_value']</label>
				<div>{$_field_value}</div>
			</li>
HTML;
}

$IPBHTML .= <<<HTML
			<li class='template-tag-cat'>
				{$this->lang->words['tagh3_specialtags']} <div>{$this->lang->words['tagh3_specialtagsdesc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['title']</label>
				<div>{$this->lang->words['tagh_articletitle']}</div>
			</li>
			<li>
				<label>&#36;data['special']['content']</label>
				<div>{$this->lang->words['tagh_articlecontent']}</div>
			</li>
			<li>
				<label>&#36;data['special']['frontpage']</label>
				<div>{$this->lang->words['tagh_articlefp']}</div>
			</li>
			<li>
				<label>&#36;data['special']['date']</label>
				<div>{$this->lang->words['tagh_articledate']}</div>
			</li>
			<li>
				<label>&#36;data['special']['expiry']</label>
				<div>{$this->lang->words['tagh_articleexpiry']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_allowed']</label>
				<div>{$this->lang->words['tagh_articleca']}</div>
			</li>
			<li>
				<label>&#36;data['special']['comments_cutoff']</label>
				<div>{$this->lang->words['tagh_articlecc']}</div>
			</li>
			<li>
				<label>&#36;data['special']['image']</label>
				<div>{$this->lang->words['tagh_articleimage']}</div>
			</li>
		</ul>
	</div>
<!--</div>-->
HTML;
//--endhtml--//
return $IPBHTML;
}

}