<?php
class FolderDefaultPageReportView extends Slot {

	var $ModuleID = 4;
	var $SectionID = 40;
	var $target = array();
	var $request = array ();
	var $order = array('Id', 'Name', 'PageId', 'PageName',);

	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 'PageId': $this->target[0] = 'PageId'; $this->request['order'] = 'default_page'; break;
			case 'PageName': $this->target[0] = 'PageName'; $this->request['order'] = 'page_name'; 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_folders_default_pages', $this->request, $this);
		$this->getPageControl($this->Home.'/Registar/FolderDefaultPageReport/'.$this->target[0].'/'.$this->target[1]);
	}

	function fillElements() {
		GLOBAL $ROOT_PATH, $REGISTRY;
		$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 $key => $value){
			$this->TempFillEls['logs'][$key] = array(
				'number' => $key + 1,
				'id' => $value['id'],
				'name' => '<a href="/Registar/ContentManager/Update/'.$value['id'].'">'.$value['name'].'</a>',
				'view' => '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/'.$value['path'].'" class=adminlink>View</a>',
				'page_id' => $value['default_page']['id'],
				'page_name' => '<a href="/Registar/ContentManager/Update/'.$value['default_page']['id'].'">'.$value['default_page']['name'].'</a>',
				'page_view' => '<a href="'.$REGISTRY['Globals']['static']['homePath'].'/'.$value['default_page']['path'].'" class=adminlink>View</a>',
			);
		}
		$this->PreparedTemplates = $this->Action->clearTemplate($this->SectionID, 'select_folders_default_pages');
	}
}
?>