<?php
	!defined('IN_MANAGE') && exit('Access Denied!');
	$action=empty($action)?'manage':trim($action);
	$moduleid=$moduleobj->getmoduleid($mod);
	$settings=$configobj->getconfig($_SESSION['siteid'],$moduleid);

	switch($action)
	{
		case 'manage':
			if(isset($do_submit))
			{
				switch($job)
				{
					case 'settop':
						if($pageobj->pageset(array('istop'=>1),$id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
					case 'unsettop':
						if($pageobj->pageset(array('istop'=>0),$id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
					case 'pass':
						if($pageobj->pageset(array('status'=>1),$id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
					case 'unpass':
						if($pageobj->pageset(array('status'=>0),$id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
					case 'delete':
						if($pageobj->page_delete($id,0))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
				}
			}
			else
			{

				$starttime=isset($info['starttime'])?strtotime($info['starttime']):'';
				$endtime=isset($info['endtime'])?strtotime($info['endtime']):'';
				$k=isset($k)?htmlspecialchars($k):'';

				$result=$pageobj->pagelist($starttime,$endtime,$k);
				include admin_tlp('manage',$mod);
			}
			break;
		case 'add':
			if(isset($do_submit))
			{
				$info['moduleid']=$moduleid;
				$_image=imageupload('image_file',array('png','gif','jpg','jpeg'));

				if($_image)
				{
					$info['image']=$_image;
				}
				if($pageobj->admin_page_add($info))
				{
					admin_success($adminlang['manage_success']);
				}
				else
				{
					admin_error($adminlang['manage_error']);
				}
			}
			include admin_tlp('page_add',$mod);
			break;
		case 'edit':
			$id=intval($id);
			if(isset($do_submit))
			{
				$info['moduleid']=$moduleid;
				$_image=imageupload('image_file',array('png','gif','jpg','jpeg'));

				if($_image)
				{
					$info['image']=$_image;
				}
				if($pageobj->admin_page_edit($info,$id))
				{
					admin_success($adminlang['manage_success']);
				}
				else
				{
					admin_error($adminlang['manage_error']);
				}
			}
			
			$info=$pageobj->getpage($id);
			include admin_tlp('page_edit',$mod);
			break;
		case 'type':
			if(isset($job))
			{
				if($job=='edit')
				{
					if(isset($do_submit))
					{
						$info['moduleid']=$moduleid;
						if($pageobj->type_edit($info,$id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
					}
					else
					{
						$info=$pageobj->typeinfo($id);
						include admin_tlp('type_edit',$mod);
					}
				}
				else if($job=='delete')
				{
					if($pageobj->type_delete($id))
					{
						admin_success($adminlang['manage_success']);
					}
					else
					{
						admin_error($adminlang['manage_error']);
					}
				}
			}
			else
			{
				$result=$pageobj->typelist($parentid);
				include admin_tlp('type',$mod);
			}
			break;
		case 'type_add':
			if(isset($do_submit))
			{
				$info['moduleid']=$moduleid;
				if($pageobj->type_add($info))
				{
					admin_success($adminlang['manage_success']);
				}
				else
				{
					admin_error($adminlang['manage_error']);
				}
			}
			include admin_tlp('type_add',$mod);
			break;
	}
?>