<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

Hook::call('admin_tree_before');

LabCMS::i()->setAdminSkin();

$main=Factory::create('admin_tree.main');

$action='tree';
if (isset($_GET['action']) && is_callable(array($main, $_GET['action']))) $action=$_GET['action'];
call_user_func(array($main, $action));

return;


$json_response=array();

switch(true)
{
	case(LabCMS::i()->isAjax() && $_POST['action']=='show'):
		toggle_item($_POST['id'], 'show');
		break;
	case(LabCMS::i()->isAjax() && $_POST['action']=='sitemap'):
		toggle_item($_POST['id'], 'sitemap');
		break;
	case(LabCMS::i()->isAjax() && $_POST['action']=='menu'):
		toggle_item($_POST['id'], 'menu');
		break;
	case(LabCMS::i()->isAjax() && $_POST['action']=='update_tree'):
		include dirname(__FILE__)."/sort_tree.php";
		break;
	case($_GET['action']=='delete' && access('admin')):
		include dirname(__FILE__)."/delete.php";
		break;
	
	case(isset($_GET['var1'])):
		include dirname(__FILE__)."/edit.php";
		break;
	
	default:
		include dirname(__FILE__)."/tree.php";
}

Hook::call('admin_tree_after');

