<? $this->title->create($this->Language('Content')); ?>


<form style="text-align:right;margin-bottom:10px;padding-right:12px;">
<input type="hidden" name="model" value="content"/>
<input type="hidden" name="page" value="content_list"/>
<input type="text" name="search" value="<?=$_GET['search'];?>"/> <input type="submit" name="search_content" value="<?=$this->Language('Search');?>"/> <a href="<?=$this->Link();?>"><?=$this->Language('Clear');?></a>
</form>


<form method="POST" action="" name="content_form" enctype="multipart/form-data">
<input type="hidden" name="form_type" value="basic">

<table class="content" id="content_list">
<thead>
<tr>
	<th width="10"></th>
	<th width="10"></th>
	<th><?=$this->Language('name');?></th>
	<th><?=$this->Language('url');?></th>
	<!--<th><?=$this->Language('to next page');?></th>
	<th><?=$this->Language('show sub as listing');?></th>-->
	<th><?=$this->Language('is first page');?></th>
	<th><?=$this->Language('is menu active');?></th>
	<th><?=$this->Language('is content active');?></th>
	<th></th>
	<th></th>
</tr>
<tr>
	<td></td>
	<td></td>
	<td><input type="text" class="name" name="name" value=""></td>
	<td><input type="text" class="url" name="url" value=""> <span style="font-size:10px;"><?=$this->Language('(if not default)');?></span></td>
	<!--<td><input type="checkbox" class="to_next_menu" name="to_next_menu" value="1"></td>
	<td><input type="checkbox" class="show_sub_as_listing" name="show_sub_as_listing" value="1"></td>-->
	<td><input type="checkbox" class="is_first_page" name="is_first_page" value="1"></td>
	<td><input type="checkbox" class="is_enabled" name="is_enabled" value="1" checked="ckecked"></td>
	<td><input type="checkbox" class="is_active" name="is_active" value="1" checked="ckecked"></td>
	<td></td>
	<td><input type="submit" class="insert set_action" name="insert" value="<?=$this->Language('Insert');?>"></td>
</tr>
</thead>
<tbody>
<?
if(!empty($this->ContentList)){

	$array = array();
	if($_SESSION['register_parent_id'])
		$array = $_SESSION['register_parent_id'];

	foreach($this->ContentList as $row){

		$row = $this->manipulate_rows($row);
		$hidden = $row['parent_id'] > 0 && !in_array($row['parent_id'], $array) ? 'hidden ' : '';
		$open = !in_array($row['id'], $array) ? '+' : '-';
		?>
		<tr class="<?=$hidden.'submenu_'.$row['parent_id'];?>" id="id_<?=$row['id'];?>">
			<td>
			<?
			if($row['have_sub_menus']){
				?>
				<a href="#<?=$row['id']?>" class="cursor show_sub_menu current_sub_menu_link_<?=$row['id'];?>" style="color:black;"><?=$open;?></a>
				<?
			}
			?>
			</td>
			<td style="white-space: nowrap">
				<?
				if($row['down_visible'] == true) {
					echo '<a href="'.$this->Link('?action=down&id='.$row['id'].'&template_id='.$row['template_id'].'&queue='.$row['queue']).'" class="down_link" style="margin-left:'.$row['margin_left_down'].'px;">'.$row['down'].'</a>';
				}
				if($row['up_visible'] == true) {
					echo '<a href="'.$this->Link('?action=up&id='.$row['id'].'&template_id='.$row['template_id'].'&queue='.$row['queue']).'" class="up_link" style="margin-left:'.$row['margin_left_up'].'px;">'.$row['up'].'</a>';
				}
				?>
			</td>
			<td><?=$row['space'];?><a href="?model=content&page=edit&id=<?=$row['related_id'];?>&template_id=<?=$row['template_id'];?>" class="menu_link"><?=$row['name'];?></a></td>
			<td><?=$row['url'];?></td>
			<!--<td><a href="<?=$this->Link('?action='.($row['to_next_menu'] == 1 ? 'disable_next_menu' : 'enable_next_menu').'&id='.$row['id']);?>"><?=$this->Language($row['to_next_menu'] == 1 ? 'yes' : 'no');?></a></td>
			<td><a href="<?=$this->Link('?action='.($row['show_sub_as_listing'] == 1 ? 'disable_sub_menu_listing' : 'enable_sub_menu_listing').'&id='.$row['id']);?>"><?=$this->Language($row['show_sub_as_listing'] == 1 ? 'yes' : 'no');?></a></td>-->
			<td><a href="<?=$this->Link('?action='.($row['is_first_page'] == 1 ? 'disable_firstpage_menu' : 'enable_firstpage_menu').'&id='.$row['template_id']);?>"><?=$this->Language($row['is_first_page'] == 1 ? 'yes' : 'no');?></a></td>
			<td><a href="<?=$this->Link('?action='.($row['is_enabled'] == 1 ? 'disable_menu' : 'enable_menu').'&id='.$row['id']);?>"><?=$this->Language($row['is_enabled'] == 1 ? 'yes' : 'no');?></a></td>
			<td><a href="<?=$this->Link('?action='.($row['is_active'] == 1 ? 'disable_template' : 'enable_template').'&id='.$row['template_id']);?>"><?=$this->Language($row['is_active'] == 1 ? 'yes' : 'no');?></a></td>
			<td><a href="<?=$this->Link('?action=delete&id='.$row['id']);?>" class="delete" alt="<?=htmlentities($this->Language('delete').' "'.$row['name'].'"');?>"><?=$this->Language('delete');?></a></td>
			<td><a href="<?=$this->Link('?action=append&id='.$row['id']);?>"><?=$this->Language('append sub menu');?></a></td>
		</tr>

		<?
		if($_GET['action'] == 'append' && $_GET['id'] == $row['id']){
			?>
			<tr>
				<td></td>
				<td></td>
				<td><input type="text" class="name" name="append[name]" value=""></td>
				<td><input type="text" class="url" name="append[url]" value=""></td>
				<!--<td><input type="checkbox" class="to_next_menu" name="append[to_next_menu]" value="1"></td>
				<td><input type="checkbox" class="show_sub_as_listing" name="append[show_sub_as_listing]" value="1"></td>-->
				<td><input type="checkbox" class="is_first_page" name="append[is_first_page]" value="1"></td>
				<td><input type="checkbox" class="is_enabled" name="append[is_enabled]" value="1" checked="ckecked"></td>
				<td><input type="checkbox" class="is_active" name="append[is_active]" value="1" checked="ckecked"></td>
				<td></td>
				<td><input type="submit" class="insert" name="insert" value="<?=$this->Language('Insert');?>"> <a href="<?=$this->Link();?>"><?=$this->Language('cancel');?></a></td>
			</tr>
			<?
		}
	}
}
?>
</tbody>
</table>
</form>



<script type="text/javascript">
$('.set_action').click(function(){

	$('[name=content_form]').attr({'action' : '?model=content&page=content_list'});
});
</script>