<?php
/*
=====================================================
 Модуль создал: REZER (http://rezer.net)
=====================================================
 Файл: fields.php
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Назначение: Вывод всех дополнительных полей
=====================================================
*/

if( !defined( "DATALIFEENGINE" ) ) die( "Hacking attempt!" );

if( $Board->Field === false ) $Board->StartField( true );

$list = "";	
if( count( $Board->Field->DB ) > 0 )
	{
		$list .= showStart();
		foreach( $Board->Field->DB as $row )
			{
				$id = $row[0];
				$alt_name = stripslashes( $row[1] );
				$name = stripslashes( $row[2] );
				$sort = intval( $row['11'] );
				$type = $Board->Field->TypeName[ $row[12] ];
						
				$FilterHtml = $row[3] == 1 ? "Да" : "Нет";
				$FilterJs = ( $row[3] == 1 && $row[4] == 1 ) ? "Да" : "Нет";
				$FilterBr = $row[5] == 1 ? "Да" : "Нет";
				$ShowCreate = $row[8] == 1 ? "Да" : "Нет";
				$Allow_Edit = $row[9] == 1 ? "Да" : "Нет";
				$Required = ( $row[10] == 1 && ( $row[9] == 1 || $row[8] == 1 ) ) ? "Да" : "Нет";
				$AllowEdit = implode( ",", $row[6] );
				$AllowShow = implode( ",", $row[7] );
				
$list .= <<<HTML

<div id="del_Field_{$id}">
	<table width="100%" border="0">
		<tr height="30px" onmouseover="this.bgColor='#F1F7FE'" onmouseout="this.bgColor='#FFFFFF'">
			<td width="50px" align="center" id="StatusIDField_{$id}">{$id}</td>
			<td>
				<a href="javascript:void(0);" onmouseover="showhint( '<b>Альтернативное имя:</b> {$alt_name}<br /><b>Разрешить HTML:</b> {$FilterHtml}<br /><b>Разрешить JS:</b> {$FilterJs}<br /><b>Новые строки на br:</b> {$FilterBr}<br /><b>Показ при создании:</b> {$ShowCreate}<br /><b>Ред. после создания:</b> {$Allow_Edit}<br /><b>Обязательное поле:</b> {$Required}<br /><b>Разрешено редактировать:</b> {$AllowEdit}<br /><b>Разрешено просматривать:</b> {$AllowShow}', this, event, '250px')" onclick="EditField( '{$id}' ); return false;">{$name}</a>
			</td>
			<td width="150px" align="center">{$type}</td>
			<td width="100px" align="center">
				<input type="text" name="sort[{$id}]" value="{$sort}" style="text-align: center; width: 40px;" class="edit" />
			</td>
			<td width="100px" align="center">
				<a onclick="return dropdownmenu( this, event, MenuField( '{$id}' ), '120px')" href="javascript:void(0);">
					<img src="engine/skins/images/browser_action.gif" border="0">
				</a>
			</td>
			<td width="30px">
				<input type="checkbox" name="CheckFields[]" value="{$id}" />
			</td>
		</tr>
		<tr>
			<td colspan="10" background="engine/skins/images/mline.gif" height="1"></td>
		</tr>
	</table>
</div>

HTML;

			}
	}
		else
	{
		$list = showStart()."<div style=\"padding: 15px; text-align: center;\">Дополнительных полей не обнаружено</div>".showStart();
	}

$list = <<<HTML

<form name="fields" method="post" action="" onsubmit="SetFormSubmit( 'fields' ); return false;">
	<table width="100%" border="0" style="margin: 2px 0px 2px 0px;">
		<tr>
			<td width="50px" align="center">ID</td>
			<td>Название</td>
			<td width="150px" align="center">Тип</td>
			<td width="100px" align="center">Сортировка</td>
			<td width="100px" align="center">Действие</td>
			<td width="30px">
				<input type="checkbox" name="ChecboxAll" onclick="CheckboxAllSelect( 'fields' );" />
			</td>
		</tr>
	</table>
	<div class="hr_line"></div>
	{$list}
	<div class="hr_line"></div>
	<div style="padding: 5px;">
		<table width="100%" border="0">
			<tr>
				<td>
					<input type="button" value="Добавить поле" class="edit" onclick="AddField(); return false;" />
				</td>
				<td align="right">
					<span id="status_fields"></span>
					<select name="action" id="action_fields">
						<option value=""> - Выберите действие - </option>
						<option value="sort">Отсортировать</option>
						<option value="del">Удалить</option>
					</select>
					<input type="submit" name="submit" value="Сохранить" class="edit" />
					<input type="hidden" name="TypeAction" value="fields" />
				</td>
			</tr>
		</table>
	</div>
</form>

HTML;

opentable();
tableheader( "Список дополнительных полей" );
echo $list;
closetable();

?>