ApiModule.php 1.68 KB
Newer Older
raphael's avatar
raphael committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/**
 * Api Module
 *
 * @author Tibor Katelbach <oceatoon@mail.com>
 * @version 0.0.3
 *
*/

class ApiModule extends CWebModule
{
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		Yii::app()->setComponents(array(
		    'errorHandler'=>array(
		        'errorAction'=>'/'.$this->id.'/error'
		    )
		));
		
		Yii::app()->homeUrl = Yii::app()->createUrl($this->id);
Raphael's avatar
Modif    
Raphael committed
24
25
		Yii::app()->theme  = $this->getTheme();

raphael's avatar
raphael committed
26
27
28
29
30
		Yii::app()->language = (isset(Yii::app()->session["lang"])) ? Yii::app()->session["lang"] : 'fr';
		
		// import the module-level models and components
		$this->setImport(array(
			'citizenToolKit.models.*',
Raph El's avatar
Modif    
Raph El committed
31
			'eco.models.*',
Raph El's avatar
Raph El committed
32
			'places.models.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
33
			'news.models.*',
raphael's avatar
raphael committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
			$this->id.'.models.*',
			$this->id.'.components.*',
			$this->id.'.messages.*',
		));
	}

	public function beforeControllerAction($controller, $action)
	{
		if (parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
	private $_assetsUrl;

	public function getAssetsUrl()
	{
		if ($this->_assetsUrl === null)
	        $this->_assetsUrl = Yii::app()->getAssetManager()->publish(
	            Yii::getPathOfAlias($this->id.'.assets') );
	    return $this->_assetsUrl;
	}
Raphael's avatar
Modif    
Raphael committed
60
61

	public function getTheme() {
Raph El's avatar
Raph El committed
62
		$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
63
64
65
		if (!empty(Yii::app()->params['theme'])) {
			$theme = Yii::app()->params['theme'];
		} else if (empty(Yii::app()->theme)) {
Raph El's avatar
Raph El committed
66
			$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
67
68
69
70
71
		}

		if(@$_GET["tpl"] == "iframesig"){ $theme = $_GET["tpl"]; }
		return $theme;
	}
raphael's avatar
raphael committed
72
}