<?php
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Ajax загрузчик формы списка исправленных таблиц.
 * 
 * Файл: /admin/ExecSqlQuery/action/load_repair_table.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
function LoadAjaxData(&$admin_forms)
{
	$on_page = $admin_forms->GetOnPageCount();

	$page = to_int($_REQUEST['limit']);
	$begin = ($page == 0) ? 0 : ($page - 1) * $on_page;

	$param = array();

	$param['limit'][0] = array('begin' => $begin, 'count' => $on_page);

	$new_path_array[] = array (
	'link' => $admin_forms->GetHtmlCallDoLoadAjax($admin_forms->AAction, '', 0, 'load_data'),
	'onclick' => $admin_forms->GetOnClickCallDoLoadAjax($admin_forms->AAction, '', 0, 'load_data'),
	'name' => $GLOBALS['MSG_ExecSqlQuery']['form_title']);

	$new_path_array[] = array (
	'link' => $admin_forms->GetHtmlCallDoLoadAjax($admin_forms->AAction, '', 126, 'load_data'),
	'onclick' => $admin_forms->GetOnClickCallDoLoadAjax($admin_forms->AAction, '', 126, 'load_data'),
	'name' => $GLOBALS['MSG_ExecSqlQuery']['repair_table_title']);

	$DataBase = & singleton('DataBase');

	$ExecSqlQuery = new ExecSqlQuery();

	// Получаем список всех таблиц БД
	$query = $ExecSqlQuery->GetTableNames();

	$query = "REPAIR TABLE $query";

	$tables_resource = $DataBase->query($query);

	// Выборка нужных записей.
	$j = 1;

	while ($row = mysql_fetch_row($tables_resource))
	{
		$param['data'][0][$j]['param_table_name'] = $row[0];
		$param['data'][0][$j]['param_operation_name'] = $row[1];
		$param['data'][0][$j]['param_message_type'] = $row[2];
		$param['data'][0][$j]['param_message_text'] = $row[3];

		$j++;
	}

	// Число нужных записей.
	$count = $j-1;

	$param['total_count'][] = $count;
	$param['current_page'] = $page;
	$param['on_page'] = $on_page;
	$param['path_array'] = $new_path_array;

	$param['title'] = $GLOBALS['MSG_ExecSqlQuery']['repair_table_title'];

	$param['error'] = show_message($GLOBALS['MSG_ExecSqlQuery']['repair_success']);
	return $param;
}

?>