<?php
class MenusReportView extends Slot {

	var $ModuleID = 4;
	var $SectionID = 40;
	var $target = array();
	var $request = array();
	var $order = array('Id', 'Name', 'Path', 'SiteMap', 'Left', 'Tabs', 'Right', 'Bottom',);

	function __construct($pquery) {
		parent::__construct($pquery);
	}

	function init() {
		$this->request['pageRecordsQty'] = 50;
		$this->request['curPageNumber'] = isset($this->LocalTarget[2]) ? $this->LocalTarget[2] + 1 : 1;
		switch(@$this->LocalTarget[0]) {
			default:
			case 'Id': $this->target[0] = 'Id'; $this->request['order'] = 'id'; break;
			case 'Name': $this->target[0] = 'Name'; $this->request['order'] = 'name'; break;
			case 'Path': $this->target[0] = 'Path'; $this->request['order'] = 'path'; break;
			case 'SiteMap': $this->target[0] = 'SiteMap'; $this->request['order'] = 'sitemap'; break;
			case 'Left': $this->target[0] = 'Left'; $this->request['order'] = 'left'; break;
			case 'Tabs': $this->target[0] = 'Tabs'; $this->request['order'] = 'tabs'; break;
			case 'Right': $this->target[0] = 'Right'; $this->request['order'] = 'right'; break;
			case 'Bottom': $this->target[0] = 'Bottom'; $this->request['order'] = 'bottom'; break;
		}
		switch(@$this->LocalTarget[1]) {
			default:
			case 'ASC': $this->target[1] = 'ASC'; $this->request['direction'] = 'ASC'; break;
			case 'DESC': $this->target[1] = 'DESC'; $this->request['direction'] = 'DESC'; break;
		}
		$this->Action->processEvent($this->SectionID,'select_logs_menus', $this->request, $this);
		$this->getPageControl($this->Home.'/Registar/MenusReport/'.$this->target[0].'/'.$this->target[1]);
	}

	function fillElements() {
		GLOBAL $REGISTRY;
		$this->PreparedTemplates = $this->Action->getTemplate($this->SectionID,'select_logs_menus');
		$this->TempFillEls['order'] = $this->target[0];
		$this->TempFillEls['direction'] = $this->target[1];
		$this->TempFillEls['cur'] = isset($this->LocalTarget[2]) ? '/'.$this->LocalTarget[2] : '';
		foreach ($this->order as $value)
			$this->TempFillEls['to_'.strtolower($value).'_direction'] = $this->target[1];
		$this->TempFillEls['to_'.strtolower($this->target[0]).'_direction'] = $this->target[1] == 'ASC' ? 'DESC' : 'ASC';
		$this->TempFillEls[strtolower($this->target[0]).'_direction'] = $this->target[1] == 'ASC' ? '<img src="'.$REGISTRY['Globals']['static']['adminpicPath'].'/arrow_up.gif">' : '<img src="'.$REGISTRY['Globals']['static']['adminpicPath'].'/arrow_down.gif">';
		foreach($this->PreparedTemplates['curPage'] as $ind => $val) {
			$this->TempFillEls['logs'][] = array(
				'number' => ($this->PreparedTemplates['pageRecordsQty']*($this->PreparedTemplates['curPageNumber']-1))+($ind+1),
				'id'=>$val['id'],
				'name'=>'<a href="/Registar/ContentManager/Update/'.$val['id'].'">'.$val['name'].'</a>',
				'path'=>empty($val['path']) ? '&nbsp;' : wordwrap($val['path'], 30, '<br>', 1),
				'menu1'=>(!empty($val['menu1'])? '<img src="'.$REGISTRY['Globals']['static']['adminpicPath'].'/tick1.gif">' : '&nbsp;'),
				'menu4'=>(!empty($val['menu4'])? '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/Registar/MenuManager/LeftMenu/Update/'.$val['id_menu4'].'">'.$val['menu4'].'</a>' : '&nbsp;'),
				'menu7'=>(!empty($val['menu7'])? '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/Registar/MenuManager/TabsMenu/Update/'.$val['id_menu7'].'">'.$val['menu7'].'</a>' : '&nbsp;'),
				'menu6'=>(!empty($val['menu6'])? '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/Registar/MenuManager/RightMenu/Update/'.$val['id_menu6'].'">'.$val['menu6'].'</a>' : '&nbsp;'),
				'menu3'=>(!empty($val['menu3'])? '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/Registar/MenuManager/BottomMenu/Update/'.$val['id_menu3'].'">'.$val['menu3'].'</a>' : '&nbsp;'),
			);
		}
		$this->PreparedTemplates = $this->Action->clearTemplate($this->SectionID, 'select_logs_menus');
	}
	
}
?>