summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/controls/Layout.php
blob: 5106a72b92ad1b7140d2d559cd149ac433f3e064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

class Layout extends TTemplateControl
{
	public function __construct()
	{
		if(isset($this->Request['notheme']))
			$this->Service->RequestedPage->EnableTheming=false;
		parent::__construct();
	}

	public function onLoad($param)
	{
		parent::onLoad($param);
		$url=$this->Request->RequestUri;
		if(strpos($url,'?')===false)
			$url.='?notheme=true';
		else
			$url.='&amp;notheme=true';
		$this->PrinterLink->NavigateUrl=$url;

		if(isset($this->Request['notheme']))
		{
			$this->MainMenu->Visible=false;
			$this->TopicPanel->Visible=false;
		}

		$this->languages->DataSource = TPropertyValue::ensureArray($this->Application->Parameters['languages']);
		$this->languages->dataBind();
	}

	public function languageLinkCreated($sender, $param)
	{
		$item = $param->Item;
		if($item->ItemType == TListItemType::Item || $item->ItemType == TListItemType::AlternatingItem)
		{
			$params = $this->Request->toArray();
			$params['lang'] = $sender->DataKeys[$item->ItemIndex];
			unset($params[$this->Request->ServiceID]);
			$url = $this->Service->ConstructUrl($this->Service->RequestedPagePath, $params);
			$item->link->NavigateUrl = $url;
			if($this->Application->Globalization->Culture == $params['lang'])
				$item->link->CssClass="active";
		}
	}
}

?>