<?
$files = "(SELECT COUNT(*) FROM file WHERE record_id=t1.id AND source='".$table."') AS files";

switch ($table) {
    case 'page':
        if (strlen($sort) == 0) {
            $sort = 'sequence ASC, page ASC, subpage ASC, subsubpage ASC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.page,
		t1.subpage,
		t1.subsubpage, 
		t1.name AS link_name,
		t1.home,
		t1.hidden,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
    case 'news':
        if (strlen($sort) == 0) {
            $sort = 'news_date DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.headline,
		t1.news_date, 
		t1.hidden, 
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'event':
        if (strlen($sort) == 0) {
            $sort = 'start_date DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.name,
		t1.start_date, 
		t1.end_date,
		t1.hidden,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
    case 'article':
        if (strlen($sort) == 0) {
            $sort = 'article_date DESC';
        }
        $columns = "
		t1.status,
		t1.id,

		t1.name,
		t1.article_date,
		t1.hidden,

		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated,
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'gallery':
        if (strlen($sort) == 0) {
            $sort = 't1.sequence ASC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
        (SELECT name FROM gallery_category WHERE id=t1.gallery_category_id) AS category,
		t1.name,
		t1.description,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'gallery_category':
        if (strlen($sort) == 0) {
            $sort = 'id DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.name,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
    case 'slideshow':
        if (strlen($sort) == 0) {
            $sort = 'sequence ASC, name ASC';
        }
        $columns = "
		t1.status,
		t1.id,

		t1.name,

		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated,
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'advert':
        if (strlen($sort) == 0) {
            $sort = 'sequence ASC, name ASC, position ASC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.name,
		t1.position, 
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'newsletter':
        if (strlen($sort) == 0) {
            $sort = 'id DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.heading,
        t1.link_name,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created, ".$files;
        break;
    case 'contact':
        if (strlen($sort) == 0) {
            $sort = 'id DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.first_name,
		t1.last_name,
		CONCAT('<a href=\"mailto:',t1.email,'\">',t1.email,'</a>') AS email, 
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
    case 'contact_category':
        if (strlen($sort) == 0) {
            $sort = 'id DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.name,
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
    case 'client':
		if (strlen($sort) == 0) {
			$sort = 'last_name ASC, first_name ASC, year_matric ASC';
		}
		$columns = "
		t1.status,
		t1.id,

		t1.first_name,
		t1.last_name,
        t1.maiden_name,
        t1.year_matric,
		CONCAT('<a href=\"mailto:',t1.email,'\">',t1.email,'</a>') AS email,

		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated,
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
		break;
    case 'user':
        if (strlen($sort) == 0) {
            $sort = 'id DESC';
        }
        $columns = "
		t1.status, 
		t1.id, 
		
		t1.first_name, 
		t1.last_name, 
		CONCAT('<a href=\"mailto:',t1.email,'\">',t1.email,'</a>') AS email, 
		
		DATE_FORMAT(t1.date_modified, '%d-%m-%Y') AS updated, 
		DATE_FORMAT(t1.date_created, '%d-%m-%Y') AS created";
        break;
}
?>